/* ==========================================================================
   ВедиSMM — Design System
   A hand-built, enterprise-grade token + component library. No frameworks.
   Light & dark theme, fully responsive, accessible focus states.
   ========================================================================== */

/* ------------------------------------------------------------------ Tokens */
:root {
    /* Brand */
    --brand-50:  #eef0ff;
    --brand-100: #e0e3ff;
    --brand-200: #c7ccff;
    --brand-300: #a5a8ff;
    --brand-400: #8a83ff;
    --brand-500: #5b4bff;
    --brand-600: #4d3ce6;
    --brand-700: #3f30bf;
    --brand-800: #342a99;
    --brand-900: #2b2478;
    --accent-500: #ff5c8a;
    --accent-600: #eb3d70;

    /* Semantic */
    --success-50: #e7f8f0; --success-500: #12b76a; --success-600: #0e9a58;
    --warning-50: #fff4e5; --warning-500: #f79009; --warning-600: #d97706;
    --danger-50:  #fdeceb; --danger-500:  #f04438; --danger-600:  #d92d20;
    --info-50:    #e8f2ff; --info-500:    #2e90fa; --info-600:    #1570cd;

    /* Neutrals (slate) */
    --gray-0:   #ffffff;
    --gray-25:  #fcfcfd;
    --gray-50:  #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e6ebf1;
    --gray-300: #d3dbe4;
    --gray-400: #9aa7b8;
    --gray-500: #6b7a90;
    --gray-600: #4c586b;
    --gray-700: #364152;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --gray-950: #0b0f19;

    /* Surface / semantic aliases (light theme) */
    --bg:            var(--gray-50);
    --bg-elevated:   var(--gray-0);
    --surface:       var(--gray-0);
    --surface-2:     var(--gray-50);
    --surface-hover: var(--gray-100);
    --border:        var(--gray-200);
    --border-strong: var(--gray-300);
    --text:          var(--gray-900);
    --text-secondary:var(--gray-600);
    --text-muted:    var(--gray-500);
    --text-inverse:  var(--gray-0);
    --brand:         var(--brand-500);
    --brand-contrast:#ffffff;

    /* Typography */
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
                 "PT Sans", "Noto Sans", Arial, sans-serif;
    --font-mono: ui-monospace, "SFMono-Regular", "Menlo", "Consolas", monospace;
    --text-xs: 12px; --text-sm: 13px; --text-base: 14px; --text-md: 15px;
    --text-lg: 17px; --text-xl: 20px; --text-2xl: 24px; --text-3xl: 30px;
    --text-4xl: 38px; --text-5xl: 48px;

    /* Spacing scale */
    --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px;
    --sp-6: 24px; --sp-8: 32px; --sp-10: 40px; --sp-12: 48px; --sp-16: 64px;
    --sp-20: 80px; --sp-24: 96px;

    /* Radius */
    --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px; --r-2xl: 28px; --r-full: 999px;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(16,24,40,.05);
    --shadow-sm: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.04);
    --shadow-md: 0 4px 12px rgba(16,24,40,.08), 0 2px 4px rgba(16,24,40,.04);
    --shadow-lg: 0 12px 28px rgba(16,24,40,.12), 0 4px 8px rgba(16,24,40,.05);
    --shadow-xl: 0 24px 48px rgba(16,24,40,.16);
    --ring: 0 0 0 4px rgba(91,75,255,.16);

    /* Motion */
    --ease: cubic-bezier(.4, 0, .2, 1);
    --dur: .18s;

    --sidebar-w: 260px;
    --topbar-h: 64px;
    --container: 1200px;
    --touch-target: 44px;
    --z-content-popover: 40;
    --z-topbar: 50;
    --z-sidebar-backdrop: 55;
    --z-sidebar: 60;
    --z-sidebar-overlay: 70;
    --z-dropdown: 80;
    --z-popup: 120;
    --z-toast: 200;
    --z-cookie-consent: 210;
    --z-modal: 260;
}

:root[data-theme="dark"] {
    --bg:            var(--gray-950);
    --bg-elevated:   #131a26;
    --surface:       #141b28;
    --surface-2:     #10161f;
    --surface-hover: #1c2533;
    --border:        #232d3d;
    --border-strong: #2f3b4d;
    --text:          #eaf0f7;
    --text-secondary:#a7b4c6;
    --text-muted:    #7787a0;
    --text-inverse:  #0b0f19;
    --brand:         var(--brand-400);
    --shadow-xs: 0 1px 2px rgba(0,0,0,.3);
    --shadow-sm: 0 1px 3px rgba(0,0,0,.4);
    --shadow-md: 0 4px 12px rgba(0,0,0,.45);
    --shadow-lg: 0 12px 28px rgba(0,0,0,.5);
    --shadow-xl: 0 24px 48px rgba(0,0,0,.6);
    --ring: 0 0 0 4px rgba(138,131,255,.24);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg:            var(--gray-950);
        --bg-elevated:   #131a26;
        --surface:       #141b28;
        --surface-2:     #10161f;
        --surface-hover: #1c2533;
        --border:        #232d3d;
        --border-strong: #2f3b4d;
        --text:          #eaf0f7;
        --text-secondary:#a7b4c6;
        --text-muted:    #7787a0;
        --text-inverse:  #0b0f19;
        --brand:         var(--brand-400);
        --shadow-md: 0 4px 12px rgba(0,0,0,.45);
        --shadow-lg: 0 12px 28px rgba(0,0,0,.5);
    }
}

/* -------------------------------------------------------------------- Reset */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    min-height: 100vh;
}
img, svg, video, canvas { display: block; max-width: 100%; }
img, video { height: auto; }
input, button, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: none; }
h1, h2, h3, h4 { line-height: 1.2; font-weight: 700; letter-spacing: -.02em; color: var(--text); }
ul, ol { list-style: none; padding: 0; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }
::selection { background: var(--brand-200); color: var(--gray-900); }
hr { border: none; border-top: 1px solid var(--border); }

/* ------------------------------------------------------------- Utilities */
.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 var(--sp-6); }
.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.between { display: flex; align-items: center; justify-content: space-between; }
.gap-1 { gap: var(--sp-1);} .gap-2 { gap: var(--sp-2);} .gap-3 { gap: var(--sp-3);}
.gap-4 { gap: var(--sp-4);} .gap-6 { gap: var(--sp-6);}
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.muted { color: var(--text-muted); }
.secondary { color: var(--text-secondary); }
.small { font-size: var(--text-sm); }
.xs { font-size: var(--text-xs); }
.center { text-align: center; }
.mt-2{margin-top:var(--sp-2)}.mt-3{margin-top:var(--sp-3)}.mt-4{margin-top:var(--sp-4)}
.mt-6{margin-top:var(--sp-6)}.mt-8{margin-top:var(--sp-8)}
.mb-2{margin-bottom:var(--sp-2)}.mb-4{margin-bottom:var(--sp-4)}.mb-6{margin-bottom:var(--sp-6)}
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.truncate[data-full-text]:focus { overflow: visible; white-space: normal; text-overflow: clip; overflow-wrap: anywhere;
    outline: 2px solid var(--brand-400); outline-offset: 2px; border-radius: var(--r-xs); }
.nowrap { white-space: nowrap; }

/* ---------------------------------------------------------------- Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
    height: 40px; padding: 0 var(--sp-4); border-radius: var(--r-md);
    font-size: var(--text-base); font-weight: 600; white-space: nowrap;
    border: 1px solid transparent; transition: all var(--dur) var(--ease);
    user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--brand-500); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--brand-600); box-shadow: var(--shadow-md); }
.btn-gradient {
    background: linear-gradient(120deg, var(--brand-500), #7b6bff 60%, var(--accent-500));
    color: #fff; box-shadow: 0 6px 18px rgba(91,75,255,.35);
}
.btn-gradient:hover { filter: brightness(1.05); box-shadow: 0 8px 24px rgba(91,75,255,.45); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-hover); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); }
.btn-danger { background: var(--danger-500); color: #fff; }
.btn-danger:hover { background: var(--danger-600); }
.btn-danger-soft { background: var(--danger-50); color: var(--danger-600); }
.btn-danger-soft:hover { background: var(--danger-500); color:#fff; }
.btn-sm { height: 32px; padding: 0 var(--sp-3); font-size: var(--text-sm); border-radius: var(--r-sm); }
.btn-lg { height: 48px; padding: 0 var(--sp-6); font-size: var(--text-md); border-radius: var(--r-lg); }
.btn-block { width: 100%; }
.btn-icon { width: 40px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn:disabled, .btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ------------------------------------------------------------------ Cards */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
}
.card-pad { padding: var(--sp-6); }
.card-header { padding: var(--sp-5) var(--sp-6); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.card-header h3 { font-size: var(--text-lg); }
.card-body { padding: var(--sp-6); }
.card-hover { transition: all var(--dur) var(--ease); }
.card-hover:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); }

/* ----------------------------------------------------------------- Forms */
.field { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.label { font-size: var(--text-sm); font-weight: 600; color: var(--text-secondary); }
.label .req { color: var(--danger-500); }
.input, .textarea, .select {
    width: 100%; height: 42px; padding: 0 var(--sp-3);
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border-strong); border-radius: var(--r-md);
    transition: border-color var(--dur), box-shadow var(--dur);
    font-size: var(--text-base);
}
.textarea { height: auto; min-height: 96px; padding: var(--sp-3); resize: vertical; line-height: 1.55; }
textarea.input { height: auto; min-height: 96px; padding: var(--sp-3); resize: vertical; line-height: 1.55; }
.input:focus, .textarea:focus, .select:focus { border-color: var(--brand-400); box-shadow: var(--ring); }
.input::placeholder, .textarea::placeholder { color: var(--text-muted); }
.input.error, .textarea.error { border-color: var(--danger-500); }
.field-error { font-size: var(--text-sm); color: var(--danger-600); }
.field-hint { font-size: var(--text-sm); color: var(--text-muted); }
.select { appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%236b7a90' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.input-group { position: relative; --input-prefix-space: 40px; }
.input-group.prefix-wide { --input-prefix-space: 74px; }
.input-group.prefix-url { --input-prefix-space: 82px; }
.input-group .prefix { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.input-group .input { padding-left: var(--input-prefix-space); }

/* toggle switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: var(--sp-3); cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch .track { width: 42px; height: 24px; border-radius: var(--r-full); background: var(--gray-300); transition: background var(--dur); flex: none; }
.switch .thumb { position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform var(--dur); }
.switch input:checked ~ .track { background: var(--brand-500); }
.switch input:checked ~ .track .thumb { transform: translateX(18px); }

/* checkbox pill (network / account picker) */
.check-pill { display: inline-flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3);
    border: 1px solid var(--border-strong); border-radius: var(--r-full); cursor: pointer;
    transition: all var(--dur) var(--ease); background: var(--surface); font-weight: 600; font-size: var(--text-sm); }
.check-pill:hover { border-color: var(--brand-400); background: var(--brand-50); }
.check-pill input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.check-pill:focus-within { outline: 2px solid var(--brand-500); outline-offset: 2px; }
.check-pill.selected { border-color: var(--brand-500); background: var(--brand-50); color: var(--brand-700); box-shadow: var(--ring); }
:root[data-theme="dark"] .check-pill.selected, :root[data-theme="dark"] .check-pill:hover { background: rgba(91,75,255,.15); color: var(--brand-300); }
/* Checkmark appears only when the pill is actually selected (avoids a false "selected" look). */
.check-pill .check-mark { display: none; }
.check-pill.selected .check-mark { display: inline-flex; }

.color-swatch { position: relative; cursor: pointer; }
.color-swatch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.color-swatch input:focus-visible + span { outline: 2px solid var(--brand-500); outline-offset: 3px; }

/* --------------------------------------------------------------- Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 var(--sp-2);
    font-size: var(--text-xs); font-weight: 700; border-radius: var(--r-full);
    background: var(--surface-hover); color: var(--text-secondary); text-transform: none; }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: var(--success-50); color: var(--success-600); }
.badge-warning { background: var(--warning-50); color: var(--warning-600); }
.badge-danger  { background: var(--danger-50);  color: var(--danger-600); }
.badge-info    { background: var(--info-50);    color: var(--info-600); }
.badge-brand   { background: var(--brand-50);   color: var(--brand-700); }
:root[data-theme="dark"] .badge-success{background:rgba(18,183,106,.16);color:#3ddc94}
:root[data-theme="dark"] .badge-warning{background:rgba(247,144,9,.16);color:#f9b155}
:root[data-theme="dark"] .badge-danger{background:rgba(240,68,56,.16);color:#f5867d}
:root[data-theme="dark"] .badge-info{background:rgba(46,144,250,.16);color:#6bb2fb}
:root[data-theme="dark"] .badge-brand{background:rgba(91,75,255,.18);color:#a5a8ff}

/* --------------------------------------------------------------- Avatars */
.avatar { width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center;
    justify-content: center; font-weight: 700; color: #fff; flex: none; overflow: hidden;
    background: linear-gradient(135deg, var(--brand-500), var(--accent-500)); font-size: var(--text-sm); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 30px; height: 30px; font-size: var(--text-xs); }
.avatar-lg { width: 56px; height: 56px; font-size: var(--text-lg); }

/* network glyph */
.net { width: 34px; height: 34px; border-radius: var(--r-md); display: inline-flex; align-items: center;
    justify-content: center; color: #fff; flex: none; }
.net svg { width: 20px; height: 20px; }
.net-sm { width: 24px; height: 24px; border-radius: var(--r-sm); }
.net-sm svg { width: 15px; height: 15px; }
.net-lg { width: 48px; height: 48px; border-radius: var(--r-lg); }
.net-lg svg { width: 26px; height: 26px; }

/* --------------------------------------------------------------- Alerts */
.alert { display: flex; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md);
    border: 1px solid var(--border); background: var(--surface-2); font-size: var(--text-sm); align-items: flex-start; }
.alert svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.alert-success { background: var(--success-50); border-color: #b6ebd0; color: var(--success-600); }
.alert-warning { background: var(--warning-50); border-color: #ffdca8; color: var(--warning-600); }
.alert-danger  { background: var(--danger-50);  border-color: #f7c6c2; color: var(--danger-600); }
.alert-info    { background: var(--info-50);    border-color: #bcdcff; color: var(--info-600); }
:root[data-theme="dark"] .alert-success{background:rgba(18,183,106,.1);border-color:rgba(18,183,106,.3);color:#5fdca0}
:root[data-theme="dark"] .alert-warning{background:rgba(247,144,9,.1);border-color:rgba(247,144,9,.3);color:#f9b155}
:root[data-theme="dark"] .alert-danger{background:rgba(240,68,56,.1);border-color:rgba(240,68,56,.3);color:#f5867d}
:root[data-theme="dark"] .alert-info{background:rgba(46,144,250,.1);border-color:rgba(46,144,250,.3);color:#6bb2fb}

/* --------------------------------------------------------------- Tables */
.table-wrap { overflow-x: auto; border-radius: var(--r-lg); border: 1px solid var(--border); }
.table { width: 100%; border-collapse: collapse; background: var(--surface); }
.table th { text-align: left; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .04em;
    color: var(--text-muted); font-weight: 700; padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); background: var(--surface-2); }
.table td { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); font-size: var(--text-sm); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background var(--dur); }
.table tbody tr:hover { background: var(--surface-2); }

@media (max-width: 640px) {
    .page .truncate { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; }
    .responsive-table { display: block; }
    .responsive-table thead { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
        overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
    .responsive-table tbody { display: grid; gap: var(--sp-3); padding: var(--sp-3); }
    .responsive-table tbody tr { display: block; border: 1px solid var(--border); border-radius: var(--r-md);
        background: var(--surface); overflow: hidden; }
    .responsive-table tbody td { --responsive-label-width: 108px; position: relative; display: block;
        width: 100%; max-width: none !important; min-height: var(--touch-target);
        padding: var(--sp-3) var(--sp-3) var(--sp-3) calc(var(--responsive-label-width) + var(--sp-5));
        border-bottom: 1px solid var(--border); text-align: left !important;
        white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; }
    .responsive-table tbody td:last-child { border-bottom: 0; }
    .responsive-table tbody td::before { content: attr(data-label); position: absolute; left: var(--sp-3); top: 50%;
        width: var(--responsive-label-width); transform: translateY(-50%); color: var(--text-muted); font-size: var(--text-xs);
        font-weight: 700; text-transform: uppercase; letter-spacing: .04em; overflow-wrap: normal; }
    .responsive-table tbody td[data-label="Действия"] { padding-top: 38px; padding-left: var(--sp-3); }
    .responsive-table tbody td[data-label="Действия"]::before { top: var(--sp-3); width: auto; transform: none; }
    .responsive-table tbody td > .row { min-width: 0; flex-wrap: wrap; justify-content: flex-start !important; }
    .responsive-table tbody td form { min-width: 0; }
}

/* --------------------------------------------------------------- Tabs */
.tabs { display: inline-flex; gap: 2px; padding: 4px; background: var(--surface-2); border-radius: var(--r-md); border: 1px solid var(--border); }
.tab { padding: var(--sp-2) var(--sp-4); border-radius: var(--r-sm); font-weight: 600; font-size: var(--text-sm); color: var(--text-secondary); transition: all var(--dur); }
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface); color: var(--brand-600); box-shadow: var(--shadow-xs); }
:root[data-theme="dark"] .tab.active { color: var(--brand-300); }

/* --------------------------------------------------------- Empty state */
.empty { text-align: center; padding: var(--sp-12) var(--sp-6); }
.empty .empty-icon { width: 64px; height: 64px; border-radius: var(--r-xl); background: var(--brand-50);
    color: var(--brand-500); display: inline-flex; align-items: center; justify-content: center; margin-bottom: var(--sp-4); }
.empty .empty-icon svg { width: 30px; height: 30px; }
:root[data-theme="dark"] .empty .empty-icon { background: rgba(91,75,255,.14); }
.empty h3 { font-size: var(--text-lg); margin-bottom: var(--sp-2); }
.empty p { color: var(--text-muted); max-width: 420px; margin: 0 auto var(--sp-4); }

/* --------------------------------------------------------------- Toasts */
#toasts { position: fixed; top: var(--sp-4); right: var(--sp-4); z-index: var(--z-toast); display: flex; flex-direction: column; gap: var(--sp-2); max-width: 360px; }
.toast { display: flex; gap: var(--sp-3); align-items: flex-start; padding: var(--sp-3) var(--sp-4);
    background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--brand-500);
    border-radius: var(--r-md); box-shadow: var(--shadow-lg); animation: toastIn .25s var(--ease); font-size: var(--text-sm); }
.toast.success { border-left-color: var(--success-500); }
.toast.error { border-left-color: var(--danger-500); }
.toast.info { border-left-color: var(--info-500); }
.toast svg { width: 20px; height: 20px; flex: none; }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
.toast.out { animation: toastOut .2s var(--ease) forwards; }
@keyframes toastOut { to { opacity: 0; transform: translateX(20px); } }

/* --------------------------------------------------------------- Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(11,15,25,.5); backdrop-filter: blur(3px);
    z-index: var(--z-modal); display: flex; align-items: center; justify-content: center; padding: var(--sp-4); animation: fade .2s var(--ease); }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl);
    box-shadow: var(--shadow-xl); width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; animation: pop .22s var(--ease); }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(8px); } }
.modal-header { padding: var(--sp-5) var(--sp-6); border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { font-size: var(--text-lg); }
.modal-body { padding: var(--sp-6); }
.modal-footer { padding: var(--sp-4) var(--sp-6); border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: var(--sp-3); }
@media (max-width: 520px) {
    .modal-footer { padding: var(--sp-3) var(--sp-4); gap: var(--sp-2); }
    .modal-footer .btn { padding: 0 var(--sp-3); font-size: var(--text-sm); }
}

/* --------------------------------------------------------------- Progress */
.progress { height: 8px; background: var(--surface-hover); border-radius: var(--r-full); overflow: hidden; }
.progress .bar { height: 100%; background: linear-gradient(90deg, var(--brand-500), var(--accent-500)); border-radius: var(--r-full); transition: width .3s var(--ease); }

/* --------------------------------------------------------------- Misc */
.divider { height: 1px; background: var(--border); margin: var(--sp-4) 0; }
.dot-sep::before { content: "•"; margin: 0 var(--sp-2); color: var(--text-muted); }
.kbd { font-family: var(--font-mono); font-size: var(--text-xs); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 2px 6px; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border-strong); border-top-color: var(--brand-500); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Cookie consent banner */
.cookie-consent { position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-cookie-consent); padding: var(--sp-3); pointer-events: none; }
.cookie-consent-visible { padding-bottom: var(--cookie-consent-height, 0); }
.cookie-consent-visible .page { padding-bottom: calc(var(--sp-6) + var(--cookie-consent-height, 0px)); }
.cookie-consent[hidden] { display: none; }
.cookie-consent-inner { pointer-events: auto; max-width: 720px; margin: 0 auto; display: flex; align-items: center; gap: var(--sp-4); flex-wrap: wrap; justify-content: space-between; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg, 0 8px 30px rgba(0,0,0,.18)); border-radius: var(--r-lg, 14px); padding: var(--sp-3) var(--sp-4); }
.cookie-consent-text { margin: 0; font-size: var(--text-sm); color: var(--text-secondary); flex: 1 1 320px; }
.cookie-consent-text a { color: var(--brand-500); text-decoration: underline; }
.cookie-consent-actions { display: flex; gap: var(--sp-2); flex: 0 0 auto; }
@media (max-width: 520px) { .cookie-consent-actions { width: 100%; } .cookie-consent-actions .btn { flex: 1; } }

/* Comfortable standalone controls on touch-sized viewports. The visual icon
   can stay compact while the interactive box remains easy to hit. */
@media (max-width: 640px) {
    .btn, .btn-sm { min-height: var(--touch-target); height: var(--touch-target); }
    .btn-icon, .btn-icon.btn-sm { min-width: var(--touch-target); width: var(--touch-target); padding: 0; }
    .input, .select { min-height: var(--touch-target); height: var(--touch-target); }
    textarea.input, .textarea, .editor-area { height: auto; }
    .tab, .check-pill, .cal-chip, .check-inline, .switch, summary {
        min-height: var(--touch-target);
        display: inline-flex;
        align-items: center;
    }
    .switch { min-width: var(--touch-target); justify-content: center; }
    .control-hitbox { width: var(--touch-target); height: var(--touch-target); }
}

.control-hitbox { display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }

/* Consent checkbox row (registration, forms) */
.checkbox-row { display: flex; align-items: flex-start; gap: var(--sp-2); cursor: pointer; }
.checkbox-row input[type="checkbox"] { margin-top: 2px; width: 16px; height: 16px; flex: 0 0 auto; accent-color: var(--brand-500); cursor: pointer; }
.checkbox-row a { color: var(--brand-500); text-decoration: underline; }
.analytics-post-link { color:inherit; text-decoration:none; border-radius:var(--radius); }
.analytics-post-link:hover { background:var(--surface-hover); }
.community-stats { grid-template-columns:repeat(5,minmax(130px,1fr)); }
@media (max-width:900px) { .community-stats { grid-template-columns:repeat(2,minmax(130px,1fr)); } }

/* Unified comments inbox */
.inbox-page-head { margin-bottom: var(--sp-5); }
.inbox-shell { display:grid; grid-template-columns:190px minmax(280px, 360px) minmax(420px, 1fr); min-height:calc(100vh - 190px); max-height:calc(100vh - 145px); border:1px solid var(--border); border-radius:var(--radius-lg); background:var(--surface); overflow:hidden; }
.inbox-filters { padding:var(--sp-4); border-right:1px solid var(--border); overflow:auto; }
.inbox-filters h3 { margin:0 0 var(--sp-3); font-size:.9rem; }
.inbox-filter-list { display:flex; flex-direction:column; gap:4px; margin-bottom:var(--sp-5); }
.inbox-filter-list a { display:flex; align-items:center; justify-content:space-between; min-height:38px; padding:7px 10px; border-radius:var(--radius); color:var(--text-secondary); font-size:.9rem; text-decoration:none; }
.inbox-filter-list a:hover,.inbox-filter-list a.active { background:var(--surface-hover); color:var(--text); }
.inbox-list { position:relative; border-right:1px solid var(--border); overflow:auto; outline:none; }
.inbox-list-head { position:sticky; top:0; z-index:2; display:flex; justify-content:space-between; padding:var(--sp-4); border-bottom:1px solid var(--border); background:var(--surface); }
.inbox-item { width:100%; display:flex; flex-direction:column; gap:7px; padding:14px 16px; border:0; border-bottom:1px solid var(--border); background:transparent; color:var(--text); text-align:left; cursor:pointer; }
.inbox-item:hover,.inbox-item.active { background:var(--surface-hover); }
.inbox-item.active { box-shadow:inset 3px 0 var(--brand-500); }
.inbox-item.unread strong::after { content:''; display:inline-block; width:7px; height:7px; margin-left:7px; border-radius:50%; background:var(--brand-500); vertical-align:middle; }
.inbox-item-top { display:flex; align-items:center; gap:7px; min-width:0; font-size:.88rem; }
.inbox-item-top strong { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.inbox-item-top time { margin-left:auto; color:var(--text-tertiary); font-size:.75rem; white-space:nowrap; }
.inbox-item-text { display:-webkit-box; overflow:hidden; -webkit-line-clamp:2; -webkit-box-orient:vertical; font-size:.9rem; line-height:1.4; }
.inbox-item-post { overflow:hidden; color:var(--text-tertiary); font-size:.75rem; text-overflow:ellipsis; white-space:nowrap; }
.inbox-empty,.inbox-thread-empty { padding:48px 24px; }
.inbox-more { display:flex; margin:12px auto; }
.inbox-state { position:sticky; bottom:0; padding:10px; background:var(--surface); text-align:center; font-size:.85rem; }
.inbox-error { color:var(--danger-600); }
.inbox-thread { display:flex; flex-direction:column; min-width:0; overflow:auto; outline:none; }
.inbox-thread-head { position:sticky; top:0; z-index:3; display:flex; align-items:center; gap:10px; min-height:62px; padding:10px 16px; border-bottom:1px solid var(--border); background:var(--surface); }
.inbox-back { display:none; }
.inbox-post-context { padding:14px 18px; border-bottom:1px solid var(--border); background:var(--surface-hover); }
.inbox-post-context p { margin:6px 0 9px; white-space:pre-wrap; }
.inbox-messages { flex:1; display:flex; flex-direction:column; gap:12px; padding:18px; }
.inbox-message { align-self:flex-start; max-width:min(78%, 680px); padding:11px 14px; border-radius:4px 14px 14px; background:var(--surface-hover); }
.inbox-message.ours { align-self:flex-end; border-radius:14px 4px 14px 14px; background:var(--brand-50); }
.inbox-message-meta { display:flex; gap:12px; align-items:baseline; margin-bottom:5px; font-size:.8rem; }
.inbox-message-meta time { color:var(--text-tertiary); }
.inbox-message p { margin:0; white-space:pre-wrap; overflow-wrap:anywhere; }
.inbox-message-actions { display:flex; gap:6px; margin-top:7px; }
.inbox-composer { position:sticky; bottom:0; display:flex; flex-direction:column; gap:9px; padding:12px 16px calc(12px + env(safe-area-inset-bottom)); border-top:1px solid var(--border); background:var(--surface); }
.inbox-composer textarea { resize:vertical; min-height:70px; max-height:220px; }
.inbox-coverage { position:sticky; bottom:0; margin:12px 16px calc(12px + env(safe-area-inset-bottom)); }

@media (max-width: 1100px) {
    .inbox-shell { grid-template-columns:150px minmax(260px, 330px) minmax(360px, 1fr); }
}
@media (max-width: 900px) {
    .inbox-shell { display:block; min-height:calc(100dvh - 150px); max-height:none; }
    .inbox-filters { display:flex; gap:8px; padding:10px; border-right:0; border-bottom:1px solid var(--border); overflow-x:auto; }
    .inbox-filters h3,.inbox-filters .field-label,.inbox-filters select { display:none; }
    .inbox-filter-list { flex-direction:row; margin:0; }
    .inbox-filter-list a { white-space:nowrap; }
    .inbox-list { min-height:calc(100dvh - 230px); border-right:0; }
    .inbox-thread { display:none; min-height:calc(100dvh - 210px); }
    .inbox-shell.thread-open .inbox-filters,.inbox-shell.thread-open .inbox-list { display:none; }
    .inbox-shell.thread-open .inbox-thread { display:flex; }
    .inbox-back { display:inline-flex; }
}
@media (max-width: 540px) {
    .inbox-page-head p { display:none; }
    .inbox-shell { margin-inline:calc(var(--sp-4) * -1); border-left:0; border-right:0; border-radius:0; }
    .inbox-message { max-width:90%; }
}
