:root {
  --bg: #10131c;
  --bg2: #161a26;
  --panel: #1b2030;
  --panel2: #222839;
  --line: #2d3448;          /* dividers only */
  --field-border: #6b7591;  /* form controls: ≥3:1 against panels */
  --text: #e8ecf4;
  --muted: #98a2b8;
  --accent: #ffd54a;
  --accent-ink: #2a2110;
  --blue: #5aa9ff;
  --green: #3ecf8e;
  --red: #ef6b6b;
  --amber: #f5b942;
  --purple: #a77bf3;
  --radius: 10px;
  --pixel: "Pixelify Sans", ui-monospace, monospace;
  /* roles (same names in light and dark) */
  --hover: #2a3146;
  --elev: #232a3b;              /* popovers, toasts, tooltips */
  --overlay: rgba(6, 8, 14, .66);
  --map-bg: #10131c;
  --chip-bg: #2b3247;
  --msg-mine: #2b3a5c;
  --soft-accent: rgba(255, 213, 74, .10);
  --warn-bg: rgba(245, 185, 66, .10); --warn-line: rgba(245, 185, 66, .38); --warn-text: #f3d08a;
  --ok-bg: rgba(62, 207, 142, .12); --ok-line: rgba(62, 207, 142, .45);
  --ai-bg: rgba(124, 58, 237, .12); --ai-line: rgba(124, 58, 237, .45);
  --urgent: #ef4444; --urgent-bg: rgba(239, 68, 68, .14); --urgent-strong: #dc2626;
  --badge: #3b82f6; --badge-ink: #fff;     /* counts are blue — red is kept for urgent things */
  --shadow-1: 0 1px 2px rgba(0,0,0,.25);
  --shadow-2: 0 10px 30px rgba(0,0,0,.4);
  --shadow-3: 0 30px 80px rgba(0,0,0,.5);
  --text-xs: 11.5px; --text-s: 12.5px; --text-m: 14px; --text-l: 16px; --text-xl: 20px;
  color-scheme: dark;
}
/* Light theme: WCAG AA contrast (text ≥ 4.5:1, controls ≥ 3:1), easier to read outdoors */
:root[data-theme="light"] {
  --bg: #f3f5f9;
  --bg2: #ffffff;
  --panel: #ffffff;
  --panel2: #eef2f7;
  --line: #e1e6ee;
  --field-border: #8590a4;
  --text: #121826;
  --muted: #566074;
  --accent: #ffcd29;
  --accent-ink: #2a2110;
  --blue: #1d5fd6;
  --green: #157a45;
  --red: #c62828;
  --amber: #a85b00;
  --purple: #6d28d9;
  --hover: #e8edf4;
  --elev: #ffffff;
  --overlay: rgba(15, 23, 42, .38);
  --map-bg: #e6ebf2;
  --chip-bg: #eef2f7;
  --msg-mine: #dbe7ff;
  --soft-accent: rgba(255, 205, 41, .18);
  --warn-bg: #fff6e0; --warn-line: #f2c46a; --warn-text: #6b4400;
  --ok-bg: #e6f6ee; --ok-line: #8fd3ae;
  --ai-bg: #f1ebff; --ai-line: #c7b2f5;
  --urgent: #d92d20; --urgent-bg: #fde8e6; --urgent-strong: #c62828;
  --badge: #1d5fd6; --badge-ink: #fff;
  --shadow-1: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow-2: 0 8px 24px rgba(16, 24, 40, .12);
  --shadow-3: 0 24px 60px rgba(16, 24, 40, .18);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg2);
  border: 1px solid var(--field-border);
  border-radius: 8px;
  padding: 8px 10px;
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(90, 169, 255, .45); }
/* visible keyboard focus everywhere (WCAG 2.4.7 / 2.4.11) */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
textarea { resize: vertical; min-height: 70px; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; font-weight: 500; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--panel2); border-radius: 8px;
  padding: 8px 14px; font-weight: 600; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--hover); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--red); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn.block { width: 100%; }
.link-btn { background: none; border: 0; color: var(--blue); padding: 0; font-weight: 500; }

/* ---------- auth ---------- */
.auth {
  min-height: 100%; display: grid; place-items: center; padding: 24px 16px;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(138, 168, 146, .25), transparent),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 28px; box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.auth-card h1 { font-family: var(--pixel); font-size: 26px; margin: 10px 0 4px; letter-spacing: .5px; }
.auth-card p { margin: 0 0 18px; color: var(--muted); }
.auth-art { display: flex; gap: 6px; justify-content: center; margin-bottom: 4px; }
.auth-art canvas { image-rendering: pixelated; }
.check { display: flex; gap: 8px; align-items: flex-start; margin: 4px 0 16px; color: var(--muted); font-size: 13px; }
.check input { width: auto; margin-top: 2px; }
.error { color: var(--red); font-size: 13px; min-height: 18px; margin: 4px 0 10px; }
.error:empty { min-height: 0; margin: 0; }
.center { text-align: center; }
.btn.google { background: #fff; color: #1f1f1f; border-color: #dadce0; gap: 10px; min-height: 44px; font-weight: 600; text-decoration: none; }
.btn.google:hover { background: #f2f4f7; text-decoration: none; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 16px 0; }
.divider::before, .divider::after { content: ''; flex: 1; border-top: 1px solid var(--line); }
.pw-fallback { margin-top: 14px; }
.pw-fallback summary { cursor: pointer; margin-bottom: 10px; }

/* ---------- app shell ---------- */
.app { height: 100%; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--bg2);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.brand > div { min-width: 0; }
.brand-name { overflow: hidden; text-overflow: ellipsis; }
.logo { width: 30px; height: 30px; border-radius: 7px; background: #8aa892; position: relative; flex: none; box-shadow: inset 0 -3px 0 rgba(0,0,0,.15); }
.logo span { position: absolute; left: 7px; top: 13px; width: 16px; height: 8px; background: #d2a165; box-shadow: 4px -8px 0 -1px #4aa3df; }
.brand-name { font-family: var(--pixel); font-size: 18px; font-weight: 600; letter-spacing: .3px; white-space: nowrap; }
.brand-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub .bad { color: var(--red); }
.top-actions { display: flex; align-items: center; gap: 10px; }
.presence { position: relative; display: flex; align-items: center; }
.presence select { padding: 6px 28px 6px 26px; width: auto; font-size: 13px; }
.pdot { position: absolute; left: 10px; width: 9px; height: 9px; border-radius: 50%; background: var(--green); pointer-events: none; }
.user-menu { position: relative; }
.user-chip { display: flex; align-items: center; gap: 8px; background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 12px 3px 6px; font-weight: 600; }
.avatar-sm { width: 24px; height: 32px; image-rendering: pixelated; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 6px; min-width: 210px; z-index: 30; box-shadow: var(--shadow-2); background: var(--elev);
}
.menu button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 7px; }
.menu button:hover { background: var(--panel2); }

.layout { flex: 1; display: flex; min-height: 0; }
.stage { flex: 1; display: flex; flex-direction: column; min-width: 0; padding: 12px; gap: 8px; }
.office-wrap {
  flex: 1; position: relative; min-height: 280px; border-radius: var(--radius); overflow: hidden;
  background: var(--map-bg); border: 1px solid var(--line);
}
/* absolutely placed so the canvas size never feeds back into the box it measures */
#office { display: block; image-rendering: pixelated; position: absolute; left: 0; top: 0; }
.stage-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.stage-tools { display: flex; align-items: center; gap: 8px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
#workNav, #adminSections { display: flex; width: 100%; }
#workNav button, #adminSections button { flex: 1; padding: 6px 4px; }
.seg button { background: transparent; border: 0; padding: 4px 10px; font-size: 12px; color: var(--muted); }
.seg button.on { background: var(--panel2); color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }

.tooltip {
  position: absolute; pointer-events: none; z-index: 5; max-width: 260px;
  background: var(--elev); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  box-shadow: var(--shadow-2); font-size: 13px; color: var(--text);
}
.tooltip .t-name { font-weight: 700; }
.tooltip .t-title { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.tooltip .t-task { margin-top: 6px; }

/* ---------- sidebar ---------- */
.sidebar { width: 400px; flex: none; border-left: 1px solid var(--line); background: var(--bg2); display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; padding: 8px 8px 0; gap: 2px; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; background: none; border: 0; padding: 10px 6px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.panel { flex: 1; overflow-y: auto; padding: 14px; min-height: 0; }
.panel h3 { margin: 0 0 10px; font-size: 15px; }
.panel h4 { margin: 18px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.panel-head { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip { border: 1px solid var(--line); background: transparent; color: var(--muted); padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; }
.chip.on { background: var(--panel2); color: var(--text); border-color: var(--accent); }
.chip b { color: var(--text); font-weight: 600; margin-left: 2px; }

.person {
  display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 10px; cursor: pointer; border: 1px solid transparent;
}
.person:hover { background: var(--panel); }
.person.sel { background: var(--panel); border-color: var(--field-border); }
.person canvas { width: 30px; height: 40px; image-rendering: pixelated; flex: none; }
.person .p-main { min-width: 0; flex: 1; }
.person .p-name { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.person .p-task { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person .p-side { text-align: right; font-size: 11px; color: var(--muted); flex: none; }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--panel2); white-space: nowrap; }
.pill i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.tag { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 1px 6px; border-radius: 5px; background: var(--chip-bg); color: var(--muted); }
.tag.you { background: var(--accent); color: var(--accent-ink); }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 8px; font-size: 12.5px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.feed li time { color: var(--muted); flex: none; width: 56px; font-size: 12px; padding-top: 1px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.profile-head { display: flex; gap: 14px; align-items: center; }
.profile-head canvas { width: 60px; height: 80px; image-rendering: pixelated; background: #8aa892; border-radius: 10px; flex: none; }
.profile-head .name { font-size: 18px; font-weight: 700; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 12px; }
.stat { background: var(--bg2); border-radius: 8px; padding: 8px; text-align: center; }
.stat b { display: block; font-size: 18px; }
.stat span { font-size: 12px; color: var(--muted); }
.stat.warn b { color: var(--red); }
.skills { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.skills span { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: var(--chip-bg); color: var(--text); }

/* tasks */
.task { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.task.focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.task-top { display: flex; gap: 8px; align-items: flex-start; }
.task-name { font-weight: 600; flex: 1; word-break: break-word; }
.task-name a { color: var(--text); }
.task-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--muted); margin-top: 4px; }
.task-meta .overdue { color: var(--red); font-weight: 600; }
.task-actions { display: flex; gap: 6px; margin-top: 8px; align-items: center; }
.task-actions select { width: auto; flex: 1; padding: 5px 8px; font-size: 12px; }
.flag { width: 8px; height: 8px; border-radius: 2px; flex: none; margin-top: 6px; background: #5d6675; }
.flag.p1 { background: #ef4444; } .flag.p2 { background: #f59e0b; } .flag.p3 { background: #5aa9ff; } .flag.p4 { background: #8b95a7; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 4px; }
.now-card { display: flex; gap: 10px; align-items: center; background: linear-gradient(135deg, rgba(62,207,142,.14), rgba(90,169,255,.08)); border: 1px solid var(--ok-line); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; }
.now-card .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.empty { text-align: center; color: var(--muted); padding: 24px 10px; font-size: 13px; }
.notice { background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn-text); border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }

/* assistant */
.chat { display: flex; flex-direction: column; height: 100%; }
.chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding-bottom: 10px; min-height: 120px; }
.msg { max-width: 92%; padding: 9px 12px; border-radius: 12px; font-size: 13.5px; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--msg-mine); border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.assistant ul { margin: 6px 0; padding-left: 18px; }
.msg.assistant p { margin: 0 0 6px; }
.msg.assistant p:last-child { margin: 0; }
.msg.thinking { color: var(--muted); font-style: italic; }
.proposal { align-self: stretch; background: var(--bg2); border: 1px solid var(--field-border); border-radius: 12px; padding: 12px; }
.proposal .p-title { font-weight: 700; margin-bottom: 6px; display: flex; justify-content: space-between; gap: 8px; }
.proposal dl { display: grid; grid-template-columns: 82px 1fr; gap: 3px 8px; margin: 0 0 10px; font-size: 12.5px; }
.proposal dt { color: var(--muted); }
.proposal dd { margin: 0; word-break: break-word; }
.proposal .state { font-size: 11px; font-weight: 700; text-transform: uppercase; }
.proposal .state.approved { color: var(--green); } .proposal .state.rejected { color: var(--muted); } .proposal .state.failed { color: var(--red); }
.chat-input { border-top: 1px solid var(--line); padding-top: 10px; }
.chat-input textarea { min-height: 54px; max-height: 160px; }
.suggestions { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }

/* admin */
.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table th { text-align: left; color: var(--muted); font-weight: 600; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.table td { padding: 8px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table select { padding: 4px 6px; font-size: 12px; }
.user-row { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 8px; background: var(--panel); }
.user-row .ur-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.user-row .ur-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
.user-row .ur-grid select, .user-row .ur-grid input { padding: 5px 8px; font-size: 12px; }
.user-row .ur-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.okline { color: var(--green); font-size: 12.5px; }
.code { font-family: ui-monospace, Consolas, monospace; background: var(--bg2); border: 1px solid var(--line); padding: 2px 6px; border-radius: 5px; user-select: all; }

/* modal */
.modal-back { position: fixed; inset: 0; background: var(--overlay); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; box-shadow: var(--shadow-3); }
.modal.wide { max-width: 760px; }
.modal h2 { margin: 0 0 14px; font-size: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.editor { display: grid; grid-template-columns: 170px 1fr; gap: 18px; }
.editor-preview { background: #8aa892; border-radius: 12px; display: grid; place-items: center; padding: 10px; position: relative; }
.editor-preview canvas { image-rendering: pixelated; width: 120px; height: 200px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.swatch { width: 24px; height: 24px; border-radius: 6px; border: 2px solid transparent; padding: 0; }
.swatch.on { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg); }
.swatches input[type=color] { width: 30px; height: 26px; padding: 0 2px; border-radius: 6px; }
.opt-row { margin-bottom: 12px; }
.opt-row > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; font-weight: 500; }

#toasts { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; align-items: flex-end; max-width: min(420px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; background: var(--elev); color: var(--text); border: 1px solid var(--field-border); padding: 10px 12px 10px 16px; border-radius: 10px; box-shadow: var(--shadow-2); font-size: 13.5px; }
.toast .x { background: none; border: 0; color: var(--muted); padding: 0 2px; font-size: 16px; line-height: 1; }
.conn-banner { background: var(--warn-bg); color: var(--warn-text); border-bottom: 1px solid var(--warn-line); font-size: 13px; padding: 6px 16px; text-align: center; }
.office-wrap.stale #office { opacity: .55; filter: grayscale(.4); }
.setup-card { border-color: var(--ok-line); background: linear-gradient(135deg, var(--soft-accent), var(--ok-bg)); }
.setup-card ol { margin: 6px 0 0; padding-left: 20px; }
.setup-card li { margin: 4px 0; }
.setup-card li.done { color: var(--muted); text-decoration: line-through; }
.skeleton { height: 54px; border-radius: 10px; margin-bottom: 8px; background: linear-gradient(90deg, var(--panel) 0%, var(--panel2) 50%, var(--panel) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; }
@keyframes shimmer { to { background-position: -200% 0; } }
button.person { width: 100%; text-align: left; background: transparent; color: inherit; font: inherit; min-height: 52px; }
.person .p-main, .person .p-task, .person .p-dept { display: block; }
.person .p-dept { margin-top: 2px; }
.legend b { font-size: 12px; width: 12px; text-align: center; display: inline-block; }
#calmBtn.on { border-color: var(--accent); color: var(--text); }
.ur-compact { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.ur-meta { font-size: 12px; color: var(--muted); }
.saved-mark { color: var(--green); font-size: 12px; margin-left: 6px; }
.toast.err { border-color: var(--urgent); color: var(--text); box-shadow: inset 3px 0 0 var(--urgent), var(--shadow-2); }
.toast.ok { border-color: var(--ok-line); box-shadow: inset 3px 0 0 var(--green), var(--shadow-2); }

/* ---------- notices, knock, office hub ---------- */
.count { display: inline-block; min-width: 16px; padding: 0 5px; margin-left: 5px; border-radius: 999px; background: var(--badge); color: var(--badge-ink); font-size: 10.5px; line-height: 16px; text-align: center; font-weight: 700; vertical-align: 1px; }
.chip .count { margin-left: 4px; }
.icon-btn { position: relative; }
.icon-btn .count { position: absolute; top: -5px; right: -6px; margin: 0; }
.kbd { font-size: 10.5px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
.nboard h3 { font-size: 15px; }
.nboard.unread { box-shadow: 0 0 0 1px var(--accent); }
.nboard.pinned { background: linear-gradient(180deg, var(--soft-accent), transparent 60%), var(--panel); }
.nbody { margin-top: 8px; font-size: 13.5px; }
.nbody p { margin: 0 0 6px; }
.nbody ul { margin: 4px 0 6px; padding-left: 18px; }
.kb-body { font-size: 14px; line-height: 1.55; }
.reactions { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 10px; }
.react { border: 1px solid var(--line); background: var(--bg2); border-radius: 999px; padding: 2px 8px; font-size: 12.5px; min-height: 28px; }
.react.on { border-color: var(--accent); background: var(--soft-accent); }
.poll { margin-top: 10px; }
.poll-opt { display: flex; gap: 8px; align-items: center; margin: 4px 0; cursor: pointer; }
.poll-opt input { width: auto; flex: none; }
.poll-bar { flex: 1; position: relative; display: flex; justify-content: space-between; gap: 8px; padding: 5px 8px; border-radius: 7px; background: var(--bg2); overflow: hidden; font-size: 13px; }
.poll-bar::before { content: ''; position: absolute; inset: 0 auto 0 0; width: var(--w); background: rgba(90,169,255,.22); }
.poll-bar > * { position: relative; }
.poll-bar b { font-weight: 600; color: var(--muted); white-space: nowrap; }
.celebrate { border-color: var(--warn-line); background: linear-gradient(135deg, var(--soft-accent), rgba(244,114,182,.08)); }
#knockCards { position: fixed; top: 64px; right: 16px; z-index: 55; display: flex; flex-direction: column; gap: 8px; width: min(360px, calc(100vw - 32px)); }
.knock-card { background: var(--elev); color: var(--text); border: 1px solid var(--accent); border-radius: 12px; padding: 12px; box-shadow: var(--shadow-3); animation: knockIn .35s ease-out; }
.knock-card canvas { width: 30px; height: 40px; image-rendering: pixelated; flex: none; }
.knock-card .x { background: none; border: 0; color: var(--muted); font-size: 16px; flex: none; }
@keyframes knockIn { 0% { transform: translateX(14px); opacity: 0; } 30% { transform: translateX(-4px); } 50% { transform: translateX(3px); } 100% { transform: none; opacity: 1; } }
.timeline { position: relative; height: 34px; margin: 10px 0 4px; border-radius: 6px; background: var(--bg2); }
.timeline .tick { position: absolute; top: 0; bottom: 0; border-left: 1px dashed var(--line); font-size: 10px; color: var(--muted); padding-left: 2px; }
.timeline .slot { position: absolute; top: 12px; height: 18px; border-radius: 4px; background: #ef6b6b; opacity: .85; }
.timeline .slot.mine { background: var(--accent); }
.timeline .nowline { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--blue); }
.hd-row { display: block; color: inherit; font: inherit; }
.project { padding: 0; }
.proj-head { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 12px 14px; color: inherit; }
.project > div { padding: 0 14px 10px; }
.progress { height: 6px; border-radius: 99px; background: var(--bg2); margin: 8px 0 4px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--green); }
.overdue { color: var(--red); font-weight: 600; }
.org, .org ul { list-style: none; margin: 0; padding: 0; }
.org ul { margin-left: 14px; padding-left: 8px; border-left: 1px dashed var(--line); }
.org-node { display: flex; align-items: center; gap: 2px; }
.org-node.hit .org-person { background: var(--soft-accent); }
.org-toggle { width: 22px; flex: none; background: none; border: 0; color: var(--muted); padding: 0; min-height: 28px; }
.org-person { flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: 4px 6px; border-radius: 6px; font-size: 13px; color: inherit; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.org-person:hover { background: var(--panel); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.table.dash td, .table.dash th { padding: 6px 4px; white-space: nowrap; }
.table.dash td.bad { color: var(--red); font-weight: 700; }
.chip.mood { font-size: 18px; padding: 2px 10px; }
label.chip { cursor: pointer; }
.cmd { max-width: 560px; align-self: start; margin-top: 10vh; padding: 12px; }
.cmd input { font-size: 15px; padding: 10px 12px; }
#cmdList { list-style: none; margin: 8px 0 0; padding: 0; max-height: 50vh; overflow-y: auto; }
#cmdList li { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
#cmdList li.on { background: var(--panel2); box-shadow: inset 2px 0 0 var(--accent); }
.cmd-main { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media print {
  body.printing > *:not(#modalRoot) { display: none !important; }
  body.printing .modal-back { position: static; background: none; padding: 0; }
  body.printing .modal { max-height: none; box-shadow: none; border: 0; background: #fff; color: #000; }
  body.printing .no-print { display: none; }
  body.printing .muted { color: #444; }
  body.printing .table th, body.printing .table td { border-color: #ccc; color: #000; }
}

/* =================== UX pass: rail, search, bell, My day, tour, phone =================== */
.topbar { gap: 14px; }
.brand { flex: 0 1 auto; }
.brand-sub { display: flex; align-items: center; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); margin-right: 6px; flex: none; box-shadow: 0 0 0 3px rgba(62, 207, 142, .18); }
.search-box {
  flex: 1 1 340px; max-width: 460px; min-width: 0; display: flex; align-items: center; gap: 8px; margin-left: auto;
  background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; color: var(--muted); text-align: left;
}
.search-box:hover { border-color: var(--field-border); color: var(--text); }
.search-box .sb-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.top-actions { flex: none; }
.bell-wrap { position: relative; }
#bellBtn { font-size: 15px; padding: 4px 9px; }
.pop {
  position: absolute; right: 0; top: calc(100% + 8px); width: min(360px, calc(100vw - 24px)); z-index: 40;
  background: var(--elev); border: 1px solid var(--line); border-radius: 12px; padding: 12px; box-shadow: var(--shadow-3);
}
.pop-head, .pop-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.pop-head { margin-bottom: 8px; }
.pop-foot { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); justify-content: flex-start; gap: 16px; }
.menu button { display: flex; gap: 8px; align-items: center; }

/* layout: map | panel | rail */
.sidebar { width: 380px; }
.panel-title { font-family: var(--pixel); font-size: 17px; font-weight: 600; padding: 12px 16px 10px; border-bottom: 1px solid var(--line); letter-spacing: .3px; }
.rail {
  width: 76px; flex: none; display: flex; flex-direction: column; gap: 2px; padding: 8px 6px;
  background: var(--bg2); border-left: 1px solid var(--line); overflow-y: auto; scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.rail button {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; width: 100%;
  background: none; border: 0; border-radius: 10px; padding: 9px 2px 8px; color: var(--muted); font-size: 11px; font-weight: 600;
}
.rail button i { font-style: normal; font-size: 19px; line-height: 1; filter: grayscale(.5); opacity: .85; }
.rail button:hover { background: var(--panel); color: var(--text); }
.rail button.on { background: var(--panel2); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.rail button.on i { filter: none; opacity: 1; }
.rail .count { position: absolute; top: 4px; right: 10px; margin: 0; }
.phone-only { display: none !important; }

/* My day */
.hello h2 { margin: 0; font-size: 20px; }
.hello { margin-bottom: 12px; }
.row.between { justify-content: space-between; }
.row.between > * { flex: none; }
.row.between > h3 { flex: 1; min-width: 0; }
.day-card h3 { margin: 0; }
.where-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.where-btn {
  display: flex; align-items: center; gap: 8px; padding: 12px; border-radius: 10px; min-height: 48px;
  background: var(--bg2); border: 1px solid var(--line); font-weight: 600; text-align: left;
}
.where-btn span { font-size: 20px; }
.where-btn:hover { border-color: var(--accent); background: var(--soft-accent); }
.prio { list-style: none; margin: 10px 0 0; padding: 0; }
.prio li { padding: 5px 0; }
.prio label { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.prio input { width: 18px; height: 18px; flex: none; margin-top: 1px; accent-color: var(--green); }
.prio input:checked + span { color: var(--muted); text-decoration: line-through; }
.needs { display: flex; flex-direction: column; gap: 6px; }
.need {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; min-height: 46px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px;
}
.need:hover { border-color: var(--field-border); background: var(--panel2); }
.need.urgent { border-left: 3px solid var(--amber); }
.need-ic { font-size: 18px; flex: none; }
.need-text { flex: 1; min-width: 0; }
.need-go { color: var(--muted); font-size: 20px; line-height: 1; }
.empty-state { display: flex; gap: 12px; align-items: center; }
.empty-state > span { font-size: 26px; }
.card.tight { padding: 6px 12px; margin-bottom: 8px; }
.agenda { display: flex; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 13.5px; }
.agenda:last-child { border-bottom: 0; }
.agenda-time { flex: none; width: 108px; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.agenda-title { flex: 1; min-width: 0; word-break: break-word; }
.agenda-title a { color: var(--text); }
.agenda-title a:hover { color: var(--blue); }
.around { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.around button { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 4px; text-align: center; }
.around button:hover { border-color: var(--field-border); }
.around b { display: block; font-size: 20px; }
.around span { font-size: 11.5px; color: var(--muted); }
.occasion { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.occasion:last-child { border-bottom: 0; }
.setup-list { list-style: none; margin: 8px 0 0; padding: 0; }
.setup-list li { padding: 4px 0; }
.setup-list li.done { color: var(--muted); }
.panel > section { margin-bottom: 6px; }
.panel h4:first-child { margin-top: 4px; }

/* tour */
.tour { text-align: center; }
.tour-icon { font-size: 44px; line-height: 1; margin: 6px 0 10px; }
.tour h2 { font-family: var(--pixel); font-size: 22px; letter-spacing: .3px; }
.tour-body { text-align: left; font-size: 14.5px; line-height: 1.6; }
.tour-body p { margin: 0 0 10px; }
.tour-legend { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; background: var(--bg2); border-radius: 10px; padding: 10px 14px; margin-bottom: 10px; font-size: 13.5px; }
.tour-legend b { display: inline-block; width: 16px; text-align: center; }
.tour-dots { display: flex; justify-content: center; gap: 6px; margin-top: 8px; }
.tour-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.tour-dots i.on { background: var(--accent); width: 18px; border-radius: 4px; }
.tour .modal-foot { justify-content: center; }

/* comfy tap targets */
.btn.sm { min-height: 32px; }

/* tablet */
@media (max-width: 1150px) {
  .sidebar { width: 340px; }
  .search-box .sb-text, .search-box .kbd, .top-actions .lbl { display: none; }
  .search-box { flex: 0 0 auto; }
  .stage-bar .legend { display: none; }
}

/* phone: one screen at a time, bottom navigation, map on its own tab */
@media (max-width: 760px) {
  .app { height: 100dvh; }
  .topbar { padding: 8px 10px; gap: 8px; }
  .brand-sub, #meName, .logo { display: none; }
  .brand-name { font-size: 16px; }
  .top-actions { gap: 4px; }
  .search-box { padding: 6px 9px; border: 0; background: transparent; font-size: 17px; }
  .presence select { width: 40px; padding: 6px 4px 6px 22px; color: transparent; }
  .presence select option { color: var(--text); }
  .pdot { left: 13px; }
  .user-chip { padding: 2px 6px; }
  .layout { flex-direction: column; }
  .stage, .sidebar { display: none; }
  body[data-tab="map"] .stage { display: flex; flex: 1; padding: 6px; min-height: 0; }
  .office-wrap { min-height: 0; }
  body:not([data-tab="map"]) .sidebar { display: flex; flex: 1; width: auto; border: 0; }
  .panel { padding: 12px 12px 18px; }
  .panel-title { display: none; }
  .rail {
    order: 2; width: auto; flex-direction: row; justify-content: space-around; padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    border-left: 0; border-top: 1px solid var(--line); overflow: visible;
  }
  .rail button { flex: 1; padding: 7px 0 5px; }
  .rail button.on { box-shadow: inset 0 3px 0 var(--accent); }
  .rail [data-more] { display: none !important; }
  .phone-only { display: flex !important; }
  .rail .count { right: calc(50% - 22px); }
  .more-menu { position: fixed; right: 8px; bottom: 64px; left: auto; top: auto; min-width: 200px; }
  .stage-tools .muted { display: none; }
  .grid2, .editor { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .around { grid-template-columns: repeat(2, 1fr); }
  #knockCards { top: 56px; }
  #toasts { bottom: 72px; }
  .modal { padding: 16px; }
}

/* map zoom controls */
.map-zoom { position: absolute; right: 10px; top: 10px; z-index: 4; display: flex; flex-direction: column; border-radius: 9px; overflow: hidden; border: 1px solid var(--line); background: var(--elev); box-shadow: var(--shadow-2); }
.map-zoom button { width: 36px; height: 34px; background: none; border: 0; border-bottom: 1px solid var(--line); color: var(--text); font-size: 18px; font-weight: 700; line-height: 1; }
.map-zoom button:last-child { border-bottom: 0; font-size: 16px; }
.map-zoom button:hover:not(:disabled) { background: var(--panel2); }
.map-zoom button:disabled { color: var(--muted); opacity: .45; cursor: default; }
@media (max-width: 760px) { .map-zoom button { width: 42px; height: 40px; } }

/* invite your team */
.invite-card { border-color: var(--ok-line); background: linear-gradient(135deg, var(--soft-accent), var(--ok-bg)); }
.invite-list { max-height: 46vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 4px 10px; }
.invite-row { display: flex; gap: 10px; align-items: flex-start; padding: 7px 0; border-bottom: 1px dashed var(--line); cursor: pointer; }
.invite-row:last-child { border-bottom: 0; }
.invite-row input { width: 18px; height: 18px; flex: none; margin-top: 2px; }
.invite-out { max-height: 55vh; overflow-y: auto; }
.invite-msg pre { white-space: pre-wrap; font: 13px/1.5 Inter, system-ui, sans-serif; margin: 8px 0 4px; user-select: all; }
.invite-msg.sent { opacity: .6; }
@media print { body.printing .invite-out { max-height: none; overflow: visible; } body.printing .invite-msg { break-inside: avoid; border: 1px solid #ccc; } body.printing .btn { display: none; } }

/* =================== chat & huddles =================== */
#tab-chat .count.dot-only { min-width: 10px; width: 10px; height: 10px; padding: 0; font-size: 0; top: 7px; right: 18px; }
.conv { display: flex; gap: 10px; align-items: center; width: 100%; text-align: left; background: none; border: 0; border-radius: 9px; padding: 7px 8px; min-height: 48px; }
.conv:hover { background: var(--panel); }
.conv-ic { width: 26px; flex: none; display: grid; place-items: center; }
.conv-ic b { font-size: 17px; color: var(--muted); }
.conv-ic canvas { width: 24px; height: 32px; image-rendering: pixelated; }
.conv-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.conv-name { font-weight: 600; display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-last { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv.unread .conv-name, .conv.unread .conv-last { color: var(--text); }
.conv.unread .conv-name { font-weight: 700; }
.conv-side { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; font-size: 11px; color: var(--muted); }
.conv-side .count { margin: 0; }
.udot { width: 8px; height: 8px; border-radius: 50%; background: var(--text); display: inline-block; }
.cdot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin: 0 4px 0 2px; flex: none; }
.tag.live { background: var(--ok-bg); color: var(--green); }

.panel:has(.chat) { display: flex; flex-direction: column; padding-bottom: 10px; }
.chat { flex: 1; min-height: 0; }
.thread-head { display: flex; align-items: center; gap: 8px; padding-bottom: 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.thread-head > .btn { flex: none; }
.thread-title { flex: 1; min-width: 0; }
.thread-title b { display: inline-flex; align-items: center; gap: 4px; }
.thread-title .small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-log { gap: 0; padding: 6px 0 10px; }
.day-sep { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 11.5px; font-weight: 600; margin: 12px 0 6px; }
.day-sep::before, .day-sep::after { content: ''; flex: 1; border-top: 1px solid var(--line); }
.msg-row { display: flex; gap: 8px; padding: 5px 4px 2px; border-radius: 8px; position: relative; }
.msg-row.grouped { padding-top: 0; }
.msg-row:hover { background: var(--hover); }
.msg-row.mentioned { background: var(--soft-accent); box-shadow: inset 2px 0 0 var(--accent); }
.msg-av { width: 24px; flex: none; }
.msg-av canvas { width: 24px; height: 32px; image-rendering: pixelated; }
.msg-body { flex: 1; min-width: 0; }
.msg-head { font-size: 13px; }
.msg-head time { color: var(--muted); font-size: 11px; margin-left: 4px; }
.msg-text { font-size: 13.5px; line-height: 1.45; word-wrap: break-word; overflow-wrap: anywhere; }
.msg-text a { word-break: break-all; }
.mention { color: var(--blue); font-weight: 600; }
.mention.me { color: var(--accent-ink); background: var(--accent); border-radius: 4px; padding: 0 3px; }
.msg-del { position: absolute; right: 4px; top: 2px; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; font-size: 12px; padding: 1px 5px; opacity: 0; }
.msg-row:hover .msg-del, .msg-del:focus-visible { opacity: 1; }
.mention-list { background: var(--elev); border: 1px solid var(--line); border-radius: 10px; padding: 4px; margin-bottom: 6px; box-shadow: var(--shadow-2); }
.mention-list button { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; background: none; border: 0; padding: 5px 8px; border-radius: 7px; }
.mention-list button.on, .mention-list button:hover { background: var(--panel2); }
.mention-list canvas { width: 18px; height: 24px; image-rendering: pixelated; }

.huddle-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 7px 16px;
  background: linear-gradient(90deg, var(--ok-bg), rgba(90, 169, 255, .1)); border-bottom: 1px solid var(--ok-line); font-size: 13px;
}
.hb-live { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0 rgba(62,207,142,.6); animation: hbPulse 1.6s infinite; flex: none; }
@keyframes hbPulse { 70% { box-shadow: 0 0 0 8px rgba(62,207,142,0); } 100% { box-shadow: 0 0 0 0 rgba(62,207,142,0); } }
.hb-topic { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30ch; }
.hb-meta { color: var(--muted); }
.hb-meta time { font-variant-numeric: tabular-nums; }
.hb-people { display: inline-flex; gap: 2px; }
.hb-people canvas { width: 18px; height: 24px; image-rendering: pixelated; }
.hb-actions { margin-left: auto; display: flex; gap: 6px; }
.hb-actions .btn { text-decoration: none; }
.huddle-card { border-color: var(--green); }
@media (max-width: 760px) {
  .huddle-bar { padding: 6px 10px; gap: 6px; }
  .hb-people, .hb-meta { display: none; }
  .hb-actions { margin-left: 0; width: 100%; }
}

/* =================== Andon =================== */
.btn.danger-solid { background: var(--urgent-strong); border-color: var(--urgent-strong); color: #fff; }
.btn.danger-solid:hover { filter: brightness(1.08); }
.btn.danger-solid:disabled { opacity: .5; }
.andon-btn { font-size: 15px; padding: 4px 9px; background: transparent; }
.andon-btn.live { background: rgba(239, 68, 68, .18); border-color: rgba(239, 68, 68, .6); animation: andonBlink 1.2s infinite; }
@keyframes andonBlink { 50% { background: rgba(239, 68, 68, .45); } }
.andon-kinds { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin-bottom: 14px; }
.andon-kind { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 8px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg2); font-weight: 700; text-align: center; cursor: pointer; min-height: 84px; justify-content: center; }
.andon-kind span { font-size: 26px; }
.andon-kind:hover { border-color: var(--urgent); }
.andon-kind.on { border-color: var(--urgent); background: var(--urgent-bg); }
.andon-photo { max-width: 100%; max-height: 220px; border-radius: 10px; margin-top: 6px; }
.card.andon.waiting { border-color: var(--urgent); box-shadow: inset 3px 0 0 var(--urgent); }
.card.andon.acked { border-color: rgba(245, 185, 66, .6); box-shadow: inset 3px 0 0 var(--amber); }
.card.andon.fixed { opacity: .85; }
.andon-thumb { display: block; margin-top: 8px; padding: 0; border: 0; background: none; }
.andon-thumb img { max-width: 100%; max-height: 160px; border-radius: 8px; display: block; }
.andon-card { border-color: var(--urgent); box-shadow: 0 0 0 2px var(--urgent-bg), var(--shadow-3); background: var(--elev); background-image: linear-gradient(var(--urgent-bg), var(--urgent-bg)); }
.stat-tile { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 4px; text-align: center; }
.stat-tile b { display: block; font-size: 16px; }
.stat-tile span { font-size: 11.5px; color: var(--muted); }

/* =================== task board =================== */
.modal.board-modal { max-width: min(1400px, calc(100vw - 24px)); width: 100%; height: calc(100vh - 32px); display: flex; flex-direction: column; }
.board-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.board-head > input { width: auto; }
.board { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: 10px; overflow-x: auto; }
.bcol { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; display: flex; flex-direction: column; min-height: 0; }
.bcol header { display: flex; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.bcol.over { border-color: var(--accent); background: var(--soft-accent); }
.bcards { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.bcard { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; cursor: grab; }
.bcard:hover { border-color: var(--field-border); }
.bcard.dragging { opacity: .45; }
.bcard .bname { font-weight: 600; word-break: break-word; }
.bcard .bname a { color: var(--text); }
.bmove { margin-top: 6px; padding: 2px 6px; font-size: 11.5px; color: var(--muted); background: transparent; border-color: var(--line); }
.bempty { color: var(--muted); font-size: 12.5px; text-align: center; padding: 18px 6px; border: 1px dashed var(--line); border-radius: 10px; }

/* =================== whiteboard =================== */
.wb-wrap { flex: 1; min-height: 0; display: grid; place-items: center; }
.wb-stage { position: relative; max-width: 100%; max-height: 100%; width: 100%; background: #fbfaf6; border-radius: 12px; overflow: hidden; box-shadow: inset 0 0 0 1px #d8d4c8; touch-action: none;
  background-image: radial-gradient(#e3dfd3 1px, transparent 1px); background-size: 24px 24px; }
.wb-stage { width: min(100%, calc((100vh - 170px) * 1.6)); height: auto; aspect-ratio: 16 / 10; max-height: none; }
@media (max-width: 760px) { .wb-stage { width: 100%; } .wb-note { min-width: 90px; font-size: 11px; } }
.wb-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.wb-stage[data-tool="pen"] canvas { cursor: crosshair; }
.wb-stage[data-tool="note"] { cursor: copy; }
.wb-stage[data-tool="pen"] .wb-note { pointer-events: auto; }
.wb-note { position: absolute; width: 11%; min-width: 120px; min-height: 80px; color: #231d2e; border-radius: 4px; box-shadow: 0 6px 14px rgba(0,0,0,.18); font-size: 13px; display: flex; flex-direction: column; }
.wb-note.dragging { box-shadow: 0 14px 28px rgba(0,0,0,.3); transform: rotate(-1.5deg); z-index: 3; }
.wb-note-bar { display: flex; align-items: center; gap: 4px; padding: 3px 5px; cursor: move; background: rgba(0,0,0,.06); border-radius: 4px 4px 0 0; font-size: 10.5px; }
.wb-by { flex: 1; font-weight: 700; opacity: .65; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wb-note-bar button, .wb-task { background: rgba(255,255,255,.55); border: 0; border-radius: 4px; padding: 1px 5px; font-size: 10.5px; color: #231d2e; font-weight: 700; }
.wb-task { text-decoration: none; background: rgba(62, 207, 142, .55); }
.wb-text { flex: 1; padding: 6px 7px; outline: none; white-space: pre-wrap; word-break: break-word; min-height: 50px; cursor: text; }
.wb-text:focus { background: rgba(255,255,255,.35); }
.wb-colors { display: flex; gap: 4px; }
.wb-colors .swatch { width: 22px; height: 22px; border: 2px solid var(--line); }
.wb-viewers { display: inline-flex; align-items: center; gap: 2px; }
.wb-viewers canvas { width: 18px; height: 24px; image-rendering: pixelated; }

/* =================== chai, streaks, goals =================== */
.chai-bar { background: linear-gradient(90deg, rgba(210, 161, 101, .22), var(--soft-accent)); border-bottom-color: var(--warn-line); }
.chai-card { border-color: #d2a165; }
.streak { margin-top: 8px; font-weight: 600; color: var(--amber); }
.goal-card { display: block; width: 100%; text-align: left; margin-bottom: 10px; }
.goal-card.reached, .goal-row.reached { border-color: var(--ok-line); }
.goal-row.mine { box-shadow: inset 3px 0 0 var(--accent); }
.goal-row .progress { margin-top: 8px; }
.streak-card { background: linear-gradient(135deg, rgba(255, 140, 50, .14), var(--soft-accent)); border-color: var(--warn-line); }
.streak-n { font-size: 28px; font-weight: 800; color: var(--amber); line-height: 1; }

@media (max-width: 760px) {
  .modal.board-modal { height: calc(100dvh - 16px); padding: 12px; }
  .board { grid-template-columns: repeat(4, 82vw); scroll-snap-type: x mandatory; }
  .bcol { scroll-snap-align: start; }
  .board-head .small.muted { display: none; }
  .andon-kinds { grid-template-columns: 1fr 1fr; }
}

/* =================== Hero HQ (3D) =================== */
#office3d { position: absolute; left: 0; top: 0; display: block; }
.office-wrap.hero { background: radial-gradient(120% 90% at 50% 0%, #d8ecff 0%, #b8d6f2 45%, #8fb3d9 100%); border-color: #9fc0e0; }
.office-wrap.hero #office { background: transparent; }
body.switching .office-wrap { opacity: .4; transition: opacity .2s; }
.hero-preview { width: 100%; aspect-ratio: 3 / 4; border-radius: 14px; background: radial-gradient(100% 80% at 50% 10%, #e8f3ff, #b9d4ee); overflow: hidden; touch-action: none; }
.hero-preview canvas { display: block; cursor: grab; }
.hero-editor { grid-template-columns: 220px 1fr; }
.hero-invite { border-color: var(--ai-line); background: linear-gradient(135deg, var(--ai-bg), rgba(14, 165, 233, .08)); }
.style-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.style-card { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; text-align: left; background: var(--bg2); border: 2px solid var(--line); border-radius: 14px; padding: 14px; }
.style-card:hover { border-color: var(--field-border); }
.style-card.on { border-color: var(--accent); }
.style-art { font-size: 34px; width: 100%; text-align: center; border-radius: 10px; padding: 14px 0; background: var(--map-bg); }
.style-art.hero { background: radial-gradient(120% 90% at 50% 0%, #d8ecff, #8fb3d9); }
@media (max-width: 760px) { .style-cards, .hero-editor { grid-template-columns: 1fr; } .hero-preview { max-width: 240px; margin: 0 auto; } }

/* AI fix helper + Andon insights */
.ai-box { margin-top: 8px; padding: 8px 10px; border-radius: 10px; background: var(--ai-bg); border: 1px solid var(--ai-line); font-size: 13px; }
.ai-causes { margin: 6px 0 4px; padding-left: 18px; }
.ai-causes li { margin-bottom: 4px; }
.ai-past { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line); }
.ai-safety { color: var(--amber); margin: 4px 0; font-weight: 600; }
.andon-card .ai-box { background: var(--panel2); }
.bar-row { display: grid; grid-template-columns: 34% 1fr auto; gap: 8px; align-items: center; font-size: 12.5px; margin: 4px 0; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 10px; background: var(--bg2); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, #ef4444, #f59e0b); border-radius: 99px; }
.bar-val { white-space: nowrap; color: var(--text); }
.weeks { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; align-items: end; height: 90px; }
.wk { height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 3px; }
.wk i { width: 100%; min-height: 3px; background: #ef4444; border-radius: 4px 4px 0 0; opacity: .85; }
.wk span { font-size: 11px; color: var(--muted); }

/* machine builds */
.card.build { display: block; width: 100%; text-align: left; }
.card.build.high { box-shadow: inset 3px 0 0 var(--amber); }
.card.build.medium { box-shadow: inset 3px 0 0 var(--amber); }
.stage-dots { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; margin: 8px 0 6px; }
.stage-dots i { height: 7px; border-radius: 4px; background: var(--line); }
.stage-dots i.done { background: var(--green); }
.stage-dots i.now { background: var(--blue); box-shadow: 0 0 0 2px rgba(90,169,255,.3); }
.stage-dots i.late { background: var(--amber); }
.ai-line { margin-top: 6px; padding: 5px 8px; border-radius: 8px; background: var(--ai-bg); }
.radar .radar-row { padding: 7px 0; border-bottom: 1px dashed var(--line); cursor: pointer; }
.radar .radar-row:last-child { border-bottom: 0; }
.ai-plan { border-color: var(--ai-line); background: linear-gradient(135deg, var(--ai-bg), rgba(14, 165, 233, .05)); }
.build-stages td { vertical-align: middle; }
.build-stages tr.done td { color: var(--muted); }
.build-stages tr.late td:nth-child(2) b { color: var(--red); }
.build-stages input, .build-stages select { padding: 4px 6px; font-size: 12px; }

/* site reports */
.card.report-row { display: block; width: 100%; text-align: left; }
.voice textarea { min-height: 70px; }
.btn.rec { background: #dc2626; color: #fff; border-color: #dc2626; animation: andonBlink 1.2s infinite; }
.check-row { display: grid; grid-template-columns: 1fr 34%; gap: 8px; align-items: center; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.check-row .check-note { padding: 4px 8px; font-size: 12px; }
.rp-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.rp-photos figure { position: relative; margin: 0; }
.rp-photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; }
.rp-photos .x { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.6); color: #fff; border: 0; border-radius: 50%; width: 24px; height: 24px; }
.rp-add { display: flex; flex-direction: column; align-items: center; justify-content: center; aspect-ratio: 1; border: 2px dashed var(--line); border-radius: 8px; cursor: pointer; font-size: 22px; }
.rp-add span { font-size: 12px; color: var(--muted); }
.sign-pad { width: 100%; max-width: 600px; aspect-ratio: 3 / 1; background: #fff; border-radius: 10px; touch-action: none; cursor: crosshair; display: block; }
@media (max-width: 760px) { .check-row { grid-template-columns: 1fr; } }

/* installed machines */
.card.im-row { display: block; width: 100%; text-align: left; }
.card.im-row.renew { box-shadow: inset 3px 0 0 var(--amber); }

/* spares */
.card.sp-row { display: block; width: 100%; text-align: left; }
.card.sp-row.low { box-shadow: inset 3px 0 0 var(--amber); }

/* AI helpers */
.briefing { border-color: var(--warn-line); background: linear-gradient(135deg, var(--warn-bg), transparent); }
.briefing ol { margin: 6px 0 0; padding-left: 20px; }
.briefing li { margin: 3px 0; }
.nt-row { display: grid; grid-template-columns: auto 1fr 170px 140px; gap: 6px; align-items: center; margin-bottom: 6px; }
.nt-row input[type=checkbox] { width: 18px; height: 18px; }
.ai-answer { border-color: var(--ai-line); background: var(--ai-bg); line-height: 1.55; }
.msg-tr { right: 4px; }
.msg-text .tr { margin-top: 3px; }
@media (max-width: 760px) { .nt-row { grid-template-columns: auto 1fr; } .nt-row select, .nt-row input[type=date] { grid-column: 2; } }

/* =================== Design refresh: calmer surfaces, icons, touch targets =================== */
.ico { display: block; flex: none; }
.btn .ico, .search-box .ico { display: inline-block; vertical-align: -4px; }
.sidebar { background: var(--bg); }
.card { border-color: var(--line); box-shadow: var(--shadow-1); border-radius: 12px; }
:root[data-theme="light"] .card { border-color: #e6eaf1; }
.panel h4 { font-size: 11.5px; font-weight: 700; letter-spacing: .07em; color: var(--muted); margin: 20px 0 8px; }
.panel-title { font-family: Inter, system-ui, sans-serif; font-weight: 700; font-size: 16px; letter-spacing: 0; }
.btn { border-radius: 9px; }
.btn.sm { min-height: 34px; padding: 6px 11px; }
/* top bar: square icon buttons, one size */
.top-actions .icon-btn, #andonBtn, #bellBtn { width: 38px; height: 36px; padding: 0; display: inline-grid; place-items: center; font-size: 0; }
#checkinBtn { min-height: 36px; }
.andon-btn { color: var(--urgent); }
.andon-btn:not(.live) { color: var(--muted); }
.andon-btn:hover { color: var(--urgent); }
/* side rail: line icons, a pill for the active place */
.rail button i { filter: none; opacity: 1; color: var(--muted); display: grid; place-items: center; width: 44px; height: 30px; border-radius: 15px; transition: background .15s, color .15s; }
.rail button { padding: 6px 2px 7px; font-size: 11px; color: var(--muted); }
.rail button:hover { background: none; color: var(--text); }
.rail button:hover i { background: var(--hover); color: var(--text); }
.rail button.on { background: none; box-shadow: none; color: var(--text); }
.rail button.on i { background: var(--soft-accent); color: var(--text); box-shadow: inset 0 0 0 1.5px var(--accent); }
.rail .count { top: 2px; right: 8px; }
.more-menu button .ico { display: inline-block; vertical-align: -5px; margin-right: 6px; }
/* lists inside panels read as rows, not boxes-in-boxes */
.need { border-radius: 12px; }
.need.urgent { border-left: 0; box-shadow: inset 3px 0 0 var(--amber), var(--shadow-1); }
.need.urgent[data-go="andon"], .need.urgent[data-go^="andon"] { box-shadow: inset 3px 0 0 var(--urgent), var(--shadow-1); }
/* overdue text is amber; red is for urgent things only */
.task-meta .overdue, .overdue { color: var(--amber); }
:root[data-theme="light"] .tooltip { border-color: #e1e6ee; }
:root[data-theme="light"] .office-wrap { border-color: #dfe5ee; }
:root[data-theme="light"] .topbar { box-shadow: 0 1px 0 #e6eaf1; }
:root[data-theme="light"] .msg.assistant { background: var(--panel2); }
@media (max-width: 760px) {
  /* phones: comfortable thumbs (≥44px), tidy top bar */
  .btn, .btn.sm, .chip, select, input:not([type=checkbox]):not([type=radio]) { min-height: 44px; }
  .chip { display: inline-flex; align-items: center; }
  .rail button { min-height: 54px; }
  .brand { display: none; }
  .search-box { margin-left: 0; order: -1; }
  .topbar { justify-content: space-between; }
  .top-actions .icon-btn, #andonBtn, #bellBtn { width: 42px; height: 42px; }
  .need { min-height: 52px; }
  .modal .modal-foot { position: sticky; bottom: -16px; background: var(--panel); padding: 10px 0 4px; margin-bottom: -4px; }
}
/* My day: greeting row with where-I-am chip; slim promo */
.hello { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.where-chip { flex: none; border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 6px 12px; font-weight: 600; font-size: 13px; box-shadow: var(--shadow-1); max-width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.where-chip:hover { border-color: var(--field-border); }
.hero-invite.slim { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; margin-top: 16px; }
.briefing { padding: 12px 14px; }
.briefing ol { margin-top: 4px; }

/* inbox (bell) */
.inbox-row { display: flex; align-items: stretch; gap: 4px; }
.inbox-row .need { flex: 1; min-width: 0; }
.inbox-acts { display: flex; flex-direction: column; gap: 3px; }
.inbox-btn { flex: 1; width: 32px; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; font-size: 13px; color: var(--muted); }
.inbox-btn:hover { color: var(--text); border-color: var(--field-border); }
.pop { max-height: min(70vh, 560px); overflow-y: auto; }

/* who's around */
.who-group { margin-bottom: 6px; }
.who-group > summary { cursor: pointer; list-style: none; font-size: 12px; font-weight: 700; letter-spacing: .04em; color: var(--muted); padding: 10px 4px 6px; display: flex; gap: 6px; align-items: center; }
.who-group > summary::-webkit-details-marker { display: none; }
.who-group > summary::before { content: '▾'; font-size: 11px; transition: transform .15s; }
.who-group:not([open]) > summary::before { transform: rotate(-90deg); }
.person-row { display: flex; align-items: center; gap: 2px; border-radius: 10px; }
.person-row:hover { background: var(--panel); }
.person-row .person { flex: 1; min-width: 0; }
.person-row:hover .person { background: none; }
.row-acts { display: flex; gap: 2px; padding-right: 4px; opacity: .0; transition: opacity .12s; }
.person-row:hover .row-acts, .person-row:focus-within .row-acts { opacity: 1; }
.qa { width: 32px; height: 32px; border-radius: 8px; border: 0; background: none; font-size: 15px; }
.qa:hover { background: var(--hover); }
@media (hover: none) { .row-acts { opacity: 1; } .qa { width: 40px; height: 40px; } }

/* Andon banner — red is reserved for urgent alerts like this */
.andon-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 16px; background: var(--urgent-strong); color: #fff; font-size: 14px; }
.andon-bar b { letter-spacing: .04em; }
.ab-light { width: 12px; height: 12px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 0 rgba(255,255,255,.7); animation: abPulse 1.1s infinite; flex: none; }
@keyframes abPulse { 70% { box-shadow: 0 0 0 10px rgba(255,255,255,0); } 100% { box-shadow: 0 0 0 0 rgba(255,255,255,0); } }
.ab-what { font-weight: 600; }
.ab-time { opacity: .9; font-variant-numeric: tabular-nums; }
.ab-more { background: rgba(255,255,255,.2); border-radius: 999px; padding: 1px 8px; font-size: 12px; }
.ab-acts { margin-left: auto; display: flex; gap: 6px; }
.andon-bar .btn { border-color: rgba(255,255,255,.6); background: rgba(255,255,255,.12); color: #fff; }
.andon-bar .btn.ab-on { background: #fff; color: var(--urgent-strong); border-color: #fff; font-weight: 700; }
@media (max-width: 760px) { .andon-bar { padding: 6px 10px; gap: 4px 8px; font-size: 13px; } .ab-acts { margin-left: auto; } .ab-acts .btn { min-height: 40px; } }
@media (hover: hover) {
  .person-row { position: relative; }
  .row-acts { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: var(--elev); border: 1px solid var(--line); border-radius: 10px; padding: 2px; box-shadow: var(--shadow-1); pointer-events: none; }
  .person-row:hover .row-acts, .person-row:focus-within .row-acts { pointer-events: auto; }
}
@media (max-width: 760px) {
  /* phones: tapping the person already shows them; keep Message + Knock only */
  .row-acts .qa[data-qa="locate"] { display: none; }
  .person-row .p-side .pill { padding: 2px 6px; }
}
@media (max-width: 760px) {
  /* inbox: full width under the top bar, above the page */
  .topbar { position: relative; z-index: 45; }
  .pop { position: fixed; left: 8px; right: 8px; width: auto; top: auto; margin-top: 6px; max-height: 70vh; }
}

/* two kinds of knock */
.knock-level { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.kl { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 12px; cursor: pointer; min-height: 56px; }
.kl.on { border-color: var(--accent); background: var(--soft-accent); }
.kl.urgent.on { border-color: var(--urgent); background: var(--urgent-bg); }
.knock-card.urgent { border: 2px solid var(--urgent); box-shadow: 0 0 0 4px var(--urgent-bg), var(--shadow-3); animation: kUrg 1s ease-in-out 3; }
@keyframes kUrg { 50% { transform: translateX(-3px); } }
.urgent-tag { background: var(--urgent-bg); color: var(--urgent); }
@media (max-width: 480px) { .knock-level { grid-template-columns: 1fr; } }

/* site reports: Pass / Fail / N/A checklist and the outbox */
.ck-row { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.ck-row .check-note { grid-column: 1 / -1; padding: 8px 10px; font-size: 13px; }
.ck-row.fail .check-note { border-color: var(--urgent); }
.ck-item { font-weight: 500; }
.ck-btns { display: flex; gap: 4px; }
.ck-b { min-width: 64px; min-height: 44px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--panel); color: var(--text); font-weight: 600; font-size: 13px; }
.ck-b.pass.on { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok, #16a34a); }
.ck-b.fail.on { background: var(--urgent-bg); border-color: var(--urgent); color: var(--urgent); }
.ck-b.na.on { background: var(--chip-bg); border-color: var(--muted); }
@media (max-width: 760px) { .ck-row { grid-template-columns: 1fr; } .ck-btns { display: grid; grid-template-columns: repeat(3, 1fr); } .ck-b { min-height: 52px; font-size: 15px; } }
.sync-line { font-size: 12px; color: var(--muted); margin-top: 2px; }
.sync-line.phone { color: var(--warn-text); font-weight: 600; }
.card.outbox { border-color: var(--warn-line); background: var(--warn-bg); }
.ob-bad { margin-top: 6px; font-size: 13px; }
.warn-note { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-text); }

/* customisable menu */
.rail .user-hidden { display: none !important; }
@media (max-width: 760px) { .rail .phone-pin { display: flex !important; } }
.nav-opts { display: grid; gap: 4px; }
.nav-opt { padding: 8px 4px; border-bottom: 1px solid var(--line); margin: 0; align-items: flex-start; }
