:root {
  --ink: #2b2140;
  --paper: #fff8ea;
  --card: #fffdf7;
  --line: #2b2140;
  --muted: #7a7191;
  --red: #ff3b5c;
  --green: #34b67a;
  --blue: #3d86ff;
  --amber: #ffb020;
  --font: "Nunito", "Baloo 2", ui-rounded, "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", "Fira Code", ui-monospace, "DejaVu Sans Mono", monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { display: flex; flex-direction: column; background: var(--paper); color: var(--ink); font-family: var(--font); font-weight: 700; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }

/* ---------- top bar ---------- */
#top { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-bottom: 3px solid var(--line); background: var(--paper); z-index: 3; }
.logo { background: var(--ink); color: #fff; font-weight: 900; font-size: 17px; letter-spacing: .5px; padding: 5px 12px; border-radius: 10px; }
.logo b { color: #ffcf4d; }
.spacer { flex: 1; }
#chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border: 2.5px solid var(--line); border-radius: 999px; background: var(--card); font-size: 13.5px; font-weight: 800; white-space: nowrap; }
.chip i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.chip.alert { background: var(--red); color: #fff; cursor: pointer; animation: throb 1s ease-in-out infinite; }
.chip.alert i { background: #fff; }
@keyframes throb { 50% { transform: scale(1.06); } }
#clock { font-size: 15px; font-weight: 900; font-variant-numeric: tabular-nums; }
#top button { border: 2.5px solid var(--line); background: var(--card); border-radius: 10px; padding: 4px 12px; font-weight: 800; font-size: 13.5px; box-shadow: 0 3px 0 var(--line); }
#top a.nav { border: 2.5px solid var(--line); background: #ffcf4d; border-radius: 10px; padding: 4px 12px; font-weight: 900; font-size: 13.5px; box-shadow: 0 3px 0 var(--line); color: inherit; text-decoration: none; white-space: nowrap; }
#top button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }

/* ---------- stage ---------- */
main { flex: 1; position: relative; min-height: 0; }
#office { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#empty { position: absolute; left: 50%; top: 26%; transform: translate(-50%, -50%); text-align: center; background: var(--card); border: 3px solid var(--line); border-radius: 18px; padding: 14px 26px; box-shadow: 0 5px 0 var(--line); }
#empty h2 { margin: 0 0 4px; font-weight: 900; }
#empty p { margin: 0; color: var(--muted); font-size: 14px; }
code { font-family: var(--mono); font-size: .9em; background: #f1e9d6; padding: 1px 6px; border-radius: 6px; }
#offline { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 6px 16px; border-radius: 999px; font-size: 13px; }
[hidden] { display: none !important; }

/* ---------- roster ---------- */
#roster { display: flex; gap: 10px; padding: 9px 12px 11px; border-top: 3px solid var(--line); background: var(--paper); overflow-x: auto; min-height: 84px; z-index: 3; }
#roster:empty { display: none; }
.card { flex: 0 0 236px; display: grid; grid-template-columns: 50px 1fr; gap: 2px 9px; align-items: center; padding: 7px 10px 8px; border: 2.5px solid var(--line); border-radius: 14px; background: var(--card); box-shadow: 0 4px 0 var(--line); cursor: pointer; text-align: left; position: relative; overflow: hidden; }
.card:hover { transform: translateY(-2px); box-shadow: 0 6px 0 var(--line); }
.card.sel { background: var(--accent-soft, #fff3cf); }
.card.waiting { border-color: var(--red); box-shadow: 0 4px 0 var(--red); animation: nudge 1.1s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateY(-3px); } }
.card img { grid-row: span 3; width: 50px; height: 50px; border-radius: 12px; border: 2.5px solid var(--line); }
.card .who { display: flex; align-items: center; gap: 6px; font-weight: 900; font-size: 14.5px; min-width: 0; }
.card .who span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .where, .card .what { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .what { color: var(--ink); font-weight: 800; }
.card .stripe { position: absolute; left: 0; top: 0; bottom: 0; width: 5px; }
.card .bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: #eee3cc; }
.card .bar b { display: block; height: 100%; background: var(--green); }
.badge { font-size: 10.5px; font-weight: 900; padding: 1px 7px; border-radius: 999px; border: 2px solid var(--line); white-space: nowrap; text-transform: uppercase; letter-spacing: .3px; }
.badge.working { background: #dbe9ff; }
.badge.waiting { background: var(--red); color: #fff; }
.badge.done { background: #cdf3df; }
.badge.away { background: #efe6ff; }
.badge.leaving, .badge.past { background: #e8e6ee; }

/* ---------- case file drawer ---------- */
#drawer { position: absolute; top: 10px; right: 10px; bottom: 10px; width: min(470px, calc(100% - 20px)); background: var(--card); border: 3px solid var(--line); border-radius: 18px; box-shadow: -4px 6px 0 rgba(43, 33, 64, .25); display: flex; flex-direction: column; overflow: hidden; z-index: 2; }
.d-head { display: flex; gap: 11px; align-items: center; padding: 12px 14px; border-bottom: 2.5px solid var(--line); background: var(--accent-soft, #fff3cf); }
.d-head img { width: 58px; height: 58px; border-radius: 14px; border: 2.5px solid var(--line); background: #fff; }
.d-head h2 { margin: 0; font-size: 20px; font-weight: 900; line-height: 1.1; display: flex; gap: 8px; align-items: center; }
.d-head .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.d-head .x { margin-left: auto; align-self: flex-start; border: 2.5px solid var(--line); background: #fff; border-radius: 10px; width: 32px; height: 32px; font-weight: 900; font-size: 15px; flex: none; }
.d-body { flex: 1; overflow-y: auto; padding: 12px 14px 18px; }
.d-body h3 { margin: 16px 0 6px; font-size: 12px; letter-spacing: .8px; text-transform: uppercase; color: var(--muted); font-weight: 900; }
.d-body h3:first-child { margin-top: 0; }
.screenwrap { display: flex; gap: 12px; align-items: flex-start; }
.screenwrap canvas { width: 224px; height: 132px; border: 2.5px solid var(--line); border-radius: 10px; flex: none; background: #222; }
.now { font-size: 14px; font-weight: 800; }
.now small { display: block; color: var(--muted); font-weight: 700; font-size: 12px; margin-top: 4px; overflow-wrap: anywhere; }
.alertbox { background: var(--red); color: #fff; border: 2.5px solid var(--line); border-radius: 12px; padding: 8px 12px; margin-bottom: 10px; font-size: 13.5px; }
.task { font-size: 15px; font-weight: 900; }
.prompt { font-size: 13px; font-weight: 700; color: #4d4466; white-space: pre-wrap; overflow-wrap: anywhere; background: #f6efdd; border-radius: 10px; padding: 8px 10px; margin-top: 6px; max-height: 120px; overflow: auto; }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.tile { border: 2.5px solid var(--line); border-radius: 11px; padding: 5px 4px; text-align: center; background: #fff; }
.tile b { display: block; font-size: 18px; font-weight: 900; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile span { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.tile.bad b { color: var(--red); }
.summary { font-size: 13.5px; font-weight: 700; line-height: 1.45; }
.summary ul { margin: 6px 0 0; padding-left: 18px; }
.summary li { margin: 2px 0; overflow-wrap: anywhere; }
.summary .ext { color: #c2334d; font-weight: 900; }
.todos { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.todos li { padding: 2px 0 2px 22px; position: relative; }
.todos li::before { content: ""; position: absolute; left: 0; top: 4px; width: 12px; height: 12px; border: 2.5px solid var(--line); border-radius: 4px; background: #fff; }
.todos li.completed { color: var(--muted); text-decoration: line-through; }
.todos li.completed::before { background: var(--green); }
.todos li.in_progress::before { background: var(--amber); }
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.filters button { border: 2.5px solid var(--line); border-radius: 999px; background: #fff; padding: 2px 11px; font-size: 12px; font-weight: 800; }
.filters button.on { background: var(--ink); color: #fff; }
.tl { position: relative; }
.chapter { margin: 12px 0 6px; padding: 8px 10px; border: 2.5px solid var(--line); border-radius: 12px; background: #e8f1ff; font-size: 13.5px; font-weight: 800; white-space: pre-wrap; overflow-wrap: anywhere; }
.chapter small { display: block; color: var(--blue); font-weight: 900; font-size: 10.5px; letter-spacing: .6px; text-transform: uppercase; margin-bottom: 2px; }
.ev { display: grid; grid-template-columns: 54px 14px 1fr; gap: 0 6px; font-size: 12.5px; padding: 3px 0; align-items: start; }
.ev time { color: var(--muted); font-size: 10.5px; font-variant-numeric: tabular-nums; padding-top: 2px; font-weight: 800; }
.ev .dot { width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--line); margin-top: 3px; background: #fff; }
.ev .txt { min-width: 0; overflow-wrap: anywhere; }
.ev .txt .meta { color: var(--muted); font-size: 11px; font-weight: 800; }
.ev.has-more { cursor: pointer; }
.ev.has-more:hover .txt > span:first-child { text-decoration: underline; }
.ev.fail .txt { color: #c2334d; }
.ev.say .txt { background: #f4eeff; border-radius: 9px; padding: 5px 9px; white-space: pre-wrap; font-weight: 700; }
.ev.note .txt { background: #fff1c4; border-radius: 9px; padding: 5px 9px; font-weight: 800; }
.ev.wait .txt { color: #c2334d; font-weight: 900; }
.ev pre { grid-column: 3; margin: 4px 0 6px; padding: 8px 9px; background: #231e36; color: #e9e4ff; border-radius: 9px; font-family: var(--mono); font-size: 11px; font-weight: 500; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 260px; overflow: auto; }
.tag { display: inline-block; font-size: 9.5px; font-weight: 900; border: 2px solid var(--line); border-radius: 999px; padding: 0 6px; margin-left: 5px; vertical-align: 1px; text-transform: uppercase; }
.tag.out { background: #ffd9df; }
.tag.bot { background: #d9fff0; }
.d-foot { display: flex; gap: 8px; padding: 9px 14px; border-top: 2.5px solid var(--line); background: #fff8ea; }
.d-foot a, .d-foot button { border: 2.5px solid var(--line); border-radius: 10px; background: #fff; padding: 3px 11px; font-size: 12.5px; font-weight: 800; color: inherit; text-decoration: none; }
.shot { display: block; max-width: 100%; border: 2.5px solid var(--line); border-radius: 10px; margin-top: 6px; }
.empty-note { color: var(--muted); font-size: 13px; }

/* ---------- archive ---------- */
#modal { position: fixed; inset: 0; background: rgba(43, 33, 64, .45); display: grid; place-items: center; z-index: 10; }
.sheet { width: min(760px, 94vw); max-height: 84vh; background: var(--card); border: 3px solid var(--line); border-radius: 18px; box-shadow: 0 8px 0 var(--line); display: flex; flex-direction: column; overflow: hidden; }
.sheet .d-head { background: #dbe9ff; }
.sheet .list { overflow-y: auto; padding: 8px 12px 14px; }
.past { display: grid; grid-template-columns: 44px 1fr auto; gap: 2px 10px; align-items: center; padding: 7px 8px; border-radius: 12px; cursor: pointer; border: 2.5px solid transparent; }
.past:hover { border-color: var(--line); background: #fff; }
.past img { grid-row: span 2; width: 44px; height: 44px; border-radius: 11px; border: 2.5px solid var(--line); }
.past .t { font-weight: 900; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.past .s { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.past .n { grid-row: span 2; font-size: 11.5px; color: var(--muted); text-align: right; white-space: nowrap; }
