/* =========================================================
   NEXT — base.css
   Design tokens, reset, typography and shared components.
   Direction: a navy departure board with amber signals.
   ========================================================= */

@font-face {
    font-family: 'Bricolage';
    font-style: normal;
    font-display: swap;
    font-weight: 200 800;
    src: url('/fonts/bricolage-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'Bricolage';
    font-style: normal;
    font-display: swap;
    font-weight: 200 800;
    src: url('/fonts/bricolage-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- Tokens ---------- */

:root {
    --font: 'Bricolage', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

    --r-xs: 6px;
    --r-sm: 10px;
    --r-md: 14px;
    --r-lg: 20px;
    --r-xl: 28px;

    --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
    --spring: cubic-bezier(0.34, 1.45, 0.64, 1);

    --accent: #ffb224;
    --accent-ink: #1a1100;

    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

:root,
:root[data-theme='dark'] {
    color-scheme: dark;
    --bg: #070c1a;
    --bg-2: #0a1124;
    --panel: #0e1730;
    --panel-2: #131f3f;
    --sunken: #091022;
    --raised: #182550;
    --line: rgba(148, 175, 255, 0.12);
    --line-2: rgba(148, 175, 255, 0.23);
    --text: #eaf0ff;
    --text-2: #b6c3e8;
    --muted: #8091ba;
    --link: #93b8ff;
    --ok: #3ddc97;
    --warn: #ffb224;
    --bad: #ff6f6f;
    --info: #6aa8ff;
    --shadow: 0 24px 60px -18px rgba(0, 0, 0, 0.65);
    --dots: rgba(148, 175, 255, 0.07);
    --accent-text: var(--accent);
}

:root[data-theme='light'] {
    color-scheme: light;
    --bg: #edf1f9;
    --bg-2: #e5eaf5;
    --panel: #ffffff;
    --panel-2: #f4f6fc;
    --sunken: #eef1f9;
    --raised: #ffffff;
    --line: rgba(13, 27, 70, 0.1);
    --line-2: rgba(13, 27, 70, 0.2);
    --text: #0a1230;
    --text-2: #35426b;
    --muted: #66739a;
    --link: #1f46c8;
    --ok: #0e8f5a;
    --warn: #a35f00;
    --bad: #c93a3a;
    --info: #1f5fd0;
    --shadow: 0 24px 60px -20px rgba(20, 35, 90, 0.28);
    --dots: rgba(13, 27, 70, 0.055);
    --accent-text: color-mix(in srgb, var(--accent) 50%, #1a1100);
}

/* ---------- Reset ---------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-optical-sizing: auto;
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image: radial-gradient(var(--dots) 1px, transparent 1px);
    background-size: 26px 26px;
    mask-image: linear-gradient(to bottom, #000 0%, transparent 70%);
    -webkit-mask-image: linear-gradient(to bottom, #000 0%, transparent 70%);
}
h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
ul[role='list'], ol[role='list'], .plain { list-style: none; padding: 0; margin: 0; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
::selection { background: color-mix(in srgb, var(--accent) 40%, transparent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.sr-only {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Typography ---------- */

h1 { font-size: clamp(28px, 4.2vw, 40px); line-height: 1.08; letter-spacing: -0.028em; font-weight: 750; }
h2 { font-size: 21px; line-height: 1.2; letter-spacing: -0.02em; font-weight: 700; }
h3 { font-size: 16.5px; line-height: 1.3; letter-spacing: -0.012em; font-weight: 650; }
.lede { color: var(--text-2); font-size: 16px; max-width: 58ch; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.strong { font-weight: 650; }
.clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Brand ---------- */

.brand { display: flex; align-items: center; gap: 12px; color: var(--text); font-weight: 750; font-size: 19px; letter-spacing: -0.03em; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark {
    display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 11px;
    background: var(--bg); border: 1px solid var(--line-2);
}
.brand-mark svg { width: 24px; height: 24px; }
.brand-mark path { fill: none; stroke: var(--accent); stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; }
.brand-mark path:nth-child(2) { stroke-opacity: 0.42; }
.brand-sm { font-size: 17px; }
.brand-sm .brand-mark { width: 32px; height: 32px; }

/* ---------- Icons ---------- */

.ic { width: 1.25em; height: 1.25em; flex: none; stroke-width: 1.8; }
.ic-sm { width: 1.05em; height: 1.05em; }
.ic-lg { width: 1.6em; height: 1.6em; }
.spin { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Layout helpers ---------- */

.stack { display: flex; flex-direction: column; gap: var(--gap, 16px); }
.stack-sm { --gap: 8px; }
.stack-lg { --gap: 28px; }
.row { display: flex; align-items: center; gap: var(--gap, 12px); }
.row-wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.grid { display: grid; gap: var(--gap, 16px); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) {
    .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .stat { padding: 14px 16px; }
    .stat-value { font-size: 28px; }
}

/* ---------- Buttons ---------- */

.btn {
    --h: 42px;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: var(--h); padding: 0 18px;
    border: 1px solid transparent; border-radius: var(--r-sm);
    background: var(--panel-2); color: var(--text);
    font-size: 14px; font-weight: 650; letter-spacing: -0.005em; line-height: 1;
    white-space: nowrap; text-decoration: none;
    transition: transform 0.18s var(--ease), background 0.18s var(--ease), border-color 0.18s var(--ease), box-shadow 0.2s var(--ease), opacity 0.2s;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.985); }
.btn:disabled, .btn[aria-disabled='true'] { opacity: 0.5; pointer-events: none; }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 22px -10px color-mix(in srgb, var(--accent) 80%, transparent); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #fff); box-shadow: 0 12px 28px -10px color-mix(in srgb, var(--accent) 90%, transparent); }
.btn-ghost { background: transparent; border-color: var(--line-2); }
.btn-ghost:hover { background: var(--panel-2); border-color: color-mix(in srgb, var(--accent) 45%, var(--line-2)); }
.btn-soft:hover { background: var(--raised); }
.btn-danger { background: color-mix(in srgb, var(--bad) 14%, transparent); border-color: color-mix(in srgb, var(--bad) 38%, transparent); color: var(--bad); }
.btn-danger:hover { background: color-mix(in srgb, var(--bad) 24%, transparent); }
.btn-warn { background: color-mix(in srgb, var(--warn) 14%, transparent); border-color: color-mix(in srgb, var(--warn) 38%, transparent); color: var(--warn); }
.btn-sm { --h: 34px; padding: 0 13px; font-size: 13px; }
.btn-lg { --h: 50px; padding: 0 24px; font-size: 15.5px; border-radius: var(--r-md); }
.btn-block { width: 100%; }
.btn-icon { width: var(--h); padding: 0; }
.btn.is-busy { pointer-events: none; opacity: 0.75; }
.btn.is-busy::after {
    content: ''; width: 14px; height: 14px; border-radius: 50%;
    border: 2px solid currentColor; border-right-color: transparent;
    animation: spin 0.7s linear infinite;
}

/* ---------- Forms ---------- */

.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field > label, .label { font-size: 13px; font-weight: 650; color: var(--text-2); }
.hint { font-size: 12.5px; color: var(--muted); }
.field-error { font-size: 13px; color: var(--bad); }

.input, .select, .textarea {
    width: 100%; min-height: 44px; padding: 10px 14px;
    background: var(--sunken); color: var(--text);
    border: 1px solid var(--line-2); border-radius: var(--r-sm);
    transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease), background 0.15s;
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: 0.8; }
.input:hover, .select:hover, .textarea:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--line-2)); }
.input:focus, .select:focus, .textarea:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 20%, transparent);
}
.input:disabled { opacity: 0.55; cursor: not-allowed; }
.select {
    appearance: none; -webkit-appearance: none; padding-right: 38px; cursor: pointer;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238091ba' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 14px center;
}
.input-group { position: relative; }
.input-group .input { padding-right: 46px; }
.input-group .reveal-btn {
    position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
    width: 38px; height: 38px; display: grid; place-items: center;
    background: transparent; border: 0; border-radius: var(--r-xs); color: var(--muted);
}
.input-group .reveal-btn:hover { color: var(--text); }
.input-icon { position: relative; }
.input-icon .ic { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon .input { padding-left: 42px; }

.check { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; color: var(--text-2); cursor: pointer; }
.check input {
    appearance: none; -webkit-appearance: none; flex: none;
    width: 20px; height: 20px; margin: 1px 0 0; border-radius: 6px;
    border: 1.5px solid var(--line-2); background: var(--sunken); cursor: pointer;
    display: grid; place-items: center; transition: background 0.15s, border-color 0.15s, transform 0.15s var(--spring);
}
.check input::after {
    content: ''; width: 10px; height: 6px; margin-top: -2px;
    border-left: 2.5px solid var(--accent-ink); border-bottom: 2.5px solid var(--accent-ink);
    transform: rotate(-45deg) scale(0); transition: transform 0.18s var(--spring);
}
.check input:checked { background: var(--accent); border-color: var(--accent); }
.check input:checked::after { transform: rotate(-45deg) scale(1); }
.check input:active { transform: scale(0.9); }

.switch {
    position: relative; flex: none; width: 46px; height: 28px; padding: 0;
    border-radius: 999px; border: 1px solid var(--line-2); background: var(--sunken);
    transition: background 0.2s, border-color 0.2s;
}
.switch::after {
    content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
    background: var(--text-2); transition: transform 0.25s var(--spring), background 0.2s;
}
.switch[aria-checked='true'] { background: var(--accent); border-color: var(--accent); }
.switch[aria-checked='true']::after { transform: translateX(18px); background: var(--accent-ink); }

.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--sunken); border: 1px solid var(--line); border-radius: 999px; }
.seg button {
    height: 32px; padding: 0 15px; border: 0; border-radius: 999px; background: transparent;
    color: var(--muted); font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px;
    transition: background 0.15s, color 0.15s;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed='true'], .seg button.on { background: var(--raised); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); }

.meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 2px; }
.meter i { height: 4px; border-radius: 4px; background: var(--line-2); transition: background 0.2s; }
.meter[data-level='1'] i:nth-child(-n + 1) { background: var(--bad); }
.meter[data-level='2'] i:nth-child(-n + 2) { background: var(--warn); }
.meter[data-level='3'] i:nth-child(-n + 3) { background: var(--info); }
.meter[data-level='4'] i:nth-child(-n + 4) { background: var(--ok); }

/* ---------- Cards and panels ---------- */

.card {
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg);
    padding: 22px; min-width: 0;
}
.card-flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-head h2, .card-head h3 { display: flex; align-items: center; gap: 10px; }
.card-head .ic { color: var(--accent-text); }
.card-interactive { transition: transform 0.2s var(--ease), border-color 0.2s, background 0.2s; }
.card-interactive:hover { transform: translateY(-2px); border-color: var(--line-2); background: var(--panel-2); }
.divider { height: 1px; background: var(--line); border: 0; margin: 4px 0; }

.stat { display: flex; flex-direction: column; gap: 6px; padding: 18px 20px; border-radius: var(--r-md); background: var(--panel); border: 1px solid var(--line); }
.stat-top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 13px; font-weight: 600; }
.stat-top .ic { color: var(--accent-text); }
.stat-value { font-size: 34px; font-weight: 750; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }

/* ---------- Pills, avatars, ranks ---------- */

.pill {
    display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px;
    border-radius: 999px; font-size: 12px; font-weight: 650; white-space: nowrap;
    background: var(--panel-2); color: var(--text-2); border: 1px solid var(--line);
}
.pill .ic { width: 13px; height: 13px; }
.pill-ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.pill-warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); border-color: color-mix(in srgb, var(--warn) 32%, transparent); }
.pill-bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); border-color: color-mix(in srgb, var(--bad) 32%, transparent); }
.pill-info { color: var(--info); background: color-mix(in srgb, var(--info) 12%, transparent); border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.pill-accent { color: var(--accent-text); background: var(--accent-soft, color-mix(in srgb, var(--accent) 12%, transparent)); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }

.avatar {
    --s: 40px;
    position: relative; flex: none; width: var(--s); height: var(--s); border-radius: 50%;
    display: grid; place-items: center; overflow: hidden;
    background: linear-gradient(145deg, var(--raised), var(--panel-2)); border: 1px solid var(--line-2);
    font-size: calc(var(--s) * 0.38); font-weight: 700; color: var(--text-2); letter-spacing: -0.02em;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { --s: 30px; }
.avatar-lg { --s: 64px; }
.avatar-xl { --s: 96px; }

.rank { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 650; color: var(--text-2); white-space: nowrap; }
.rank-bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.rank-bars i { width: 3px; border-radius: 1.5px; background: var(--line-2); }
.rank-bars i:nth-child(1) { height: 5px; }
.rank-bars i:nth-child(2) { height: 7px; }
.rank-bars i:nth-child(3) { height: 9px; }
.rank-bars i:nth-child(4) { height: 11px; }
.rank-bars i:nth-child(5) { height: 14px; }
.rank-bars i.on { background: var(--accent); }
.rank-num { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------- Boards (sessions, schedules) ---------- */

.board { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: var(--sunken); }
.board-row {
    display: grid; grid-template-columns: 112px 1fr auto; align-items: center; gap: 16px;
    padding: 13px 18px; border-bottom: 1px solid var(--line);
}
.board-row:last-child { border-bottom: 0; }
.board-time { font-weight: 700; font-size: 15px; color: var(--accent-text); font-variant-numeric: tabular-nums; letter-spacing: 0.01em; }
.board-time small { display: block; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: 0; }
.board-title { font-weight: 650; }
.board-row.is-next { background: color-mix(in srgb, var(--accent) 9%, transparent); box-shadow: inset 3px 0 0 var(--accent); }
@media (max-width: 560px) { .board-row { grid-template-columns: 84px 1fr; } .board-row > :last-child { grid-column: 2; } }

/* ---------- Tabs, toolbar ---------- */

.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); }
.tabs::-webkit-scrollbar { display: none; }
.tab {
    position: relative; flex: none; height: 44px; padding: 0 16px; border: 0; background: transparent;
    color: var(--muted); font-size: 14px; font-weight: 650; display: inline-flex; align-items: center; gap: 8px;
    transition: color 0.15s;
}
.tab:hover { color: var(--text); }
.tab[aria-selected='true'] { color: var(--text); }
.tab[aria-selected='true']::after {
    content: ''; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 3px;
    border-radius: 3px 3px 0 0; background: var(--accent);
}
.tab .count { font-size: 11.5px; padding: 1px 7px; border-radius: 999px; background: var(--panel-2); color: var(--text-2); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.toolbar .input-icon { flex: 1; min-width: 200px; max-width: 360px; }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--panel); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
    text-align: left; padding: 12px 16px; font-size: 12.5px; font-weight: 650; color: var(--muted);
    background: var(--sunken); border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background 0.12s; }
.table tbody tr:hover { background: color-mix(in srgb, var(--accent) 5%, transparent); }

/* ---------- Lists ---------- */

.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item:first-child { padding-top: 0; }
.list-item:last-child { padding-bottom: 0; }

/* ---------- Banners ---------- */

.banner {
    display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border-radius: var(--r-md);
    border: 1px solid var(--line-2); background: var(--panel); font-size: 14px;
}
.banner > .ic { margin-top: 1px; }
.banner strong { display: block; font-weight: 700; }
.banner-info { border-color: color-mix(in srgb, var(--info) 35%, transparent); background: color-mix(in srgb, var(--info) 8%, var(--panel)); }
.banner-info > .ic { color: var(--info); }
.banner-warning, .banner-warn { border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: color-mix(in srgb, var(--warn) 9%, var(--panel)); }
.banner-warning > .ic, .banner-warn > .ic { color: var(--warn); }
.banner-critical, .banner-bad { border-color: color-mix(in srgb, var(--bad) 42%, transparent); background: color-mix(in srgb, var(--bad) 9%, var(--panel)); }
.banner-critical > .ic, .banner-bad > .ic { color: var(--bad); }
.banner-ok { border-color: color-mix(in srgb, var(--ok) 40%, transparent); background: color-mix(in srgb, var(--ok) 8%, var(--panel)); }
.banner-ok > .ic { color: var(--ok); }

/* ---------- Empty and loading ---------- */

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 48px 20px; }
.empty-icon {
    width: 60px; height: 60px; border-radius: 18px; display: grid; place-items: center;
    background: var(--panel-2); border: 1px solid var(--line-2); color: var(--accent-text); margin-bottom: 6px;
}
.empty-icon .ic { width: 26px; height: 26px; }
.empty p { color: var(--muted); max-width: 44ch; }
.empty .btn { margin-top: 10px; }

.skeleton { position: relative; overflow: hidden; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md); min-height: 20px; }
.skeleton::after {
    content: ''; position: absolute; inset: 0; transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--text) 7%, transparent), transparent);
    animation: shimmer 1.4s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }

/* ---------- Modal ---------- */

.modal-backdrop {
    position: fixed; inset: 0; z-index: 900; display: grid; place-items: center; padding: 20px;
    background: rgba(3, 6, 16, 0.62); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    animation: fade 0.2s var(--ease) both;
}
.modal {
    width: min(100%, var(--w, 520px)); max-height: min(88vh, 860px); display: flex; flex-direction: column;
    background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--r-lg); box-shadow: var(--shadow);
    animation: pop 0.28s var(--spring) both;
}
.modal-wide { --w: 720px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 22px 4px; }
.modal-body { padding: 14px 22px 8px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px 20px; flex-wrap: wrap; }
.modal-close { width: 36px; height: 36px; display: grid; place-items: center; border: 0; border-radius: 10px; background: transparent; color: var(--muted); }
.modal-close:hover { background: var(--panel-2); color: var(--text); }
body.modal-open { overflow: hidden; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(0.97); } }
@media (max-width: 600px) {
    .modal-backdrop { align-items: end; padding: 0; }
    .modal { width: 100%; max-height: 92dvh; border-radius: var(--r-lg) var(--r-lg) 0 0; animation: sheet 0.3s var(--ease) both; }
    .modal-foot { padding-bottom: calc(20px + var(--safe-bottom)); }
    .modal-foot .btn { flex: 1; }
}
@keyframes sheet { from { transform: translateY(100%); } }

/* ---------- Toasts ---------- */

.toasts {
    position: fixed; z-index: 1000; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translateX(-50%);
    display: flex; flex-direction: column; gap: 10px; width: min(92vw, 420px); pointer-events: none;
}
.toast {
    display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-radius: var(--r-md);
    background: var(--raised); border: 1px solid var(--line-2); box-shadow: var(--shadow);
    font-size: 14px; font-weight: 550; pointer-events: auto; animation: toast-in 0.35s var(--spring) both;
}
.toast.out { animation: toast-out 0.25s var(--ease) both; }
.toast .ic { flex: none; }
.toast.ok .ic { color: var(--ok); }
.toast.err .ic { color: var(--bad); }
.toast.info .ic { color: var(--info); }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(0.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(0.98); } }

/* ---------- Boot overlay ---------- */

.boot {
    position: fixed; inset: 0; z-index: 1100; display: grid; place-items: center; background: var(--bg);
    transition: opacity 0.35s var(--ease), visibility 0.35s;
}
.boot.done { opacity: 0; visibility: hidden; pointer-events: none; }
.boot-mark { display: flex; }
.boot-mark svg { width: 46px; height: 46px; }
.boot-mark path { fill: none; stroke: var(--accent); stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; }
.boot-mark path:nth-child(1) { animation: chev 1.1s var(--ease) infinite; }
.boot-mark path:nth-child(2) { animation: chev 1.1s var(--ease) 0.18s infinite; }
@keyframes chev { 0%, 100% { opacity: 0.25; transform: translateX(-3px); } 45% { opacity: 1; transform: translateX(3px); } }

/* ---------- Motion ---------- */

.rise > * { animation: rise 0.5s var(--ease) both; animation-delay: calc(var(--i, 0) * 50ms); }
.view-enter { animation: view-in 0.28s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}
html.reduce-motion *, html.reduce-motion *::before, html.reduce-motion *::after {
    animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important;
}
html.compact .card { padding: 16px; }
html.compact .list-item { padding: 10px 0; }
html.compact .table td { padding: 8px 14px; }

/* ---------- Shared extras ---------- */

.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.sub-head { margin: 22px 0 10px; font-size: 14px; font-weight: 700; color: var(--text-2); }
.empty-inline { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--r-md); background: var(--sunken); border: 1px dashed var(--line-2); color: var(--muted); }
.empty-inline p { margin: 0; font-size: 14px; }
.copy-box { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 8px 8px 16px; background: var(--sunken); border: 1px solid var(--line-2); border-radius: var(--r-sm); }
.copy-box code { font-family: inherit; font-weight: 700; font-size: 15px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 16px 0; }
.detail-grid > div { padding: 12px 14px; background: var(--sunken); border: 1px solid var(--line); border-radius: var(--r-sm); display: flex; flex-direction: column; gap: 3px; }
.detail-grid small { color: var(--muted); font-size: 12px; font-weight: 600; }
.detail-grid strong { font-weight: 650; font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.setting-row:last-child { border-bottom: 0; }
.setting-row > div:first-child { min-width: 0; flex: 1; }
.setting-row strong { display: block; font-size: 15px; font-weight: 650; }
.setting-row p { margin-top: 2px; max-width: 54ch; }
.setting-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 640px) { .setting-row { align-items: flex-start; flex-direction: column; gap: 12px; } .setting-controls { justify-content: flex-start; } }

.code-input { font-size: 26px; font-weight: 750; letter-spacing: 0.4em; text-align: center; font-variant-numeric: tabular-nums; }
.color-input { width: 52px; height: 44px; padding: 4px; border-radius: var(--r-sm); border: 1px solid var(--line-2); background: var(--sunken); cursor: pointer; }
.range { flex: 1; min-width: 0; accent-color: var(--accent); }
.rank-input { width: 90px; flex: none; text-align: center; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.chip { height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-2); background: transparent; font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; transition: border-color 0.15s, background 0.15s; }
.chip:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.suggest { display: flex; flex-direction: column; margin-top: 6px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--sunken); overflow: hidden; }
.suggest-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; }
.suggest-item:last-child { border-bottom: 0; }
.suggest-item:hover { background: var(--panel-2); }
.row-actions { display: flex; gap: 6px; flex: none; }
