/* The new dashboard (/next). Same look as the current one (dashboard/styles.css): its dark palette is the dark
   theme here, with a matching light theme. Every colour is a token on :root. Mobile first: Dor answers on his
   phone, so tap targets are at least 44px and nothing is wider than the screen. */

:root {
  --bg: #f6f6f7;
  --card: #ffffff;
  --card-2: #f0f0f2;
  --border: #dcdce1;
  --text: #16161a;
  --muted: #5d5d66;
  --faint: #8a8a93;
  --accent: #2f6fe4;
  --accent-ink: #ffffff;
  --accent-soft: #e3ecfd;
  --amber: #8a5a00;
  --amber-soft: #fbefd9;
  --green: #1f7a45;
  --green-soft: #e2f4e9;
  --red: #b3352a;
  --red-soft: #fbe5e2;
  --field: #ffffff;
  --shadow: 0 1px 2px rgba(20, 20, 30, 0.06);
  --radius: 12px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0c0e;
    --card: #17171a;
    --card-2: #1e1e22;
    --border: #29292e;
    --text: #f3f3f4;
    --muted: #9a9aa1;
    --faint: #6c6c73;
    --accent: #4f8cff;
    --accent-ink: #ffffff;
    --accent-soft: #14294a;
    --amber: #e0a13a;
    --amber-soft: #3a2c14;
    --green: #46b877;
    --green-soft: #16331f;
    --red: #e0685c;
    --red-soft: #3a1a17;
    --field: #0f0f11;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: lining-nums;
  overflow-x: hidden;
}
a { color: var(--accent); }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.shell {
  max-width: 720px;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 96px max(16px, env(safe-area-inset-left));
}

/* ---------- header and nav ---------- */
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 44px; position: relative; z-index: 6; }
.brand { margin: 0; font-size: 1.15rem; font-weight: 700; }
.top-link { font-size: 0.9rem; padding: 10px 0; text-decoration: none; color: var(--muted); }
.top-link:hover { color: var(--text); }

/* The menu: a details element; its panel drops below the header, over the page. */
.menu { position: relative; }
.menu-btn {
  list-style: none; cursor: pointer; min-height: 44px; display: inline-flex; align-items: center;
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--card); font-size: 0.95rem;
}
.menu-btn::-webkit-details-marker { display: none; }
.menu[open] .menu-btn { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 6px); width: min(320px, calc(100vw - 32px));
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18); padding: 6px; display: flex; flex-direction: column;
}
.menu-item {
  display: flex; flex-direction: column; justify-content: center; min-height: 48px; padding: 8px 12px; border-radius: 10px;
  text-decoration: none; color: var(--text); background: none; border: none; text-align: left; font-size: 1rem;
}
.menu-item small { color: var(--muted); font-size: 0.8rem; }
.menu-item:hover, .menu-item:focus-visible { background: var(--card-2); }
.menu-danger { color: var(--red); border-top: 1px solid var(--border); border-radius: 0 0 10px 10px; margin-top: 4px; }

/* The three bottom tabs. */
.bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 8;
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--card); border-top: 1px solid var(--border);
  padding: 4px max(8px, env(safe-area-inset-right)) max(4px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
}
.bnav {
  min-height: 48px; display: flex; align-items: center; justify-content: center; border-radius: 10px;
  text-decoration: none; color: var(--muted); font-weight: 600; font-size: 0.98rem;
}
.bnav.is-active { color: var(--accent); background: var(--accent-soft); }
.tab .count { font-size: 0.75rem; font-weight: 700; min-width: 20px; padding: 1px 6px; border-radius: 999px; background: var(--red-soft); color: var(--red); text-align: center; }
.tab.is-active .count { background: var(--accent-ink); color: var(--accent); }

.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 18px; }
.tab {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--card);
  font-size: 0.92rem; text-decoration: none; color: var(--text);
}
.tab.is-active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.tab.is-soon { color: var(--faint); background: transparent; cursor: default; }
.tab em { font-style: normal; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }

.page-title { font-size: 1.6rem; margin: 0 0 6px; }
.page-title span { font-size: 1rem; font-weight: 400; color: var(--muted); }

/* ---------- status line ---------- */
.status { margin: 0 0 14px; color: var(--muted); font-size: 0.98rem; }

/* ---------- cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 0 0 12px;
  box-shadow: var(--shadow);
  overflow-wrap: anywhere;
}
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: var(--red); margin: 8px 0 0; }
.empty { color: var(--muted); margin: 4px 0 12px; }
.warn { background: var(--amber-soft); color: var(--amber); border-color: transparent; font-size: 0.92rem; }
.load-error { background: var(--red-soft); color: var(--red); border-color: transparent; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Ask BOO ---------- */
.ask-title { font-size: 1rem; margin: 0 0 8px; }
textarea, input[type="text"], input[type="date"], input[type="password"] {
  width: 100%;
  min-height: 44px;
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 1rem;           /* 16px: iOS does not zoom into the field */
  resize: vertical;
}
.row-end { display: flex; justify-content: flex-end; margin-top: 8px; }
.note { border-top: 1px solid var(--border); margin-top: 14px; padding-top: 12px; }
.reply { margin: 6px 0; padding: 8px 10px; border-radius: 10px; background: var(--card-2); }
.reply-you { background: var(--accent-soft); }

/* ---------- groups ---------- */
.group { margin-top: 22px; }
.group h2 { font-size: 1.05rem; margin: 0 0 2px; }
.group-sub { margin: 0 0 10px; color: var(--muted); font-size: 0.9rem; }
.group-only-you h2, .group-stalled h2 { color: var(--red); }

.fold { margin-top: 22px; }
.fold summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; gap: 8px; font-weight: 600; list-style: none; }
.fold summary::-webkit-details-marker { display: none; }
.fold summary::before { content: "\25B8"; color: var(--muted); transition: transform 0.15s; }
.fold[open] summary::before { transform: rotate(90deg); }

/* ---------- a question ---------- */
.q-card.is-red { border-left: 4px solid var(--red); }
.q-card.is-urgent:not(.is-red) { border-left: 4px solid var(--amber); }
.q-meta { margin: 0 0 6px; color: var(--muted); font-size: 0.86rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0 4px; }
.q-meta .who { color: var(--text); font-weight: 600; }
.badges { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.badge {
  font-size: 0.72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: var(--card-2); color: var(--muted); white-space: nowrap;
}
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.q-text { margin: 0 0 8px; font-size: 1.02rem; white-space: pre-wrap; }
.q-text.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: normal; }
.q-line { margin: 0 0 8px; font-size: 0.92rem; }
.q-rec { margin: 0 0 8px; font-size: 0.92rem; padding: 8px 10px; border-radius: 10px; background: var(--accent-soft); }
.q-prev { color: var(--muted); }
.q-warn { color: var(--amber); }
.q-answer { margin: 0 0 6px; }
.done-row { padding: 10px 14px; }
.done-row .q-text { font-size: 0.95rem; margin-bottom: 4px; }

/* ---------- controls ---------- */
.answer { margin-top: 6px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.row.two > .btn { flex: 1 1 0; }
.row.field { flex-wrap: nowrap; align-items: flex-start; }
.row.field > input, .row.field > textarea { flex: 1 1 auto; min-width: 0; }
.row.field > .btn { flex: none; }

.btn {
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card-2);
  color: var(--text);
  font-size: 1rem;
  font-weight: 500;
}
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-answer { background: var(--card); border: 1.5px solid var(--accent); color: var(--accent); font-weight: 600; min-height: 48px; }
.btn-answer:active { background: var(--accent); color: var(--accent-ink); }
.btn-quiet { background: transparent; }
.btn-wide { width: 100%; }
.chips .chip { flex: 0 1 auto; }

.link {
  background: none; border: none; padding: 10px 0; min-height: 44px;
  color: var(--accent); font-size: 0.92rem; text-align: left;
}
.link-danger { color: var(--red); }
.note-box { margin-top: 2px; }
.later { margin-top: 4px; padding: 10px 12px; border-radius: 10px; background: var(--card-2); }
.change { margin-top: 6px; }

/* ---------- sign in ---------- */
.signin h2 { margin: 0 0 4px; font-size: 1.2rem; }
.si-form { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.si-form label { font-size: 0.9rem; color: var(--muted); }
.link-btn { display: flex; align-items: center; justify-content: center; margin-top: 12px; text-decoration: none; color: var(--accent); }
/* A link drawn as the primary button keeps the button's ink: .link-btn's accent colour on the accent fill made
   Today's "Answer in <name>'s room" buttons blank blue boxes (found on the Otto build's render check, 19 Oct). */
.link-btn.btn-primary { color: var(--accent-ink); }
.signin .small { text-align: center; margin: 6px 0 0; }

/* ---------- toast (fixed, rendered at the body, never inside a transformed parent) ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(68px + env(safe-area-inset-bottom));   /* above the bottom tabs */
  max-width: min(92vw, 520px);
  padding: 12px 16px; border-radius: 12px;
  background: var(--text); color: var(--bg);
  font-size: 0.95rem; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
  z-index: 10;
}
.toast-bad { background: var(--red); color: #fff; }

@media (min-width: 900px) {
  .page-title { font-size: 1.9rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Today ---------- */
.health { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.health .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; background: currentColor; }
.health-green { background: var(--green-soft); color: var(--green); border-color: transparent; }
.health-amber { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.health-red { background: var(--red-soft); color: var(--red); border-color: transparent; }
.q-room { margin: 0 0 4px; font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.q-room a { text-transform: none; letter-spacing: 0; display: inline-flex; align-items: center; min-height: 40px; }
.q-details summary { cursor: pointer; min-height: 40px; display: flex; align-items: center; color: var(--muted); font-size: 0.9rem; }
.q-card.is-readonly .link-btn { margin-top: 4px; }
.rows { padding-top: 4px; padding-bottom: 4px; }
.orow { padding: 10px 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.orow:last-child { border-bottom: none; }
.orow p { margin: 0; }
.orow-name a { display: inline-flex; align-items: center; min-height: 40px; }
.orow-name { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.orow-meta { color: var(--muted); font-size: 0.9rem; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.orow.is-stale .orow-name b { color: var(--red); }
.bad { color: var(--red); font-weight: 600; }

/* ---------- a room (/next/#dean, #chuppy, #raul) ---------- */
.room-head { color: var(--text); font-size: 0.95rem; display: block; }
.room-head .badge { margin-left: 6px; }
.room-head.is-stale { border-left: 4px solid var(--red); }
.member { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 10px; }
.member:first-of-type { border-top: none; margin-top: 4px; padding-top: 0; }
.rrow { border-bottom: 1px solid var(--border); }
.rrow:last-child { border-bottom: none; }
.rrow summary { cursor: pointer; list-style: none; min-height: 44px; padding: 10px 0; display: flex; flex-direction: column; gap: 6px; }
.rrow summary::-webkit-details-marker { display: none; }
.rrow-name { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.grades { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.grade { display: flex; flex-direction: column; padding: 6px 8px; border-radius: 8px; background: var(--card-2); font-weight: 700; font-size: 0.95rem; }
.grade small { font-weight: 400; color: var(--muted); font-size: 0.72rem; }
.grade.is-none { font-weight: 400; color: var(--muted); font-size: 0.78rem; }
.rrow-body { padding: 0 0 10px; }
@media (max-width: 420px) { .grades { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.q-meta a { display: inline-flex; align-items: center; min-height: 40px; }
.q-card.is-done, .member.is-done { opacity: 0.6; }
.done-note, .q-sent { color: var(--green); font-weight: 600; }
/* Otto's room: Dor's messages and Otto's replies under the box (private store). */
.msg { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); overflow-wrap: anywhere; }
.msg p { margin: 2px 0; }
.msg-text, .msg-reply { white-space: pre-wrap; }
.q-meta-flow { display: block; }   /* a room card's meta line flows as one sentence instead of breaking after the name */
.q-meta-flow .badges { vertical-align: middle; }

/* ---------- Otto's private notes (/next/#otto): text from his store, drawn as plain blocks ---------- */
.md p { margin: 0 0 8px; overflow-wrap: anywhere; }
.md .md-h { font-weight: 700; margin-top: 12px; }
.md .md-lead { font-weight: 700; }
.md-list { margin: 0 0 8px; padding-left: 20px; }
.md-list li { margin: 0 0 4px; overflow-wrap: anywhere; }
.fold-card summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 600; }
.fold-card[open] summary { margin-bottom: 8px; }

/* ---------- Team (/next/#team) ---------- */
.lead { margin: 0 0 8px; font-size: 0.98rem; }
.attn-line { margin: 0 0 6px; font-size: 0.92rem; }
.attn-line a { display: inline-flex; align-items: center; min-height: 40px; font-weight: 600; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin: 0 0 12px; }
.seg-btn { min-height: 44px; display: flex; align-items: center; justify-content: center; text-decoration: none; color: var(--text); background: var(--card); font-weight: 600; font-size: 0.95rem; }
.seg-btn + .seg-btn { border-left: 1px solid var(--border); }
.seg-btn.is-active { background: var(--accent); color: var(--accent-ink); }
.tree-room { padding-top: 6px; padding-bottom: 6px; }
.pb { margin: 12px 0 2px; font-size: 0.85rem; text-transform: none; }
.pb.is-planned, .trow.is-planned { color: var(--faint); }
.trow {
  display: flex; flex-direction: column; gap: 2px; padding: 10px 0 10px 10px; min-height: 44px;
  border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); border-left: 3px solid transparent;
}
.trow:last-child { border-bottom: none; }
.trow.is-act { border-left-color: var(--amber); }
.trow.is-watch { border-left-color: var(--border); }
.trow-name { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.trow-job { font-size: 0.88rem; }
.trow-meta { font-size: 0.85rem; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.trow.is-planned .trow-job { color: var(--faint); }
.gbadge { background: var(--card-2); color: var(--text); }
.gbadge-A, .gbadge-B { background: var(--green-soft); color: var(--green); }
.gbadge-C { background: var(--amber-soft); color: var(--amber); }
.gbadge-D { background: var(--red-soft); color: var(--red); }
.gbadge-none { background: var(--card-2); color: var(--muted); font-weight: 600; }
.q-line > a, p > a.tap { display: inline-flex; align-items: center; min-height: 40px; }
.dots-wrap { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.dots { display: inline-flex; gap: 4px; align-items: center; }
.dot { width: 11px; height: 11px; border-radius: 50%; border: 1.5px solid var(--faint); background: transparent; flex: none; }
.dot-ran { background: var(--green); border-color: var(--green); }
.dot-missed { background: var(--red); border-color: var(--red); }
.dot-outage { background: var(--border); border-color: var(--border); border-radius: 2px; }
.dot-later { border-style: dashed; }
.bottom-line { font-size: 0.95rem; }
.bottom-line a { display: inline-flex; align-items: center; min-height: 40px; }
.element .el-head { margin: 0 0 4px; font-size: 1.02rem; }
.reading { font-weight: 600; }

/* ---------- an agent's page ---------- */
.back { margin: 0 0 4px; }
.back a { display: inline-flex; align-items: center; min-height: 44px; text-decoration: none; font-weight: 600; }
.room-head a { display: inline-flex; align-items: center; min-height: 40px; }
.orow-pair { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.orow-pair > b { white-space: nowrap; }
.orow a { display: inline-flex; align-items: center; min-height: 40px; overflow-wrap: anywhere; }

/* ---------- Library ---------- */
.lib-search input { width: 100%; min-height: 44px; background: var(--field); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: 1rem; }
.lib-room { padding-top: 4px; padding-bottom: 4px; }
.lib-room > summary, .lib-month > summary { cursor: pointer; list-style: none; min-height: 44px; display: flex; align-items: center; flex-wrap: wrap; gap: 0 4px; }
.lib-room > summary::-webkit-details-marker, .lib-month > summary::-webkit-details-marker { display: none; }
.lib-room > summary::before, .lib-month > summary::before { content: "\25B8"; color: var(--muted); margin-right: 6px; transition: transform 0.15s; }
.lib-room[open] > summary::before, .lib-month[open] > summary::before { transform: rotate(90deg); }
.lib-month { margin-left: 8px; }
.lib-month > summary { font-weight: 600; font-size: 0.92rem; }
.lrow { display: block; min-height: 44px; padding: 11px 0 11px 18px; border-top: 1px solid var(--border); text-decoration: none; color: var(--text); font-size: 0.94rem; line-height: 1.4; }
.doc { overflow-wrap: anywhere; }
.doc-md p { margin: 0 0 10px; }
.doc-md .md-h { font-size: 1.02rem; margin: 18px 0 6px; }
.doc-md .md-h1 { font-size: 1.15rem; }
.md-quote { border-left: 3px solid var(--border); padding-left: 10px; color: var(--muted); }
.code { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--card-2); border-radius: 8px; padding: 10px; font-size: 0.82rem; margin: 0 0 10px; }
.table-wrap { max-width: 100%; overflow-x: auto; margin: 0 0 10px; }
.table-wrap table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 0.84rem; }
.table-wrap th, .table-wrap td { border: 1px solid var(--border); padding: 5px 6px; text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.table-wrap th { background: var(--card-2); }

/* ---------- Running & cost ---------- */
.outage-note { background: var(--card-2); }
.strip-head { margin: 0 0 8px; }
.strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cell { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 48px; border-radius: 8px; padding: 2px; background: var(--card-2); text-align: center; }
.cell-day { font-size: 0.7rem; color: var(--muted); white-space: nowrap; }
.cell-val { font-size: 0.82rem; font-weight: 700; white-space: nowrap; }
.cell-ok { background: var(--green-soft); }
.cell-ok .cell-val { color: var(--green); }
.cell-some { background: var(--amber-soft); }
.cell-some .cell-val { color: var(--amber); }
.cell-none { background: var(--red-soft); }
.cell-none .cell-val { color: var(--red); }
.cell-off .cell-val, .cell-later .cell-val { color: var(--faint); font-weight: 400; font-size: 0.78rem; }
.cell-outage { background: repeating-linear-gradient(135deg, var(--card-2), var(--card-2) 4px, var(--border) 4px, var(--border) 6px); }
.cell-outage .cell-val { color: var(--muted); font-weight: 600; font-size: 0.78rem; }
.cell.is-today { outline: 2px solid var(--accent); outline-offset: -2px; }
.strip-missed { margin-top: 8px; }
table.cost td:first-child, table.cost th:first-child { width: 42%; }
.faint { color: var(--faint); }
/* Five rooms on one row at 375px: equal columns, the count as a small badge on the pill's corner. */
.switcher { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin: 6px 0 14px; }
.switcher .tab { position: relative; justify-content: center; padding: 8px 4px; font-size: 0.9rem; }
.switcher .tab .count { position: absolute; top: -7px; right: -4px; min-width: 18px; padding: 1px 5px; font-size: 0.7rem; box-shadow: 0 0 0 2px var(--bg); }
