/* ==========================================================================
   Publii panel — design system
   Tokens → base → layout → components → utilities.
   Brand color lives in --primary; change it there only.
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
    color-scheme: light;

    --bg: #f6f6f7;
    --surface: #ffffff;
    --surface-muted: #f1f1f3;
    --border: #e4e4e7;
    --text: #18181b;
    --text-muted: #6b6b73;

    --primary: #111111;
    --primary-hover: #2a2a2a;
    --primary-contrast: #ffffff;

    --success: #15803d;
    --success-soft: #e8f6ed;
    --warning: #b45309;
    --warning-soft: #fdf3e2;
    --danger: #b91c1c;
    --danger-soft: #fdecec;
    --danger-contrast: #ffffff;

    --focus-ring: 0 0 0 3px color-mix(in srgb, var(--primary) 30%, transparent);

    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --fs-xs: 0.75rem;   /* 12 */
    --fs-sm: 0.875rem;  /* 14 */
    --fs-md: 1rem;      /* 16 */
    --fs-lg: 1.25rem;   /* 20 */
    --fs-xl: 1.5rem;    /* 24 */
    --fs-2xl: 2rem;     /* 32 */

    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 20px;
    --sp-6: 24px;
    --sp-8: 32px;
    --sp-10: 40px;

    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 1px 3px rgb(0 0 0 / 0.06);
    --duration: 160ms;

    --sidebar-width: 232px;
    --bottom-nav-height: 64px;
}

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;

        --bg: #0c0c0d;
        --surface: #161618;
        --surface-muted: #1f1f22;
        --border: #2a2a2e;
        --text: #f4f4f5;
        --text-muted: #a1a1aa;

        --primary: #f4f4f5;
        --primary-hover: #d4d4d8;
        --primary-contrast: #111111;

        --success: #4ade80;
        --success-soft: #12261a;
        --warning: #fbbf24;
        --warning-soft: #2a2110;
        --danger: #f87171;
        --danger-soft: #2c1515;
        --danger-contrast: #1c0606;

        --shadow: 0 1px 2px rgb(0 0 0 / 0.4);
    }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: var(--fs-md);
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }

a { color: inherit; }

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 4px;
}

.icon {
    width: 1.125em;
    height: 1.125em;
    flex-shrink: 0;
}

.skip-link {
    position: absolute;
    left: var(--sp-4);
    top: -100px;
    z-index: 100;
    padding: var(--sp-2) var(--sp-4);
    background: var(--primary);
    color: var(--primary-contrast);
    border-radius: var(--radius);
}
.skip-link:focus { top: var(--sp-4); }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- Layout ---------- */
.app {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: var(--sp-6);
    padding: var(--sp-5) var(--sp-3);
    background: var(--surface);
    border-right: 1px solid var(--border);
}

.sidebar__footer {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    margin-top: auto;
}

.sidebar__version {
    padding: 0 var(--sp-3);
    font-size: var(--fs-xs);
    color: var(--text-muted);
}

.account {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.account__avatar {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--surface-muted);
    font-size: var(--fs-sm);
    font-weight: 600;
}
.account__text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; }
.account__name, .account__business { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account__name { font-size: var(--fs-sm); font-weight: 600; }
.account__business { font-size: var(--fs-xs); color: var(--text-muted); }

.main { min-width: 0; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-4);
    padding: var(--sp-6) var(--sp-8) 0;
}

.topbar__title {
    font-size: var(--fs-xl);
    font-weight: 650;
    letter-spacing: -0.01em;
}


.content {
    display: flex;
    flex-direction: column;
    gap: var(--sp-6);
    max-width: 1080px;
    padding: var(--sp-2) var(--sp-8) var(--sp-10);
}
.content:focus { outline: none; }

.page-lead { color: var(--text-muted); }

/* Centered layout (errors, login, installer) */
.centered {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: var(--sp-4);
}
.centered__box {
    display: flex;
    flex-direction: column;
    gap: var(--sp-6);
    width: 100%;
    max-width: 480px;
}

/* ---------- Brand ---------- */
.brand {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: 0 var(--sp-3);
    text-decoration: none;
    font-weight: 700;
    font-size: var(--fs-lg);
    letter-spacing: -0.02em;
}
.brand--center { justify-content: center; }

.brand__mark {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius);
    background: var(--primary);
    color: var(--primary-contrast);
    font-size: var(--fs-md);
}

/* ---------- Navigation ---------- */
.nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav__item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    min-height: 40px;
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: var(--fs-sm);
    font-weight: 500;
    text-decoration: none;
    transition: background var(--duration), color var(--duration);
}
.nav__item:hover { background: var(--surface-muted); color: var(--text); }
.nav__item.is-active { background: var(--primary); color: var(--primary-contrast); }
.nav__icon { width: 18px; height: 18px; }

/* ---------- Card ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: var(--sp-6);
}

.card__header {
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
    margin-bottom: var(--sp-5);
}
.card__title { font-size: var(--fs-md); font-weight: 650; }
.card__subtitle { font-size: var(--fs-sm); color: var(--text-muted); }

/* ---------- Stats ---------- */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--sp-4);
}

.stat {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    padding: var(--sp-5);
}
.stat__label { font-size: var(--fs-sm); color: var(--text-muted); }
.stat__value {
    font-size: var(--fs-2xl);
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}
.stat__value small { font-size: var(--fs-md); font-weight: 500; color: var(--text-muted); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    min-height: 44px;
    padding: 0 var(--sp-5);
    border: 1px solid transparent;
    border-radius: var(--radius);
    font: inherit;
    font-size: var(--fs-sm);
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background var(--duration), border-color var(--duration), color var(--duration);
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }

.btn--primary { background: var(--primary); color: var(--primary-contrast); }
.btn--primary:hover { background: var(--primary-hover); }

.btn--secondary { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn--secondary:hover { background: var(--surface-muted); }

.btn--ghost { background: transparent; color: var(--text); }
.btn--ghost:hover { background: var(--surface-muted); }

.btn--danger { background: var(--danger); color: var(--danger-contrast); }
.btn--danger:hover { filter: brightness(0.92); }

.btn--sm { min-height: 36px; padding: 0 var(--sp-3); }
.btn--block { width: 100%; }
.btn--icon { width: 36px; min-height: 36px; padding: 0; }

/* ---------- Chips ---------- */
.chip {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    padding: 2px var(--sp-2);
    border-radius: 999px;
    background: var(--surface-muted);
    color: var(--text-muted);
    font-size: var(--fs-xs);
    font-weight: 600;
    white-space: nowrap;
}
.chip--success { background: var(--success-soft); color: var(--success); }
.chip--warning { background: var(--warning-soft); color: var(--warning); }
.chip--danger { background: var(--danger-soft); color: var(--danger); }

/* ---------- Steps (onboarding) ---------- */
.steps {
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
    list-style: none;
}

.step {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: var(--sp-4);
    padding: var(--sp-4) 0;
    border-top: 1px solid var(--border);
}
.step:first-child { border-top: 0; padding-top: 0; }
.step:last-child { padding-bottom: 0; }

.step__marker {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 50%;
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text-muted);
}
.step.is-done .step__marker { background: var(--success-soft); border-color: transparent; color: var(--success); }
.step__title { font-size: var(--fs-sm); font-weight: 600; }
.step.is-done .step__title { color: var(--text-muted); text-decoration: line-through; }
.step__text { font-size: var(--fs-sm); color: var(--text-muted); }

/* ---------- Checklist (system status) ---------- */
.checklist {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    margin: 0;
    padding: 0;
    list-style: none;
}

.checklist__item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: var(--sp-3);
    font-size: var(--fs-sm);
}

.checklist__icon {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
}
.checklist__icon .icon { width: 14px; height: 14px; }
.checklist__item--ok .checklist__icon { background: var(--success-soft); color: var(--success); }
.checklist__item--warn .checklist__icon { background: var(--warning-soft); color: var(--warning); }
.checklist__item--fail .checklist__icon { background: var(--danger-soft); color: var(--danger); }
.checklist__detail { color: var(--text-muted); text-align: right; }

/* Narrow containers: detail goes under the label. */
.centered .checklist__item { grid-template-columns: auto 1fr; }
.centered .checklist__detail { grid-column: 2; text-align: left; font-size: var(--fs-xs); }

/* ---------- Empty state ---------- */
.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-10) var(--sp-6);
    text-align: center;
}

.empty__icon {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    margin-bottom: var(--sp-2);
    border-radius: 50%;
    background: var(--surface-muted);
    color: var(--text);
}
.empty__icon .icon { width: 24px; height: 24px; }
.empty__code { font-size: var(--fs-2xl); font-weight: 700; color: var(--text-muted); }
.empty__title { font-size: var(--fs-lg); font-weight: 650; }
.empty__text { max-width: 420px; color: var(--text-muted); margin-bottom: var(--sp-2); }

.debug {
    width: 100%;
    max-height: 320px;
    overflow: auto;
    margin: var(--sp-4) 0 0;
    padding: var(--sp-4);
    border-radius: var(--radius);
    background: var(--surface-muted);
    font-family: var(--mono);
    font-size: var(--fs-xs);
    text-align: left;
    white-space: pre-wrap;
}

/* ---------- Intro (centered pages) ---------- */
.intro { display: flex; flex-direction: column; gap: var(--sp-1); text-align: center; }
.intro__title { font-size: var(--fs-xl); font-weight: 650; letter-spacing: -0.01em; }
.intro__text { color: var(--text-muted); font-size: var(--fs-sm); }
.help-text { font-size: var(--fs-sm); color: var(--text-muted); text-align: center; }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: var(--sp-5); }
.form > .card__header { margin-bottom: 0; }
.form__section {
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
    margin: 0;
    padding: 0;
    border: 0;
    min-width: 0;
}
.form__section legend { padding: 0; margin-bottom: var(--sp-4); }
.form__narrow { display: flex; flex-direction: column; gap: var(--sp-4); max-width: 420px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: var(--fs-sm); font-weight: 600; }
.field__hint { font-size: var(--fs-xs); color: var(--text-muted); }
.field__error { font-size: var(--fs-xs); font-weight: 500; color: var(--danger); }
.field__control { position: relative; }

.input {
    width: 100%;
    min-height: 44px;
    padding: 0 var(--sp-3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: var(--fs-md); /* 16px avoids iOS zoom on focus */
    transition: border-color var(--duration), box-shadow var(--duration);
}
.input:hover { border-color: var(--text-muted); }
.input:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus-ring); }
.input:disabled { opacity: 0.6; cursor: not-allowed; }
.has-error .input { border-color: var(--danger); }
.field__control .input[type="password"], .field__control .input.is-revealed { padding-right: 84px; }

.field__toggle {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    min-height: 32px;
    padding: 0 var(--sp-2);
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-size: var(--fs-xs);
    font-weight: 600;
    cursor: pointer;
}
.field__toggle:hover { background: var(--surface-muted); color: var(--text); }

/* ---------- Alerts ---------- */
.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-2);
    margin: 0;
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--radius);
    font-size: var(--fs-sm);
}
.alert .icon { margin-top: 2px; }
.card > .alert { margin-top: var(--sp-4); }
.alert--danger { background: var(--danger-soft); color: var(--danger); }
.alert--warning { background: var(--warning-soft); color: var(--warning); }

/* ---------- Toasts ---------- */
.toasts {
    position: fixed;
    top: var(--sp-4);
    right: var(--sp-4);
    z-index: 90;
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    max-width: min(400px, calc(100vw - 2 * var(--sp-4)));
}
.toast {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--sp-4);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 8px 24px rgb(0 0 0 / 0.12);
    font-size: var(--fs-sm);
    animation: toast-in 200ms ease-out;
}
.toast span { flex: 1; }
.toast--success > .icon { color: var(--success); }
.toast--danger > .icon { color: var(--danger); }
.toast.is-leaving { opacity: 0; transform: translateY(-4px); transition: opacity 200ms, transform 200ms; }
.toast__close {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}
.toast__close:hover { background: var(--surface-muted); }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(-8px); }
}

/* ---------- Details list ---------- */
.details { display: flex; flex-direction: column; gap: var(--sp-3); margin: 0 0 var(--sp-5); }
.details div { display: grid; grid-template-columns: 120px 1fr; gap: var(--sp-4); font-size: var(--fs-sm); }
.details dt { color: var(--text-muted); }
.details dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }

.empty--compact { padding: var(--sp-6); }
.empty--compact .empty__text { margin: 0; }

/* ---------- Utilities ---------- */
.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}
.link {
    color: var(--text);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}
.muted-center { padding: var(--sp-8) 0; color: var(--text-muted); text-align: center; font-size: var(--fs-sm); }

/* ---------- Dropzone ---------- */
.dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-1);
    padding: var(--sp-6);
    border: 1.5px dashed var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    text-align: center;
    transition: border-color var(--duration), background var(--duration);
}
.dropzone--large { padding: var(--sp-10) var(--sp-6); }
.dropzone:focus-within { border-color: var(--text-muted); }
.dropzone.is-dragging { border-color: var(--primary); background: var(--surface-muted); }
.dropzone__icon {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    margin-bottom: var(--sp-2);
    border-radius: 50%;
    background: var(--surface-muted);
}
.dropzone--large .dropzone__icon { width: 56px; height: 56px; }
.dropzone__title { font-size: var(--fs-md); font-weight: 650; }
.dropzone__text { font-size: var(--fs-sm); color: var(--text-muted); }
/* Touch devices can't drag files: only offer the picker. */
@media (hover: none) {
    .drag-only { display: none; }
}
.dropzone__hint { font-size: var(--fs-xs); color: var(--text-muted); }
.dropzone .link:focus-visible, .dropzone input:focus-visible + * { outline: 2px solid var(--primary); }

/* ---------- Upload queue ---------- */
.uploads { display: flex; flex-direction: column; gap: var(--sp-2); margin: 0; padding: 0; list-style: none; }
.upload {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: var(--sp-2) var(--sp-4);
    padding: var(--sp-3) var(--sp-4);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}
.upload__info { display: flex; justify-content: space-between; gap: var(--sp-3); min-width: 0; font-size: var(--fs-sm); }
.upload__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.upload__status { flex-shrink: 0; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.upload .progress { grid-column: 1; }
.upload__action { grid-column: 2; grid-row: 1 / span 2; }
.upload[data-state="done"] .upload__status { color: var(--success); }
.upload[data-state="error"] .upload__status { color: var(--danger); white-space: normal; text-align: right; }
.upload[data-state="error"] .progress__bar { background: var(--danger); }
.upload[data-state="done"] .progress__bar { background: var(--success); }

.progress { height: 6px; overflow: hidden; border-radius: 999px; background: var(--surface-muted); }
.progress__bar { width: 0; height: 100%; border-radius: inherit; background: var(--primary); transition: width 200ms linear; }

/* ---------- Tabs ---------- */
.section-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); margin-bottom: var(--sp-4); }
.tabs { display: flex; gap: var(--sp-1); padding: 3px; border-radius: var(--radius); background: var(--surface-muted); }
.tabs__item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding: 0 var(--sp-3);
    border-radius: 6px;
    color: var(--text-muted);
    font-size: var(--fs-sm);
    font-weight: 500;
    text-decoration: none;
}
.tabs__item:hover { color: var(--text); }
.tabs__item.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.tabs__count { font-size: var(--fs-xs); color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ---------- Media grid ---------- */
.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--sp-4);
    margin: 0;
    padding: 0;
    list-style: none;
}
.media-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow);
}
.media-card__thumb {
    position: relative;
    display: block;
    aspect-ratio: 16 / 9;
    background: #000;
    overflow: hidden;
}
.media-card__thumb img { width: 100%; height: 100%; object-fit: contain; transition: transform 250ms; }
.media-card__thumb:hover img { transform: scale(1.03); }
.media-card__thumb:focus-visible { outline-offset: -3px; border-radius: 0; }
.media-card__placeholder { display: grid; place-items: center; height: 100%; color: #a1a1aa; }
.media-card__placeholder .icon { width: 32px; height: 32px; }
.media-card__play {
    position: absolute;
    inset: 50% auto auto 50%;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgb(0 0 0 / 0.55);
    color: #fff;
    transform: translate(-50%, -50%);
    opacity: 0.9;
    transition: opacity var(--duration);
}
.media-card__play .icon { width: 18px; height: 18px; margin-left: 2px; fill: currentColor; }
.media-card__thumb:hover .media-card__play { opacity: 1; }
.media-card__badge {
    position: absolute;
    right: var(--sp-2);
    bottom: var(--sp-2);
    padding: 2px 6px;
    border-radius: 4px;
    background: rgb(0 0 0 / 0.7);
    color: #fff;
    font-size: var(--fs-xs);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.media-card__body { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-3) var(--sp-2) var(--sp-3) var(--sp-4); }
.media-card__text { flex: 1; min-width: 0; }
.media-card__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-sm); font-weight: 600; }
.media-card__meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-xs); color: var(--text-muted); }
.media-card__warning { margin-top: var(--sp-1); }
.media-card .btn--icon { color: var(--text-muted); }
.media-card .btn--icon:hover { color: var(--danger); background: var(--danger-soft); }

/* ---------- Modal ---------- */
.modal {
    width: min(420px, calc(100vw - 2 * var(--sp-4)));
    max-height: calc(100vh - 2 * var(--sp-8));
    padding: var(--sp-6);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 24px 64px rgb(0 0 0 / 0.25);
}
.modal--wide { width: min(960px, calc(100vw - 2 * var(--sp-4))); }
.modal::backdrop { background: rgb(0 0 0 / 0.55); }
.modal[open] { animation: modal-in 180ms ease-out; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }

.modal__header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4); margin-bottom: var(--sp-4); }
.modal__icon {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    margin-bottom: var(--sp-4);
    border-radius: 50%;
    background: var(--danger-soft);
    color: var(--danger);
}
.modal__title { font-size: var(--fs-lg); font-weight: 650; overflow-wrap: anywhere; }
.modal__subtitle { font-size: var(--fs-sm); color: var(--text-muted); }
.modal__text { margin-top: var(--sp-2); color: var(--text-muted); font-size: var(--fs-sm); }
.modal__note { margin-top: var(--sp-3); font-size: var(--fs-xs); color: var(--text-muted); }
.modal__actions { display: flex; justify-content: flex-end; gap: var(--sp-2); margin-top: var(--sp-6); }

.preview {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: var(--radius);
    background: #000;
}
.preview video, .preview img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }

/* ---------- Page header ---------- */
.page-header { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; }
.note { font-size: var(--fs-sm); color: var(--text-muted); }
.optional { margin-left: var(--sp-1); font-size: var(--fs-xs); font-weight: 500; color: var(--text-muted); }
.text-warning { color: var(--warning); }
.btn--danger-hover:hover { color: var(--danger); background: var(--danger-soft); }

/* ---------- Switch (instant toggle button) ---------- */
.switch {
    position: relative;
    width: 44px;
    height: 26px;
    flex-shrink: 0;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: var(--border);
    cursor: pointer;
    transition: background var(--duration);
}
.switch[aria-checked="true"] { background: var(--success); }
.switch__thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgb(0 0 0 / 0.3);
    transition: transform var(--duration);
}
.switch[aria-checked="true"] .switch__thumb { transform: translateX(18px); }

/* ---------- Toggle (checkbox styled as a switch, inside forms) ---------- */
.toggle { display: flex; align-items: flex-start; gap: var(--sp-3); cursor: pointer; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle__track {
    position: relative;
    flex-shrink: 0;
    width: 40px;
    height: 24px;
    margin-top: 1px;
    border-radius: 999px;
    background: var(--border);
    transition: background var(--duration);
}
.toggle__thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgb(0 0 0 / 0.3);
    transition: transform var(--duration);
}
.toggle input:checked + .toggle__track { background: var(--primary); }
.toggle input:checked + .toggle__track .toggle__thumb { transform: translateX(16px); background: var(--primary-contrast); }
.toggle input:focus-visible + .toggle__track { outline: 2px solid var(--primary); outline-offset: 2px; }
.toggle__label { display: block; font-size: var(--fs-sm); font-weight: 600; }
.toggle__hint { display: block; font-size: var(--fs-xs); color: var(--text-muted); }

/* ---------- Live indicator ---------- */
.pulse { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }

/* ---------- Campaign list ---------- */
.campaigns { display: flex; flex-direction: column; gap: var(--sp-3); margin: 0; padding: 0; list-style: none; }
.campaign {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: var(--sp-4);
    padding: var(--sp-4);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow);
}
.campaign.is-paused .campaign__thumbs, .campaign.is-paused .campaign__main { opacity: 0.6; }
.campaign__thumbs { display: flex; width: 120px; height: 68px; overflow: hidden; border-radius: var(--radius); background: #000; }
.campaign__thumbs img, .campaign__thumb-placeholder { flex: 1; min-width: 0; height: 100%; object-fit: cover; }
.campaign__thumbs > * + * { border-left: 2px solid var(--surface); }
.campaign__thumb-placeholder { display: grid; place-items: center; color: #a1a1aa; }
.campaign__main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.campaign__head { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.campaign__name { font-size: var(--fs-md); font-weight: 650; }
.campaign__name a { text-decoration: none; }
.campaign__name a:hover { text-decoration: underline; text-underline-offset: 3px; }
.campaign__meta, .campaign__schedule { font-size: var(--fs-sm); color: var(--text-muted); }
.campaign__schedule .icon { width: 14px; height: 14px; margin-right: 4px; vertical-align: -2px; }
.campaign__schedule > span { white-space: nowrap; }
.campaign__schedule > span:first-child { white-space: normal; }
.campaign__validity { margin-left: var(--sp-3); }
.campaign__actions { display: flex; align-items: center; gap: var(--sp-1); }
.campaign__actions .switch { margin-right: var(--sp-2); }

/* ---------- Campaign form ---------- */
.campaign-form { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: var(--sp-6); align-items: start; }
.campaign-form__main { display: flex; flex-direction: column; gap: var(--sp-4); min-width: 0; }
.campaign-form__aside { position: sticky; top: var(--sp-6); }
.card.has-error { border-color: var(--danger); }
.card > .field__error { margin: calc(-1 * var(--sp-2)) 0 var(--sp-3); }

.inline-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--sp-4); }
.input-suffix { display: flex; align-items: center; gap: var(--sp-2); }
.input-suffix .input { width: 96px; }
.input-suffix span { font-size: var(--fs-sm); color: var(--text-muted); }

/* Media picker */
.picker { display: flex; flex-direction: column; gap: var(--sp-2); margin: 0; padding: 0; list-style: none; }
.picker__item {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding-right: var(--sp-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color var(--duration), background var(--duration);
}
.picker__item.is-selected { border-color: var(--primary); background: var(--surface-muted); }
.picker__label { display: flex; flex: 1; align-items: center; gap: var(--sp-3); min-width: 0; padding: var(--sp-2) var(--sp-3); cursor: pointer; }
.picker__label input { width: 18px; height: 18px; flex-shrink: 0; accent-color: var(--primary); }
.picker__thumb {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 72px;
    height: 40px;
    overflow: hidden;
    border-radius: 4px;
    background: #000;
    color: #a1a1aa;
}
.picker__thumb img { width: 100%; height: 100%; object-fit: cover; }
.picker__text { display: flex; flex-direction: column; min-width: 0; }
.picker__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-sm); font-weight: 600; }
.picker__meta { font-size: var(--fs-xs); color: var(--text-muted); }
.picker__position {
    margin-left: auto;
    min-width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--primary-contrast);
    font-size: var(--fs-xs);
    font-weight: 700;
    line-height: 24px;
    text-align: center;
}
.picker__position:empty { display: none; }
.picker__order { display: flex; gap: 2px; }
.picker__order[hidden] { display: none; }
.picker__order .btn:disabled { opacity: 0.3; }

/* Display mode cards */
.mode-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-3); margin-bottom: var(--sp-5); }
.mode-option {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
    padding: var(--sp-3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color var(--duration), box-shadow var(--duration);
}
.mode-option input { position: absolute; opacity: 0; }
.mode-option:has(input:checked) { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.mode-option:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }
.mode-option__label { font-size: var(--fs-sm); font-weight: 600; }
.mode-option__text { font-size: var(--fs-xs); color: var(--text-muted); }

.mode-art {
    position: relative;
    display: block;
    aspect-ratio: 16 / 9;
    margin-bottom: var(--sp-2);
    overflow: hidden;
    border-radius: 4px;
    background: linear-gradient(135deg, #2f6b3a, #4d8a52);
}
.mode-art > span { position: absolute; background: var(--primary); border: 1px solid var(--primary-contrast); }
.mode-art--fullscreen > span { inset: 0; border: 0; }
.mode-art--lbar > span { inset: auto 0 0 0; height: 26%; }
.mode-art--corner > span { right: 6%; bottom: 8%; width: 34%; height: 34%; border-radius: 2px; }

/* Segmented control */
.segmented { display: inline-flex; flex-wrap: wrap; gap: var(--sp-1); margin-bottom: var(--sp-4); padding: 3px; border-radius: var(--radius); background: var(--surface-muted); }
.segmented label { position: relative; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; }
.segmented span { display: block; padding: var(--sp-2) var(--sp-3); border-radius: 6px; font-size: var(--fs-sm); font-weight: 500; color: var(--text-muted); }
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.segmented input:focus-visible + span { outline: 2px solid var(--primary); }

/* Schedule rows */
.slots { display: flex; flex-direction: column; align-items: flex-start; gap: var(--sp-3); }
.slots[hidden] { display: none; }
.slots > [data-slot-list] { display: flex; flex-direction: column; gap: var(--sp-3); width: 100%; }
.slot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    min-width: 0; /* fieldsets default to min-content and overflow narrow cards */
    margin: 0;
    padding: var(--sp-3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.slot__days { display: flex; flex-wrap: wrap; gap: var(--sp-1); }
.day-chip { position: relative; cursor: pointer; }
.day-chip input { position: absolute; opacity: 0; }
.day-chip span {
    display: grid;
    place-items: center;
    min-width: 40px;
    height: 36px;
    padding: 0 var(--sp-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--text-muted);
    user-select: none;
}
.day-chip input:checked + span { border-color: var(--primary); background: var(--primary); color: var(--primary-contrast); }
.day-chip input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.slot__times { display: flex; align-items: center; gap: var(--sp-2); }
.slot__time .input { width: 136px; }
.slot__sep { font-size: var(--fs-sm); color: var(--text-muted); }

.screen-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.screen-list[hidden] { display: none; }
.check { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }

/* Summary + TV preview */
.summary { display: flex; flex-direction: column; gap: var(--sp-4); }
.tv {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border: 4px solid #111;
    border-radius: 6px;
    background: #111;
}
.tv__show { position: absolute; inset: 0; background: repeating-linear-gradient(90deg, #2f6b3a 0 18px, #357540 18px 36px); }
.tv__score { position: absolute; top: 6px; left: 6px; padding: 1px 6px; border-radius: 2px; background: rgb(0 0 0 / 0.7); color: #fff; font-size: 10px; font-weight: 700; }
.tv__ad {
    position: absolute;
    display: grid;
    place-items: center;
    overflow: hidden;
    background: #000;
    transition: all 250ms ease;
}
.tv__ad img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.tv__ad[hidden], .tv__ad img[hidden], .tv__ad-label[hidden] { display: none; }
.tv__ad-label { color: #fff; font-size: var(--fs-xs); font-weight: 600; }
.tv[data-mode="fullscreen"] .tv__ad { inset: 0; }
.tv[data-mode="lbar"] .tv__ad { inset: auto 0 0 0; height: 24%; }
.tv[data-mode="lbar"] .tv__ad img { object-fit: cover; }
.tv[data-mode="corner"] .tv__ad { right: 5%; bottom: 7%; width: 36%; height: 36%; border: 1px solid rgb(255 255 255 / 0.6); }

.summary__list { display: flex; flex-direction: column; gap: var(--sp-2); margin: 0; font-size: var(--fs-sm); }
.summary__list div { display: flex; justify-content: space-between; gap: var(--sp-3); }
.summary__list dt { color: var(--text-muted); }
.summary__list dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.summary__actions { display: flex; flex-direction: column; gap: var(--sp-2); }

@media (max-width: 1023px) {
    .campaign-form { grid-template-columns: 1fr; }
    .campaign-form__aside { position: static; }
}

/* ---------- Screens ---------- */
.text-success { color: var(--success); }
.empty__icon--success { background: var(--success-soft); color: var(--success); }

.pairing { display: flex; flex-wrap: wrap; gap: var(--sp-6) var(--sp-8); align-items: center; }
.pairing__steps { display: flex; flex: 1 1 280px; flex-direction: column; gap: var(--sp-4); min-width: 0; }
.numbered { display: flex; flex-direction: column; gap: var(--sp-3); margin: 0; padding-left: var(--sp-5); font-size: var(--fs-sm); }
.numbered li::marker { font-weight: 700; }
.numbered li > .field__error { display: block; margin-top: var(--sp-1); }
.copy { display: flex; align-items: center; gap: var(--sp-2); margin-top: var(--sp-2); }
.copy code {
    min-width: 0;
    overflow: hidden;
    padding: var(--sp-2) var(--sp-3);
    border-radius: 6px;
    background: var(--surface-muted);
    font-family: var(--mono);
    font-size: var(--fs-sm);
    text-overflow: ellipsis;
    white-space: nowrap;
    user-select: all;
}

.pairing__code, .pairing__result {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-3);
    flex: 1 1 300px;
    padding: var(--sp-6);
    border-radius: var(--radius-lg);
    background: var(--surface-muted);
    text-align: center;
}
.pairing__code[hidden], .pairing__result[hidden] { display: none; }
.pairing__result-title { font-weight: 650; }
.code { display: flex; gap: 6px; margin: 0; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.code span:not(.code__gap) {
    display: grid;
    place-items: center;
    width: 40px;
    height: 52px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    font-size: 28px;
    font-weight: 700;
}
.code__gap { width: 8px; }
.pairing__status { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); color: var(--text-muted); }
.pairing__status [data-countdown] { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text); }
.spinner {
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--text);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.screens { display: flex; flex-direction: column; gap: var(--sp-3); margin: 0; padding: 0; list-style: none; }
.screen {
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    padding: var(--sp-4) var(--sp-4) var(--sp-4) var(--sp-5);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow);
}
.status-dot { flex-shrink: 0; width: 10px; height: 10px; border-radius: 50%; background: var(--text-muted); opacity: 0.5; }
.status-dot.is-online { background: var(--success); opacity: 1; box-shadow: 0 0 0 4px var(--success-soft); }
.screen__main { flex: 1; min-width: 0; }
.screen__name { font-size: var(--fs-md); font-weight: 650; }
.screen__meta { font-size: var(--fs-sm); color: var(--text-muted); }
.screen__actions { position: relative; display: flex; align-items: center; gap: var(--sp-1); }

.rename summary { list-style: none; }
.rename summary::-webkit-details-marker { display: none; }
.rename[open] summary { background: var(--surface-muted); }
.rename__form {
    position: absolute;
    top: calc(100% + var(--sp-2));
    right: 0;
    z-index: 20;
    display: flex;
    gap: var(--sp-2);
    width: min(340px, calc(100vw - 2 * var(--sp-4)));
    padding: var(--sp-3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 12px 32px rgb(0 0 0 / 0.18);
}
.rename__form .input { min-height: 36px; }

/* ---------- Dashboard ---------- */
.stat--link { color: inherit; text-decoration: none; transition: border-color var(--duration); }
.stat--link:hover { border-color: var(--text-muted); }
.stat__hint { font-size: var(--fs-xs); color: var(--text-muted); }
.card__header--row { flex-direction: row; align-items: flex-start; justify-content: space-between; gap: var(--sp-4); }

.alerts { display: flex; flex-direction: column; gap: var(--sp-2); }
.notice {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--sp-4);
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: var(--fs-sm);
}
.notice p { flex: 1; }
.notice > .icon { flex-shrink: 0; }
.notice--danger { background: var(--danger-soft); color: var(--danger); }
.notice--warning { background: var(--warning-soft); color: var(--warning); }
.notice--info { border-color: var(--border); background: var(--surface); color: var(--text); }
.notice--info > .icon { color: var(--text-muted); }
.notice .btn { color: inherit; flex-shrink: 0; }

.live-list { display: flex; flex-direction: column; gap: var(--sp-3); margin: 0; padding: 0; list-style: none; }
.live-list li { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.live-list a { font-weight: 600; text-decoration: none; }
.live-list a:hover { text-decoration: underline; }

/* ---------- Reports ---------- */
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--sp-4); padding: var(--sp-4); }
.filters__fields { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--sp-3); }
.filters__field { display: flex; flex-direction: column; gap: 4px; font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted); }
.filters__field .input { min-height: 40px; width: auto; }

.chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart__axis { stroke: var(--border); }
.chart__bar { fill: var(--text-muted); opacity: 0.55; transition: opacity var(--duration); }
.chart__bar:hover, .chart__bar.is-max { fill: var(--primary); opacity: 1; }
.chart__label { fill: var(--text-muted); font-size: 11px; font-family: var(--font); }
.chart__data { margin-top: var(--sp-4); font-size: var(--fs-sm); }
.chart__data summary { color: var(--text-muted); cursor: pointer; }
.chart__data .table-wrap { margin-top: var(--sp-3); max-height: 280px; overflow: auto; }

.table-wrap { overflow-x: auto; margin: 0 calc(-1 * var(--sp-2)); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th, .table td { padding: var(--sp-2); border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table thead th { font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.table tbody th { font-weight: 600; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table tbody th.muted { color: var(--text-muted); font-style: italic; font-weight: 500; }
.table tbody tr:last-child > * { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .share { width: 140px; white-space: nowrap; }
.share-bar { width: 90px; height: 6px; vertical-align: middle; }
.share-bar__bg { fill: var(--surface-muted); }
.share-bar__fg { fill: var(--primary); }
.share__pct { display: inline-block; width: 36px; margin-left: var(--sp-1); text-align: right; font-size: var(--fs-xs); color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* The share bar is a nice-to-have: drop it before the numbers get squeezed. */
@media (max-width: 1099px) {
    .table .share { display: none; }
    .table tbody th { max-width: 180px; }
    .table thead th, .table thead th.num { white-space: normal; }
}

/* ---------- Settings ---------- */
.settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: var(--sp-4); align-items: start; }
.disclosure summary { list-style: none; display: inline-flex; }
.disclosure summary::-webkit-details-marker { display: none; }
.disclosure[open] summary { margin-bottom: var(--sp-4); }
.disclosure__body { padding-top: var(--sp-2); }
.account-logout { margin-top: var(--sp-4); padding-top: var(--sp-4); border-top: 1px solid var(--border); }
.backup-options { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.backup-options li { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); padding: var(--sp-4) 0; border-top: 1px solid var(--border); }
.backup-options li:first-child { padding-top: 0; border-top: 0; }
.backup-options li:last-child { padding-bottom: 0; }
.backup-options__title { font-size: var(--fs-sm); font-weight: 600; }
.backup-options__text { font-size: var(--fs-sm); color: var(--text-muted); }

/* ---------- Responsive: bottom navigation on phones ---------- */
@media (max-width: 767px) {
    .app { grid-template-columns: 1fr; }

    .sidebar {
        position: fixed;
        inset: auto 0 0 0;
        z-index: 50;
        height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
        padding: 0 0 env(safe-area-inset-bottom);
        border-right: 0;
        border-top: 1px solid var(--border);
    }
    .sidebar .brand, .sidebar__footer { display: none; }
    .toasts { top: auto; bottom: calc(var(--bottom-nav-height) + var(--sp-4)); left: var(--sp-4); right: var(--sp-4); max-width: none; }
    .details div { grid-template-columns: 1fr; gap: 2px; }

    .media-grid { grid-template-columns: repeat(2, 1fr); gap: var(--sp-3); }
    .media-card__body { padding: var(--sp-2) var(--sp-1) var(--sp-2) var(--sp-3); }
    .tabs { width: 100%; }
    .tabs__item { flex: 1; justify-content: center; padding: 0 var(--sp-2); white-space: nowrap; }
    .modal { padding: var(--sp-5); }
    .modal__actions .btn { flex: 1; }

    .campaign { grid-template-columns: 1fr auto; gap: var(--sp-3); }
    .campaign__thumbs { display: none; }
    .campaign__validity { display: block; margin-left: 0; }
    .mode-options { grid-template-columns: 1fr; }
    .mode-option { flex-direction: row; flex-wrap: wrap; align-items: center; column-gap: var(--sp-3); }
    .mode-option .mode-art { width: 80px; margin: 0; }
    .mode-option__label { flex: 1; }
    .mode-option__text { flex-basis: 100%; }
    .segmented { display: flex; }
    .segmented label { flex: 1; text-align: center; }
    .slot { padding: var(--sp-2); }
    .slot__days { width: 100%; flex-wrap: nowrap; gap: 3px; }
    .slot__days .day-chip { flex: 1; min-width: 0; }
    .day-chip span { min-width: 0; padding: 0; }
    .slot__times { width: 100%; }
    .slot__time { flex: 1; min-width: 0; }
    .slot__time .input { width: 100%; padding: 0 var(--sp-2); }

    .pairing__code, .pairing__result { padding: var(--sp-5) var(--sp-3); }
    .code span:not(.code__gap) { width: 38px; height: 48px; font-size: 24px; }
    .screen { padding-left: var(--sp-4); gap: var(--sp-3); }

    .stat__hint { display: none; }
    .notice { flex-wrap: wrap; }
    .notice .btn { margin-left: auto; }
    .filters, .filters__fields { width: 100%; }
    .filters__field { flex: 1 1 130px; }
    .filters__field .input { width: 100%; }
    .table .share { display: none; }
    .settings { grid-template-columns: 1fr; }
    .backup-options li { flex-wrap: wrap; }
    .card__header--row { flex-wrap: wrap; }

    .nav { flex-direction: row; height: 100%; gap: 0; }
    .nav__item {
        flex: 1;
        flex-direction: column;
        justify-content: center;
        gap: 2px;
        min-width: 0;
        padding: var(--sp-1);
        border-radius: 0;
        font-size: 11px;
    }
    .nav__item.is-active { background: transparent; color: var(--text); }
    .nav__item.is-active .nav__icon { color: var(--text); }
    .nav__label { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

    .topbar { padding: var(--sp-5) var(--sp-4) 0; }
    .content {
        padding: var(--sp-2) var(--sp-4) calc(var(--bottom-nav-height) + var(--sp-8));
        gap: var(--sp-4);
    }
    .card { padding: var(--sp-5) var(--sp-4); }

    .stats { grid-template-columns: repeat(3, 1fr); gap: var(--sp-2); }
    .stat { padding: var(--sp-3); gap: var(--sp-1); }
    .stat__label { font-size: var(--fs-xs); line-height: 1.3; }
    .stat__value { font-size: var(--fs-xl); }

    .step { grid-template-columns: auto 1fr; }
    .step > .btn, .step > .chip { grid-column: 2; justify-self: start; }

    .checklist__item { grid-template-columns: auto 1fr; }
    .checklist__detail { grid-column: 2; text-align: left; font-size: var(--fs-xs); }
}
