/* Layout: an operator's console - a rail of bots (your chats and the server's bots) beside one working
   surface: health strip, then the inbox of decisions next to Herd's 30-basket test, then the team and the
   feed. Phones get one section at a time under a bottom tab bar. The Lore's look: near-black, white type,
   yellow only where something needs you. */
:root {
  --bg: #0b0b0c; --rail: #0f0f11; --panel: #141416; --raised: #1a1a1d; --sunk: #101012; --line: #26262a; --line-soft: #1e1e22;
  --fg: #f3f2ee; --muted: #a3a19b; --faint: #6e6d68;
  --accent: #ffe866; --accent-ink: #191600; --accent-soft: rgba(255, 232, 102, .11);
  --good: #4fbf7b; --good-soft: rgba(79, 191, 123, .14); --bad: #ef6b60; --bad-soft: rgba(239, 107, 96, .14); --warn: #e8b85c; --warn-soft: rgba(232, 184, 92, .13);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70;            /* Binance, Bybit, Hyperliquid (validated set) */
  --av-bg-l: 30%; --av-fg-l: 88%;
  --font-display: "Montserrat", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --font-body: "Montserrat", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f3ef; --rail: #efeee9; --panel: #ffffff; --raised: #f8f7f3; --sunk: #f1f0eb; --line: #e1dfd8; --line-soft: #ebe9e3;
    --fg: #151517; --muted: #5b5a55; --faint: #8a8983;
    --accent: #866c00; --accent-ink: #fffbe0; --accent-soft: rgba(196, 160, 0, .13);
    --good: #2c8a4d; --good-soft: rgba(44, 138, 77, .11); --bad: #c5463c; --bad-soft: rgba(197, 70, 60, .1); --warn: #9a6a10; --warn-soft: rgba(196, 140, 30, .13);
    --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a;
    --av-bg-l: 88%; --av-fg-l: 27%;
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f4f3ef; --rail: #efeee9; --panel: #ffffff; --raised: #f8f7f3; --sunk: #f1f0eb; --line: #e1dfd8; --line-soft: #ebe9e3;
  --fg: #151517; --muted: #5b5a55; --faint: #8a8983;
  --accent: #866c00; --accent-ink: #fffbe0; --accent-soft: rgba(196, 160, 0, .13);
  --good: #2c8a4d; --good-soft: rgba(44, 138, 77, .11); --bad: #c5463c; --bad-soft: rgba(197, 70, 60, .1); --warn: #9a6a10; --warn-soft: rgba(196, 140, 30, .13);
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a;
  --av-bg-l: 88%; --av-fg-l: 27%;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; }
body { background: var(--bg); color: var(--fg); font: 500 14px/1.45 var(--font-body); }
h1, h2, h3 { font-family: var(--font-display); margin: 0; text-wrap: balance; }
button { font: inherit; color: inherit; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app { display: grid; grid-template-columns: 268px minmax(0, 1fr); min-height: 100%; }

/* ── rail: the bots ── */
.rail { background: var(--rail); border-right: 1px solid var(--line-soft); padding: 22px 14px 18px; display: flex; flex-direction: column; gap: 16px; position: sticky; top: env(safe-area-inset-top, 0px); height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--fg); color: var(--bg); display: grid; place-items: center; font: 800 .8rem var(--font-display); letter-spacing: -.02em; }
.brand b { font: 800 1.02rem var(--font-display); letter-spacing: -.01em; }
.brand span { display: block; color: var(--faint); font-size: .72rem; }
.rail-hd { font: 700 .64rem var(--font-body); letter-spacing: .13em; text-transform: uppercase; color: var(--faint); padding: 0 8px; display: flex; justify-content: space-between; }
.bots { display: flex; flex-direction: column; gap: 2px; }
.bot { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px; border-radius: 10px; border: 0; background: transparent; text-align: left; cursor: pointer; width: 100%; }
.bot:hover { background: var(--raised); }
.bot[aria-pressed="true"] { background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); }
.bot .nm { min-width: 0; }
.bot .nm b { display: block; font-weight: 700; font-size: .86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bot .nm span { display: block; color: var(--muted); font-size: .74rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bot .tm { font: 500 .66rem var(--font-mono); color: var(--faint); align-self: start; padding-top: 3px; }
.bot .tm.need { color: var(--accent); font-weight: 600; }
.rail-ft { margin-top: auto; color: var(--faint); font-size: .72rem; line-height: 1.5; padding: 0 8px; }

.av { --h: 210; position: relative; flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font: 700 .64rem var(--font-body);
  background: hsl(var(--h) 45% var(--av-bg-l)); color: hsl(var(--h) 70% var(--av-fg-l)); }
.av.lg { width: 34px; height: 34px; font-size: .78rem; border-radius: 11px; }
.av .live { position: absolute; right: -2px; bottom: -2px; width: 10px; height: 10px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 2px var(--rail); }
.av .live.need { background: var(--accent); }
.av .live.idle { background: var(--faint); }
@media (prefers-reduced-motion: no-preference) {
  .av .live.run::after { content: ""; position: absolute; inset: -3px; border-radius: 50%; border: 2px solid var(--good); opacity: 0; animation: ping 2.4s ease-out infinite; }
  @keyframes ping { 0% { transform: scale(.6); opacity: .7; } 80%, 100% { transform: scale(1.5); opacity: 0; } }
}

/* ── main ── */
.main { min-width: 0; padding-inline: clamp(16px, 2.6vw, 34px); padding-block: 24px 120px; display: flex; flex-direction: column; gap: 16px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.head h1 { font-size: clamp(1.5rem, 2.3vw, 2rem); font-weight: 800; letter-spacing: -.02em; }
.brief { margin: 6px 0 0; max-width: 72ch; color: var(--muted); font-size: .92rem; line-height: 1.5; }
.brief b { color: var(--fg); }
.clocks { display: flex; gap: 18px; text-align: right; }
.clocks div b { display: block; font: 600 1.15rem var(--font-mono); font-variant-numeric: tabular-nums; }
.clocks div span { color: var(--faint); font-size: .72rem; }

/* health strip */
.health { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.ht { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ht .lb { display: flex; align-items: center; gap: 7px; font: 700 .64rem var(--font-body); letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }
.ht .st { margin-left: auto; font: 700 .6rem var(--font-body); letter-spacing: .06em; padding: 1px 6px; border-radius: 999px; }
.ht.ok .st { color: var(--good); background: var(--good-soft); }
.ht.warn .st { color: var(--warn); background: var(--warn-soft); }
.ht.bad .st { color: var(--bad); background: var(--bad-soft); }
.ht b { font: 600 1.02rem var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ht span.sub { color: var(--muted); font-size: .74rem; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* panels */
.grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); grid-template-areas: "inbox side" "team team"; gap: 12px; align-items: start; }
.side { grid-area: side; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.inbox { grid-area: inbox; } .team { grid-area: team; }
.p-hd { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.p-hd h2 { font-size: 1.02rem; font-weight: 700; }
.p-hd span { font: 600 .72rem var(--font-mono); color: var(--faint); }
.sub-hd { font: 700 .64rem var(--font-body); letter-spacing: .13em; text-transform: uppercase; color: var(--faint); display: flex; justify-content: space-between; gap: 8px; margin-top: 4px; }
.empty { color: var(--muted); font-size: .84rem; padding: 4px 0; margin: 0; }

/* inbox cards */
.cards-i { display: flex; flex-direction: column; gap: 8px; }
.ic { background: var(--raised); border: 1px solid var(--line-soft); border-radius: 12px; padding: 12px 13px; display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.ic.urgent { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.ic-top { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: .76rem; color: var(--muted); }
.ic-top b { color: var(--fg); font-weight: 700; }
.ic-top .chip-s { margin-left: auto; }
.chip-s { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font: 700 .64rem var(--font-body); letter-spacing: .04em; white-space: nowrap; background: var(--sunk); color: var(--muted); border: 1px solid var(--line); }
.chip-s.urgent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip-s.soon { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip-s.late { color: var(--bad); border-color: var(--bad); background: transparent; }
.ic h3 { font: 700 .95rem/1.35 var(--font-body); }
.ic p { margin: 0; color: var(--muted); font-size: .82rem; line-height: 1.5; }
.ic .code { display: flex; gap: 6px; min-width: 0; }
.ic .code pre { margin: 0; flex: 1; min-width: 0; overflow-x: auto; padding: 7px 9px; border-radius: 8px; background: var(--sunk); border: 1px solid var(--line); font: 500 .72rem/1.45 var(--font-mono); white-space: pre; }
.acts { display: flex; flex-wrap: wrap; gap: 6px; }
.btn { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--line); background: transparent; color: var(--fg); font: 600 .78rem var(--font-body); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--fg); }
.btn.primary { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.btn.primary:hover { opacity: .88; }
.btn.ghost { border-color: transparent; color: var(--muted); padding: 0 8px; }
.btn.ghost:hover { color: var(--fg); }
.btn:disabled { opacity: .45; cursor: default; }
.opt summary { cursor: pointer; color: var(--muted); font-size: .8rem; font-weight: 600; padding: 4px 2px; width: fit-content; }
.opt summary:hover { color: var(--fg); }
.opt[open] summary { margin-bottom: 8px; }
.queued { background: var(--good-soft); border-radius: 9px; padding: 8px 10px; font-size: .8rem; color: var(--fg); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.queued b { font-weight: 700; }

/* herd */
.herd-top { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 18px; align-items: center; }
.big { display: flex; align-items: baseline; gap: 6px; }
.big b { font: 700 2.6rem/1 var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.big span { font: 600 1rem var(--font-mono); color: var(--faint); }
.herd-top .lbl { color: var(--muted); font-size: .78rem; margin-top: 4px; }
.verdict { display: flex; flex-direction: column; gap: 4px; }
.verdict b { font-weight: 700; font-size: .92rem; }
.verdict span { color: var(--muted); font-size: .8rem; line-height: 1.45; }
.cells { display: flex; flex-direction: column; gap: 6px; }
.crow { display: grid; grid-template-columns: 92px minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.crow .bk { display: flex; align-items: center; gap: 7px; font-weight: 700; font-size: .78rem; }
.sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.crow .cl { display: grid; grid-template-columns: repeat(30, minmax(0, 1fr)); gap: 2px; }
.cell { aspect-ratio: 1; border-radius: 3px; background: transparent; box-shadow: inset 0 0 0 1px var(--line); max-width: 100%; }
.cell.pos { box-shadow: none; }
.cell.neg { box-shadow: none; }
.crow .sum { font: 500 .72rem var(--font-mono); color: var(--muted); text-align: right; white-space: nowrap; }
.chart { position: relative; height: 230px; }
.chart svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.chart .grid-l { stroke: var(--line); stroke-width: 1; }
.chart .zero { stroke: var(--faint); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .ax { fill: var(--faint); font: 500 10px var(--font-mono); }
.chart .ln { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .end { font: 600 10.5px var(--font-mono); fill: var(--muted); }
.chart .cross { stroke: var(--muted); stroke-width: 1; }
.tip { position: absolute; pointer-events: none; background: var(--fg); color: var(--bg); border-radius: 8px; padding: 7px 9px; font: 500 .74rem/1.45 var(--font-mono); white-space: nowrap; transform: translate(-50%, -100%); }
.tip i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: .8rem; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend b { font-weight: 700; }
.legend em { font: 500 .78rem var(--font-mono); font-style: normal; color: var(--muted); }
.tbl-wrap summary { cursor: pointer; color: var(--muted); font-size: .78rem; font-weight: 600; width: fit-content; }
.tbl-wrap summary:hover { color: var(--fg); }
.tbl { max-height: 260px; overflow-y: auto; margin-top: 8px; border: 1px solid var(--line-soft); border-radius: 10px; }
.tbl table { width: 100%; border-collapse: collapse; font: 500 .74rem var(--font-mono); font-variant-numeric: tabular-nums; }
.tbl th { position: sticky; top: 0; background: var(--raised); font: 700 .62rem var(--font-body); letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.tbl th, .tbl td { padding: 5px 10px; text-align: right; border-bottom: 1px solid var(--line-soft); }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.rail .bots .rail-hd { margin-top: 10px; padding-bottom: 2px; }

/* team */
.tcards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tc { background: var(--raised); border: 1px solid var(--line-soft); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 9px; min-width: 0; }
.tc-hd { display: flex; align-items: center; gap: 9px; min-width: 0; }
.tc-hd .nm { min-width: 0; }
.tc-hd .nm b { display: block; font-weight: 700; font-size: .88rem; }
.tc-hd .nm span { display: block; color: var(--faint); font-size: .72rem; line-height: 1.35; }
.state { margin-left: auto; font: 700 .62rem var(--font-body); letter-spacing: .05em; padding: 2px 7px; border-radius: 999px; white-space: nowrap; }
.state.run { color: var(--good); background: var(--good-soft); }
.state.need { color: var(--accent); background: var(--accent-soft); }
.state.idle { color: var(--muted); background: var(--sunk); }
.state.sched { color: var(--s1); background: color-mix(in srgb, var(--s1) 14%, transparent); }
.fld span { display: block; font: 700 .6rem var(--font-body); letter-spacing: .12em; text-transform: uppercase; color: var(--faint); }
.fld p { margin: 1px 0 0; font-size: .8rem; line-height: 1.42; }
.fld p.hot { color: var(--accent); }
.quote { font-size: .76rem; line-height: 1.45; color: var(--muted); border-top: 1px solid var(--line-soft); padding-top: 8px; }
.quote b { color: var(--faint); font-weight: 600; font-size: .68rem; display: block; margin-bottom: 1px; }
.metric { font: 500 .72rem/1.45 var(--font-mono); color: var(--muted); }

/* feed */
.days { display: flex; flex-direction: column; gap: 12px; }
.day h3 { font: 700 .64rem var(--font-body); letter-spacing: .13em; text-transform: uppercase; color: var(--faint); margin-bottom: 4px; }
.ev { display: grid; grid-template-columns: 46px 22px minmax(0, 1fr); gap: 9px; align-items: start; padding: 7px 0; border-top: 1px solid var(--line-soft); }
.day .ev:first-of-type { border-top: 0; }
.ev .t { font: 500 .72rem var(--font-mono); color: var(--faint); padding-top: 3px; }
.ev .tx { font-size: .82rem; line-height: 1.45; min-width: 0; }
.ev .tx em { font-style: normal; font: 700 .6rem var(--font-body); letter-spacing: .08em; text-transform: uppercase; color: var(--faint); margin-right: 6px; }
.ev .tx em.alert { color: var(--bad); }
.ev .tx em.decision { color: var(--accent); }
.ev .tx a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; margin-left: 4px; }

/* ask */
.ask { position: fixed; left: calc(268px + (100% - 268px) / 2); transform: translateX(-50%); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); width: min(680px, calc(100% - 268px - 48px)); z-index: 20; }
.ask form { display: flex; gap: 8px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 6px 6px 6px 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); }
.ask input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--fg); font: 500 16px var(--font-body); outline: none; padding: 8px 0; }
.ask input::placeholder { color: var(--faint); }
.answer { margin-bottom: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); max-height: 46vh; overflow-y: auto; }
.answer .q { font-size: .76rem; color: var(--faint); margin-bottom: 6px; display: flex; justify-content: space-between; gap: 8px; }
.answer .a { font-size: .9rem; line-height: 1.55; white-space: pre-wrap; }

.tabs { display: none; }
.sugs { display: none; }
.p-hd { flex-wrap: wrap; } .p-hd span { white-space: nowrap; }
.brand b { white-space: nowrap; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(86px + env(safe-area-inset-bottom, 0px)); background: var(--fg); color: var(--bg); padding: 8px 14px; border-radius: 999px; font: 600 .8rem var(--font-body); z-index: 40; }

@media (max-width: 1360px) {
  .health { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .rail { position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto; padding: 12px 16px; gap: 12px; border-right: 0; border-bottom: 1px solid var(--line-soft); }
  .rail .rail-hd, .rail .rail-ft { display: none; }
  .brand span { display: none; }
  .bots { flex-direction: row; gap: 6px; }
  .bot { grid-template-columns: 24px auto; padding: 5px 12px 5px 6px; border-radius: 999px; border: 1px solid var(--line); width: auto; flex: none; }
  .bots .rail-hd { display: none; }
  .bot .av.lg { width: 24px; height: 24px; font-size: .62rem; border-radius: 50%; }
  .bot .nm span, .bot .tm { display: none; }
  .grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "inbox" "herd" "team" "feed"; }
  .side { display: contents; }
  .herd { grid-area: herd; } .feed { grid-area: feed; }
  .ask { left: 50%; width: min(680px, calc(100% - 32px)); }
}
@media (max-width: 900px) and (min-width: 761px) { .tcards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) {
  .main { padding-block: 16px calc(150px + env(safe-area-inset-bottom, 0px)); }
  .health { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .clocks { display: none; }
  .grid { display: block; }
  .grid .panel { display: none; }
  .grid .panel.on { display: flex; }
  body:not([data-tab="inbox"]) .head, body:not([data-tab="inbox"]) .health { display: none; }
  .brief { font-size: .88rem; }
  .health { gap: 6px; }
  .ht { padding: 9px 11px; }
  .ht.ok, .ht span.sub { display: none; }
  .ht b { font-size: .92rem; }
  .ask:not([hidden]) { display: none; }
  body[data-tab="ask"] .ask:not([hidden]) { display: block; }
  body[data-tab="ask"] .grid, body[data-tab="ask"] .head, body[data-tab="ask"] .health { display: none; }
  body[data-tab="ask"] .sugs { display: flex; }
  .sugs { flex-direction: column; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
  .sugs p { margin: 0 0 4px; color: var(--muted); font-size: .86rem; line-height: 1.5; }
  .sugs .btn { white-space: normal; text-align: left; min-height: 38px; padding: 8px 12px; }
  body[data-tab="ask"] .answer:not([hidden]) ~ .sugs { display: none; }
  .tcards { grid-template-columns: minmax(0, 1fr); }
  .crow { grid-template-columns: 104px minmax(0, 1fr); row-gap: 4px; }
  .crow .cl { grid-template-columns: repeat(15, minmax(0, 1fr)); gap: 3px; }
  .crow .sum { grid-column: 2; text-align: left; }
  .herd-top { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .tabs { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--rail); border-top: 1px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px)); }
  .tabs button { border: 0; background: transparent; color: var(--faint); font: 700 .7rem var(--font-body); letter-spacing: .03em; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; border-radius: 10px; cursor: pointer; }
  .tabs button b { font: 700 .95rem var(--font-mono); color: var(--muted); }
  .tabs button[aria-selected="true"] { color: var(--fg); background: var(--raised); }
  .tabs button[aria-selected="true"] b { color: var(--fg); }
  .tabs button .n { color: var(--accent); }
  .ask { bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }
  .toast { bottom: calc(140px + env(safe-area-inset-bottom, 0px)); }
}

/* ── app additions: header actions, the op sheet, forms, the log-in and Settings pages ── */
[hidden] { display: none !important; }
.head-actions { display: flex; align-items: flex-end; gap: 14px; }
dialog.sheet { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--fg); padding: 18px; width: min(440px, calc(100% - 32px)); }
dialog.sheet::backdrop { background: rgba(0, 0, 0, .6); }
dialog.sheet h3 { font: 700 1.02rem var(--font-body); margin: 0 0 6px; }
dialog.sheet p { color: var(--muted); font-size: .86rem; line-height: 1.5; margin: 0 0 12px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; font-size: .8rem; color: var(--muted); font-weight: 600; }
.field input, input.grow { font: 500 16px var(--font-body); color: var(--fg); background: var(--sunk); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
input.grow { flex: 1; min-width: 0; }
.err { color: var(--bad); font-size: .82rem; margin: 0 0 10px; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.auth { min-height: 100vh; display: grid; place-items: center; padding: calc(24px + env(safe-area-inset-top, 0px)) 16px 24px; }
.auth .panel { width: min(400px, 100%); }
.settings { max-width: 720px; margin: 0 auto; padding: calc(24px + env(safe-area-inset-top, 0px)) 16px 80px; display: flex; flex-direction: column; gap: 12px; }
.settings h1 { font-size: 1.6rem; font-weight: 800; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.row span { color: var(--muted); font-size: .84rem; }
#nokey { margin: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; font-size: .86rem; color: var(--muted); }
#nokey a { color: var(--fg); }
@media (max-width: 1100px) { .rail { padding-top: calc(12px + env(safe-area-inset-top, 0px)); } }
.times { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.row input[type="time"] { font: 500 16px var(--font-body); color: var(--fg); background: var(--sunk); border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; }
