:root {
    --bg: #0b1020;
    --panel: #141b2d;
    --text: #e5e7eb;
    --muted: #9aa3b2;
    --accent: #e10600;
    --border: rgba(255, 255, 255, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
    color: var(--text);
    background:
        repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 12px),
        radial-gradient(circle at 8% 8%, rgba(225, 6, 0, 0.26), transparent 40%),
        #050608;
}

body.theme-light {
    --bg: #cfd6e4;
    --panel: #e2e7f0;
    --text: #101623;
    --muted: #4a5568;
    --border: rgba(15, 23, 42, 0.16);
    background:
        repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.1) 0 1px, transparent 1px 14px),
        radial-gradient(circle at 8% 8%, rgba(225, 6, 0, 0.14), transparent 42%),
        radial-gradient(circle at top, #cfd6e4, #c1c9d7 55%, #b3bccd);
}

.topbar {
    max-width: 1080px;
    margin: 0 auto;
    padding: 28px 24px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.brand {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.brand-f1 {
    color: var(--accent);
    font-weight: 700;
    font-size: 28px;
}

.brand-name {
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-weight: 700;
    font-size: 20px;
}

h1 {
    margin: 8px 0 0;
    font-size: 28px;
}

.muted {
    color: var(--muted);
}

.topbar-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 16px;
    border-radius: 12px;
    cursor: pointer;
    text-decoration: none;
}

.topbar-actions a.ghost {
    text-decoration: none;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    display: inline-flex;
    align-items: center;
}

.ghost:hover {
    border-color: rgba(255, 255, 255, 0.2);
}

body.theme-light .ghost:hover {
    border-color: rgba(15, 23, 42, 0.2);
}

.settings-grid {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 24px 50px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.panel {
    background:
        repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 6px),
        linear-gradient(160deg, rgba(20, 27, 45, 0.96), rgba(12, 18, 34, 0.96));
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px;
}

body.theme-light .panel {
    background: #ffffff;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
}

.panel h2 {
    margin: 0;
}

.field {
    display: grid;
    gap: 6px;
    margin-top: 12px;
}

.field input {
    width: 100%;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 11px 12px;
    color: var(--text);
}

body.theme-light .field input {
    background: #ffffff;
}

.setting-row {
    margin-top: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.setting-title {
    font-weight: 700;
}

.setting-desc {
    font-size: 13px;
    color: var(--muted);
}

.switch {
    position: relative;
    width: 50px;
    height: 28px;
    display: inline-flex;
    align-items: center;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.35);
    border: 1px solid var(--border);
    transition: 0.2s ease;
}

.slider::before {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    left: 3px;
    top: 3px;
    border-radius: 50%;
    background: #ffffff;
    transition: 0.2s ease;
}

.switch input:checked + .slider {
    background: linear-gradient(120deg, var(--accent), #ff4c3b);
}

.switch input:checked + .slider::before {
    transform: translateX(22px);
}

.primary {
    margin-top: 14px;
    padding: 12px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(120deg, var(--accent), #ff4c3b);
    box-shadow: 0 12px 24px rgba(225, 6, 0, 0.35);
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

.primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

.danger-actions {
    margin-top: 12px;
    display: grid;
    gap: 10px;
}

.danger {
    padding: 11px 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 123, 114, 0.5);
    background: rgba(255, 123, 114, 0.08);
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

.danger:hover {
    border-color: rgba(255, 123, 114, 0.8);
    background: rgba(255, 123, 114, 0.16);
}

.danger:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.prefs-list {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.prefs-item {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
}

body.theme-light .prefs-item {
    background: rgba(255, 255, 255, 0.75);
}

.prefs-item input {
    width: 16px;
    height: 16px;
}

.prefs-item input:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.prefs-item input:disabled + span {
    opacity: 0.7;
}

.panel-message {
    min-height: 20px;
    margin: 10px 0 0;
    font-size: 14px;
}

.panel-message.success {
    color: #56d364;
}

.panel-message.error {
    color: #ff7b72;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(5, 8, 16, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 50;
}

.modal-backdrop.active {
    display: flex;
}

.modal-card {
    width: min(520px, 100%);
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(5, 8, 16, 0.6);
    padding: 18px;
}

body.theme-light .modal-card {
    background: #ffffff;
}

.modal-head {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.modal-head h3 {
    margin: 0;
    font-size: 18px;
}

.modal-body {
    display: grid;
    gap: 14px;
    font-size: 14px;
}

.modal-body p {
    margin: 0;
}

.confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

@media (max-width: 980px) {
    .settings-grid {
        grid-template-columns: 1fr;
    }
}
