:root {
  color-scheme: dark;
  --bg: #0b0e0b;
  --panel: #161c16;
  --line: #2b3429;
  --text: #eff2e9;
  --muted: #8b958b;
  --accent: #d2f793;
  font-family: system-ui, 'Noto Sans TC', sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
button, a, textarea { -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; }
button:disabled { opacity: .4; cursor: not-allowed; }
button:focus-visible, a:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:hover:not(:disabled) { filter: brightness(1.2); }
.topbar { flex: 0 0 44px; min-width: 0; display: flex; align-items: center; gap: 14px; padding: 5px 8px; border-bottom: 1px solid var(--line); background: #171d16; }
.brand { display: flex; align-items: center; gap: 6px; color: var(--text); text-decoration: none; font-size: 12px; font-weight: 800; letter-spacing: 1px; }
.brand-mark { color: var(--accent); font-size: 24px; line-height: 1; }
.segmented { display: flex; gap: 2px; padding: 2px; border-radius: 5px; background: #0d120c; }
.segmented button { border: 0; border-radius: 3px; padding: 6px 10px; background: transparent; color: var(--muted); font-size: 11px; white-space: nowrap; }
.segmented button[aria-pressed=true] { color: var(--accent); background: #2b3823; }
.capacity { font-size: 10px; color: var(--muted); white-space: nowrap; }
.capacity b { font-weight: 500; color: var(--text); }
.actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-height: 30px; padding: 5px 9px; border: 1px solid #364230; border-radius: 4px; background: #222b1e; color: var(--text); font-size: 11px; white-space: nowrap; }
.button.subtle { background: transparent; border-color: transparent; color: #b1b9ae; }
.button.primary { background: var(--accent); border-color: var(--accent); color: #1b2812; font-weight: 700; }
main { flex: 1; min-height: 0; padding: 3px; }
.wall { height: 100%; display: grid; gap: 3px; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); }
.wall[data-layout='6'] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.wall[data-layout='9'] { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); }
.tile { min-width: 0; min-height: 0; display: flex; flex-direction: column; border: 1px solid var(--line); overflow: hidden; background: var(--panel); }
.tile.audible { border-color: var(--accent); }
.tile-top { flex: 0 0 26px; height: 26px; display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 0 5px; background: #1b2319; }
.tile-label { display: flex; align-items: center; gap: 7px; min-width: 0; }
.channel-id { font: 10px monospace; color: #7e897b; white-space: nowrap; }
.tile-title { font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #c8d0c4; }
.tile-actions { display: flex; flex-shrink: 0; gap: 2px; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 24px; border: 0; border-radius: 3px; background: transparent; color: #9aa693; font-size: 16px; }
.icon-button:hover { color: var(--accent); background: #30382d; }
.icon-button[aria-pressed=true] { color: var(--accent); background: #35452a; }
.screen { flex: 1; min-height: 0; position: relative; background: #000; }
.screen iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.empty-screen { width: 100%; height: 100%; border: 0; background: #111610; color: var(--muted); display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 7px; }
.empty-screen:hover { background: #192118; }
.empty-plus { color: var(--accent); font-size: 28px; line-height: 1; }
.empty-main { font-size: 12px; color: #b7c2af; }
.empty-sub { font-size: 10px; color: #6e7c66; }
.screen-message { position: absolute; inset: 0; display: flex; justify-content: center; align-items: center; flex-direction: column; gap: 12px; background: #141a14; padding: 12px; text-align: center; font-size: 12px; color: #b5bfae; }
.screen-message a { color: var(--accent); }
.wall.has-focus { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
.wall.has-focus .tile:not(.focused) { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
dialog { background: #1b211b; color: var(--text); border: 1px solid #3b4736; border-radius: 10px; padding: 24px; width: min(500px, calc(100% - 32px)); max-height: calc(100dvh - 32px); overflow: auto; box-shadow: 0 30px 120px #0008; }
dialog::backdrop { background: #050805b8; backdrop-filter: blur(6px); }
.dialog-top, .dialog-bottom { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.eyebrow { font: 10px monospace; letter-spacing: 2px; color: var(--accent); }
h2 { font-size: 23px; margin: 14px 0 10px; }
dialog p { font-size: 12px; line-height: 1.8; color: var(--muted); }
dialog label { display: block; font-size: 12px; margin: 22px 0 9px; }
textarea { font: 12px/1.8 system-ui; width: 100%; resize: vertical; background: #111610; border: 1px solid #3b4834; border-radius: 5px; color: var(--text); padding: 12px; }
dialog .form-error { color: #ffaaa0; min-height: 20px; margin: 7px 0 14px; }
.dialog-bottom > span { font-size: 11px; color: var(--muted); }
#toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--accent); color: #233119; padding: 10px 18px; border-radius: 5px; font-size: 12px; z-index: 10; max-width: 90%; display: none; }
#toast.visible { display: block; }
@media (max-width: 850px) {
  .topbar { gap: 8px; }
  .brand > span:last-child { display: none; }
  .actions .subtle span { display: none; }
  .button.subtle { width: 30px; padding: 4px; font-size: 16px; }
}
@media (max-width: 600px) {
  body { height: auto; min-height: 100dvh; overflow: auto; }
  .topbar { position: sticky; top: 0; z-index: 2; flex-wrap: wrap; gap: 4px; }
  .brand, .capacity { display: none; }
  .segmented button { padding: 6px 7px; }
  .actions { gap: 2px; }
  .actions .button { padding: 5px 6px; }
  .actions .button span { display: none; }
  .actions .button { min-width: 30px; font-size: 15px; }
  main { flex: none; }
  .wall, .wall[data-layout='6'], .wall[data-layout='9'] { height: auto; grid-template-columns: minmax(0, 1fr); grid-template-rows: none; grid-auto-rows: auto; }
  .screen { flex: none; aspect-ratio: 16 / 9; }
  .wall.has-focus { height: calc(100dvh - 50px); grid-template-rows: minmax(0, 1fr); }
  .tile.focused .screen { flex: 1; aspect-ratio: auto; }
}
