/* EMLbot console: the www v3 system (white, black type, one blue accent) as a product UI. Dark mode follows the system. */
@font-face { font-family: "Inter"; src: url("fonts/inter.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Inter Tight"; src: url("fonts/inter-tight.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  --bg: #ffffff;
  --bg-2: #f7f8fa;
  --bg-3: #eff1f4;
  --panel: #ffffff;
  --ink: #0a0a0a;
  --ink-2: #2a2d33;
  --muted: #5d636e;
  --faint: #8d939e;
  --line: #e7e9ee;
  --line-2: #d9dce3;
  --blue: #005afd;
  --blue-soft: rgba(0, 90, 253, .09);
  --blue-ink: #0047c9;
  --go: #0e9f6e;
  --go-soft: rgba(14, 159, 110, .1);
  --hold: #b86e00;
  --hold-soft: rgba(184, 110, 0, .1);
  --stop: #dc3c42;
  --stop-soft: rgba(220, 60, 66, .09);
  --shadow: 0 1px 2px rgba(10, 10, 10, .04), 0 8px 24px -12px rgba(10, 10, 10, .16);
  --shadow-lg: 0 2px 6px rgba(10, 10, 10, .05), 0 32px 64px -24px rgba(10, 10, 10, .28);
  --r: 14px;
  --r-lg: 20px;
  --ease: cubic-bezier(.2, .7, .1, 1);
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Inter Tight", "Inter", system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --mint: #eaf7f1; --mint-ink: #0e7a55;
  --sky: #eaf2fe; --sky-ink: #1c5fd6;
  --lilac: #f1edfb; --lilac-ink: #6b4fc8;
  --peach: #fdf0e8; --peach-ink: #b5531e;
  --butter: #fbf6e3; --butter-ink: #8a6a00;
  --side: #fafbfc;
  --sb: 248px;
  --top: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0d12;
    --bg-2: #11141b;
    --bg-3: #171b24;
    --panel: #12151c;
    --ink: #f3f5f9;
    --ink-2: #d6dae3;
    --muted: #9aa1ae;
    --faint: #6f7684;
    --line: #222733;
    --line-2: #2d3341;
    --blue: #4d8dff;
    --blue-soft: rgba(77, 141, 255, .14);
    --blue-ink: #8db5ff;
    --go: #34c38f;
    --go-soft: rgba(52, 195, 143, .14);
    --hold: #f0a43a;
    --hold-soft: rgba(240, 164, 58, .14);
    --stop: #ff6b70;
    --stop-soft: rgba(255, 107, 112, .14);
    --mint: rgba(52, 195, 143, .14); --mint-ink: #6fe0b5;
    --sky: rgba(77, 141, 255, .16); --sky-ink: #9cc0ff;
    --lilac: rgba(160, 130, 255, .16); --lilac-ink: #c6b5ff;
    --peach: rgba(255, 150, 100, .15); --peach-ink: #ffb58f;
    --butter: rgba(240, 200, 80, .14); --butter-ink: #f0d27a;
    --side: #0e1117;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .6);
    --shadow-lg: 0 2px 6px rgba(0, 0, 0, .3), 0 32px 64px -24px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 14.5px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
img, video, svg { display: block; max-width: 100%; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { font-family: var(--display); margin: 0; letter-spacing: -0.025em; color: var(--ink); text-wrap: balance; }
h1 { font-size: 28px; line-height: 1.1; font-weight: 700; }
h2 { font-size: 17px; line-height: 1.25; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0; }
code, .mono { font-family: var(--mono); font-size: .9em; }
:not(pre) > code { background: var(--bg-3); padding: .12em .4em; border-radius: 6px; overflow-wrap: anywhere; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 8px; }
.skip { position: absolute; left: -9999px; top: 8px; z-index: 100; background: var(--ink); color: var(--bg); padding: 8px 12px; border-radius: 8px; }
.skip:focus { left: 12px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hint { color: var(--muted); font-size: 13px; }
.lede { color: var(--muted); font-size: 15px; max-width: 64ch; margin-top: 6px; }
[hidden] { display: none !important; }
.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Logo: light and dark files swap with the scheme */
.brand { display: inline-flex; align-items: center; gap: 9px; text-decoration: none !important; }
.brand img { height: 22px; width: auto; }
.brand .mark { height: 26px; }
.only-dark { display: none !important; }
@media (prefers-color-scheme: dark) { .only-light { display: none !important; } .only-dark { display: block !important; } }

/* Buttons */
button, .btn { font: 600 13.5px/1 var(--sans); display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--panel); color: var(--ink); cursor: pointer; text-decoration: none !important; white-space: nowrap; transition: background .15s, border-color .15s, transform .15s, box-shadow .15s; }
button:hover, .btn:hover { background: var(--bg-2); border-color: var(--faint); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: not-allowed; }
.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.primary:hover { background: var(--blue-ink); border-color: var(--blue-ink); }
.accent { background: var(--blue); border-color: var(--blue); color: #fff; }
.accent:hover { background: var(--blue-ink); border-color: var(--blue-ink); }
.danger { color: var(--stop); border-color: color-mix(in srgb, var(--stop) 35%, var(--line)); }
.danger:hover { background: var(--stop-soft); border-color: var(--stop); }
.ghost { border-color: transparent; background: transparent; }
.ghost:hover { background: var(--bg-3); border-color: transparent; }
.small { min-height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.icon-btn { width: 38px; padding: 0; }
.link { border: 0; background: none; padding: 0; min-height: 0; color: var(--blue); font-weight: 600; }
.link:hover { background: none; text-decoration: underline; }
button svg, .btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Forms */
input, textarea, select { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; padding: 9px 12px; width: 100%; transition: border-color .15s, box-shadow .15s; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
textarea { resize: vertical; min-height: 90px; }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; accent-color: var(--blue); }
label { font-weight: 600; font-size: 13px; }
.field { display: grid; gap: 6px; }
.form { display: grid; gap: 16px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.check { display: flex; align-items: flex-start; gap: 10px; font-weight: 500; }
.check input { margin-top: 2px; flex: none; }
fieldset { border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px 14px; margin: 0; }
legend { font-weight: 650; font-size: 13px; padding: 0 6px; }
.checks { display: flex; flex-wrap: wrap; gap: 10px 18px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* Chips, pills, badges */
.chips { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; background: var(--bg-3); color: var(--ink-2); font: 600 11.5px/1.5 var(--sans); }
.chip button { min-height: 0; padding: 0; border: 0; background: none; color: inherit; font-size: 13px; }
.chip.ok { background: var(--go-soft); color: var(--go); }
.chip.admin, .chip.blue { background: var(--blue-soft); color: var(--blue); }
.chip.warn { background: var(--hold-soft); color: var(--hold); }
.chip.bad { background: var(--stop-soft); color: var(--stop); }
.chip.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.soon { background: var(--blue-soft); color: var(--blue); text-transform: uppercase; letter-spacing: .04em; font-size: 10px; }
.badge-n { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--hold); color: #fff; font: 700 11px/20px var(--sans); text-align: center; }
.kbd { font: 600 11px/1 var(--mono); padding: 3px 6px; border-radius: 6px; border: 1px solid var(--line-2); color: var(--muted); background: var(--bg-2); }

/* App shell */
.app { display: grid; grid-template-columns: var(--sb) minmax(0, 1fr); min-height: 100vh; }
.sb { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px; padding: 14px 12px; border-right: 1px solid var(--line); background: var(--side); overflow-y: auto; }
.sb__brand { display: flex; align-items: center; padding: 6px 8px 12px; }
.ws { width: 100%; justify-content: flex-start; gap: 10px; padding: 8px 10px; min-height: 48px; border-radius: 12px; background: var(--panel); border-color: var(--line); text-align: left; }
.ws__logo { width: 28px; height: 28px; border-radius: 8px; background: var(--blue); display: grid; place-items: center; flex: none; }
.ws__logo img { width: 20px; height: auto; }
.ws__txt { display: grid; line-height: 1.2; min-width: 0; }
.ws__txt b { font-size: 13px; }
.ws__txt span { font-size: 11.5px; color: var(--muted); font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.ws svg:last-child { margin-left: auto; color: var(--faint); }
.nav { display: grid; gap: 2px; margin-top: 8px; }
.nav__label { padding: 12px 10px 4px; font: 600 11px/1 var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
.nav a { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 10px; color: var(--ink-2); font-weight: 550; text-decoration: none; transition: background .15s, color .15s; }
.nav a:hover { background: var(--bg-3); }
.nav a[aria-current="page"] { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
.nav a[aria-current="page"] svg { color: var(--blue); }
.nav svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; color: var(--muted); }
.nav .chip.soon { margin-left: auto; font-size: 9px; padding: 2px 6px; }
.sb__foot { margin-top: auto; padding-top: 12px; display: grid; gap: 10px; }
.sb__film { position: relative; border-radius: 14px; overflow: hidden; aspect-ratio: 16 / 10; background: var(--bg-3); }
.sb__film video, .sb__film img { width: 100%; height: 100%; object-fit: cover; }
.sb__film p { position: absolute; left: 10px; right: 10px; bottom: 8px; color: #fff; font: 600 12px/1.3 var(--sans); text-shadow: 0 1px 8px rgba(0, 0, 0, .5); }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 30; height: var(--top); display: flex; align-items: center; gap: 12px; padding: 0 24px; background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: saturate(180%) blur(14px); -webkit-backdrop-filter: saturate(180%) blur(14px); border-bottom: 1px solid var(--line); }
.top .brand { display: none; }
.search { flex: 1; max-width: 520px; justify-content: flex-start; gap: 10px; color: var(--muted); font-weight: 500; background: var(--bg-2); border-color: var(--line); }
.search .kbd { margin-left: auto; }
.top__right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; overflow: hidden; flex: none; font: 700 13px/1 var(--sans); color: #fff; background: var(--blue); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 44px; height: 44px; font-size: 16px; }
.avatar.sq { border-radius: 12px; }
.me-btn { padding: 0 4px 0 4px; border-radius: 999px; min-height: 40px; gap: 8px; }
.view { padding: 28px clamp(16px, 3vw, 36px) 48px; width: 100%; max-width: 1360px; }
.view.full { max-width: none; padding: 0; }
.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 22px; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }

.menu { position: absolute; z-index: 50; min-width: 240px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; }
.menu a, .menu button { display: flex; width: 100%; justify-content: flex-start; gap: 10px; padding: 9px 10px; min-height: 0; border: 0; border-radius: 9px; background: none; color: var(--ink); font-weight: 550; text-decoration: none; }
.menu a:hover, .menu button:hover { background: var(--bg-3); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; }
.menu .menu__head { padding: 10px; display: grid; gap: 2px; }

/* Cards, stats */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card__head a { font-size: 13px; font-weight: 600; }
.grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 16px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px 18px; display: grid; gap: 4px; }
.stat b { font: 700 30px/1.1 var(--display); letter-spacing: -0.03em; }
.stat span { color: var(--muted); font-size: 13px; font-weight: 550; }
.stat small { color: var(--faint); font-size: 12px; }
.stat svg { width: 18px; height: 18px; stroke: var(--blue); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Hero header: a calm white card, film on the right (no dark panels in light mode) */
.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); align-items: stretch; border-radius: 24px; overflow: hidden; margin-bottom: 16px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); }
.hero__txt { padding: 26px 28px; display: grid; align-content: center; gap: 8px; }
.hero h1 { font-size: clamp(26px, 2.6vw, 34px); }
.hero p { color: var(--muted); max-width: 52ch; }
.hero .chips { margin-top: 8px; }
.hero__art { position: relative; min-height: 210px; background: var(--bg-3); }
.hero__art video, .hero__art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

/* Lists and feed */
.list { list-style: none; margin: 0; padding: 0; display: grid; }
.list > li { border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.feed li { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 10px 6px; border-radius: 12px; }
.feed li.new { animation: flash 1.6s var(--ease); }
@keyframes flash { from { background: var(--blue-soft); } to { background: transparent; } }
.feed .ev { font-size: 13.5px; color: var(--ink-2); min-width: 0; }
.feed .ev b { color: var(--ink); }
.feed .ev .sub { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed time { color: var(--faint); font-size: 12px; white-space: nowrap; }
.ev-ico { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; }
.ev-ico svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.ev-ico.in { background: var(--blue-soft); color: var(--blue); }
.ev-ico.out { background: var(--go-soft); color: var(--go); }
.ev-ico.hold { background: var(--hold-soft); color: var(--hold); }
.live { display: inline-flex; align-items: center; gap: 7px; font: 600 12px/1 var(--sans); color: var(--go); }
.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--go); box-shadow: 0 0 0 0 var(--go); animation: ping 2s infinite; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--go) 60%, transparent); } 70% { box-shadow: 0 0 0 8px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

.mini-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--line); text-decoration: none !important; color: inherit; }
.mini-row:last-child { border-bottom: 0; }
.mini-row:hover { background: var(--bg-2); border-radius: 10px; }
.mini-row .grow { min-width: 0; flex: 1; }
.mini-row .grow b { display: block; font-size: 13.5px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-row .grow span { display: block; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Empty states with film */
.empty { display: grid; justify-items: center; text-align: center; gap: 10px; padding: 36px 18px; color: var(--muted); }
.empty h3 { color: var(--ink); font-size: 17px; }
.empty p { max-width: 46ch; }
.empty .art { width: min(360px, 100%); aspect-ratio: 16 / 10; border-radius: 18px; overflow: hidden; background: var(--bg-3); margin-bottom: 6px; box-shadow: var(--shadow); }
.empty .art video, .empty .art img { width: 100%; height: 100%; object-fit: cover; }
.soon-page { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 28px; align-items: center; }
.soon-page .art { border-radius: 24px; overflow: hidden; aspect-ratio: 16 / 11; background: var(--bg-3); box-shadow: var(--shadow-lg); }
.soon-page .art video, .soon-page .art img { width: 100%; height: 100%; object-fit: cover; }
.soon-page h1 { font-size: clamp(28px, 3.4vw, 44px); margin-top: 12px; }
.soon-page ul { margin: 16px 0 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.soon-page li { display: flex; gap: 10px; color: var(--ink-2); }
.soon-page li::before { content: ""; flex: none; width: 18px; height: 18px; margin-top: 2px; border-radius: 50%; background: var(--blue-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath d='M5 9.2 7.6 11.8 13 6.4' fill='none' stroke='%23005afd' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/18px no-repeat; }
.preview-ui { margin-top: 22px; border: 1px dashed var(--line-2); border-radius: 18px; padding: 14px; display: grid; gap: 10px; opacity: .9; }
.preview-ui .ph-row { display: flex; gap: 10px; align-items: center; }
.preview-ui .ph-bar { height: 10px; border-radius: 6px; background: var(--bg-3); }

/* Skeletons and spinners */
.sk { background: linear-gradient(90deg, var(--bg-3) 25%, var(--bg-2) 37%, var(--bg-3) 63%); background-size: 400% 100%; animation: sk 1.3s ease infinite; border-radius: 10px; }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.spin { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 18px 4px; }
.spin::before { content: ""; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--blue); animation: rot .8s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }

/* Notes and toasts */
.note { border-radius: 14px; padding: 12px 14px; border: 1px solid var(--line); background: var(--bg-2); color: var(--ink-2); }
.note.err { background: var(--stop-soft); border-color: color-mix(in srgb, var(--stop) 30%, transparent); }
.note.warn { background: var(--hold-soft); border-color: color-mix(in srgb, var(--hold) 30%, transparent); }
.note.good { background: var(--go-soft); border-color: color-mix(in srgb, var(--go) 30%, transparent); }
.secret { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.secret code { flex: 1; padding: 10px 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); overflow-wrap: anywhere; font-size: 13px; }
#toasts { position: fixed; z-index: 90; right: 18px; bottom: 18px; display: grid; gap: 8px; }
.toast { background: var(--panel); color: var(--ink); border: 1px solid var(--line); padding: 11px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); font-weight: 550; animation: up .3s var(--ease); max-width: 380px; }
.toast.err { background: var(--peach); color: var(--peach-ink); border-color: transparent; }
@keyframes up { from { opacity: 0; transform: translateY(8px); } }

/* Tables */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--panel); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font: 600 11.5px/1 var(--sans); letter-spacing: .05em; text-transform: uppercase; color: var(--faint); padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--bg-2); }
td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tr.revoked td { opacity: .5; }

/* Segmented tabs */
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 12px; background: var(--bg-3); max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg > * { flex: none; }
.seg a, .seg button { padding: 7px 12px; min-height: 0; border: 0; border-radius: 9px; background: none; color: var(--muted); font: 600 13px/1 var(--sans); text-decoration: none !important; text-transform: capitalize; }
.seg [aria-current="true"], .seg [aria-pressed="true"] { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }

/* Inbox: three panes */
.mail { display: grid; grid-template-columns: 220px minmax(280px, 380px) minmax(0, 1fr); height: calc(100vh - var(--top)); border-top: 0; }
.mail__folders { border-right: 1px solid var(--line); padding: 16px 10px; overflow-y: auto; background: var(--bg-2); display: grid; align-content: start; gap: 2px; }
.mail__folders .who { padding: 4px 8px 14px; display: grid; gap: 2px; }
.mail__folders .who b { font-size: 14px; overflow-wrap: anywhere; }
.mail__folders a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; color: var(--ink-2); font-weight: 550; text-decoration: none; }
.mail__folders a:hover { background: var(--bg-3); }
.mail__folders a.btn, .mail__folders a.btn:hover { color: #fff; background: var(--blue); }
.mail__folders a[aria-current="true"] { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
.mail__folders a span:last-child { margin-left: auto; color: var(--faint); font-size: 12px; }
.mail__folders .lbl::before { content: ""; width: 8px; height: 8px; border-radius: 3px; background: var(--faint); }
.mail__list { border-right: 1px solid var(--line); overflow-y: auto; display: flex; flex-direction: column; min-width: 0; }
.mail__bar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px); }
.mail__bar input { min-height: 36px; padding: 7px 12px; }
.msg { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none !important; position: relative; }
.msg:hover { background: var(--bg-2); }
.msg[aria-current="true"] { background: var(--blue-soft); }
.msg.unread::before { content: ""; position: absolute; left: 5px; top: 22px; width: 6px; height: 6px; border-radius: 50%; background: var(--blue); }
.msg__top { display: flex; gap: 8px; align-items: baseline; }
.msg__from { font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.msg.unread .msg__from, .msg.unread .msg__subj { font-weight: 700; }
.msg__top time { color: var(--faint); font-size: 12px; flex: none; }
.msg__subj { color: var(--ink-2); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg__prev { color: var(--muted); font-size: 12.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.msg .chips { margin-top: 6px; }
.mail__read { overflow-y: auto; min-width: 0; background: var(--bg); }
.reader { padding: 22px clamp(16px, 2.6vw, 34px) 40px; display: grid; gap: 16px; max-width: 920px; }
.reader__head { display: grid; gap: 12px; }
.reader__head h1 { font-size: 23px; }
.reader__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.reader__meta > div:last-child:not(.grow) { margin-left: auto; }
.reader__meta .grow { min-width: 0; flex: 1; }
.reader__meta .grow b { display: block; overflow-wrap: anywhere; }
.reader__meta .grow span { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.reader__body { border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: #fff; }
.reader__body pre { margin: 0; padding: 18px; white-space: pre-wrap; font: 14px/1.6 var(--sans); color: #111; overflow-wrap: anywhere; }
iframe.mail-frame { width: 100%; min-height: 380px; border: 0; display: block; background: #fff; }
.atts { display: flex; flex-wrap: wrap; gap: 8px; }
.atts button { justify-content: flex-start; gap: 10px; }
.composer { border: 1px solid var(--line); border-radius: 16px; padding: 14px; background: var(--panel); display: grid; gap: 12px; }
.composer textarea { border: 0; padding: 4px 2px; box-shadow: none !important; min-height: 110px; background: transparent; }
.reader-empty { height: 100%; display: grid; place-items: center; padding: 24px; }
.back-btn { display: none; }

/* Approvals */
.queue { display: grid; grid-template-columns: minmax(260px, 360px) minmax(0, 1fr); gap: 16px; align-items: start; }
.queue__list { display: grid; gap: 8px; }
.qitem { display: grid; gap: 4px; text-align: left; justify-content: stretch; padding: 12px 14px; min-height: 0; border-radius: 14px; white-space: normal; font-weight: 500; }
.qitem[aria-pressed="true"] { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.qitem b { font-size: 14px; }
.qitem span { color: var(--muted); font-size: 12.5px; }
.diff { display: grid; gap: 10px; }
.diff__row { display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 10px; align-items: start; font-size: 13.5px; }
.diff__row > span:first-child { color: var(--muted); font-weight: 600; padding-top: 3px; }
.diff__body { border: 1px solid var(--line); border-radius: 14px; background: var(--bg-2); padding: 14px; white-space: pre-wrap; font: 13.5px/1.6 var(--sans); overflow-wrap: anywhere; max-height: 360px; overflow-y: auto; }
.decide { position: sticky; bottom: 0; display: flex; gap: 8px; padding-top: 12px; }

/* Bots directory */
.bots { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.bot { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; display: grid; gap: 12px; transition: transform .3s var(--ease), box-shadow .3s var(--ease); }
.bot:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.bot__top { display: flex; gap: 12px; align-items: center; }
.bot__top .grow { min-width: 0; }
.bot__top .grow b { display: block; font-size: 15px; }
.bot__top .grow span { display: block; color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.bot dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; font-size: 12.5px; }
.bot dt { color: var(--muted); }
.bot dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.bot .actions { margin-top: 2px; }

/* Keys */
.scope-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.scope-pick label { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--line-2); border-radius: 999px; cursor: pointer; font-weight: 600; }
.scope-pick input { position: absolute; opacity: 0; width: 0; height: 0; }
.scope-pick label:has(input:checked) { background: var(--sky); border-color: var(--sky-ink); color: var(--sky-ink); }
.scope-pick label:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--blue-soft); }
.keycards { display: grid; gap: 10px; }
.keycard { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 14px 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); }
.keycard.revoked { opacity: .5; }
.keycard b { display: block; }
.keycard .k { color: var(--muted); font-size: 12px; display: block; margin-bottom: 4px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

/* Drawer, dialog, palette */
.drawer { position: fixed; z-index: 70; top: 0; right: 0; bottom: 0; width: min(540px, 100vw); background: var(--panel); border-left: 1px solid var(--line); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slide .3s var(--ease); }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.drawer__head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer__body { padding: 20px; overflow-y: auto; flex: 1; }
.scrim { position: fixed; inset: 0; z-index: 60; background: rgba(8, 10, 14, .38); animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
dialog { border: 1px solid var(--line); border-radius: 20px; padding: 22px; background: var(--panel); color: var(--ink); box-shadow: var(--shadow-lg); max-width: min(460px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(8, 10, 14, .42); }
dialog h2 { font-size: 19px; margin-bottom: 8px; }
dialog p { color: var(--muted); margin-bottom: 18px; }
dialog .actions { justify-content: flex-end; }
.palette { position: fixed; z-index: 80; top: 12vh; left: 50%; transform: translateX(-50%); width: min(620px, calc(100vw - 24px)); background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-lg); overflow: hidden; animation: up .2s var(--ease); }
.palette input { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 16px 18px; font-size: 16px; box-shadow: none !important; }
.palette ul { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow-y: auto; }
.palette li button { width: 100%; justify-content: flex-start; gap: 12px; border: 0; background: none; padding: 10px 12px; border-radius: 10px; font-weight: 550; min-height: 0; }
.palette li button[aria-selected="true"] { background: var(--blue-soft); color: var(--ink); }
.palette li .hint { margin-left: auto; }
.palette .group { padding: 10px 12px 4px; font: 600 11px/1 var(--sans); text-transform: uppercase; letter-spacing: .06em; color: var(--faint); }

/* Phone tab bar */
.tabbar { display: none; }

/* Sign-in and auth */
.gate { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); background: var(--bg); }
.gate-side { display: grid; place-items: center; padding: 32px 20px; }
.gate-card { width: min(420px, 100%); display: grid; gap: 14px; }
.gate-card .brand img { height: 28px; }
.gate-card .brand .mark { height: 34px; }
.gate-card h1 { font-size: 30px; margin-top: 18px; }
.gate-card > p { color: var(--muted); font-size: 15px; }
.gbtn { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 48px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--panel); color: var(--ink); font: 600 15px/1 var(--sans); text-decoration: none !important; transition: background .15s, box-shadow .15s; margin-top: 8px; }
.gbtn:hover { background: var(--bg-2); box-shadow: var(--shadow); }
.gbtn svg { width: 20px; height: 20px; }
.gbtn[aria-disabled="true"] { opacity: .6; pointer-events: none; }
.or { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.keylink { min-height: 46px; border-radius: 12px; width: 100%; }
.keyform { display: grid; gap: 10px; }
.keyform label { display: grid; gap: 4px; }
.keyform input { min-height: 46px; }
.keyform .primary { min-height: 46px; }
.gate-legal { color: var(--faint); font-size: 12.5px; margin-top: 8px; }
.gate-media { position: relative; margin: 12px; border-radius: 28px; overflow: hidden; background: #1c2330 center/cover; min-height: 420px; }
.gate-media video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.gate-media figcaption { position: absolute; left: 24px; right: 24px; bottom: 22px; color: #fff; font: 600 clamp(18px, 1.8vw, 24px)/1.25 var(--display); letter-spacing: -0.02em; text-shadow: 0 2px 18px rgba(0, 0, 0, .45); max-width: 26ch; }
.gate-media::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 55%, rgba(8, 10, 14, .55)); }
.gate-media figcaption { z-index: 1; }

/* Pastel tints (status chips, room badges, levels, avatars) */
.t-mint { background: var(--mint) !important; color: var(--mint-ink) !important; }
.t-sky { background: var(--sky) !important; color: var(--sky-ink) !important; }
.t-lilac { background: var(--lilac) !important; color: var(--lilac-ink) !important; }
.t-peach { background: var(--peach) !important; color: var(--peach-ink) !important; }
.t-butter { background: var(--butter) !important; color: var(--butter-ink) !important; }
.chip.ok { background: var(--mint); color: var(--mint-ink); }
.chip.warn { background: var(--butter); color: var(--butter-ink); }
.chip.bad { background: var(--peach); color: var(--peach-ink); }
.chip.blue, .chip.admin { background: var(--sky); color: var(--sky-ink); }
.chip.soon { background: var(--lilac); color: var(--lilac-ink); }
.lvl { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px 3px 4px; border-radius: 999px; font: 600 11.5px/1.5 var(--sans); white-space: nowrap; }
.lvl b { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: rgba(255, 255, 255, .75); font-size: 11px; }
.presence { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; box-shadow: 0 0 0 2px var(--panel); }
.presence.online { background: #2fbf86; }
.presence.idle { background: #f0b429; }
.presence.offline { background: #c4c9d2; }
.ribbon { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 14px; background: var(--lilac); color: var(--lilac-ink); font-size: 13px; font-weight: 550; margin-bottom: 16px; }
.ribbon b { font-weight: 700; }
.ribbon button { margin-left: auto; min-height: 30px; font-size: 12.5px; background: var(--panel); border-color: transparent; color: var(--lilac-ink); }
.dial { display: inline-flex; flex-wrap: wrap; max-width: 100%; padding: 3px; border-radius: 12px; background: var(--bg-3); gap: 2px; }
.dial button { min-height: 30px; padding: 0 12px; border: 0; border-radius: 9px; background: none; color: var(--muted); font-size: 12.5px; }
.dial button[aria-pressed="true"] { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
.dial button[aria-pressed="true"][data-v="Manual"] { color: var(--peach-ink); }
.dial button[aria-pressed="true"][data-v="Supervised"] { color: var(--sky-ink); }
.dial button[aria-pressed="true"][data-v="Autonomous"] { color: var(--mint-ink); }

/* Bot profile */
.profile { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.profile__head { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.profile__head .avatar { width: 64px; height: 64px; border-radius: 18px; font-size: 22px; }
.kv2 { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 10px 14px; font-size: 13.5px; margin: 0; }
.kv2 dt { color: var(--muted); }
.kv2 dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; }
.timeline li { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); align-items: center; font-size: 13.5px; }
.timeline li:last-child { border-bottom: 0; }
.timeline .ev-ico { width: 30px; height: 30px; border-radius: 9px; }
.timeline time { color: var(--faint); font-size: 12px; }

/* Chat (IRC-style) */
.chat { display: grid; grid-template-columns: 240px minmax(0, 1fr) 260px; height: calc(100vh - var(--top)); }
.chat__rooms { border-right: 1px solid var(--line); background: var(--side); padding: 14px 10px; overflow-y: auto; display: grid; align-content: start; gap: 2px; }
.chat__rooms a { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 10px; color: var(--ink-2); font-weight: 550; text-decoration: none; }
.chat__rooms a:hover { background: var(--bg-3); }
.chat__rooms a[aria-current="true"] { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
.chat__rooms .hash { color: var(--faint); font-weight: 700; width: 14px; text-align: center; }
.chat__rooms .n { margin-left: auto; min-width: 20px; height: 20px; border-radius: 999px; background: var(--sky); color: var(--sky-ink); font: 700 11px/20px var(--sans); text-align: center; }
.chat__main { display: flex; flex-direction: column; min-width: 0; }
.chat__head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.chat__head h1 { font-size: 18px; }
.chat__head p { color: var(--muted); font-size: 13px; }
.chat__stream { flex: 1; overflow-y: auto; padding: 14px 18px; display: grid; align-content: start; gap: 2px; }
.cmsg { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 12px; padding: 8px 10px; border-radius: 12px; }
.cmsg:hover { background: var(--bg-2); }
.cmsg.pinned { background: var(--butter); }
.cmsg .avatar { border-radius: 11px; }
.head > * { min-width: 0; max-width: 100%; }
.cmsg__top { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.cmsg__top b { font-size: 14px; }
.cmsg__top time { color: var(--faint); font-size: 12px; }
.cmsg__body { color: var(--ink-2); overflow-wrap: anywhere; }
.cmsg__body .mention { background: var(--sky); color: var(--sky-ink); padding: 0 4px; border-radius: 5px; font-weight: 600; }
.cmsg__cmd { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 6px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); font-size: 13px; }
.cmsg__cmd code { background: var(--lilac); color: var(--lilac-ink); }
.cmsg__meta { display: flex; gap: 10px; margin-top: 4px; font-size: 12.5px; color: var(--muted); }
.chat__compose { padding: 12px 18px 16px; border-top: 1px solid var(--line); position: relative; }
.chat__compose .box { display: flex; gap: 8px; align-items: center; border: 1px solid var(--line-2); border-radius: 14px; padding: 6px 6px 6px 14px; background: var(--panel); }
.chat__compose input { border: 0; padding: 8px 0; box-shadow: none !important; }
.slash { position: absolute; left: 18px; right: 18px; bottom: calc(100% - 6px); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; display: grid; }
.slash button { justify-content: flex-start; gap: 10px; border: 0; background: none; padding: 8px 10px; min-height: 0; border-radius: 9px; font-weight: 500; }
.slash button:hover, .slash button[aria-selected="true"] { background: var(--sky); }
.slash code { background: var(--lilac); color: var(--lilac-ink); }
.chat__side { border-left: 1px solid var(--line); padding: 16px; overflow-y: auto; display: grid; align-content: start; gap: 16px; background: var(--side); }
.member { display: flex; align-items: center; gap: 10px; padding: 5px 0; font-size: 13.5px; text-decoration: none; color: inherit; }
.member .avatar { width: 28px; height: 28px; font-size: 11px; border-radius: 9px; }
.member .presence { margin-left: auto; }

/* Tasks (Kanban) */
.board { display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: 14px; align-items: start; overflow-x: auto; padding-bottom: 8px; }
.col { background: var(--side); border: 1px solid var(--line); border-radius: 18px; padding: 12px; display: grid; gap: 10px; min-height: 160px; align-content: start; }
.col__head { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 13.5px; padding: 2px 4px; }
.col__head .n { color: var(--faint); font-weight: 600; }
.col.drop { outline: 2px dashed var(--blue); outline-offset: -4px; }
.tcard { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: grid; gap: 10px; box-shadow: 0 1px 2px rgba(10, 10, 10, .03); cursor: grab; }
.tcard:hover { box-shadow: var(--shadow); }
.tcard b { font-size: 13.5px; font-weight: 600; line-height: 1.35; }
.tcard__foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.tcard__foot .avatar { width: 24px; height: 24px; font-size: 10px; border-radius: 8px; }

/* Security */
.lvl-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.lvl-card { border-radius: 16px; padding: 14px; display: grid; gap: 6px; }
.lvl-card b { font: 700 26px/1 var(--display); }
.lvl-card span { font-weight: 650; }
.lvl-card p { font-size: 12.5px; opacity: .9; }
.policy { display: flex; align-items: center; gap: 14px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.policy:last-child { border-bottom: 0; }
.switch { position: relative; width: 40px; height: 24px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line-2); transition: background .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); transition: transform .2s; }
.switch input:checked + span { background: var(--blue); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px var(--blue-soft); }
.matrix td, .matrix th { white-space: nowrap; }

/* Connections */
.conn { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.conn .card { display: grid; gap: 10px; align-content: start; }
.codebox { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font: 12.5px/1.6 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink-2); margin: 0; }

/* Collapsible create forms (webhooks, people) */
details.card { padding: 0; margin-bottom: 18px; }
details.card > summary { list-style: none; cursor: pointer; padding: 16px 18px; font: 650 15px/1.2 var(--display); display: flex; align-items: center; gap: 10px; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::before { content: "+"; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--sky); color: var(--sky-ink); font: 600 16px/1 var(--sans); }
details.card[open] > summary::before { content: "−"; }
details.card > .form { padding: 0 18px 18px; }
.grow { flex: 1; min-width: 0; }
.more { display: flex; justify-content: center; padding: 12px; }
.list > li > .item { display: block; padding: 14px 16px; color: inherit; text-decoration: none; }
.item-top { display: flex; justify-content: space-between; gap: 10px; }

/* Responsive */
@media (max-width: 1180px) {
  .chat { grid-template-columns: 220px minmax(0, 1fr); }
  .chat__side { display: none; }
  .profile { grid-template-columns: 1fr; }
  .lvl-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
  .mail { grid-template-columns: 190px minmax(240px, 320px) minmax(0, 1fr); }
  .keycard { grid-template-columns: minmax(0, 1fr) auto; }
  .keycard .hide-md { display: none; }
}
@media (max-width: 900px) {
  :root { --top: 58px; }
  .app { grid-template-columns: 1fr; padding-bottom: 72px; }
  .sb { position: fixed; z-index: 75; left: 0; top: 0; width: min(300px, 86vw); transform: translateX(-102%); transition: transform .3s var(--ease); box-shadow: var(--shadow-lg); }
  .app.nav-open .sb { transform: none; }
  .top { padding: 0 14px; }
  .top .brand { display: inline-flex; }
  .top .brand img { height: 20px; }
  .search { max-width: none; min-width: 0; padding: 0 10px; }
  .search .lbl, .search .kbd { display: none; }
  .search { flex: 0 0 auto; width: 40px; justify-content: center; margin-left: auto; }
  .top__right { margin-left: 0; }
  .top__right .hide-sm { display: none; }
  .tabbar { position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, 1fr); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
  .tabbar a, .tabbar button { display: grid; justify-items: center; gap: 3px; min-height: 52px; padding: 6px 0 0; border: 0; background: none; color: var(--muted); font: 600 11px/1 var(--sans); text-decoration: none !important; position: relative; }
  .tabbar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .tabbar [aria-current="page"] { color: var(--blue); }
  .tabbar .badge-n { position: absolute; top: 2px; left: calc(50% + 6px); margin: 0; min-width: 18px; height: 18px; line-height: 18px; font-size: 10px; }
  .view { padding: 20px 16px 32px; }
  h1 { font-size: 24px; }
  .hero { grid-template-columns: 1fr; border-radius: 20px; }
  .hero__art { order: -1; min-height: 180px; }
  .hero__txt { padding: 18px; }
  .mail { display: block; height: auto; }
  .mail__folders { display: flex; overflow-x: auto; gap: 6px; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .mail__folders .who, .mail__folders .lbl-head { display: none; }
  .mail__folders a { flex: none; padding: 8px 12px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); }
  .mail__folders a span:last-child { margin-left: 4px; }
  .mail__list { border-right: 0; }
  .mail.reading .mail__folders, .mail.reading .mail__list { display: none; }
  .mail:not(.reading) .mail__read { display: none; }
  .back-btn { display: inline-flex; }
  .chat { display: block; height: auto; }
  .chat__rooms { display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 10px 12px; gap: 6px; }
  .chat__rooms .nav__label { display: none; }
  .chat__rooms a { flex: none; border: 1px solid var(--line); background: var(--panel); border-radius: 999px; }
  .board { grid-template-columns: repeat(4, minmax(260px, 82vw)); scroll-snap-type: x mandatory; }
  .col { scroll-snap-align: start; }
  .lvl-grid { grid-template-columns: 1fr 1fr; }
  .kv2 { grid-template-columns: 100px minmax(0, 1fr); }
  .reader__meta .grow { flex-basis: calc(100% - 60px); }
  .reader__meta > div:last-child:not(.grow), .reader__meta > .chip { margin-left: 56px; text-align: left !important; }
  .queue, .soon-page { grid-template-columns: 1fr; }
  .gate { grid-template-columns: 1fr; }
  .gate-media { order: -1; min-height: 260px; margin: 12px 12px 0; border-radius: 22px; }
  .gate-side { padding: 22px 18px 40px; place-items: start center; }
  .keycard { grid-template-columns: 1fr; }
  #toasts { left: 12px; right: 12px; bottom: 84px; }
}
@media (max-width: 520px) {
  .stats { gap: 8px; }
  .stat { padding: 12px 14px; }
  .stat b { font-size: 24px; }
  .head { align-items: flex-start; }
  .feed li { grid-template-columns: 32px minmax(0, 1fr); }
  .feed time { grid-column: 2; }
  .diff__row { grid-template-columns: 1fr; gap: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---- Live chat and board (tracks A/B) ---- */
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.avatar.xs { width: 20px; height: 20px; font-size: 9px; border-radius: 7px; flex: none; }
.linkish { background: none; border: 0; padding: 0; min-height: 0; color: var(--muted); font: inherit; cursor: pointer; box-shadow: none; }
.linkish:hover { color: var(--ink); text-decoration: underline; }
.cmsg .cmsg__act { opacity: 0; transition: opacity .15s; }
.cmsg:hover .cmsg__act, .cmsg:focus-within .cmsg__act { opacity: 1; }
.cmsg__top .cmsg__act { margin-left: auto; }
.cmsg.sys { grid-template-columns: 38px minmax(0, 1fr); align-items: center; padding: 4px 10px; color: var(--muted); font-size: 13px; }
.cmsg.sys > span:first-child { display: grid; place-items: center; width: 26px; height: 26px; margin-left: 6px; border-radius: 9px; background: var(--bg-3); color: var(--faint); }
.cmsg.sys .cmsg__body { color: var(--muted); }
.taskref { font-weight: 650; color: var(--blue); text-decoration: none; background: var(--sky); padding: 0 5px; border-radius: 5px; }
.taskref:hover { text-decoration: underline; }
.board--5 { grid-template-columns: repeat(5, minmax(190px, 1fr)); }
.tcard { cursor: pointer; }
.tcard:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.tone-bad { color: var(--peach-ink); }
.tone-warn { color: var(--butter-ink); }
.tone-blue { color: var(--sky-ink); }
ul.plain { list-style: none; padding: 0; margin: 0; }
@media (max-width: 760px) {
  .board--5 { grid-template-columns: repeat(5, minmax(78vw, 1fr)); scroll-snap-type: x mandatory; }
  .board--5 .col { scroll-snap-align: start; }
}
@media (hover: none) { .cmsg .cmsg__act { opacity: 1; } }
.grid-2 > *, .grid > * { min-width: 0; }
