:root {
  color-scheme: light;
  --ink: #000; --ink-soft: rgba(0,0,0,.70); --ink-faint: #666;
  --paper: #fff; --wash: #f5f5f5; --line: #777; --rule: rgba(0,0,0,.10);
  --occupied: #d8174a; --occupied-fill: #d8174a; --occupied-soft: rgba(216,23,74,.08);
  --upcoming: #3b82f6; --upcoming-soft: rgba(59,130,246,.15);
  --sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', '微软雅黑', 'PingFang SC', 'Hiragino Sans GB', sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', 'Droid Sans Mono', 'Microsoft YaHei UI', 'PingFang SC', 'Noto Sans CJK SC', monospace;
  --room: clamp(17px, 1.08vw, 20px); --body: clamp(14px, .90vw, 17px);
  --small: clamp(12px, .78vw, 14px); --pad: clamp(16px, 1.2vw, 24px); --gap: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font: 400 16px/1.45 var(--sans); color: var(--ink); background: var(--paper); }
h1, h2, p { margin: 0; }
[hidden] { display: none !important; }
::selection { color: white; background: #363636; }
#app, .board-shell { min-height: 100vh; }
.board-shell { display: flex; flex-direction: column; }
.board-header { flex: none; min-height: 44px; padding: 8px 20px; background: rgba(0,0,0,.90); color: white; }
.header-content, .header-left, .header-right, .header-stats, .refresh-status { display: flex; align-items: center; }
.header-content { justify-content: space-between; gap: 12px; min-height: 28px; }
.header-left, .header-right { gap: clamp(12px, 1.2vw, 25px); }
.header-title { font: 700 clamp(14px, 1vw, 18px)/1.2 var(--sans); }
.header-time { font: 700 clamp(20px, 1.45vw, 28px)/1 var(--mono); letter-spacing: 3px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.header-date { font-size: 12px; color: rgba(255,255,255,.70); }
.header-stats { gap: 12px; font-weight: 600; font-size: 12px; white-space: nowrap; }
.header-stat > span, .refresh-status, .digits { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.header-stat > span { font-size: 1.2em; }
.header-stat.occupied { color: #ff6b8a; }
.refresh-status { gap: 6px; padding: 4px 10px; border: 1px solid rgba(255,255,255,.30); border-radius: 4px; font: 500 12px/1.2 var(--mono); color: rgba(255,255,255,.90); }
.refresh-indicator, .state-dot { display: inline-block; flex: none; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.refresh-indicator { background: #66ce90; }
.refresh-indicator.stale, .board-alert .state-dot { background: #986809; }
.refresh-indicator.error { background: #ff8da9; }
.board-alert { display: flex; align-items: center; gap: 9px; margin: 8px var(--pad) 0; padding: 5px 10px; border: 1px solid var(--rule); color: var(--ink-soft); font-size: var(--small); }
.empty-state, .error-state, .loading-state { margin: var(--pad); padding: 32px; border: 1px solid var(--rule); text-align: center; }
.empty-state strong, .error-state strong { display: block; font-size: var(--room); }
.empty-state span, .error-state span { display: block; margin-top: 6px; color: var(--ink-soft); }
.status-layout, .dense-table, .focus-columns, .timeline-shell { margin: var(--pad); }
.status-badge, .schedule-item-status, .meeting-caption b { display: inline-block; flex: none; width: max-content; padding: 4px 10px; font: 700 13px/1.2 var(--mono); letter-spacing: 1px; white-space: nowrap; }
.status-badge.free { background: rgba(0,0,0,.10); color: #000; }
.status-badge.occupied, .schedule-item-status.ongoing, .meeting-caption .current { background: rgba(216,23,74,.12); color: var(--occupied); }
.schedule-item-status.upcoming, .meeting-caption .upcoming { background: var(--upcoming-soft); color: var(--upcoming); }
.schedule-item-status.past { background: rgba(0,0,0,.08); color: #666; }

/* The standard view keeps the TV's idle rail and hard-edged room cards. */
.status-layout { display: flex; gap: var(--gap); align-items: stretch; flex: 1; min-height: 0; }
.idle-rooms-rail { flex: 0 0 clamp(200px, 18vw, 280px); min-width: 0; align-self: stretch; border: 1px solid rgba(0,0,0,.06); padding: 10px; background: rgba(255,255,255,.92); }
.idle-rooms-title, .room-meta, .focus-panel-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.idle-rooms-title { font-size: 12px; font-weight: 800; color: rgba(0,0,0,.70); margin-bottom: 10px; }
.idle-rooms-title > span, .focus-panel-heading > span { color: var(--ink-soft); font: 400 var(--small)/1.4 var(--mono); }
.idle-room-pill { background: rgba(0,0,0,.04); border: 1px solid rgba(0,0,0,.06); padding: 10px; margin-bottom: 8px; }
.idle-room-name { font-size: 13px; font-weight: 800; overflow-wrap: anywhere; }
.idle-room-meta, .idle-room-empty { color: rgba(0,0,0,.60); font-size: 12px; margin-top: 3px; }
.room-floor-grid { display: grid; flex: 1; min-width: 0; gap: var(--gap); align-content: start; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); }
.room-card {
  contain: layout paint;
 display: flex; flex-direction: column; min-width: 0; height: clamp(250px, calc((100vh - 102px) / 2), 376px); padding: 14px; border: 2px solid var(--line); }
.room-card.occupied { border-left-color: var(--occupied-fill); box-shadow: inset 4px 0 var(--occupied-fill); }
.room-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.room-name { text-align: right; font-size: 18px; font-weight: 700; line-height: 1.28; overflow-wrap: anywhere; }
.room-meta { margin: 12px 0 8px; color: rgba(0,0,0,.70); font: 400 14px/1.4 var(--mono); }
.room-meta span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; color: var(--ink); }
.room-meta span:last-child { white-space: nowrap; }
.room-schedule-list { flex: 1; min-height: 0; overflow-y: auto; border-top: 1px solid var(--rule); padding-top: 5px; }
.schedule-item { padding: 6px 0; border-bottom: 1px solid rgba(0,0,0,.05); }
.schedule-item:last-child { border-bottom: 0; }
.schedule-item.ongoing { padding: 8px 10px; background: rgba(216,23,74,.12); border: 1px solid rgba(216,23,74,.18); margin: 6px 0; }
.schedule-item.ongoing .schedule-item-title { font-size: 15px; font-weight: 800; color: rgba(0,0,0,.90); }
.schedule-item.ongoing .schedule-item-time { font-size: 13px; color: rgba(0,0,0,.85); }
.schedule-item.ongoing .schedule-item-organizer { font-size: 12px; color: rgba(0,0,0,.75); }
.schedule-item-top { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.schedule-item-status { padding: 2px 6px; margin-right: 4px; font-size: 10px; letter-spacing: 0; }
.schedule-item-time { font: 400 var(--small)/1.4 var(--mono); white-space: nowrap; }
.schedule-item-organizer { margin-left: auto; color: var(--ink-faint); font-size: 12px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
.schedule-item-title { margin-top: 3px; font-size: 13px; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.schedule-item.past { color: var(--ink-faint); opacity: .5; }
.all-idle .idle-rooms-rail { flex-basis: 100%; align-self: flex-start; display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 10px; }
.all-idle .idle-rooms-title { grid-column: 1/-1; margin-bottom: 0; }
.all-idle .idle-room-pill { margin: 0; }
.all-idle .idle-rooms-rail { align-content: start; }
.all-idle .room-floor-grid { display: none; }

/* Stable columns put room availability in the same place on every row. */
.dense-table, .focus-panel, .timeline-wrap { border: 2px solid var(--line); }
.dense-table-head, .dense-row {
 display: grid; align-items: center; grid-template-columns: 1.35fr .48fr 1.55fr 1.05fr 1.65fr; gap: 16px; padding: 8px 15px; }
.dense-table-head, .timeline-scale { background: var(--wash); font-size: var(--small); font-weight: 700; color: var(--ink-soft); }
.dense-row { contain: layout paint; min-height: clamp(61px, 8.7vh, 87px); border-top: 1px solid var(--rule); }
.dense-row > *, .focus-room > * { min-width: 0; overflow-wrap: anywhere; }
.dense-room strong, .focus-room-name { display: block; font-size: var(--room); font-weight: 700; line-height: 1.25; }
.dense-room small, .focus-room-detail span { display: block; margin-top: 3px; font-size: var(--small); color: var(--ink-soft); }
.dense-meeting, .focus-room-detail strong { font-size: var(--body); font-weight: 700; }
.dense-state { display: flex; gap: 7px; align-items: center; font-weight: 700; }
.dense-cell-muted { color: var(--ink-soft); font-size: var(--body); }
.dense-time, .focus-room-time { font: 700 var(--body)/1.4 var(--mono); }
.occupied .dense-state, .dense-time.occupied, .occupied .focus-room-time { color: var(--occupied); }
.focus-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: var(--gap); }
.focus-panel-heading { padding: 12px 16px; background: var(--wash); }
.focus-panel-heading h2, .timeline-intro h2 { font-size: clamp(21px,1.65vw,29px); line-height: 1.25; }
.focus-room {
  contain: layout paint;
 display: grid; grid-template-columns: minmax(0,.95fr) minmax(0,1.45fr) minmax(100px,.75fr); align-items: center; gap: 12px; min-height: clamp(70px, 9.5vh, 94px); padding: 9px 14px; border-top: 1px solid var(--rule); }
.focus-room-detail strong { display: block; line-height: 1.3; }
.focus-room-time { font-size: var(--small); text-align: right; }
.focus-empty { padding: 24px 16px; color: var(--ink-soft); }

/* Axis labels, grid, bookings and the now rule share exactly one time scale. */
.timeline-intro, .timeline-legend, .timeline-legend span, .room-verdict, .meeting-caption { display: flex; align-items: center; }
.timeline-intro { justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 12px; }
.timeline-intro h2 { font-weight: 800; letter-spacing: -.02em; }
.timeline-intro p { margin-top: 4px; color: var(--ink-soft); font-size: var(--small); }
.timeline-legend { flex-wrap: wrap; gap: 12px; color: var(--ink-soft); font-size: var(--small); }
.timeline-legend span { gap: 5px; }
.legend-swatch { display: inline-block; width: 18px; height: 11px; border: 1px solid #b3b3b3; background: var(--wash); }
.timeline-shell { --timeline-columns: minmax(250px, 24%) minmax(0, 1fr) minmax(250px, 20%); }
.timeline-scale, .timeline-row, .timeline-guides { display: grid; grid-template-columns: var(--timeline-columns); }
.timeline-body { position: relative; }
.timeline-guides { position: absolute; inset: 0; pointer-events: none; }
.timeline-guides > div { grid-column: 2; position: relative; min-width: 0; }
.timeline-scale > span { align-self: end; padding: 10px 16px; }
.timeline-scale > span:last-child, .timeline-room-summary { border-left: 1px solid var(--rule); }
.timeline-axis, .timeline-track { position: relative; min-width: 0; margin-inline: 0; }
.timeline-axis { height: 54px; }
.axis-labels { position: absolute; inset: auto 0 8px; height: 1.5em; padding-inline: 4px; font: 400 var(--small)/1.5 var(--mono); }
.axis-labels span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.axis-labels span:first-child { transform: none; }
.axis-labels span:last-child { transform: translateX(-100%); }
.now-flag { position: absolute; top: 4px; left: clamp(3.35em, var(--now), calc(100% - 3.35em)); transform: translateX(-50%); padding: 2px 7px; background: var(--ink); color: white; font: 700 var(--small)/1.35 var(--mono); white-space: nowrap; }
.timeline-row { contain: layout paint; min-height: clamp(76px, 8.8vh, 100px); border-top: 1px solid var(--rule); }
.timeline-room-head, .timeline-room-summary { min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 5px; padding: 10px 16px; }
.timeline-room-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.timeline-room-name strong { font-size: clamp(20px, 1.22vw, 26px); line-height: 1.2; overflow-wrap: anywhere; }
.timeline-room-state { display: inline-block; flex: none; width: 6px; height: 26px; background: #999; }
.timeline-room-state.occupied { background: var(--occupied); }
.room-verdict, .meeting-caption { gap: 8px; font: 400 var(--small)/1.4 var(--mono); }
.room-verdict > span:last-child { color: var(--ink); font-weight: 700; }
.room-verdict .status-badge, .meeting-caption b { padding: 3px 6px; font-size: 11px; letter-spacing: 0; }
.grid-line { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--rule); }
.track-lane { position: absolute; top: 50%; left: 0; right: 0; height: clamp(30px, 3.3vh, 36px); transform: translateY(-50%); background: #f5f5f5; border-block: 1px solid #ddd; overflow: hidden; }
.timeline-event { position: absolute; top: 0; bottom: 0; display: flex; flex-direction: column; justify-content: center; min-width: 3px; padding: 2px 7px; border: 1px solid; overflow: hidden; }
.timeline-event.past, .legend-swatch.past { background: #d9d9d9; border-color: #aaa; }
.timeline-event.upcoming, .legend-swatch.upcoming { background: #d7e5fb; border-color: #5b86ca; }
.timeline-event.current, .legend-swatch.current { background: var(--occupied-fill); border-color: var(--occupied); z-index: 1; color: #fff; }
.now-rule { position: absolute; z-index: 2; top: 0; bottom: 0; border-left: 2px solid var(--ink); }
.timeline-event-time { font: 700 9px/1.15 var(--mono); white-space: nowrap; }
.timeline-event-title { margin-top: 2px; font-size: clamp(10px, .65vw, 12px); line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timeline-event.narrow { padding-inline: 2px; }
.timeline-event.narrow .timeline-event-time, .timeline-event.narrow .timeline-event-title { display: none; }
.meeting-name { font-size: clamp(16px, 1vw, 20px); line-height: 1.25; overflow-wrap: anywhere; }
.meeting-caption { margin-top: 2px; }
.meeting-subcaption, .timeline-summary-empty span { color: var(--ink-soft); font-size: var(--small); }
.timeline-summary-empty { display: flex; flex-direction: column; gap: 4px; }
.timeline-summary-empty strong { font-size: var(--body); }
.timeline-clear { color: var(--ink-faint); font-size: var(--body); }

@media (min-width: 901px) {
  .board-shell { height: 100vh; }
  /* Reserve room for the header, column labels and a one-line sync warning. */
  .dense-table, .focus-columns { --list-row: calc((100vh - 185px) / var(--list-rows)); }
  .dense-row, .focus-room {
    min-height: clamp(42px, var(--list-row), 87px);
    padding-block: clamp(2px, calc((var(--list-row) - 44px) / 2), 8px);
  }
  .status-layout:not(.all-idle) .idle-room-pill {
    --idle-row: calc((100vh - 170px) / var(--idle-rows));
    padding-block: clamp(2px, calc((var(--idle-row) - 48px) / 2), 10px);
    margin-bottom: clamp(3px, calc(var(--idle-row) - 55px), 8px);
  }
  .timeline-shell { --row-space: clamp(48px, calc((100vh - 205px) / var(--room-count)), 96px); }
  .timeline-row { min-height: var(--row-space); }
  .timeline-room-head, .timeline-room-summary {
    padding-block: clamp(2px, calc((var(--row-space) - 76px) / 2), 10px);
    gap: clamp(1px, calc((var(--row-space) - 70px) / 4), 5px);
  }
}
@media (min-width: 901px) and (max-height: 850px) {
  .timeline-intro { align-items: center; margin-bottom: 6px; }
  .timeline-intro p { display: none; }
  .timeline-axis { height: 46px; }
  .timeline-room-state { height: 20px; }
}
@media (max-width: 900px) {
  :root { --pad: 12px; }
  .header-date { display: none; }
  .status-layout { flex-direction: column; }
  .idle-rooms-rail { flex-basis: auto; }
  .all-idle .idle-rooms-rail { width: 100%; grid-template-columns: repeat(auto-fill, minmax(min(215px, 100%), 1fr)); }
  .focus-columns { grid-template-columns: 1fr; }
  .timeline-shell { --timeline-columns: 28% minmax(0,1fr) 30%; }
  .room-verdict { flex-wrap: wrap; gap: 4px; }
}
@media (max-width: 700px) {
  .header-content { flex-wrap: wrap; }
  .header-title, .header-time { white-space: nowrap; }
  .header-left, .header-right { gap: 10px; }
  .timeline-shell { --timeline-columns: 46% minmax(0,1fr); }
  .timeline-axis, .timeline-track, .timeline-guides, .timeline-legend { display: none; }
  .timeline-room-head, .timeline-room-summary, .timeline-scale > span { padding-inline: 8px; }
  .dense-table-head { display: none; }
  .dense-row { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 6px 12px; }
  .dense-row .dense-room { grid-column: 1/-1; }
  .focus-room { grid-template-columns: 1fr 1.4fr; }
  .focus-room-time { grid-column: 1/-1; text-align: left; }
}
