:root {
  --bg: #F3F6FA;
  --surface: #FFFFFF;
  --surface-2: #F7F9FC;
  --fg: #17212B;
  --muted: #5A6B7B;
  --faint: #8C9AA8;
  --border: #E4E9EF;
  --border-strong: #CFD6DE;
  --primary: #00AAAD;
  --primary-hover: #00898B;
  --primary-ink: #00787A;
  --primary-0: #E8F8F8;
  --primary-1: #C9EFEF;
  --ok-bg: #E2F6EC; --ok-fg: #12704F;
  --warn-bg: #FCEFDF; --warn-fg: #9A5410;
  --bad-bg: #FCE7E6; --bad-fg: #AE2A1F;
  --info-bg: #E4F4FB; --info-fg: #0A6585;
  --video-bg: #0B1117;
  --shadow-menu: 0 6px 18px rgba(16,24,40,.08);
  --shadow-card: 0 1px 2px rgba(16,24,40,.04);
  --font-sans: "IBM Plex Sans Thai", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --r-sm: 6px; --r-md: 10px;
  --gap: 20px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E151D; --surface: #151F29; --surface-2: #1A2631; --fg: #E5ECF2; --muted: #A1AFBD; --faint: #7A8997;
    --border: #243241; --border-strong: #324456; --primary: #22C3C6; --primary-hover: #4FD3D5; --primary-ink: #62DEE0; --primary-0: #12302F; --primary-1: #1A4644;
    --ok-bg: #12342A; --ok-fg: #6EDFB2; --warn-bg: #382916; --warn-fg: #F1B474; --bad-bg: #3B1D1C; --bad-fg: #F39A90; --info-bg: #12303C; --info-fg: #7DD1F0;
    --video-bg: #05090D;
    --shadow-menu: 0 6px 18px rgba(0,0,0,.45); --shadow-card: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0E151D; --surface: #151F29; --surface-2: #1A2631; --fg: #E5ECF2; --muted: #A1AFBD; --faint: #7A8997;
  --border: #243241; --border-strong: #324456; --primary: #22C3C6; --primary-hover: #4FD3D5; --primary-ink: #62DEE0; --primary-0: #12302F; --primary-1: #1A4644;
  --ok-bg: #12342A; --ok-fg: #6EDFB2; --warn-bg: #382916; --warn-fg: #F1B474; --bad-bg: #3B1D1C; --bad-fg: #F39A90; --info-bg: #12303C; --info-fg: #7DD1F0;
  --video-bg: #05090D;
  --shadow-menu: 0 6px 18px rgba(0,0,0,.45); --shadow-card: none; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--fg); font-family: var(--font-sans); font-size: 14px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
.mono { font-family: var(--font-mono); font-size: 12px; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
svg { flex: none; }

.app { height: 100%; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr) auto; }
.topbar { position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--border); padding-inline: 24px; height: 64px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 24px; align-items: center; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--fg); text-decoration: none; }
.brand:hover b { color: var(--primary-ink); }
.brand-mark { width: 32px; height: 32px; flex: none; object-fit: contain; }
.brand-text { min-width: 0; }
.brand b { display: block; font-size: 15px; line-height: 1.2; font-weight: 600; white-space: nowrap; }
.brand small { color: var(--muted); font-size: 12px; white-space: nowrap; }

.search { position: relative; width: 100%; max-width: 560px; justify-self: center; }
.search input { width: 100%; height: 40px; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface-2); padding: 0 64px 0 42px; font-size: 14.5px; }
.search input:focus { outline: 2px solid var(--primary-1); border-color: var(--primary); background: var(--surface); }
.search > svg { position: absolute; left: 15px; top: 11px; width: 18px; height: 18px; color: var(--faint); }
.kbd { position: absolute; right: 12px; top: 9px; font-family: var(--font-mono); font-size: 11px; color: var(--muted); border: 1px solid var(--border); border-radius: 6px; padding: 2px 7px; background: var(--surface); pointer-events: none; }
.search input:not(:placeholder-shown) ~ .kbd { display: none; }
.search-results { position: absolute; left: 0; right: 0; top: 48px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-menu); max-height: 420px; overflow-y: auto; padding: 6px; }
.result { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; width: 100%; border: 0; background: none; text-align: left; padding: 8px 12px; border-radius: var(--r-sm); cursor: pointer; }
.result svg { width: 16px; height: 16px; color: var(--muted); }
.result:hover, .result:focus-visible { background: var(--primary-0); outline: none; }
.result .mono { color: var(--muted); }
.result-empty { padding: 10px 12px; color: var(--muted); }

.settings { position: relative; }
.settings > .btn[aria-expanded="true"] { background: var(--primary-0); border-color: var(--primary); color: var(--primary-ink); }
.popover { position: absolute; right: 0; top: 46px; width: 300px; max-width: calc(100vw - 32px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-menu); display: flex; flex-direction: column; }
.popover section { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 14px 16px; }
.popover section + section { border-top: 1px solid var(--border); }
.popover h3 { margin: 0; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.popover .muted { margin: 0; color: var(--muted); font-size: 13px; }
.popover form { margin: 0; }
.popover { max-height: calc(100vh - 90px); overflow-y: auto; }
.hidden-list { list-style: none; margin: 0; padding: 0; width: 100%; display: flex; flex-direction: column; gap: 6px; }
.hidden-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hidden-list li > span { display: flex; flex-direction: column; min-width: 0; }
.hidden-list .mono { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spin svg, .notice svg { animation: spin 1.6s linear infinite; }
.spin { display: inline-grid; }
.info { display: inline-grid; color: var(--muted); cursor: help; border-radius: 999px; text-transform: none; letter-spacing: normal; }
.info svg { width: 15px; height: 15px; }
.info:hover, .info:focus-visible { color: var(--primary-ink); }
.tooltip { position: absolute; left: 12px; right: 12px; top: 36px; padding: 10px 12px; border-radius: var(--r-sm); background: var(--fg); color: var(--bg); font-size: 12.5px; line-height: 1.55; font-weight: 400; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow-menu); opacity: 0; visibility: hidden; transition: opacity .12s ease; z-index: 2; pointer-events: none; }
.info:hover .tooltip, .info:focus .tooltip { opacity: 1; visibility: visible; }
.who { display: flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%; }
.who-email { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 28px; height: 28px; border-radius: 999px; background: var(--primary-0); color: var(--primary-ink); display: grid; place-items: center; font-weight: 600; font-size: 11px; flex: none; }
.avatar:empty { display: none; }

.toolbar-bar { padding: 14px 24px 12px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; }
.filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.select { position: relative; display: inline-flex; align-items: center; height: 34px; border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface); color: var(--fg); }
.select:hover { border-color: var(--primary); }
.select.is-set { border-color: var(--primary); background: var(--primary-0); color: var(--primary-ink); }
.select svg { width: 15px; height: 15px; color: var(--muted); position: absolute; pointer-events: none; }
.select.is-set svg { color: var(--primary-ink); }
.select svg:first-child { left: 10px; }
.select svg:last-child { right: 9px; }
.select select { appearance: none; border: 0; background: none; color: inherit; height: 100%; min-width: 150px; padding: 0 32px 0 33px; font-weight: 500; cursor: pointer; }
.select select:focus-visible { outline: none; }
.select:focus-within { outline: 2px solid var(--primary-1); border-color: var(--primary); }
.link-btn { border: 0; background: none; color: var(--primary-ink); cursor: pointer; padding: 0 4px; font-size: 13.5px; text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; }
.query-chip { background: var(--primary-0); border-color: var(--primary); color: var(--primary-ink); font-weight: 500; }
.query-chip svg { width: 14px; height: 14px; }
.filter-chip { display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; color: var(--fg); font-size: 13.5px; white-space: nowrap; }
.filter-chip:hover { border-color: var(--primary); }
.filter-chip .count { font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.filter-chip[aria-pressed="true"] { background: var(--primary-0); border-color: var(--primary); color: var(--primary-ink); font-weight: 600; }
.filter-chip[aria-pressed="true"] .count { color: var(--primary-ink); }
.controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.result-count { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.pager { display: flex; align-items: center; gap: 4px; }
.pager .mono { min-width: 44px; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }
.segmented { display: inline-flex; padding: 2px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border-strong); gap: 2px; }
.segmented button { border: 0; background: none; min-width: 32px; height: 28px; padding: 0 10px; border-radius: 999px; cursor: pointer; color: var(--muted); font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.segmented button[aria-pressed="true"] { background: var(--primary); color: #fff; }
.switch { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px 0 8px; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface); cursor: pointer; color: var(--fg); font-weight: 500; }
.switch:hover { border-color: var(--primary); }
.switch-track { width: 32px; height: 18px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background .15s ease; }
.switch-thumb { position: absolute; left: 2px; top: 2px; width: 14px; height: 14px; border-radius: 999px; background: #fff; box-shadow: 0 1px 2px rgba(16,24,40,.2); transition: transform .15s ease; }
.switch[aria-checked="true"] { border-color: var(--primary); color: var(--primary-ink); }
.switch[aria-checked="true"] .switch-track { background: var(--primary); }
.switch[aria-checked="true"] .switch-thumb { transform: translateX(14px); }
.single-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.single-title { display: flex; flex-direction: column; min-width: 0; }
.single-title b { font-size: 18px; font-weight: 600; line-height: 1.3; }
.single-title .mono { color: var(--primary-ink); }
.notice { flex-basis: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-radius: var(--r-md); background: var(--info-bg); color: var(--info-fg); font-size: 13.5px; }
.notice svg { width: 16px; height: 16px; }
.notice-paused { background: var(--warn-bg); color: var(--warn-fg); }
.notice-paused svg { animation: none; }
.hint { color: var(--muted); font-size: 12.5px; margin: 0; padding: 8px 24px 14px; }

.btn { height: 34px; padding: 0 12px; border-radius: var(--r-sm); border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; text-decoration: none; color: var(--fg); }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-icon { width: 34px; padding: 0; }
.btn svg { width: 16px; height: 16px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 11.5px; font-weight: 500; white-space: nowrap; }
.chip-ok { background: var(--ok-bg); color: var(--ok-fg); }
.chip-warn { background: var(--warn-bg); color: var(--warn-fg); }
.chip-muted { background: var(--surface-2); color: var(--muted); }
.chip-still { background: rgba(11, 17, 23, .62); color: #D5DEE6; }

.empty { padding: 48px 28px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.loading { display: flex; justify-content: center; padding: 120px 0; }
.spinner { width: 32px; height: 32px; border-radius: 999px; border: 3px solid var(--primary-1); border-top-color: var(--primary); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.stage { min-height: 0; padding-inline: 24px; container-type: size; display: grid; place-items: start center; }
.stage:fullscreen { background: #000; padding: 0; place-items: center; }
.wall { display: grid; gap: 6px; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); width: min(100cqw, 100cqh * 16 / 9); }
.stage:fullscreen .wall { gap: 2px; }
.tile { position: relative; aspect-ratio: 16 / 9; background: var(--video-bg); border-radius: var(--r-sm); overflow: hidden; }
.stage:fullscreen .tile { border-radius: 0; }
.tile-still { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; }
.tile-empty { position: absolute; inset: 0; display: grid; place-items: center; color: #4A5866; }
.tile-empty svg { width: 28px; height: 28px; }
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: var(--video-bg); opacity: 0; transition: opacity .2s ease; }
.tile.has-video video { opacity: 1; }
.tile-open { position: absolute; inset: 0; background: transparent; border: 0; padding: 0; cursor: zoom-in; border-radius: inherit; }
.tile:hover .tile-open { box-shadow: inset 0 0 0 3px var(--primary); }
.tile-label { position: absolute; left: 8px; bottom: 8px; display: flex; align-items: baseline; gap: 8px; padding: 2px 10px; border-radius: 999px; background: rgba(11, 17, 23, .72); color: #fff; font-size: 12.5px; pointer-events: none; max-width: calc(100% - 16px); overflow: hidden; white-space: nowrap; }
.tile-label .mono { color: #9EE7E8; font-size: 11.5px; }
.tile-status { position: absolute; right: 8px; top: 8px; pointer-events: none; }
.tile-status:empty { display: none; }
.wall-single .tile-label { bottom: auto; top: 8px; }

.login-page { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-menu); padding: 32px 28px; display: flex; flex-direction: column; align-items: center; gap: 18px; text-align: center; }
.login-card .brand { padding: 0; min-height: 0; text-align: left; }
.login-card .brand-text, .login-card .brand small { display: block; }
.login-card h1 { font-size: 22px; margin: 0; }
.login-error { align-self: stretch; margin: 0; padding: 10px 12px; border-radius: var(--r-sm); background: var(--bad-bg); color: var(--bad-fg); font-size: 13.5px; }
.btn-google { height: 44px; width: 100%; font-weight: 500; }
.btn-google svg { width: 18px; height: 18px; }

@media (max-width: 1100px) {
  .kbd, .brand small { display: none; }
  .search input { padding-right: 16px; }
}
@media (max-width: 820px) {
  .app { height: auto; min-height: 100%; }
  .topbar { padding-inline: 16px; gap: 12px; height: 60px; }
  .brand-text { display: none; }
  .search { justify-self: stretch; }
  .toolbar-bar { padding-inline: 16px; }
  .filters { flex: 1 1 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .select { min-width: 0; }
  .select select { min-width: 0; width: 100%; }
  .query-chip, .link-btn { grid-column: 1 / -1; justify-self: start; }
  .stage { padding-inline: 16px; container-type: normal; }
  .wall { width: 100%; grid-template-columns: repeat(min(var(--cols), 2), minmax(0, 1fr)); gap: 4px; }
  .hint { padding-inline: 16px; }
  .chip-still { display: none; }
}
@media (max-width: 480px) {
  .result-count { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
