:root {
  --fs: 15px;
  --bg: #0e0e12; --panel: #17171d; --panel2: #1f1f27; --line: #2b2b36;
  --fg: #ececf1; --muted: #9a9aaa; --accent: #8f6bff; --ok: #3ccf7a; --warn: #f3b33d; --err: #ff5a5f;
  --tw: #9146ff; --yt: #ff0033; --tt: #fe2c55; --bl: #00a1d6; --x: #8b98a5; --se: #e8a33d;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --tint: 255 255 255;   /* what a faint overlay is made of: white on dark themes, a dark tone on light ones */
  --link: #b9a6ff; --on-dark: #ececf1; --on-accent: #fff;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overscroll-behavior: none; }
body {
  background: var(--bg); color: var(--fg);
  font: 400 var(--fs)/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans JP", "Noto Sans SC", sans-serif;
  display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr); overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  /* pinned to the visual viewport so the composer stays above the on-screen keyboard (iOS + Android) */
  position: fixed; left: 0; right: 0; top: var(--app-top, 0px); height: var(--app-h, 100dvh);
  padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px);
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--link); }
[hidden] { display: none !important; }

/* ---------- header ---------- */
#top {
  display: flex; align-items: center; gap: 8px; padding: calc(6px + var(--safe-t)) 8px 6px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; letter-spacing: .5px; background: var(--accent); color: var(--on-accent); border-radius: 8px; padding: 2px 7px; font-size: 13px; }
.pills { display: flex; gap: 6px; overflow-x: auto; flex: 1; min-width: 0; scrollbar-width: none; }
.pills::-webkit-scrollbar { display: none; }
.pill {
  display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); background: var(--panel2);
  border-radius: 999px; padding: 2px 8px 2px 3px; white-space: nowrap; cursor: pointer; font-size: 12px;
}
.pill.muted { opacity: .35; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: #555; }
.pill.st-live .dot { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.pill.st-connecting .dot { background: var(--warn); animation: pulse 1s infinite; }
.pill.st-error .dot { background: var(--err); }
.pill.st-offline .dot { background: #777; }
.pill .vc { color: var(--muted); font-variant-numeric: tabular-nums; }
@keyframes pulse { 50% { opacity: .3; } }
.top-actions { display: flex; gap: 4px; }
.iconbtn { background: transparent; border: 1px solid var(--line); border-radius: 8px; width: 34px; height: 30px; cursor: pointer; }
.iconbtn.on { background: var(--warn); color: #000; border-color: var(--warn); }

.pchip {
  display: inline-grid; place-items: center; min-width: 22px; height: 18px; padding: 0 4px; border-radius: 5px;
  font-size: 10px; font-weight: 800; color: #fff; letter-spacing: .3px; flex: none;
}

.adbar { display: flex; gap: 10px; align-items: center; padding: 4px 10px; background: #231a33; font-size: 13px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.ad-soon { color: var(--warn); font-weight: 700; }
.ad-live { color: #000; background: var(--warn); padding: 1px 6px; border-radius: 4px; font-weight: 800; }
.hype { color: #ffb3f0; font-weight: 600; }

/* ---------- main / views ---------- */
#main { min-height: 0; min-width: 0; position: relative; display: grid; grid-template-columns: minmax(0, 1fr); }
.view { min-height: 0; overflow-y: auto; }
.pad { padding: 10px; }
/* explicit rows: a hidden #adbar must not shift the tab bar into the flexible row */
#top { grid-row: 1; } #strips { grid-row: 2; } #main { grid-row: 3; } #tabs { grid-row: 4; }

/* layout is set by main.js on <body data-layout>: 1 = phone portrait, 2 = split (desktop / phone landscape), 3 = wide desktop */
body[data-layout="2"] #main { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
body[data-layout="3"] #main { grid-template-columns: minmax(380px, 1.25fr) minmax(360px, 1fr) minmax(300px, .8fr); }
body:not([data-layout="1"]) .view { min-width: 0; }
body:not([data-layout="1"]) #view-chat { grid-column: 1; grid-row: 1; border-right: 1px solid var(--line); }
body:not([data-layout="1"]) .view:not(#view-chat) { grid-column: 2; grid-row: 1; }
body[data-layout="3"] #view-events { grid-column: 3; border-left: 1px solid var(--line); }
body:not([data-layout="1"]) .tabs .tab-chat, body[data-layout="3"] .tabs [data-tab="events"] { display: none; }

/* phone in landscape (handlebar / chest mount): tabs become a left rail, header slims down.
   html.gs-land / html.gs-slim are set by the page (index.html, main.js) from the DEVICE's orientation, not from the
   viewport's shape: with the on-screen keyboard up a portrait phone's viewport is wider than tall, and a media query
   on orientation then flipped the whole app into the landscape layout while typing. */
  :where(html.gs-land) body { grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr); }
  :where(html.gs-land) #top { grid-column: 1 / -1; grid-row: 1; padding-top: 4px; padding-bottom: 4px; }
  :where(html.gs-land) #strips { grid-column: 1 / -1; grid-row: 2; }
  :where(html.gs-land) #main { grid-column: 2; grid-row: 3; }
  :where(html.gs-land) #tabs {
    grid-column: 1; grid-row: 3; grid-auto-flow: row; grid-auto-rows: 1fr; grid-auto-columns: auto;
    width: 62px; border-top: 0; border-right: 1px solid var(--line); padding-bottom: var(--safe-b);
  }
  :where(html.gs-land) .tabs button { box-shadow: none; }
  :where(html.gs-land) .tabs button.on { box-shadow: inset 3px 0 var(--accent); }
  :where(html.gs-land) .composer { padding-top: 5px; padding-bottom: 5px; }

/* ---------- chat ---------- */
.chat-view { display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto auto; grid-template-columns: minmax(0, 1fr); position: relative; min-height: 0; }
#monitorBar { grid-row: 1; } #player { grid-row: 2; } #chatList { grid-row: 3; } #replyBar { grid-row: 4; } #composer { grid-row: 5; }
.chat-list { overflow-y: auto; padding: 6px 8px 10px; overscroll-behavior: contain; min-height: 0; }
.msg { padding: 3px 4px; border-radius: 6px; word-wrap: break-word; overflow-wrap: anywhere; cursor: pointer; }
.msg:hover { background: rgb(var(--tint) / .03); }
.msg > * { vertical-align: middle; }
.msg .ts { color: var(--muted); font-size: .78em; margin-right: 4px; font-variant-numeric: tabular-nums; }
.msg .pchip { margin-right: 4px; transform: translateY(-1px); }
.msg .avatar { width: 1.4em; height: 1.4em; border-radius: 50%; margin-right: 4px; object-fit: cover; }
.badges .badge { height: 1.1em; margin-right: 2px; vertical-align: -2px; }
.tbadge { font-size: .7em; font-weight: 800; padding: 0 4px; border-radius: 4px; margin-right: 3px; background: #444; color: #fff; vertical-align: 1px; }
.tbadge.b-owner { background: #e91916; } .tbadge.b-mod { background: #00ad03; } .tbadge.b-vip { background: #e005b9; }
.tbadge.b-sub { background: #6441a5; } .tbadge.b-medal { background: #3a7bd5; }
.tbadge.b-collab { background: #00a3c4; text-transform: none; }
.msg .name { font-weight: 700; }
.msg .amount { background: var(--warn); color: #000; font-weight: 800; border-radius: 4px; padding: 0 5px; margin-left: 5px; font-size: .85em; }
.msg.action .text { font-style: italic; }
.msg .emote { height: 1.8em; vertical-align: middle; margin: -4px 1px; }
.msg.history { opacity: .55; }
.msg.deleted .text { text-decoration: line-through; opacity: .4; }
.msg.hl-first { background: #3ccf7a1a; box-shadow: inset 3px 0 var(--ok); }
.msg.hl-mention { background: #ff5a5f22; box-shadow: inset 3px 0 var(--err); }
.msg.hl-super, .msg.hl-bits { background: #f3b33d1f; box-shadow: inset 3px 0 var(--warn); }
.msg.hl-collab { background: #00c2ff14; box-shadow: inset 3px 0 #00c2ff; }
.msg.hl-sub, .msg.hl-raid, .msg.hl-event, .msg.hl-follow, .msg.hl-redeem, .msg.hl-ad { background: #8f6bff18; box-shadow: inset 3px 0 var(--accent); }
.msg.k-system .text { color: var(--muted); font-style: italic; }
.msg.k-event .text { font-weight: 600; }
.new-pill {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 64px; z-index: 5;
  background: var(--accent); color: var(--on-accent); border: 0; border-radius: 999px; padding: 6px 14px; font-weight: 700; box-shadow: 0 4px 16px #0008;
}
.reply-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 4px 10px; background: var(--panel2); font-size: .85em; color: var(--muted); }
.composer { display: flex; gap: 6px; padding: 8px 8px calc(8px); background: var(--panel); border-top: 1px solid var(--line); }
.composer input { flex: 1; min-width: 0; }

/* ---------- monitor strip + live view ---------- */
.monitor { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 8px; background: var(--panel); border-bottom: 1px solid var(--line); }
.mcell { flex: none; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 4px 10px; min-width: 0; text-align: left; color: inherit; font: inherit; }
.mcell .mv { font-weight: 800; font-size: 1.25em; font-variant-numeric: tabular-nums; line-height: 1.15; white-space: nowrap; }
.mcell .mv .unit { font-size: .6em; font-weight: 700; color: var(--muted); }
.mcell .ml { font-size: .68em; color: var(--muted); white-space: nowrap; max-width: 46vw; overflow: hidden; text-overflow: ellipsis; }
.mcell.dur.on { border-color: #6e2228; }
.mcell.dur.on .ml { color: var(--err); font-weight: 800; }
.mcell.br { flex: 1 1 140px; min-width: 0; overflow: hidden; }
.mcell.br .ml { max-width: none; }
.mcell.vw { flex: 1 1 auto; }
.links { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.link { font-size: .66em; font-weight: 700; padding: 1px 6px; border-radius: 999px; background: rgb(var(--tint) / .07); font-variant-numeric: tabular-nums; white-space: nowrap; }
.link.dead { background: #3a1517; color: #ffb4b6; }
.mcell.br .meter { height: 4px; background: rgb(var(--tint) / .09); border-radius: 3px; margin-top: 3px; overflow: hidden; }
.mcell.br .fill { height: 100%; background: var(--ok); transition: width .6s; }
.mcell.br.low .fill { background: var(--warn); } .mcell.br.low .mv { color: var(--warn); }
.mcell.br.alarm { border-color: var(--err); background: #3a1517; animation: pulse 1s infinite; }
.mcell.br.alarm .fill { background: var(--err); } .mcell.br.alarm .mv { color: #ffb4b6; }
.vrow { display: flex; gap: 8px; align-items: center; white-space: nowrap; }
.vchip { display: inline-flex; align-items: center; gap: 3px; font-variant-numeric: tabular-nums; font-size: 1.05em; }
.vchip .pchip { min-width: 18px; height: 15px; font-size: 8px; }
.vchip.total { color: var(--muted); }
.vchip.total b { color: var(--fg); }
.tvbtn { cursor: pointer; text-align: center; }
.tvbtn.on { border-color: var(--accent); }
.player { position: relative; background: #000; overflow: hidden; border-bottom: 1px solid var(--line); }
.player .pinner { position: absolute; inset: 0; }
.player .pinner iframe { display: block; width: 100%; height: 100%; border: 0; }
.player .pframe { position: absolute; inset: 0; display: block; width: 100%; height: 100%; border: 0; object-fit: contain; background: #000; }
.player .pmsg { padding: 14px; color: var(--muted); text-align: center; font-size: .9em; }
  :where(html.gs-land) .monitor { padding: 4px 6px; gap: 4px; } :where(html.gs-land) .mcell { padding: 2px 8px; } :where(html.gs-land) .mcell .mv { font-size: 1.05em; }
  :where(html.gs-land) .mcell.dur .ml, :where(html.gs-land) .mcell.vw .ml, :where(html.gs-land) .tvbtn .ml { display: none; }
  :where(html.gs-land) .links { margin-top: 2px; }

/* ---------- events ---------- */
.event-list { padding: 0 8px 12px; }
.event { display: flex; gap: 6px; align-items: center; padding: 6px; border-bottom: 1px solid var(--line); }
.event .ts { color: var(--muted); font-size: .78em; font-variant-numeric: tabular-nums; }
.event .ev-body { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.event .ev-detail { color: var(--muted); }
.event.hl-super { background: #f3b33d14; }
.event.hl-sub, .event.hl-raid { background: #8f6bff14; }
.event.hl-collab { background: #00c2ff12; }
.collab-on { color: #00c2ff; font-weight: 700; }
.linkbox { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .78em; word-break: break-all; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.preview-frame { width: 100%; aspect-ratio: 16 / 9; border: 1px solid var(--line); border-radius: 10px; background: #111; }
.typechips label { display: inline-flex; align-items: center; gap: 4px; font-size: .9em; }

/* ---------- controls ---------- */
input, select, textarea {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-height: 38px; width: 100%;
}
input[type=checkbox], input[type=range] { width: auto; min-height: 0; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); }
input[type=range] { accent-color: var(--accent); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.num { width: 76px !important; }
.btn {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; cursor: pointer;
  min-height: 38px; white-space: nowrap; font-weight: 600;
}
.btn:hover { border-color: #444; }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.danger { background: #3a1517; border-color: #6b2226; color: #ffb4b6; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { padding: 5px 10px; min-height: 32px; font-size: .9em; }
.btn.xs { padding: 2px 7px; min-height: 26px; font-size: .8em; }
.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; }
.gap { gap: 8px; } .wrap { flex-wrap: wrap; } .grow { flex: 1; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0; }
.muted { color: var(--muted); } .small { font-size: .85em; }
.warn { color: var(--warn); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.card h3 { margin: 0 0 8px; font-size: 1.05em; }
.card h4 { margin: 14px 0 4px; font-size: .9em; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.list .item { padding: 6px 0; border-bottom: 1px solid var(--line); }
.list .item:last-child { border-bottom: 0; }
.form { display: grid; gap: 10px; margin-top: 10px; }
.form label { display: grid; gap: 4px; font-size: .9em; }
.form label.row { display: flex; }
.form small { font-weight: 400; }
details.setting > summary { cursor: pointer; font-weight: 700; list-style: none; display: flex; align-items: center; gap: 4px; }
details.setting > summary::-webkit-details-marker { display: none; }
details.setting > summary::after { content: '▸'; margin-left: auto; color: var(--muted); }
details.setting[open] > summary::after { content: '▾'; }
.st { font-weight: 700; } .st-live { color: var(--ok); } .st-error { color: var(--err); } .st-connecting { color: var(--warn); }
.statgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.stat { background: var(--panel2); border-radius: 8px; padding: 6px; text-align: center; }
.stat.red .stat-v { color: var(--err); }
.stat-v { font-weight: 800; font-variant-numeric: tabular-nums; font-size: .95em; }
.stat-l { color: var(--muted); font-size: .72em; }
.spark { width: 100%; height: 50px; color: var(--ok); margin-top: 8px; }
.vol { width: 120px; }
.db { width: 64px; text-align: right; color: var(--muted); font-size: .8em; font-variant-numeric: tabular-nums; }
.toggle { width: 22px; height: 22px; }
.bar { position: relative; background: var(--panel2); border-radius: 6px; margin: 4px 0; padding: 5px 8px; overflow: hidden; }
.bar-fill { position: absolute; inset: 0 auto 0 0; background: #8f6bff55; }
.bar span { position: relative; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.quote { background: var(--panel2); padding: 8px 10px; border-radius: 8px; overflow-wrap: anywhere; }
@media (max-width: 480px) { .statgrid { grid-template-columns: repeat(2, 1fr); } }

/* ---------- touch devices: 44px targets, no iOS focus-zoom (inputs ≥16px), no double-tap zoom ---------- */
button, a, .tile, .msg, label, summary { touch-action: manipulation; }
@media (pointer: coarse) {
  input, select, textarea { font-size: 16px; min-height: 44px; }
  input[type=checkbox] { width: 24px; height: 24px; min-height: 0; }
  .btn { min-height: 44px; }
  .btn.sm { min-height: 40px; padding: 6px 12px; }
  .btn.xs { min-height: 34px; padding: 4px 10px; font-size: .85em; }
  .iconbtn { width: 40px; height: 36px; }
  .pill { min-height: 30px; }
  .msg { padding: 4px 4px; }
  .tile { min-height: 96px; }
  .sheet .btn { min-height: 48px; }
  .event { padding: 8px 6px; }
}

/* ---------- board ---------- */
.board-tools { margin-bottom: 10px; }
.board-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.tile {
  position: relative; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 2px;
  min-height: 84px; padding: 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel2);
  font-weight: 700; text-align: center; cursor: pointer; user-select: none; transition: transform .06s;
}
.tile:active { transform: scale(.97); }
.tile .tile-label { font-size: 1.02em; overflow-wrap: anywhere; }
.tile .tile-kind { font-size: .68em; color: var(--muted); font-weight: 600; }
.tile.slider { cursor: default; }
.tile.slider input { width: 100%; }
.tile.busy { opacity: .5; }
.tile.active { outline: 3px solid var(--ok); outline-offset: -3px; }
.tile.wide { grid-column: span 2; }
.tile.slider { align-items: stretch; text-align: left; }
.tile .slider-row { display: flex; align-items: center; gap: 8px; width: 100%; }
.tile .slider-row input { flex: 1; min-width: 0; }
.tile .mutebtn { flex: none; min-width: 44px; min-height: 44px; border-radius: 10px; border: 1px solid color-mix(in srgb, currentColor 22%, transparent); background: #0003; color: inherit; font-size: 1.2em; }
.tile .mutebtn.on { background: #ff5a5f55; border-color: #ff5a5f; }
.tile.muted .tile-label { opacity: .7; text-decoration: line-through; }
.tile .sw { width: 44px; height: 24px; border-radius: 12px; background: #0006; border: 2px solid color-mix(in srgb, currentColor 40%, transparent); position: relative; margin-top: 6px; }
.tile .sw::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #bbb; transition: left .15s; }
.tile.active .sw { background: var(--ok); border-color: var(--ok); }
.tile.active .sw::after { left: 22px; background: #fff; }
.tile.active:has(.sw) { outline: none; }
.tile .tile-warn { display: none; font-size: .66em; font-weight: 700; color: #ffd166; }
.tile.missing { border-style: dashed; border-color: #ffd166; }
.tile.missing .tile-warn { display: block; }
.tile.custom .tile-kind { color: inherit; opacity: .75; }
.tile.red { background: #3b1518; border-color: #6e2228; } .tile.orange { background: #3a2610; border-color: #6e4618; }
.tile.green { background: #12301e; border-color: #1f5a36; } .tile.blue { background: #10243d; border-color: #1c4170; }
.tile.purple { background: #24183d; border-color: #43307a; } .tile.pink { background: #3a1430; border-color: #6c2559; }
.tile.gray { background: #23232a; }
.tile.red, .tile.orange, .tile.green, .tile.blue, .tile.purple, .tile.pink, .tile.gray { color: var(--on-dark); }   /* dark tiles in every theme */
.edit-ctrl { display: flex; gap: 4px; margin-top: 6px; }

/* ---------- tabs ---------- */
.tabs {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--panel); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.tabs button {
  position: relative; background: none; border: 0; padding: 6px 2px; color: var(--muted); font-weight: 700; font-size: .8em; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-height: 50px;
}
.tabs .ti { font-size: 1.35em; line-height: 1; filter: grayscale(.6); }
.tabs button.on .ti { filter: none; }
.tabs .tb {
  position: absolute; top: 4px; left: calc(50% + 8px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--err); color: #fff; font-size: 11px; line-height: 18px; text-align: center;
}
.tabs button.on { color: var(--fg); box-shadow: inset 0 2px var(--accent); }

/* ---------- sheets / toasts ---------- */
.sheet-wrap { position: fixed; left: 0; right: 0; top: var(--app-top, 0px); height: var(--app-h, 100dvh); background: #000a; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--panel); width: min(560px, 100%); max-height: 85vh; overflow: auto; border-radius: 16px 16px 0 0;
  border: 1px solid var(--line); padding: 12px 14px calc(14px + var(--safe-b));
}
@media (min-width: 700px) { .sheet-wrap { align-items: center; } .sheet { border-radius: 16px; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
#toasts { position: fixed; top: calc(52px + var(--safe-t)); left: 50%; transform: translateX(-50%); z-index: 60; display: grid; gap: 6px; width: min(92vw, 420px); pointer-events: none; }
.toast { background: #2a2a35; color: var(--on-dark); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; box-shadow: 0 6px 20px #0009; transition: opacity .35s, transform .35s; }
.toast.ok { border-color: #1f5a36; } .toast.error { border-color: #6e2228; background: #2e1a1c; }
.toast.out { opacity: 0; transform: translateY(-8px); }

/* relay auto-detect status (Settings → Monitor) */
.relay-status { padding: 8px 10px; border-radius: 8px; background: rgb(var(--tint) / .05); color: var(--muted); line-height: 1.4; word-break: break-word; }
.relay-status.live { color: var(--ok); background: #1f3a2a; }
.relay-status.error { color: #ffb4b6; background: #3a1517; }

/* alert filter chips (Events tab) */
.pad-x { padding: 6px 10px 0; }
.alertchips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0; padding-bottom: 4px; }
.alertchips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--panel2); color: var(--muted); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: .85em; min-height: 36px; }
.chip.on { color: var(--fg); border-color: var(--accent); background: #8f6bff22; }
.chip.filt { font-weight: 700; }
.alertchips .chip:not(.on):not(.filt) { text-decoration: line-through; opacity: .6; }
@media (pointer: coarse) { .chip { min-height: 44px; } }
.relaybox { border: 1px dashed var(--line); border-radius: 10px; padding: 10px; display: grid; gap: 8px; }
.relaybox .ok { color: var(--ok); font-weight: 700; }
.paircode { font: 800 2em/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; text-align: center; padding: 14px; border-radius: 12px; background: var(--panel2); border: 1px solid var(--accent); user-select: all; }

/* front-screen alert pop-ups */
.alertpop { position: absolute; z-index: 20; display: grid; gap: 6px; padding: 0 8px; pointer-events: none; justify-items: center; }
.apop { pointer-events: auto; width: min(100%, 480px); display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 12px; border-radius: 14px;
  background: #1d1a2bee; color: var(--on-dark); border: 1px solid var(--accent); box-shadow: 0 8px 24px #000a; backdrop-filter: blur(6px); animation: apop-in .25s ease-out; cursor: pointer; }
.apop.out { opacity: 0; transform: translateY(-8px); transition: opacity .25s, transform .25s; }
.apop-body { flex: 1; min-width: 0; }
.apop-body strong { display: block; font-size: 1.02em; line-height: 1.25; overflow-wrap: anywhere; }
.apop-detail { font-size: .85em; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.apop-x { flex: none; background: none; border: 0; color: var(--muted); font-size: 1.1em; min-width: 36px; min-height: 36px; border-radius: 8px; }
.apop.c-money { border-color: #f3b33d; background: #2b2412ee; } .apop.c-sub { border-color: #8f6bff; } .apop.c-gift { border-color: #ff6bb5; background: #2b1626ee; }
.apop.c-raid { border-color: #ff8a3d; background: #2b1a12ee; } .apop.c-hype { border-color: #ff5a5f; background: #2e1517ee; } .apop.c-redeem { border-color: #3ccf7a; }
@keyframes apop-in { from { opacity: 0; transform: translateY(-10px) scale(.98); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .apop { animation: none; } }

/* ---------- rush meter (js/rush/panel.js) ---------- */
.rushbar { display: flex; gap: 8px; align-items: center; padding: 3px 8px; background: #2a1616; color: var(--on-dark); border-bottom: 1px solid var(--line); font-size: 13px; min-height: 40px; }
.rushbar[data-phase="max"] { background: linear-gradient(90deg, #4a1d1c, #2a1616); }
.rushbar[data-phase="rush"] { background: linear-gradient(90deg, #4d3300, #2a1d0a); }
.rushbar .rb-text { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.rushbar .grow { flex: 1; }
.rushbar .btn.on { background: var(--ok); border-color: var(--ok); color: #000; }
/* listen switch (rush card + remote page): green = this device plays the rush audio, red = muted */
.btn.listen.on { background: #12452a; border-color: var(--ok); color: #c9ffe0; font-weight: 700; }
.btn.listen.off { background: #3a1517; border-color: #6b2226; color: #ffb4b6; font-weight: 700; }
.rushbar .btn.ghost { background: transparent; }
.rush-card .rush-top { align-items: flex-start; }
.rush-card .rush-status { font-weight: 800; font-size: 1.05em; margin: 4px 0; }
.rush-card .rush-presence { color: var(--muted); margin-top: 2px; }
.rush-card .ok { color: var(--ok); font-weight: 700; }
.rush-card details > * + * { margin-top: 6px; }
.rush-card details { margin-top: 10px; }
.rush-card summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.rush-card .linkbox { white-space: pre-wrap; }
.rush-song.on { box-shadow: inset 3px 0 var(--warn); }
.rush-log .rush-amt, .rush-amt { font-weight: 800; color: var(--warn); font-variant-numeric: tabular-nums; }
.rush-song { display: grid; gap: 4px; padding: 6px 8px; }
.rush-song .num { width: 64px !important; }
.rush-song input[type="radio"] { width: 22px !important; height: 22px; min-height: 0; flex: none; margin: 0; padding: 0; accent-color: var(--warn); }
.rush-song .ellipsis { font-weight: 700; }
.linkbtn { background: none; border: 0; color: var(--accent); font: inherit; padding: 2px 0; cursor: pointer; min-height: 28px; }
.linkbtn.x { margin-left: auto; color: var(--muted); min-width: 28px; }

/* QR share (Settings → Devices) */
.qrbox { width: min(100%, 280px); margin: 4px auto; background: #fff; border-radius: 12px; padding: 6px; box-sizing: border-box; }
.qrbox svg { display: block; width: 100%; height: auto; }
.paircode.sm { font-size: 1.25em; padding: 8px; letter-spacing: .08em; }
.share-list { margin: 0; padding-left: 18px; display: grid; gap: 2px; }
.share-active { display: grid; gap: 4px; }
.share-active .grow { flex: 1; min-width: 140px; }
.warnline { color: #ffb4b6; background: #3a1517; border-radius: 8px; padding: 8px 10px; margin: 0; }
.tile.srcvol { align-items: stretch; gap: 6px; }
.tile .tile-top { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 100%; padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; }
.tile.srcvol .tile-top .sw { margin-top: 4px; }
.relaybox .err { color: #ffb4b6; font-weight: 700; }

/* ---------- live view: small (half width, title + links beside it) or full; a thin line when there's nothing to show ---------- */
.player { display: flex; flex-direction: column; }
.player.small { flex-direction: row; align-items: stretch; }
.player .pframe-box { position: relative; overflow: hidden; flex: none; width: 100%; aspect-ratio: 16 / 9; background: #000; }
.player.small .pframe-box { width: 50%; }
.player.small.tw .pframe-box { width: max(50%, 300px); max-width: 100%; }   /* Twitch pauses players narrower than 300 px */
.player .pside { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; padding: 5px 8px; font-size: .74em; color: var(--muted); background: var(--panel); overflow: hidden; container-type: inline-size; }
.player:not(.small) .pside { flex: none; flex-direction: row; align-items: center; padding: 0 10px; border-top: 1px solid var(--line); }
.player:not(.small) .pside .ptitle, .player:not(.small) .pside.bare { display: none; }
.player .ptitle { color: var(--fg); font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.player .ptitle:empty { display: none; }
.player .phint { display: flex; flex-wrap: wrap; gap: 0 10px; align-items: center; margin-top: auto; }
.player:not(.small) .phint { margin-top: 0; flex: 1; }
.player .phint a { color: var(--accent); }
.player .psize { position: absolute; top: 4px; right: 4px; z-index: 2; width: 34px; height: 28px; padding: 0; border-radius: 8px; border: 1px solid #ffffff55; background: #000a; color: #fff; font-size: 14px; line-height: 1; cursor: pointer; }
.player .pmsg.over { position: absolute; inset: auto 0 0 0; background: #000b; padding: 4px 8px; font-size: .75em; }
.player.idle { display: block; }
.player .pidle { display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: center; justify-content: center; min-height: 28px; padding: 2px 10px; font-size: .74em; color: var(--muted); background: var(--panel); text-align: center; }
@container (max-width: 130px) {            /* beside a 300 px Twitch player on a phone: links only, one per line */
  .player .ptitle { display: none; }
  .player .phint { flex-direction: column; align-items: flex-start; flex-wrap: nowrap; gap: 0; margin-top: 0; }
  .player .phint .linkbtn.x { margin-left: 0; }
}

/* ---------- phones (upright or sideways): a slim top so chat gets the screen ---------- */
  :where(html.gs-slim) #top { gap: 6px; padding: calc(3px + var(--safe-t)) 6px 3px; }
  :where(html.gs-slim) #top .pill { min-height: 28px; padding: 1px 7px 1px 3px; }
  :where(html.gs-slim) #top .iconbtn { width: 36px; height: 30px; }
  :where(html.gs-slim) .rushbar { min-height: 34px; padding: 2px 6px; gap: 6px; }
  :where(html.gs-slim) .rushbar .btn.xs { min-height: 30px; padding: 2px 9px; }
  :where(html.gs-slim) .adbar { min-height: 30px; padding: 2px 8px; gap: 8px; font-size: 12px; flex-wrap: nowrap; overflow: hidden; white-space: nowrap; }
  :where(html.gs-slim) .adbar .btn.xs { min-height: 26px; padding: 1px 8px; }
  :where(html.gs-slim) .adbar > * { flex: none; } :where(html.gs-slim) .adbar > .hype { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  :where(html.gs-slim) .monitor { flex-wrap: nowrap; align-items: stretch; gap: 4px; padding: 3px 6px; }
  :where(html.gs-slim) .monitor.detail { flex-wrap: wrap; }
  :where(html.gs-slim) .mcell { display: flex; flex-direction: column; justify-content: center; padding: 2px 7px; border-radius: 8px; }
  :where(html.gs-slim) .mcell .mv { font-size: 1em; }
  :where(html.gs-slim) .mcell .ml { font-size: .6em; line-height: 1.25; }
  :where(html.gs-slim) .mcell.dur .ml, :where(html.gs-slim) .mcell.vw .ml, :where(html.gs-slim) .tvbtn .ml { display: none; }
  :where(html.gs-slim) .mcell.dur.on .mv::before { content: '●'; color: var(--err); font-size: .55em; margin-right: 4px; vertical-align: 2px; }
  :where(html.gs-slim) .mcell.br { position: relative; flex: 1 1 92px; padding: 2px 16px 5px 7px; cursor: pointer; }
  :where(html.gs-slim) .mcell.br::after { content: '▾'; position: absolute; right: 5px; top: 3px; font-size: .7em; color: var(--muted); }
  :where(html.gs-slim) .monitor.detail .mcell.br::after { content: '▴'; }
  :where(html.gs-slim) .mcell.br .meter { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; margin: 0; border-radius: 0; }
  :where(html.gs-slim) .monitor:not(.detail) .mcell.br .links { display: none; }
  :where(html.gs-slim) .monitor.detail .mcell.br { order: 9; flex: 1 0 100%; padding-bottom: 7px; }
  :where(html.gs-slim) .mcell.vw { flex: 0 1 auto; min-width: 0; max-width: 36vw; }
  :where(html.gs-slim) .mcell.vw .vrow { display: flex; flex-wrap: wrap; gap: 0 7px; line-height: 1.2; }
  :where(html.gs-slim) .vchip { font-size: .86em; }
  :where(html.gs-slim) .mcell.tvbtn { flex: none; padding: 2px 8px; }

/* ---------- rush meter card: nothing wider than the card; on phones one tidy column ---------- */
.rush-card { min-width: 0; overflow-wrap: anywhere; }
.rush-song { grid-template-columns: minmax(0, 1fr); }
.list .rush-song { padding: 6px 8px; }          /* .list .item zeroed the side padding, so the row sat under its highlight bar */
.rush-song > label { min-width: 0; }
.rush-song-opts { display: flex; align-items: center; gap: 6px 10px; min-width: 0; }
.rush-song-opts label { display: inline-flex; align-items: center; gap: 5px; }
.rush-song-opts .num { width: 62px !important; }
.rush-controls .chips .num { width: 76px !important; }
.rush-card .rush-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.rush-card .rush-head h3 { margin: 0; }
.rush-card .rush-head.sticky { position: sticky; top: -10px; z-index: 4; margin: -12px -12px 8px; padding: 6px 8px 6px 12px; background: var(--panel); border-bottom: 1px solid var(--line); border-radius: 12px 12px 0 0; }
.rushbar .btn.open { border-color: var(--accent); background: var(--panel2); color: var(--fg); }
#view-tools, #view-obs, #view-settings, #view-board, #view-events { container-type: inline-size; }
@container (max-width: 560px) {
  .rush-card .wide-only { display: none; }
  .rush-card .rush-big { flex: none; }
  /* one setting per line: name on the left, its field on the right */
  #toolsView label.row:not(.item) { flex: 1 1 100%; justify-content: space-between; min-width: 0; min-height: 44px; }
  #toolsView label.row:not(.item) > select { flex: 0 1 auto; min-width: 0; max-width: 100%; }
  #toolsView label.row:not(.item):has(> select) { white-space: nowrap; }
  .rush-card [data-rush="listen"] { flex: 1 1 100%; }
  #toolsView .chips { gap: 4px 8px; }
  .rush-card input[type="file"] { width: 100%; min-width: 0; }
  .rush-song-opts .num { width: 56px !important; padding-left: 8px; padding-right: 4px; }
  .rush-controls .chips { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .rush-controls .chips > .btn { padding-left: 4px; padding-right: 4px; }
  .rush-controls .chips > .num { grid-column: span 2; width: 100% !important; }
  .rush-controls .chips + .chips > * { grid-column: span 2; }
  /* OBS audio: the name gets its own line (two "IRLTools …" looked the same), the fader the full width */
  .arow { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "btn name db" "vol vol vol"; gap: 4px 8px; align-items: center; }
  .arow > .btn { grid-area: btn; } .arow > .aname { grid-area: name; } .arow > .db { grid-area: db; width: auto; }
  .arow > .vol { grid-area: vol; width: 100%; min-height: 32px; }
}
.rush-card details strong.small { display: block; margin-top: 8px; }

/* ---------- small fixes found on a phone ---------- */
input[type="checkbox"], input[type="radio"] { flex: none; }            /* long labels squeezed the box */
small.block { display: block; margin-top: 2px; }
.nowrap { flex-wrap: nowrap; white-space: nowrap; }
.form label.btn { display: inline-flex; align-items: center; justify-content: center; font-size: 1em; }   /* "Import settings" */
/* the whole header of a settings section is the tap target, not just its text */
details.setting > summary { margin: -12px; padding: 12px; min-height: 46px; box-sizing: border-box; }
details.setting[open] > summary { margin-bottom: 0; padding-bottom: 6px; }
/* edit arrows stay readable on light custom-coloured tiles */
.tile .edit-ctrl .btn { background: #000c; color: #fff; border-color: #ffffff55; }
/* small controls keep their size but get a finger-sized hit area */
@media (pointer: coarse) {
  #top .pill, .linkbtn, .adbar .btn.xs, .rushbar .btn.xs { position: relative; }
  #top .pill::after, .linkbtn::after, .player .psize::after, .adbar .btn.xs::after, .rushbar .btn.xs::after { content: ''; position: absolute; inset: -5px -3px; }
}

/* ---------- screen lock + rain mode (js/lock.js) ---------- */
.rain-shield { position: fixed; inset: 0; z-index: 2000; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; box-shadow: inset 0 0 0 2px #4aa3ff66; }
.rain-track { position: absolute; left: 50%; bottom: calc(16px + var(--safe-b)); transform: translateX(-50%); width: min(340px, 88vw); height: 60px; border-radius: 30px; background: #0b1220f2; border: 1px solid #4aa3ff99; box-shadow: 0 6px 24px #000a; overflow: hidden; touch-action: none; }
.rain-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: #4aa3ff3d; }
.rain-label { position: absolute; inset: 0; display: grid; place-items: center; padding-left: 52px; font-size: .82em; font-weight: 700; color: #cfe6ff; letter-spacing: .2px; pointer-events: none; white-space: nowrap; }
.rain-thumb { position: absolute; left: 4px; top: 4px; width: 52px; height: 52px; border-radius: 50%; background: #4aa3ff; color: #04121f; display: grid; place-items: center; font-size: 1.3em; font-weight: 900; touch-action: none; cursor: grab; transition: transform .2s; }
.rain-thumb.drag { transition: none; cursor: grabbing; }
html.gs-rain #toasts { z-index: 2100; }

/* ---------- Web tab (js/webtab.js): your own pages, like browser sources ---------- */
.webview { display: grid; grid-template-rows: auto minmax(0, 1fr); grid-template-columns: minmax(0, 1fr); min-height: 0; }
#view-web { overflow: hidden; display: grid; grid-template-rows: minmax(0, 1fr); grid-template-columns: minmax(0, 1fr); }
.webbar { display: flex; align-items: center; gap: 6px; padding: 5px 8px; background: var(--panel); border-bottom: 1px solid var(--line); min-width: 0; }
.webchips { display: flex; gap: 6px; overflow-x: auto; flex: 1; min-width: 0; scrollbar-width: none; }
.webchips::-webkit-scrollbar { display: none; }
.webchips .chip { min-height: 34px; padding: 4px 12px; white-space: nowrap; }
.webchips .chip.add { border-style: dashed; }
.webtools { display: flex; gap: 4px; flex: none; }
.webtools .btn.xs { min-width: 36px; min-height: 34px; padding: 2px 8px; font-size: 1em; }
.webstage { position: relative; min-height: 0; overflow: hidden; background: var(--panel); }
.wframe { position: absolute; inset: 0; }
.wframe.off { visibility: hidden; pointer-events: none; }        /* still loaded, not on show (and not rendered: the browser pauses it) */
/* "Keep running on other tabs": the page stays RENDERED, only unseen. A frame that is display: none or visibility: hidden
   gets no animation frames — animations, their end events and (on phones) video stop — and an alert overlay stalls. */
.wframe.off.bg { visibility: visible; opacity: 0; }
#view-web.keepalive[hidden] { display: grid !important; position: fixed !important; left: 0; top: 0; width: 100vw; height: 100vh; height: 100dvh; z-index: -1; opacity: 0; pointer-events: none; }
#view-web.keepalive[hidden] .wframe:not(.bg) { visibility: hidden; }
.wframe iframe { border: 0; display: block; background: transparent; }
.wframe.fit iframe { width: 100%; height: 100%; background: #fff; }
.wframe.canvas { background: repeating-conic-gradient(#1d1d24 0 25%, #17171d 0 50%) 0 0 / 24px 24px; }   /* transparent overlays read on this */
.wframe.canvas iframe { position: absolute; top: 0; left: 0; transform-origin: 0 0; }
.wframe.note { display: grid; place-items: center; padding: 20px; background: var(--panel); }
.webnote { max-width: 420px; text-align: center; display: grid; gap: 12px; justify-items: center; }
.webnote p { margin: 0; color: var(--muted); }
.webnote .btn { white-space: normal; }
.webempty { position: absolute; inset: 0; overflow-y: auto; padding: 18px 14px; display: grid; gap: 10px; align-content: start; }
.webempty h3 { margin: 0; }
.webempty p { margin: 0; }
.webcheck { margin: 0; }
.webtools .btn.is-muted { background: #3a1517; border-color: #6b2226; color: #ffb4b6; }
.webkinds { margin-bottom: 2px; }
.keyrow > input { flex: 1; min-width: 0; }
.filter-found { margin-top: -4px; }
/* seven tabs: keep the labels on one line on narrow phones */
@media (max-width: 430px) { .tabs button { font-size: .72em; padding-left: 0; padding-right: 0; } }

/* ---------- themes (Settings → Appearance; palettes for js/theme.js) ---------- */
html[data-theme="sakura"] { --bg: #1a0f18; --panel: #251624; --panel2: #311d2f; --line: #4d2e47; --fg: #ffeaf4; --muted: #c79bb5; --accent: #ff6fb1; --on-accent: #33081d; --link: #ffa6d0; }
html[data-theme="christmas"] { --bg: #0c1a14; --panel: #12261c; --panel2: #183226; --line: #26503b; --fg: #f4f1e6; --muted: #9fb8a6; --accent: #e0393e; --warn: #f2c14e; --link: #ffb3a8; }
html[data-theme="halloween"] { --bg: #140d1c; --panel: #1e1429; --panel2: #2a1b38; --line: #44305a; --fg: #f3e9ff; --muted: #a892bf; --accent: #ff7a1a; --on-accent: #2a1200; --link: #ffb37a; }
html[data-theme="cute"] {
  color-scheme: light; --tint: 120 30 70; --link: #c2307a;
  --bg: #fff5f9; --panel: #ffe9f2; --panel2: #ffd9e8; --line: #f5b5d0; --fg: #4a2338; --muted: #94607c; --accent: #f0468f;
  --ok: #12925a; --warn: #c97a00; --err: #d6333a;
}
html[data-theme="lavender"] {
  color-scheme: light; --tint: 60 40 130; --link: #6a41d8;
  --bg: #f7f4ff; --panel: #ece6ff; --panel2: #dfd6ff; --line: #c6b8f2; --fg: #2c2550; --muted: #736a9c; --accent: #7c57ee;
  --ok: #12925a; --warn: #b87400; --err: #d6333a;
}
/* light themes: the warning / good / error tints that were mixed for a dark page */
html[data-scheme="light"] .btn:hover { border-color: var(--accent); }
html[data-scheme="light"] .tile .sw::after { background: #fff; box-shadow: 0 0 0 1px #0003; }
html[data-scheme="light"] .tile:not(.red):not(.orange):not(.green):not(.blue):not(.purple):not(.pink):not(.gray):not(.custom) .sw { background: rgb(var(--tint) / .25); }
html[data-scheme="light"] .tile.missing { border-color: var(--warn); }
html[data-scheme="light"] .tile .tile-warn { color: var(--warn); }
/* cute touches: rounder corners, a mark on the logo */
html[data-theme="cute"] .btn, html[data-theme="cute"] .chip, html[data-theme="lavender"] .btn, html[data-theme="lavender"] .chip { border-radius: 999px; }
.brand[data-badge]:not([data-badge=""])::after { content: ' ' attr(data-badge); font-weight: 400; }
/* decorations: drift down over everything, never in the way of a tap */
#themeFx { position: fixed; inset: 0; z-index: 40; pointer-events: none; overflow: hidden; contain: strict; }
#themeFx i { position: absolute; top: -6%; font-style: normal; line-height: 1; opacity: .5; animation: fx-fall linear infinite; will-change: transform; }
@keyframes fx-fall { to { transform: translate3d(var(--dx, 20px), 112vh, 0) rotate(var(--rot, 180deg)); } }
@media (prefers-reduced-motion: reduce) { #themeFx { display: none; } }
html.gs-rain #themeFx { display: none; }
/* the picker */
.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 8px; }
.themebtn { display: flex; align-items: center; gap: 8px; min-height: 46px; padding: 6px 10px; border-radius: 12px; border: 2px solid var(--line); background: var(--panel2); color: var(--fg); font-weight: 600; cursor: pointer; text-align: left; }
.themebtn.on { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.themedots { display: flex; flex: none; }
.themedots i { width: 18px; height: 18px; border-radius: 50%; border: 1px solid #0004; }
.themedots i + i { margin-left: -6px; }

/* typing with the on-screen keyboard up (html.gs-kb, main.js): the tab bar steps aside so chat keeps the room */
html.gs-kb body[data-layout="1"] #tabs { display: none; }
html.gs-kb .sheet { max-height: 96%; }

/* OBS tab: audio sources can be hidden from the list (Hide / show…) */
.cardhead { margin-bottom: 6px; } .cardhead > h3 { margin: 0; }
.arow.hid { opacity: .55; }
.mutednow { margin: 0 0 8px; align-items: center; }

/* ---- Tools → TTS on stream ---- */
#ttsCard .ttsvoices { display: grid; gap: 6px; margin: 6px 0; }
#ttsCard .ttsvoice { align-items: center; flex-wrap: nowrap; }
#ttsCard .ttsvoice .ttslang { flex: none; min-width: 4.4em; }
#ttsCard .ttsvoice select { min-width: 0; flex: 1; }
#ttsCard .ttsline { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 6px 0; }
#ttsCard .ttsline .ttshead { flex: none; min-width: 4.4em; }
#ttsCard .ttsline select { flex: 1 1 17em; min-width: min(100%, 17em); width: auto; }
#ttsCard .ttsline label.ttshead { margin: 0; min-height: 44px; }
#ttsCard small.block { display: block; margin: 2px 0 6px; }
#ttsCard small.warn { color: var(--warn); }

/* ---------- Tools: a menu, one tool per page (js/tools-hub.js) ---------- */
.tools-hub { display: grid; gap: 8px; }
.tool-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; font: inherit; color: var(--fg);
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; min-height: 64px; cursor: pointer;
}
.tool-row:active { background: var(--panel2); }
.tool-row .tool-ico { flex: none; width: 34px; height: 34px; display: grid; place-items: center; font-size: 1.35em; border-radius: 10px; background: var(--panel2); }
.tool-row .tool-txt { flex: 1; min-width: 0; display: grid; gap: 2px; }
.tool-row .tool-txt strong { font-size: 1.02em; }
.tool-row .tool-txt small { color: var(--muted); font-size: .85em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-row .tool-go { flex: none; color: var(--muted); font-size: 1.5em; line-height: 1; }
.tool-row .tool-badge { flex: none; min-width: 22px; height: 22px; border-radius: 999px; display: grid; place-items: center; background: var(--warn); color: #201400; font-weight: 800; font-size: .8em; }
.tool-row.warn { border-color: color-mix(in srgb, var(--warn) 55%, var(--line)); }
.tool-row.ok .tool-txt small { color: var(--ok); }
.tool-row[data-tools="check"] .tool-ico { background: color-mix(in srgb, var(--ok) 22%, var(--panel2)); }
.tools-top {
  position: sticky; top: -12px; z-index: 3; display: flex; align-items: center; gap: 10px; margin: -12px -12px 12px; padding: 10px 12px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.tools-top .tools-title { font-size: 1.05em; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tools-page > .card > h3:first-child, .tools-page .rush-head h3 { display: none; }    /* the bar above says it */
.tools-page .rush-head { display: none; }    /* its Close is the bar's ✕ Close */
.tools-page > .card { margin-bottom: 10px; }
.tools-alerts > .card h4:first-child, .setup-check > .card h4:first-child { margin-top: 0; }

/* status line: ✓ ok · ! needs a look · ✕ not working · – off */
.statusline { display: flex; align-items: flex-start; gap: 8px; margin: 4px 0 8px; }
.statusline .sl-ico { flex: none; width: 20px; height: 20px; border-radius: 999px; display: grid; place-items: center; font-size: .75em; font-weight: 900; margin-top: 1px; background: var(--panel2); color: var(--muted); }
.statusline.ok .sl-ico { background: var(--ok); color: #03200f; }
.statusline.warn .sl-ico { background: var(--warn); color: #201400; }
.statusline.bad .sl-ico { background: var(--err); color: #fff; }

/* on / off rows */
.switchrow { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.switchrow:last-of-type { border-bottom: 0; }
input.switch { appearance: none; -webkit-appearance: none; flex: none; width: 48px !important; height: 28px !important; min-height: 0; border-radius: 999px; background: var(--panel2); border: 1px solid var(--line); position: relative; cursor: pointer; transition: background .15s; margin: 0; }
input.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 999px; background: var(--muted); transition: transform .15s, background .15s; }
input.switch:checked { background: var(--accent); border-color: var(--accent); }
input.switch:checked::after { transform: translateX(20px); background: var(--on-accent); }

/* "More options" folds */
details.more { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 4px; }
details.more > summary { cursor: pointer; color: var(--muted); font-weight: 700; list-style: none; min-height: 44px; display: flex; align-items: center; gap: 6px; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: '▸'; }
details.more[open] > summary::before { content: '▾'; }
details.more > :not(summary) { margin-top: 6px; }
.form details.more strong { display: block; margin-top: 10px; }

/* setup check rows */
.checkrow { display: flex; align-items: flex-start; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.checkrow:last-of-type { border-bottom: 0; }
.checkrow > .statusline { flex: 1; margin: 0; min-width: 0; }
.checkrow > .statusline .grow { overflow-wrap: anywhere; }
.checkrow > .btn { flex: none; }
.checkrow.optional strong { color: var(--muted); }
