:root {
  --bg: #f4f2f0;
  --card: #ffffff;
  --ink: #1f1f1f;
  --muted: #6b6b6b;
  --line: #dedad6;
  --soft: #ece9e5;
  --brand: #740f22;
  --fresh: #22a05a;
  --waiting: #f2a900;
  --overdue: #d12f2f;
  --bar-ink: #ffffff;
  color-scheme: light;
}
/* Dark follows the computer unless a station or the office picks light or dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #161616; --card: #232323; --ink: #f0f0f0; --muted: #a0a0a0; --line: #383838; --soft: #2c2c2c; color-scheme: dark; }
}
:root[data-theme="dark"] { --bg: #161616; --card: #232323; --ink: #f0f0f0; --muted: #a0a0a0; --line: #383838; --soft: #2c2c2c; color-scheme: dark; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100vh; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: .4; cursor: default; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; }
h3 { margin: 0 0 10px; font-size: 16px; }
h4 { margin: 14px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.muted { color: var(--muted); }
.hint { font-size: 12.5px; color: var(--muted); margin: 2px 0 8px; }
.spacer, .grow { flex: 1; }
.inline { display: flex; gap: 8px; align-items: center; }
.inline.wrap { flex-wrap: wrap; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; width: 100%; }
.empty { color: var(--muted); padding: 20px 4px; text-align: center; }

/* ----- Header ----- */
.bar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); background: var(--brand); color: var(--bar-ink); flex-wrap: wrap; -webkit-app-region: drag; }
.logo { height: 30px; max-width: 140px; object-fit: contain; border-radius: 4px; }
.office-title { font-size: 13px; opacity: .85; font-weight: 600; }
.bar button, .bar .menu { -webkit-app-region: no-drag; }
.station { background: none; border: 0; color: inherit; font-weight: 700; font-size: 17px; padding: 4px 2px; }
.tabs { display: flex; gap: 2px; background: rgba(0,0,0,.18); border-radius: 10px; padding: 3px; }
.tabs button { background: none; border: 0; color: inherit; opacity: .9; padding: 5px 11px; border-radius: 8px; font-size: 14px; }
.tabs button[aria-current="true"] { background: var(--card); color: var(--ink); font-weight: 600; opacity: 1; }
.count:not(:empty) { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 3px; border-radius: 9px; background: #ffd27a; color: #3a2a00; font-size: 11.5px; font-weight: 700; line-height: 18px; text-align: center; }
.bar-actions { position: relative; display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
.chip { background: color-mix(in srgb, currentColor 14%, transparent); border: 1px solid color-mix(in srgb, currentColor 30%, transparent); color: inherit; border-radius: 999px; padding: 4px 11px; font-size: 13px; }
#sound[aria-pressed="false"] { opacity: .7; text-decoration: line-through; }
#dnd[aria-pressed="true"] { background: #ffd27a; color: #3a2a00; border-color: #ffd27a; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.2); padding: 6px; display: flex; flex-direction: column; min-width: 180px; z-index: 20; }
.menu button { background: none; border: 0; text-align: left; padding: 8px 10px; border-radius: 6px; }
.menu button:hover { background: var(--soft); }

.banner { margin: 10px 12px 0; padding: 8px 12px; border-radius: 8px; font-size: 13px; }
.banner.bad { background: #fde8e8; color: #8a1c1c; }
.banner.warn { background: #fff6dd; color: #6b4e00; }
.banner.preview { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; background: var(--soft); color: var(--ink); font-weight: 600; }
.notice { background: #fff6dd; color: #6b4e00; border-radius: 8px; padding: 9px 12px; font-size: 13.5px; }
.view { padding: 12px; max-width: 980px; margin: 0 auto; }
.view-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.view-bar h3 { margin: 0; }
.search { width: 100%; max-width: 320px; }

/* ----- Panel ----- */
.grid { --sq: 52px; --sq-h: 40px; --gap: 10px; display: grid; grid-template-columns: repeat(auto-fill, min(var(--sq), calc((100% - 2 * var(--gap)) / 3))); justify-content: start; gap: var(--gap); padding: 12px; align-items: start; }
/* A station setup picks the button size. */
:root[data-tiles="small"] .grid { zoom: .85; }
/* A skinny strip keeps its three-across rooms at normal size. */
@container panel (min-width: 301px) { :root[data-tiles="large"] .grid { zoom: 1.3; } }
/* Fill the Screen sets the size from the space left (see OL.fitLights). Rooms
   are square whether they're on or off, so a light coming on doesn't change
   how much fits. */
:root[data-tiles="fill"] .grid > .tile.short:not(.on) { height: var(--sq); }
/* Room names grow with their wider buttons. */
:root[data-tiles="fill"] .tile.short:not(.on) .label { font-size: max(8px, min(28px, calc(100cqi / (var(--chars, 4) * .74)))); }
/* So does the writing on a room that's on. */
:root[data-tiles="fill"] .tile.short.on .sq-line { font-size: max(8px, min(22px, calc(100cqi / (var(--chars, 4) * .74)))); }
:root[data-tiles="fill"] .tile.short.on .sq-name { font-size: max(8px, min(22px, calc(100cqi / (var(--chars, 4) * .74)))); }
:root[data-tiles="fill"] .tile.short.on .sq-top.marked .sq-line { font-size: max(8px, min(22px, calc((100cqi - 17px) / (var(--chars, 4) * .74)))); }
:root[data-tiles="fill"] .tile.short.on .clock { font-size: max(8px, min(18px, 24cqi)); }
:root[data-tiles="fill"] .tile.short.on .sq-top.marked-time .clock { font-size: max(7px, min(16px, 21cqi)); }
:root[data-tiles="fill"] .tile.short.on .sq-who { font-size: max(8px, min(18px, calc((100cqi - 8px) / (var(--chars, 4) * .74)))); }
/* The columns stretch, so the buttons reach the right edge too. */
:root[data-tiles="fill"] .grid { grid-template-columns: repeat(auto-fill, minmax(min(var(--sq), calc((100% - 2 * var(--gap)) / 3)), 1fr)); }
/* A column is one small button wide and never stretches: a wider window fits
   more per row. A window too narrow for three makes them a bit narrower, so a
   skinny strip always gets three across. A short one (a room) takes one
   column and a light with a longer name takes three. */
.grid > .tile { grid-column: span 3; }
.grid > .tile.short { grid-column: span 1; }
.section { grid-column: 1 / -1; margin: 6px 2px -2px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.grid > .section:first-child { margin-top: 0; }
.tile { position: relative; display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 2px; min-height: 62px; padding: 8px 10px; border-radius: 12px; border: 1px solid var(--line); border-left: 6px solid var(--c); background: var(--card); text-align: left; transition: transform .08s; overflow: hidden; }
.tile:active { transform: scale(.97); }
.tile.spacer { border: 0; background: none; min-height: 0; padding: 0; }
.tile.short { min-height: var(--sq-h); padding: 4px 3px; align-items: center; justify-content: center; text-align: center; }
.tile.short:not(.on) { height: var(--sq-h); }
.tile.short .tile-head { justify-content: center; }
.tile.short:not(.on) .label { font-size: max(8px, min(18px, calc(100cqi / (var(--chars, 4) * .74)))); font-weight: 700; }
/* A short name stays on one line. Each short tile measures itself, and the
   name shrinks by its own length (--chars) to fit instead of wrapping. */
.tile.short { container: tile / inline-size; }
.tile.short:not(.on) .tile-head { max-width: 100%; }
.tile.short:not(.on) .label { white-space: nowrap; overflow: hidden; text-overflow: clip; overflow-wrap: normal; }
/* "DrTH 2": the name on one line, its number under it. */
.tile.short:not(.on) .label.two-line { display: flex; flex-direction: column; align-items: center; line-height: 1.05; }
.tile.short .tile-num { font-size: .85em; }
.tile.short.on { align-items: flex-start; justify-content: flex-start; text-align: left; }
.tile.short.on .label { font-size: 12px; font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: break-word; hyphens: auto; }
.tile.short.on .tile-name { font-size: 13px; }
/* A lit small button: room or column, provider, time. It keeps its square. */
.grid > .tile.short.on { height: var(--sq); min-height: 0; padding: 3px 3px 3px 8px; gap: 0; justify-content: space-between; align-items: stretch; }
/* The top line: the room or column, and the dot or priority at the right. */
.tile.short.on .sq-top { display: flex; align-items: center; justify-content: space-between; gap: 1px; min-width: 0; }
.tile.short.on .sq-pri { flex: none; font-size: 9px; font-weight: 800; line-height: 12px; padding: 0 2px; border-radius: 4px; background: rgba(0,0,0,.28); color: #fff; }
.tile.short.on::before { width: 5px; }
.tile.short.on .sq-line { min-width: 0; font-size: max(8px, min(12px, calc(100cqi / (var(--chars, 4) * .74)))); font-weight: 700; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: clip; }
.tile.short.on .sq-name { font-size: max(8px, min(13px, calc(100cqi / (var(--chars, 4) * .74)))); }
/* Beside a dot or priority, a line leaves room for it. */
.tile.short.on .sq-top.marked .sq-line { font-size: max(8px, min(13px, calc((100cqi - 17px) / (var(--chars, 4) * .74)))); }
.tile.short.on .clock { font-size: max(8px, min(11px, 24cqi)); padding-top: 0; margin-top: 0; }
.tile.short.on .sq-top.marked-time .clock { font-size: max(7px, min(11px, 21cqi)); }
/* The provider, as a block in their own color. */
.tile.short.on .sq-who { align-self: flex-start; max-width: 100%; padding: 0 3px; border-radius: 4px; background: rgba(0,0,0,.22); box-shadow: 0 0 0 1px rgba(255,255,255,.8); font-size: max(8px, min(12px, calc((100cqi - 8px) / (var(--chars, 4) * .74)))); }
.tile.short.on .detail { display: none; }
.tile.short .later { position: absolute; right: 2px; bottom: 1px; font-size: 9px; line-height: 1; }
.tile .label { font-weight: 650; font-size: 15px; overflow-wrap: anywhere; }
.tile .tile-top { display: flex; gap: 6px; align-items: center; font-size: 11.5px; opacity: .9; }
.tile .tile-name { font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.tile .detail { font-size: 12px; opacity: .85; }
.tile .clock { font-variant-numeric: tabular-nums; font-size: 12.5px; font-weight: 700; margin-top: auto; padding-top: 4px; }
.tile .later { position: absolute; right: 8px; bottom: 6px; font-size: 11px; color: var(--muted); }
.tile.on .later { color: inherit; opacity: .85; }
.tile.on { background: var(--c); border-color: var(--c); }
/* Aging bar: green while fresh, orange while waiting, red when overdue. */
.tile.on::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 8px; background: var(--fresh); }
.tile.on { padding-left: 18px; }
.tile.on[data-stage="waiting"]::before { background: var(--waiting); }
.tile.on[data-stage="overdue"]::before { background: var(--overdue); animation: blink 1s steps(2) infinite; }
.tile.on[data-stage="overdue"] { box-shadow: 0 0 0 3px var(--overdue); }
.tile.escalated { animation: flashall .8s ease-in-out infinite; }
.tile.flash { animation: flash .9s ease-out 2; }
/* A room's green, yellow or red dot. The white ring shows it on any color. */
.light-dot { display: inline-block; flex: none; width: 11px; height: 11px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.25); }
.dot-picks { display: inline-flex; gap: 6px; align-items: center; }
.dot-pick { width: 28px; height: 28px; padding: 0; border-radius: 50%; border: 2px solid #fff; background: var(--dot); box-shadow: 0 0 0 1px var(--line); }
.dot-pick[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--ink); }
.badge { display: inline-block; background: #1e3a8a; color: #fff; border-radius: 5px; padding: 0 6px; font-size: 11px; font-weight: 700; line-height: 17px; }
.tile .who { align-self: flex-start; font-weight: 700; font-size: 14px; padding: 1px 8px; border-radius: 6px; background: rgba(0,0,0,.22); box-shadow: 0 0 0 1px rgba(255,255,255,.8); }
.chip-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tag { display: inline-block; background: rgba(0,0,0,.22); color: inherit; border-radius: 5px; padding: 0 6px; font-size: 12px; font-weight: 600; }
.tag.dark { background: var(--soft); color: var(--ink); }
@keyframes blink { 50% { opacity: .2; } }
@keyframes flashall { 50% { filter: brightness(1.45) saturate(1.2); } }
@keyframes flash { 0% { filter: brightness(1.6); } 100% { filter: none; } }

/* ----- Sheets ----- */
.sheet { width: min(460px, calc(100vw - 20px)); max-height: calc(100vh - 30px); border: 0; border-radius: 14px; padding: 18px; background: var(--card); color: var(--ink); box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.sheet.wide { width: min(640px, calc(100vw - 20px)); padding: 0; }
.sheet::backdrop { background: rgba(0,0,0,.35); }
.sheet h2 { margin: 0 0 12px; font-size: 18px; }
.field { display: flex; flex-direction: column; gap: 5px; margin: 0 0 12px; font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea { width: 100%; }
.check { display: flex; gap: 8px; align-items: center; margin: 0 0 10px; font-size: 14px; }
.checks { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--ink); }
.choices { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.chip-btn { border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 6px 12px; font-size: 13.5px; }
.chip-btn[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
/* A provider's choice is in their color; the chosen one gets a ring. */
.chip-btn.provider-chip { font-weight: 700; border-color: transparent; }
.chip-btn.provider-chip[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--card), 0 0 0 5px var(--ink); }
.swatches { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.swatches button { width: 28px; height: 28px; border-radius: 50%; border: 3px solid transparent; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0,0,0,.15); }
.swatches button[aria-pressed="true"] { border-color: var(--ink); }
.swatches input[type=color] { width: 34px; height: 30px; padding: 2px; }
.sheet-actions { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.primary, .plain, .danger { border-radius: 8px; padding: 8px 14px; border: 1px solid var(--line); background: var(--bg); }
.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.danger { color: #b42318; border-color: #f0c4c0; background: transparent; }
.plain.small, .small { padding: 4px 10px; font-size: 13px; }
.link { background: none; border: 0; color: #2f6fd1; padding: 0 4px; font-size: 13px; }
.icon { width: 30px; height: 30px; border-radius: 7px; border: 1px solid var(--line); background: var(--bg); padding: 0; }
.form-error { color: #b42318; font-size: 13.5px; margin: 4px 0 0; }
.form-body { overflow: auto; }

/* ----- Light screen ----- */
.light-sheet { display: flex; flex-direction: column; gap: 10px; padding-bottom: 14px; }
.light-sheet > :not(.light-head) { margin-left: 14px; margin-right: 14px; }
.light-sheet .field { margin: 0; }
.light-head { padding: 10px 10px 10px 14px; border-radius: 14px 14px 0 0; }
.light-title { display: flex; gap: 8px; align-items: center; }
.light-head h2 { margin: 0; font-size: 19px; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.light-head p { margin: 3px 0 0; font-size: 12.5px; opacity: .9; }
.head-clear { background: #fff; color: #b42318; border: 0; border-radius: 8px; padding: 7px 16px; font-weight: 700; font-size: 15px; box-shadow: 0 1px 3px rgba(0,0,0,.25); flex: none; }
.head-close { background: none; border: 0; color: inherit; font-size: 24px; line-height: 1; padding: 2px 6px; opacity: .85; flex: none; }
.light-controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; flex-wrap: wrap; }
.seg button { background: var(--bg); border: 0; border-right: 1px solid var(--line); padding: 7px 12px; font-size: 13.5px; }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: #1e3a8a; color: #fff; font-weight: 600; }
.toggle { border: 1px solid var(--line); background: var(--bg); border-radius: 9px; padding: 7px 12px; font-size: 13.5px; }
.toggle[aria-pressed="true"] { background: #16a34a; border-color: #16a34a; color: #fff; font-weight: 600; }
.delay-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 13.5px; }
.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(130px, 100%), 1fr)); gap: 6px; }
.presets.small { grid-template-columns: repeat(auto-fill, minmax(min(120px, 100%), 1fr)); margin-bottom: 6px; }
.preset { border: 0; border-radius: 9px; padding: 8px; font-size: 13.5px; font-weight: 600; min-height: 40px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.preset.add { background: transparent; border: 2px dashed var(--line); color: var(--muted); box-shadow: none; }
.later-list h4 { margin-top: 0; }
.later-item { display: flex; gap: 8px; align-items: center; justify-content: space-between; font-size: 13.5px; padding: 4px 0; }
.comments { border-top: 1px solid var(--line); padding-top: 10px; }
.comments-head { display: flex; align-items: center; gap: 6px; }
.comments-head h4 { margin: 0; flex: 1; }
.timeline { list-style: none; margin: 6px 0 0; padding: 0; max-height: 220px; overflow: auto; font-size: 13.5px; }
.timeline li { padding: 5px 0; border-bottom: 1px solid var(--line); }
.timeline .c-refresh, .timeline .c-priority, .timeline .c-escalate, .timeline .c-tag { color: var(--muted); }
.time { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 6px; }

/* ----- Popups and toast ----- */
.popups { position: fixed; right: 12px; bottom: 12px; display: flex; flex-direction: column-reverse; gap: 8px; z-index: 30; max-height: calc(100vh - 80px); overflow: hidden; width: min(320px, calc(100vw - 24px)); pointer-events: none; }
.popup { display: flex; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.3); pointer-events: auto; animation: slidein .25s ease-out; }
.popup-body { flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; background: none; border: 0; color: inherit; padding: 10px 12px; text-align: left; font-size: 13px; }
.popup-body strong { font-size: 15px; }
.popup-ack { align-self: center; background: rgba(255,255,255,.92); color: #1a1a1a; border: 0; border-radius: 7px; padding: 6px 10px; font-size: 13px; font-weight: 700; margin-left: 4px; }
.sheet-actions .ack { border-color: #b42318; color: #b42318; font-weight: 600; }
.sheet.report-sheet { padding: 18px; }
.sheet.setup-sheet { padding: 18px; }
/* A long form scrolls inside the sheet, so Save is always reachable. */
#form-sheet { overflow-y: auto; }
.setup-sheet .grid-table td:not(:first-child), .setup-sheet .grid-table th:not(:first-child) { text-align: center; }
.setup-sheet .grid-table th label.check { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; }
.report-sheet textarea { width: 100%; }
.report-shot { flex-wrap: wrap; }
.report-shot img { width: 100%; max-height: 220px; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; background: var(--soft); }
.report-thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.report-thumb { position: relative; }
.report-thumb img { width: 96px; height: 72px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.report-thumb .popup-close { position: absolute; top: -6px; right: -6px; background: var(--card); color: var(--ink); border-radius: 50%; padding: 0 6px; font-size: 16px; box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.report-mine { margin-top: 14px; }
.report-list { list-style: none; margin: 0; padding: 0; font-size: 13.5px; }
.report-list li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.report-status { font-weight: 600; }
.report-status.s-new { color: #b45309; }
.report-status.s-working { color: #1d4ed8; }
.report-status.s-fixed { color: var(--fresh); }
.report-note { white-space: pre-wrap; background: var(--soft); border-radius: 8px; padding: 8px 10px; }
.report-pre { white-space: pre-wrap; font: 12px/1.4 ui-monospace, Menlo, Consolas, monospace; background: var(--soft); border-radius: 8px; padding: 8px 10px; max-height: 240px; overflow: auto; }
.report-pictures { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.report-pictures img { max-width: 100%; max-height: 260px; border-radius: 8px; border: 1px solid var(--line); }
.popup-close { background: none; border: 0; color: inherit; font-size: 20px; padding: 4px 10px; opacity: .8; }
@keyframes slidein { from { transform: translateX(40px); opacity: 0; } }
.toast { position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; gap: 12px; align-items: center; background: #222; color: #fff; padding: 10px 14px; border-radius: 10px; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.25); z-index: 40; max-width: calc(100vw - 24px); }
.toast button { background: none; border: 0; color: #ffd27a; font-weight: 700; padding: 0; }

/* ----- Focused ----- */
.focused-list { display: flex; flex-direction: column; gap: 6px; }
.focus-card { display: block; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line); border-left: 6px solid var(--fresh); border-radius: 10px; padding: 5px 10px; }
.focus-card.stage-waiting { border-left-color: var(--waiting); }
.focus-card.stage-overdue { border-left-color: var(--overdue); box-shadow: 0 0 0 2px var(--overdue); }
.focus-card.escalated { animation: flashall .8s ease-in-out infinite; }
.later-card { border-left-color: var(--muted); }
.focus-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13.5px; }
.focus-name { font-weight: 700; padding: 1px 8px; border-radius: 6px; font-size: 14px; }
.focus-notes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; line-height: 1.3; }
.note-chip { background: var(--soft); border-radius: 7px; padding: 4px 8px; font-size: 13px; }
.focus-notes .focus-now { font-weight: 600; font-size: 14.5px; }
.focus-head .focus-who { font-size: 13px; padding: 1px 8px; }
.focus-notes:has(.focus-now) { align-items: baseline; }

/* ----- Chat ----- */
.chat { display: grid; grid-template-columns: 220px 1fr; gap: 12px; height: calc(100vh - 110px); }
.chat-side { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; overflow: auto; display: flex; flex-direction: column; gap: 3px; }
.chat-side h4 { margin: 10px 4px 4px; }
.conv { display: flex; gap: 7px; align-items: center; background: none; border: 0; border-radius: 7px; padding: 7px 8px; text-align: left; font-size: 14px; }
.conv[aria-pressed="true"] { background: var(--soft); font-weight: 600; }
.conv-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .count { margin: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); flex: none; }
.dot.online { background: #22a05a; }
.chat-main { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: 12px; min-height: 0; }
.chat-title { display: flex; gap: 10px; align-items: baseline; padding: 10px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.chat-title h3 { margin: 0; }
.chat-title .muted { font-size: 12.5px; }
.messages { flex: 1; overflow: auto; padding: 10px 14px; display: flex; flex-direction: column; gap: 10px; }
.day { align-self: center; font-size: 12px; color: var(--muted); }
.msg { max-width: 78%; align-self: flex-start; }
.msg.mine { align-self: flex-end; }
.msg-meta { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.msg-text { background: var(--soft); border-radius: 12px; padding: 8px 11px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.mine .msg-text { background: #dbe7ff; color: #10203f; }
.reactions { display: flex; gap: 4px; margin-top: 3px; }
.reaction { background: none; border: 1px solid transparent; border-radius: 999px; padding: 0 6px; font-size: 13px; opacity: .55; }
.reaction[aria-pressed="true"], .reaction:hover { opacity: 1; border-color: var(--line); }
.composer { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); align-items: flex-end; }
.composer textarea { flex: 1; resize: none; }

/* ----- Status board ----- */
.status-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr)); gap: 10px; margin-bottom: 16px; }
.status-card { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; border: 0; border-radius: 12px; padding: 12px; text-align: left; min-height: 84px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.status-card strong { font-size: 16px; }
.status-name { font-weight: 600; font-size: 14px; }
.status-when { font-size: 12px; opacity: .75; margin-top: auto; }
.status-picks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.status-pick { border: 0; border-radius: 9px; padding: 12px; font-weight: 600; box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); }
.status-pick[aria-pressed="true"] { box-shadow: inset 0 0 0 3px var(--ink); }

/* ----- Activity ----- */
.history-controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 6px; }
.table-scroll { overflow-x: auto; }
.grid-table.history td { vertical-align: top; }
.grid-table.history .time { white-space: nowrap; }
.grid-table td.nowrap { white-space: nowrap; }
.grid-table.history .h-on td:nth-child(3) { color: var(--fresh); font-weight: 600; }
.grid-table.history .h-off td:nth-child(3) { color: var(--overdue); font-weight: 600; }
.cleared-line { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.log { list-style: none; margin: 0; padding: 0; font-size: 13.5px; }
.log li { padding: 7px 2px; border-bottom: 1px solid var(--line); }
.cleared { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin-bottom: 8px; font-size: 13.5px; }
.cleared summary { cursor: pointer; }

/* ----- Settings and admin ----- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 14px; }
.card.narrow { max-width: 420px; margin: 30px auto; }
.set-row { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }
.set-row:last-child { border-bottom: 0; }
.set-label { font-size: 14px; }
.grid-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.grid-table th { text-align: left; font-weight: 600; color: var(--muted); padding: 6px 4px; border-bottom: 1px solid var(--line); }
.grid-table td { padding: 6px 4px; border-bottom: 1px solid var(--line); }
.grid-table td.right { text-align: right; }
.grid-table tr:has(+ .hint-row) td { border-bottom: 0; }
.grid-table .hint-row td { padding-top: 0; }
.hint.warn { color: var(--overdue); }
.hotkeys .chip-btn { min-width: 96px; font-weight: 600; }
.card-actions { display: flex; gap: 8px; margin-top: 10px; }
.swatch-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 7px; vertical-align: -1px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.15); flex: none; }
.admin-list { list-style: none; margin: 0 0 10px; padding: 0; }
.admin-list li { display: flex; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
/* Admin's Panel list can be reordered by dragging a row's handle. */
.drag-list { position: relative; }
.drag-handle { border: 0; background: none; padding: 4px 2px; font-size: 18px; line-height: 1; color: var(--muted); cursor: grab; touch-action: none; user-select: none; }
.drag-handle:active { cursor: grabbing; }
.drag-list li.dragging { opacity: .35; }
.drop-line { position: absolute; left: 0; right: 0; height: 4px; border-radius: 2px; background: var(--brand); pointer-events: none; }
.drop-mark { position: fixed; z-index: 50; border-radius: 2px; background: var(--brand); pointer-events: none; }
.preset.dragging, .tab-block.dragging { opacity: .35; }
.preset .drag-handle { color: inherit; opacity: .6; padding: 0 2px 0 0; font-size: 15px; }
.ask-sheet { width: min(380px, calc(100vw - 20px)); }
.ask-question { margin: 0 0 8px; font-size: 15px; line-height: 1.4; }
.kind { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); width: 52px; flex: none; }
.tab-block { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 10px; }
.tab-head { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }

@media (max-width: 640px) {
  .tabs { order: 3; width: 100%; justify-content: space-between; }
  .tabs button { flex: 1; padding: 6px 4px; }
  .chat { grid-template-columns: 1fr; height: auto; }
  .chat-side { max-height: 180px; }
  .messages { min-height: 300px; }
  .msg { max-width: 92%; }
  .presets { grid-template-columns: 1fr 1fr; }
  .set-row { flex-wrap: wrap; }
}

/* ----- Icons and pictures ----- */
.icon-img { width: var(--icon, 28px); height: var(--icon, 28px); border-radius: 50%; object-fit: cover; flex: none; box-shadow: 0 0 0 2px rgba(255,255,255,.6); background: var(--soft); }
.icon-emoji { font-size: calc(var(--icon, 28px) * .8); line-height: 1; flex: none; }
.tile .tile-head { display: flex; gap: 8px; align-items: center; }
.tile.on .tile-head { margin-top: 2px; }
.status-card .tile-head { display: flex; gap: 8px; align-items: center; }
.preset { display: inline-flex; gap: 6px; align-items: center; justify-content: center; }
.focus-name { display: inline-flex; gap: 6px; align-items: center; }
.icon-field { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; color: var(--ink); }
.icon-field .preview { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--soft); overflow: hidden; }
.icon-field .preview .icon-img { --icon: 44px; box-shadow: none; }
.icon-field .preview.logo-preview { width: auto; min-width: 44px; border-radius: 6px; padding: 4px; }
.icon-field .preview.logo-preview img { height: 36px; max-width: 160px; object-fit: contain; }
.icon-field input.emoji { width: 90px; font-size: 18px; text-align: center; }
.theme-preview { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin: 6px 0 12px; }
.theme-preview .tp-bar { padding: 8px 12px; font-weight: 700; display: flex; gap: 8px; align-items: center; }
.theme-preview .tp-body { padding: 14px 12px; font-size: 13px; }

/* ----- Help ----- */
.help h1 { font-size: 24px; margin: 4px 0 14px; }
.help-toc { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; margin-bottom: 16px; columns: 2 260px; column-gap: 28px; }
.help-toc h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 8px; column-span: all; }
.help-toc ol { margin: 0; padding-left: 18px; }
.help-toc > ol > li { break-inside: avoid; margin-bottom: 8px; font-weight: 600; }
.help-toc ol ol { font-weight: 400; padding-left: 16px; list-style: disc; }
.help-toc a { color: inherit; text-decoration: none; }
.help-toc a:hover { text-decoration: underline; }
.help-body { line-height: 1.55; max-width: 760px; }
.help-section { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px 18px 10px; margin-bottom: 14px; }
.help-body h3 { font-size: 19px; margin: 14px 0 6px; }
.help-body h4 { font-size: 15.5px; margin: 16px 0 4px; text-transform: none; letter-spacing: 0; color: var(--ink); }
.help-body p, .help-body li { font-size: 14.5px; }
.help-body ol, .help-body ul { padding-left: 22px; }
.help-body li { margin: 3px 0; }
.help-body code { background: var(--soft); border-radius: 4px; padding: 1px 5px; font-size: 13px; }
.help-page { padding: 0; }
.help-body [id] { scroll-margin-top: calc(var(--bar-h, 0px) + 12px); }
/* On a wide screen the contents are a sidebar that stays in place. */
@media (min-width: 860px) {
  .view.help { max-width: 1180px; }
  .help-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 20px; align-items: start; }
  .help-layout .help-toc { position: sticky; top: calc(var(--bar-h, 0px) + 12px); max-height: calc(100vh - var(--bar-h, 0px) - 24px); overflow-y: auto; columns: auto; margin: 0; padding: 12px 10px 12px 12px; }
  .help-layout .help-toc h2 { margin-bottom: 10px; padding-left: 8px; }
  .help-layout .help-toc ol { padding-left: 0; list-style: none; }
  .help-layout .help-toc > ol > li { margin-bottom: 2px; font-size: 14px; }
  .help-layout .help-toc a { display: block; padding: 4px 8px; border-radius: 6px; }
  .help-layout .help-toc a:hover { background: var(--soft); text-decoration: none; }
  .help-layout .help-toc a.current { background: var(--soft); box-shadow: inset 3px 0 var(--brand); font-weight: 700; }
  .help-layout .help-toc ol ol { display: none; margin: 2px 0 6px; padding-left: 10px; font-size: 13.5px; }
  .help-layout .help-toc li.open > ol { display: block; }
}
.help-figure { margin: 12px 0 16px; }
.help-figure img { display: block; max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 2px 10px rgba(0,0,0,.08); }
.help-figure figcaption { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* ----- Small windows, pinned windows and touch screens -----
   The lights follow the width of the window, down to small tiles and then a
   single column. A small or pinned window gets a tighter header, with Do Not
   Disturb and Sound moved into the menu. */
#view-panel { container: panel / inline-size; }
.compact-only { display: none; }
@container panel (max-width: 760px) {
  .grid { --gap: 8px; padding: 10px; }
  .tile { min-height: 56px; padding: 7px 9px; }
  .tile .label { font-size: 14px; }
}
@container panel (max-width: 520px) {
  .grid { --gap: 6px; padding: 8px; }
  .tile.short:not(.on) .label { font-size: max(8px, min(16px, calc(100cqi / (var(--chars, 4) * .74)))); }
  .tile { min-height: 50px; padding: 6px 8px; border-radius: 10px; border-left-width: 5px; }
  .tile.on { padding-left: 14px; }
  .tile.on::before { width: 6px; }
  .tile .label { font-size: 13px; }
  .tile .tile-top, .tile .detail, .tile .clock { font-size: 11px; }
  .tile .icon-img, .tile .icon-emoji { --icon: 22px !important; }
  .tile .label { overflow-wrap: break-word; hyphens: auto; }
  .tile .tile-head { flex-direction: column; align-items: flex-start; gap: 3px; }
  .tile .tile-top { flex-wrap: wrap; gap: 4px; }
  .section { font-size: 11.5px; margin-top: 2px; }
}
/* A tall, skinny window: one light per row, rooms three to a row. */
@container panel (max-width: 300px) {
  .grid { --gap: 5px; padding: 6px; }
  .grid > .tile { grid-column: 1 / -1; }
  .grid > .tile.short { grid-column: span 1; }
  .tile { min-height: 40px; }
  .tile.short { padding: 4px; }
  .tile.short.on { padding: 4px 4px 4px 11px; }
  .tile .tile-head { flex-direction: row; align-items: center; gap: 6px; }
  .tile .icon-img, .tile .icon-emoji { --icon: 18px !important; }
  /* Room tiles stay small: no picture, just the name. */
  .tile.short .icon-img, .tile.short .icon-emoji { display: none; }
}
@media (max-width: 520px), (max-height: 320px) {
  .bar { gap: 6px; padding: 5px 8px; }
  .logo, .office-title, #dnd, #sound { display: none; }
  .station { font-size: 15px; flex: 1; min-width: 0; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .compact-only { display: block; }
  .tabs button { font-size: 13px; padding: 4px 8px; }
}
/* A small window: the light screen fills it, with less padding. */
@media (max-width: 520px), (max-height: 520px) {
  .sheet { width: calc(100vw - 8px); max-width: calc(100vw - 8px); max-height: calc(100vh - 8px); padding: 12px; border-radius: 10px; }
  .sheet.wide { width: calc(100vw - 8px); padding: 0; }
  .sheet.setup-sheet { padding: 12px; }
  .light-sheet { gap: 7px; padding-bottom: 10px; }
  .light-sheet > :not(.light-head) { margin-left: 8px; margin-right: 8px; }
  .light-head { padding: 7px 6px 7px 10px; border-radius: 10px 10px 0 0; }
  .light-head h2 { font-size: 16px; }
  .light-head .icon-img, .light-head .icon-emoji { --icon: 22px !important; }
  .head-clear { padding: 6px 12px; font-size: 14px; }
  .seg button, .toggle { padding: 5px 8px; font-size: 12.5px; }
  .light-sheet textarea { padding: 5px 7px; }
  .presets { grid-template-columns: 1fr 1fr; gap: 5px; }
  .preset { min-height: 34px; padding: 5px 6px; font-size: 12.5px; }
  .delay-row .chip-btn { padding: 3px 8px; font-size: 12.5px; }
  .sheet-actions { margin-top: 2px; }
  .primary, .plain, .danger { padding: 6px 12px; }
  .timeline { max-height: 140px; font-size: 12.5px; }
}
/* A tall, skinny window: the views stack into rows that fit the width. */
@media (max-width: 360px) {
  .tabs { display: grid; grid-template-columns: repeat(auto-fit, minmax(58px, 1fr)); gap: 2px; }
  .tabs button { min-width: 0; padding: 4px 2px; font-size: 12px; white-space: nowrap; }
  .tabs .count:not(:empty) { min-width: 15px; padding: 0 3px; margin-left: 1px; font-size: 10.5px; line-height: 15px; }
  .chip { padding: 3px 8px; font-size: 12px; }
  .view { padding: 8px; }
  .view-bar { flex-wrap: wrap; }
  .chat-side { max-height: 140px; }
  .status-card { min-height: 0; padding: 8px 10px; }
  .status-card strong { font-size: 14px; }
  .status-picks { gap: 5px; }
  .status-pick { padding: 7px 5px; font-size: 13px; }
  .card { padding: 10px; overflow-x: auto; }
  .grid-table { font-size: 12.5px; }
  .chat { grid-template-columns: minmax(0, 1fr); }
  input, select, textarea { min-width: 0; max-width: 100%; }
  .help-body { overflow-wrap: anywhere; }
}
/* Short and wide, such as pinned to the top or bottom: section headings would
   each take a whole row, so they go, and the lights flow straight across. */
@media (max-height: 320px) {
  .grid > .section, .grid > .spacer { display: none; }
  .grid { --gap: 6px; padding: 6px 8px; }
  .tile { min-height: 50px; padding: 6px 8px; }
  .tile .label { font-size: 13px; }
  .banner { margin: 6px 8px 0; padding: 5px 10px; }
}
/* Full screen on a touch screen: there's no window to drag. */
:root[data-place="full"] .bar { -webkit-app-region: no-drag; }
/* Fingers need bigger targets than a mouse. */
@media (any-pointer: coarse) {
  .tabs button, .chip, .menu button, .chip-btn, .seg button, .toggle, .primary, .plain, .preset { min-height: 40px; }
  .menu button { padding: 11px 12px; }
  .set-row input[type=checkbox], .check input[type=checkbox] { width: 22px; height: 22px; }
}

/* Setup */
.card.setup { max-width: 640px; margin: 20px auto; padding: 20px 22px; }
.setup h2 { margin: 6px 0 6px; }
.setup > p { color: var(--muted); margin: 0 0 14px; line-height: 1.45; }
.setup-steps { display: flex; gap: 6px; list-style: none; padding: 0; margin: 0 0 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.setup-steps li { padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); }
.setup-steps li.now { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.setup-steps li.done { color: var(--ink); }
.setup-pair, .setup-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.setup-providers { display: grid; gap: 4px; margin-bottom: 8px; }
.setup-provider { display: grid; grid-template-columns: minmax(0, 1fr) 80px 64px auto; gap: 8px; align-items: end; }
.setup-provider .field { margin: 0; }
.setup-provider input[type="color"] { width: 100%; height: 36px; padding: 2px; }
.setup-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0 12px; }
.setup-count { max-width: 110px; }
.setup-preview { font-size: 13px; color: var(--muted); margin: 0 0 6px; }
.setup-signals { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px; }
.setup-signal { display: flex; gap: 10px; align-items: flex-start; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.setup-signal input { margin-top: 3px; }
.setup-signal strong { display: block; font-size: 14px; }
.setup-signal .hint { margin: 2px 0 0; }
.setup-summary { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 10px; }
.setup-summary p { margin: 0 0 6px; }
@media (max-width: 520px) { .setup-pair, .setup-row { grid-template-columns: 1fr; } }

/* ----- Procedure timer ----- */
#lights-pane { min-width: 0; }
#view-panel.split { display: flex; align-items: flex-start; min-height: calc(100vh - var(--bar-h, 0px)); }
#view-panel.split #lights-pane { flex: 1; }
#view-panel.split #timer-pane { flex: none; width: clamp(300px, var(--timer-w, 380px), calc(100% - 240px)); position: sticky; top: var(--bar-h, 0px); max-height: calc(100vh - var(--bar-h, 0px)); overflow-y: auto; }
#split-bar { flex: none; width: 14px; align-self: stretch; position: relative; cursor: col-resize; touch-action: none; }
#split-bar::after { content: ""; position: sticky; display: block; top: calc(50vh - 24px); margin: 0 auto; width: 4px; height: 48px; border-radius: 2px; background: var(--muted); opacity: .55; }
#split-bar:hover::after, #split-bar.dragging::after, #split-bar:focus-visible::after { background: var(--brand); opacity: 1; }
#view-panel.split #split-bar { border-left: 1px solid var(--line); }
#view-panel.timer-only #timer-pane { max-width: 760px; margin: 0 auto; }
#timer-pane { container: timer / inline-size; padding: 12px; background: var(--bg); }
.tt-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.tt-fields .field { margin: 0; }
.tt-wide { grid-column: 1 / -1; }
.tt-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.tt-procs { display: flex; flex-direction: column; gap: 7px; margin-bottom: 10px; }
.tt-proc-grid { display: flex; flex-wrap: wrap; gap: 4px; }
.tt-proc { min-height: 40px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); font-size: 13.5px; }
.tt-cats { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 5px; }
.tt-cat { min-height: 44px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); font-size: 14px; font-weight: 600; }
.tt-cat[aria-expanded="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.tt-combo { position: relative; }
.tt-suggest { position: absolute; z-index: 25; top: calc(100% + 3px); left: 0; right: 0; max-height: 216px; overflow-y: auto; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 8px; background: var(--card); box-shadow: 0 6px 18px rgba(0, 0, 0, .18); }
.tt-suggest[hidden] { display: none; }
.tt-suggest-row { flex: none; min-height: 40px; padding: 6px 10px; border: 0; border-radius: 0; background: none; color: var(--ink); text-align: left; font-size: 14.5px; font-weight: 400; }
.tt-suggest-row:hover, .tt-suggest-row[aria-selected="true"] { background: var(--soft); }
.tt-picked { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tt-picked .tt-proc { padding: 8px 12px; font-size: 14.5px; }
.tt-proc[aria-pressed="true"], .tt-tooth[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.tt-details { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; padding: 9px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.tt-chart { display: flex; flex-direction: column; gap: 3px; }
.tt-arch { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 3px; }
.tt-arch + .tt-arch { padding-top: 3px; border-top: 1px dashed var(--line); }
.tt-tooth { min-width: 0; height: 32px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); font-size: 13px; font-variant-numeric: tabular-nums; }
.tt-surface-row { display: grid; grid-template-columns: 36px repeat(5, minmax(0, 40px)); gap: 4px; align-items: center; }
.tt-go { position: sticky; bottom: 0; padding-top: 4px; background: var(--bg); }
.tt-next { display: flex; width: 100%; min-height: 68px; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font-size: 19px; border-radius: 12px; }
.tt-next-what { font-size: 20px; }
.tt-next-word { font-weight: 400; font-size: 13.5px; opacity: .85; }
.tt-back { margin-top: 8px; }
.tt-run { display: flex; flex-direction: column; gap: 10px; }
.tt-head { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 4px 10px; }
.tt-who { display: flex; flex-direction: column; min-width: 0; }
.tt-who strong { font-size: 17px; overflow-wrap: anywhere; }
.tt-line { font-size: 13.5px; color: var(--muted); overflow-wrap: anywhere; }
.tt-tod { display: inline-flex; align-items: center; gap: 4px; line-height: 1; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tt-tod-hm { font-size: 40px; letter-spacing: -.02em; }
.tt-tod-st { display: flex; flex-direction: column; font-size: 14px; line-height: 1.1; color: var(--muted); font-weight: 600; }
.tt-edit { align-self: start; display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 8px; background: none; color: var(--muted); }
.tt-edit:hover { background: var(--soft); color: var(--ink); }
.tt-edit svg { width: 18px; height: 18px; }
.tt-ring { position: relative; width: var(--ring, 240px); max-width: 100%; aspect-ratio: 1; margin: 2px auto; touch-action: manipulation; }
.tt-ring > svg { display: block; width: 100%; height: 100%; }
.tt-ring-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; pointer-events: none; font-variant-numeric: tabular-nums; }
.tt-ring-label { max-width: 56%; font-size: clamp(10px, calc(var(--ring, 240px) * .055), 13px); line-height: 1.2; color: var(--muted); font-weight: 600; }
.tt-ring-big { font-size: calc(var(--ring, 240px) * .16); line-height: 1.1; font-weight: 650; letter-spacing: -.02em; }
.tt-ring-total { font-size: clamp(10px, calc(var(--ring, 240px) * .055), 13px); color: var(--muted); }
.tt-tip { position: absolute; z-index: 6; display: flex; flex-direction: column; gap: 1px; padding: 6px 9px; border-radius: 8px; background: var(--ink); color: var(--bg); font-size: 12.5px; white-space: nowrap; pointer-events: none; transform: translate(-50%, calc(-100% - 12px)); font-variant-numeric: tabular-nums; }
.tt-tip[hidden] { display: none; }
.tt-tip.below { transform: translate(-50%, 16px); }
.tt-tip strong { font-size: 13.5px; }
.tt-act { display: flex; flex-direction: column; gap: 6px; }
.tt-by { width: 100%; margin: 0; }
.tt-tools { display: flex; justify-content: space-around; gap: 4px; }
.tt-tool { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 64px; min-height: 52px; padding: 5px 8px; border: 0; border-radius: 8px; background: none; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.tt-tool:hover { background: var(--soft); color: var(--ink); }
.tt-tool svg { width: 22px; height: 22px; }
.tt-more-wrap { position: relative; }
.tt-menu { top: auto; bottom: calc(100% + 6px); max-height: 60vh; overflow-y: auto; }
.tt-menu[hidden] { display: none; }
.tt-menu .tt-label { padding: 6px 10px 2px; }
.tt-menu hr { width: 100%; border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.tt-more { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; }
.tt-finished .tt-summary { margin: 0 auto; }
.tt-summary { display: grid; grid-template-columns: auto auto; gap: 4px 14px; margin: 8px 0; text-align: left; font-size: 13.5px; }
.tt-summary dt { color: var(--muted); }
.tt-summary dd { margin: 0; font-variant-numeric: tabular-nums; }
#tt-active h4 { margin: 16px 0 6px; }
.tt-list { display: flex; flex-direction: column; gap: 6px; }
.tt-row { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); text-align: left; }
.tt-row strong { font-size: 14.5px; }
.tt-row-now { display: flex; flex: none; flex-direction: column; align-items: flex-end; font-size: 12px; color: var(--muted); }
.tt-row-now b { font-size: 16px; color: var(--ink); font-variant-numeric: tabular-nums; }
.tt-text { width: 100%; resize: vertical; }
.tt-table td { vertical-align: top; white-space: nowrap; }
.tt-table .hint { margin: 0; }
.tt-sheet-row { cursor: pointer; }
.tt-sheet-row:hover td { background: var(--soft); }
.view.wide-view { max-width: 1500px; }
@container timer (min-width: 620px) {
  .tt-fields { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tt-arch { grid-template-columns: repeat(16, minmax(0, 1fr)); }
}
/* Popups go on the lights side, so one never lands on the Next button. */
:root[data-timer="both"] .popups, :root[data-timer="timer"] .popups { right: auto; left: 12px; }
/* Along the bottom, the popups go to the top for the same reason. */
:root[data-timer="both"][data-timer-dock="bottom"] .popups { top: calc(var(--bar-h, 56px) + 12px); bottom: auto; left: auto; right: 12px; flex-direction: column; }
/* Along the bottom of a tall window, each half scrolls on its own. */
#view-panel.split.dock-bottom { flex-direction: column; align-items: stretch; height: calc(100vh - var(--bar-h, 0px)); min-height: 0; }
#view-panel.split.dock-bottom #lights-pane { flex: 1 1 0; min-height: 0; overflow-y: auto; }
#view-panel.split.dock-bottom #timer-pane { flex: none; width: 100%; height: clamp(220px, var(--timer-h, 420px), calc(100% - 134px)); position: static; max-height: none; overflow-y: auto; }
#view-panel.split.dock-bottom #split-bar { width: auto; height: 14px; border-left: 0; border-top: 1px solid var(--line); cursor: row-resize; }
#view-panel.split.dock-bottom #split-bar::after { position: static; width: 48px; height: 4px; margin: 4px auto 0; }
/* Along the bottom of the panel, or in a short strip: the ring, the patient and clock, and Next side by side. */
#view-panel.split.dock-bottom .tt-run { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(200px, 1fr); grid-template-areas: "ring head act"; align-items: center; gap: 10px 22px; }
#view-panel.split.dock-bottom .tt-ring { grid-area: ring; margin: 0; }
#view-panel.split.dock-bottom .tt-head { grid-area: head; grid-template-columns: auto auto; justify-content: start; align-items: start; gap: 14px 6px; }
#view-panel.split.dock-bottom .tt-head .tt-tod { grid-column: 1 / -1; grid-row: 2; }
#view-panel.split.dock-bottom .tt-tod-hm { font-size: 52px; }
#view-panel.split.dock-bottom .tt-tod-st { font-size: 18px; }
#view-panel.split.dock-bottom .tt-act { grid-area: act; }
@container timer (max-width: 640px) {
  #view-panel.split.dock-bottom .tt-run { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "ring head" "act act"; }
  #view-panel.split.dock-bottom .tt-tod-hm { font-size: 36px; }
  #view-panel.split.dock-bottom .tt-tod-st { font-size: 13px; }
}
@media (max-height: 340px) {
  #view-panel.split:not(.dock-bottom) .tt-run { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "ring head" "ring act"; align-items: center; gap: 6px 14px; }
  #view-panel.split:not(.dock-bottom) .tt-ring { grid-area: ring; margin: 0; }
  #view-panel.split:not(.dock-bottom) .tt-head { grid-area: head; }
  #view-panel.split:not(.dock-bottom) .tt-act { grid-area: act; }
  #view-panel.split:not(.dock-bottom) .tt-tod-hm { font-size: 28px; }
}
@media print {
  .bar, .banner, .history-controls, .view-bar button, .popups, .toast { display: none !important; }
  .view.wide-view { max-width: none; padding: 0; }
  .tt-table td, .tt-table th { padding: 3px 5px; font-size: 11px; }
}
