/* Trace — app styles.
   Why: mobile-first, dark "Carbon Gradient". Audited for no horizontal scroll at
   360px; tab bar on phones, top nav on desktop; shared audio dock at the bottom. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overscroll-behavior: none; background: var(--bg); }
body {
  margin: 0; min-height: 100dvh; background: var(--bg); color: var(--text);
  font: 15px/1.5 var(--font); overscroll-behavior: none; overflow-x: hidden;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
body::before {
  content: ""; position: fixed; inset: -20% -10% auto; height: 60vh; pointer-events: none; z-index: -1;
  background: radial-gradient(ellipse at 20% 0%, rgba(26, 143, 196, 0.14), transparent 60%),
              radial-gradient(ellipse at 80% 0%, rgba(147, 51, 234, 0.12), transparent 55%);
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: 1.45rem; font-weight: 700; }
h2 { font-size: 1rem; font-weight: 650; }
p { margin: 0; }
[hidden] { display: none !important; }
.icon { flex: none; display: block; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 0.85em; }
.nowrap { white-space: nowrap; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.center { display: flex; justify-content: center; align-items: center; padding: 32px 0; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface-3); padding: 8px 12px; border-radius: var(--r-sm); z-index: 100; }
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--c2); outline-offset: 2px; border-radius: 6px; }

/* ---- Boot / spinner ---- */
.boot { min-height: 100dvh; display: grid; place-items: center; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--surface-3); border-top-color: var(--c2); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--top-h);
  display: flex; align-items: center; gap: 20px; padding: 0 var(--gutter);
  padding-top: env(safe-area-inset-top);
  background: rgba(6, 5, 9, 0.78); backdrop-filter: blur(14px) saturate(140%); -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-name { font-weight: 750; font-size: 1.15rem; letter-spacing: -0.02em; }
.brand-sub { color: var(--muted); font-size: 0.78rem; padding-left: 10px; border-left: 1px solid var(--line-2); white-space: nowrap; }
.topnav { display: none; gap: 4px; margin-left: 12px; }
.navlink { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px; color: var(--text-2); font-weight: 550; font-size: 0.92rem; transition: background 0.15s, color 0.15s; }
.navlink:hover { background: var(--surface-2); color: var(--text); }
.navlink.active { background: var(--grad-soft); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }
.who { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.who-name { color: var(--text-2); font-size: 0.88rem; display: none; }

/* ---- Tab bar (phones) ---- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: rgba(10, 9, 14, 0.92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tab { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 0.7rem; font-weight: 600; }
.tab span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tab.active { color: var(--text); }
.tab.active .icon { color: var(--c3); }

/* ---- Main / pages ---- */
.main { max-width: var(--maxw); margin: 0 auto; padding: 20px var(--gutter) calc(var(--tab-h) + 32px + env(safe-area-inset-bottom)); outline: none; }
body.has-dock .main { padding-bottom: calc(var(--tab-h) + var(--dock-h) + 40px + env(safe-area-inset-bottom)); }
.page { display: flex; flex-direction: column; gap: 18px; }
.page-head { display: flex; flex-direction: column; gap: 4px; }
.page-head.row { flex-direction: row; align-items: flex-end; flex-wrap: wrap; }

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 16px; border-radius: 11px; border: 0; cursor: pointer; font-weight: 600; font-size: 0.92rem; white-space: nowrap; transition: transform 0.08s, filter 0.15s, background 0.15s; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 6px 20px rgba(147, 51, 234, 0.28); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-danger { background: rgba(248, 113, 113, 0.15); color: var(--bad); box-shadow: inset 0 0 0 1px rgba(248, 113, 113, 0.35); }
.btn-sm { height: 34px; padding: 0 12px; font-size: 0.85rem; border-radius: 9px; }
.btn-block { width: 100%; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; border: 0; background: transparent; color: var(--text-2); cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.round { border-radius: 50%; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.icon-btn.disabled { opacity: 0.3; pointer-events: none; }

/* ---- Chips & badges ---- */
.chip { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 0.75rem; font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.chip-dim { background: transparent; box-shadow: inset 0 0 0 1px var(--line-2); color: var(--muted); }
.chip-lang { background: var(--grad-soft); color: var(--text); }
.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 0.74rem; font-weight: 650; white-space: nowrap; flex: none; }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-ok { color: var(--ok); background: rgba(52, 211, 153, 0.1); }
.badge-wait { color: var(--text-2); background: var(--surface-3); }
.badge-work { color: #c4b5fd; background: rgba(147, 51, 234, 0.16); }
.badge-work .dot { animation: pulse 1.2s ease-in-out infinite; }
.badge-bad { color: var(--bad); background: rgba(248, 113, 113, 0.12); }
@keyframes pulse { 50% { opacity: 0.3; } }

/* ---- Day view ---- */
.day-head { display: flex; flex-direction: column; gap: 12px; }
.day-nav { display: flex; align-items: center; gap: 12px; }
.day-title { flex: 1; min-width: 0; text-align: center; }
.day-title h1 { font-size: 1.25rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day-sub { color: var(--muted); font-size: 0.8rem; }
.day-tools { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.date-pick { position: relative; display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 10px; border-radius: 9px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-2); color: var(--text-2); }
.date-input { background: transparent; border: 0; color: var(--text); font-size: 0.85rem; color-scheme: dark; width: 128px; }
.select-sm, select { height: 34px; border-radius: 9px; border: 0; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-2); padding: 0 10px; color: var(--text); color-scheme: dark; max-width: 100%; }

.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: var(--r); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); min-width: 0; }
.stat > div:last-child { min-width: 0; }
.stat-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--grad-soft); color: var(--text); flex: none; }
.stat-value { font-weight: 700; font-size: 1.08rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: 0.76rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.activity { padding: 14px 14px 10px; border-radius: var(--r); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.activity-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.activity-head .muted { font-size: 0.78rem; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 92px; }
.bar { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; border: 0; background: transparent; padding: 0; cursor: pointer; }
.bar-fill { width: 100%; max-width: 26px; border-radius: 5px 5px 2px 2px; background: var(--grad); background-size: 100% 300%; min-height: 0; transition: filter 0.15s; }
.bar:hover .bar-fill { filter: brightness(1.25); }
.bar.zero { cursor: default; }
.bar.zero::before { content: ""; width: 100%; max-width: 26px; height: 3px; border-radius: 2px; background: var(--surface-3); }
.bar-label { font-size: 0.66rem; color: var(--muted); height: 14px; font-variant-numeric: tabular-nums; }

.timeline { display: flex; flex-direction: column; gap: 22px; }
.hour-group { display: flex; flex-direction: column; gap: 10px; scroll-margin-top: calc(var(--top-h) + 12px); }
.hour-label { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-weight: 700; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.hour-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.hour-count { color: var(--muted); font-weight: 500; font-size: 0.78rem; order: 2; }
.hour-label::after { order: 1; }

.clip { border-radius: var(--r-lg); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; transition: box-shadow 0.2s; scroll-margin-top: calc(var(--top-h) + 16px); }
.clip.playing { box-shadow: inset 0 0 0 1px rgba(147, 51, 234, 0.55), 0 0 0 4px rgba(147, 51, 234, 0.08); }
.clip.focus { box-shadow: inset 0 0 0 1px rgba(26, 143, 196, 0.6); }
.clip-head { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.play-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; display: grid; place-items: center; background: var(--grad); color: #fff; cursor: pointer; flex: none; box-shadow: 0 4px 14px rgba(147, 51, 234, 0.3); }
.play-btn:active { transform: scale(0.95); }
.clip-when { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.clip-time { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clip-to { color: var(--muted); font-weight: 500; }
.clip-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.lines { list-style: none; margin: 0; padding: 4px 6px 10px; border-top: 1px solid var(--line); }
.line { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; padding: 7px 8px; border-radius: 9px; cursor: pointer; transition: background 0.12s; }
.line:hover { background: var(--surface-2); }
.line.active { background: var(--grad-soft); box-shadow: inset 2px 0 0 var(--c3); }
.line.found { box-shadow: inset 2px 0 0 var(--c1); background: rgba(26, 143, 196, 0.1); }
.line-time { font-family: var(--mono); font-size: 0.78rem; color: var(--muted); padding-top: 2px; font-variant-numeric: tabular-nums; }
.line.active .line-time { color: var(--text); }
.line-text { overflow-wrap: anywhere; color: var(--text); }
.clip-note { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 14px 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.88rem; }
.clip-note.err { color: var(--bad); }
.shimmer-lines { display: flex; flex-direction: column; gap: 8px; padding: 14px; border-top: 1px solid var(--line); }
.shimmer-lines span { height: 10px; border-radius: 5px; background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.shimmer-lines span.short { width: 55%; }
@keyframes shimmer { to { background-position: -200% 0; } }

.clip-del { color: var(--muted); }
.clip-del:hover { color: var(--bad); background: rgba(248, 113, 113, 0.1); }
.day-actions:empty { display: none; }
.notice { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px 10px 14px; border-radius: var(--r); background: rgba(248, 113, 113, 0.07); color: #fecaca; box-shadow: inset 0 0 0 1px rgba(248, 113, 113, 0.25); font-size: 0.9rem; }
.notice span { flex: 1; min-width: 160px; }

/* ---- Empty / error ---- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 48px 20px; border-radius: var(--r-lg); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.empty-icon { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--grad-soft); margin-bottom: 4px; }
.empty p { color: var(--muted); max-width: 360px; font-size: 0.9rem; }
.error-box { display: flex; align-items: center; gap: 10px; padding: 14px; border-radius: var(--r); background: rgba(248, 113, 113, 0.08); color: var(--bad); box-shadow: inset 0 0 0 1px rgba(248, 113, 113, 0.25); }

/* ---- Search ---- */
.search-bar { display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 14px; border-radius: 14px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-2); color: var(--muted); }
.search-bar:focus-within { box-shadow: inset 0 0 0 1px var(--c2), 0 0 0 4px rgba(147, 51, 234, 0.12); }
.search-input { flex: 1; min-width: 0; height: 42px; border: 0; background: transparent; outline: none; color: var(--text); font-size: 1rem; }
.search-input::-webkit-search-cancel-button { filter: invert(1); }
.results { display: flex; flex-direction: column; gap: 18px; }
.result-count { color: var(--muted); font-size: 0.85rem; }
.result-day { display: flex; flex-direction: column; gap: 6px; }
.result-day h2 { font-size: 0.85rem; color: var(--text-2); margin-bottom: 2px; }
.result { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 11px 12px; border-radius: var(--r); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); transition: background 0.12s; }
.result:hover { background: var(--surface-2); }
.result-text { overflow-wrap: anywhere; }
mark { background: rgba(244, 63, 127, 0.25); color: #fff; border-radius: 3px; padding: 0 2px; }

/* ---- Devices ---- */
.sys { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.sys-tile { padding: 14px; border-radius: var(--r); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); min-width: 0; position: relative; overflow: hidden; }
.sys-tile::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--ok); }
.sys-tile.tone-warn::before { background: var(--warn); }
.sys-tile.tone-bad::before { background: var(--bad); }
.sys-top { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.78rem; font-weight: 600; }
.sys-value { font-weight: 700; font-size: 1.05rem; margin: 6px 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sys-sub { color: var(--muted); font-size: 0.75rem; overflow-wrap: anywhere; }
.device-grid { display: grid; gap: 12px; }
.device { padding: 16px; border-radius: var(--r-lg); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); display: flex; flex-direction: column; gap: 14px; }
.device.off { opacity: 0.6; }
.device-head { display: flex; align-items: center; gap: 12px; }
.device-head > div { flex: 1; min-width: 0; }
.device-head h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-head .muted { font-size: 0.82rem; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.status-dot.on { background: var(--ok); box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.15); animation: glow 2s ease-in-out infinite; }
.status-dot.down { background: var(--bad); }
@keyframes glow { 50% { box-shadow: 0 0 0 7px rgba(52, 211, 153, 0.05); } }
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 16px; margin: 0; font-size: 0.86rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.setting-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.device-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 12px; border-top: 1px solid var(--line); }
.mic-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px; border-radius: var(--r); background: var(--bg-2); box-shadow: inset 0 0 0 1px var(--line); }
.mic-row.off { box-shadow: inset 0 0 0 1px rgba(248, 113, 113, 0.35); background: rgba(248, 113, 113, 0.06); }
.mic-state { flex: 1; min-width: 170px; display: flex; align-items: center; gap: 10px; }
.mic-state > div { display: flex; flex-direction: column; }
.mic-row.on .mic-state .icon { color: var(--ok); }
.mic-row.off .mic-state .icon { color: var(--bad); }
.mic-off-note { display: flex; align-items: center; gap: 8px; color: var(--bad); font-size: 0.86rem; }
.token-box { display: flex; align-items: flex-start; gap: 8px; padding: 12px; border-radius: var(--r); background: var(--bg-2); box-shadow: inset 0 0 0 1px var(--line-2); }
.token-box code { flex: 1; min-width: 0; font-family: var(--mono); font-size: 0.8rem; overflow-wrap: anywhere; color: #c4b5fd; }
.warn-note { display: flex; gap: 8px; align-items: flex-start; color: var(--warn); font-size: 0.84rem; }
.warn-note .icon { margin-top: 2px; }

/* ---- Forms ---- */
.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 0.82rem; font-weight: 600; color: var(--text-2); }
.field-hint { font-size: 0.76rem; color: var(--muted); }
.field input:not([type=range]):not([type=checkbox]), .field select {
  height: 44px; padding: 0 12px; border-radius: 11px; border: 0; background: var(--bg-2); box-shadow: inset 0 0 0 1px var(--line-2); color: var(--text); outline: none; width: 100%;
}
.field input:focus { box-shadow: inset 0 0 0 1px var(--c2), 0 0 0 4px rgba(147, 51, 234, 0.12); }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; padding-top: 4px; }
.form-error { color: var(--bad); font-size: 0.86rem; background: rgba(248, 113, 113, 0.08); padding: 10px 12px; border-radius: 10px; }
input[type=range] { width: 100%; accent-color: var(--c2); height: 28px; }
.range-val { font-family: var(--mono); color: var(--text); font-size: 0.82rem; }
.switch-row { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: var(--r); background: var(--bg-2); box-shadow: inset 0 0 0 1px var(--line); cursor: pointer; position: relative; }
.switch-row > span:first-child { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch { width: 44px; height: 26px; border-radius: 13px; background: var(--surface-3); position: relative; flex: none; transition: background 0.15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch-row input:checked + .switch { background: var(--c2); }
.switch-row input:checked + .switch::after { transform: translateX(18px); }
.switch-row input:disabled + .switch { opacity: 0.4; }
.switch-row input:focus-visible + .switch { outline: 2px solid var(--c2); outline-offset: 2px; }

/* ---- Sheets ---- */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(3px); display: flex; align-items: flex-end; justify-content: center; animation: fade 0.18s ease; overscroll-behavior: contain; }
.sheet { width: 100%; max-height: 90dvh; display: flex; flex-direction: column; background: var(--surface); border-radius: 20px 20px 0 0; box-shadow: var(--shadow), inset 0 1px 0 var(--line-2); animation: up 0.22s cubic-bezier(0.2, 0.9, 0.3, 1); padding-bottom: env(safe-area-inset-bottom); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 14px 10px 20px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-body { padding: 18px 20px 22px; overflow-y: auto; overscroll-behavior: contain; }
.sheet-wrap.closing { animation: fade 0.18s ease reverse forwards; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }

/* ---- Toasts ---- */
.toasts { position: fixed; left: 50%; transform: translateX(-50%); top: calc(var(--top-h) + 10px + env(safe-area-inset-top)); z-index: 60; display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100% - 32px)); pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--surface-3); box-shadow: var(--shadow); font-size: 0.9rem; animation: up 0.2s ease; transition: opacity 0.4s, transform 0.4s; }
.toast-error { color: #fecaca; box-shadow: var(--shadow), inset 0 0 0 1px rgba(248, 113, 113, 0.35); }
.toast-info .icon { color: var(--ok); }
.toast.out { opacity: 0; transform: translateY(-8px); }

/* ---- Audio dock ---- */
.dock { position: fixed; left: 0; right: 0; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); z-index: 19; padding: 0 10px 10px; pointer-events: none; }
.dock-inner { pointer-events: auto; max-width: 760px; margin: 0 auto; display: flex; align-items: center; gap: 4px; padding: 10px 8px 10px 10px; border-radius: 18px; background: rgba(23, 20, 31, 0.94); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); box-shadow: var(--shadow), inset 0 0 0 1px var(--line-2); }
.dock-play { width: 44px; height: 44px; border-radius: 50%; border: 0; display: grid; place-items: center; background: var(--grad); color: #fff; cursor: pointer; flex: none; }
.dock-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; padding: 0 8px; }
.dock-row { display: flex; justify-content: space-between; gap: 8px; font-size: 0.84rem; }
.dock-title { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.dock-wall { font-family: var(--mono); color: #c4b5fd; font-size: 0.8rem; flex: none; }
.dock-bar { height: 6px; border-radius: 3px; background: var(--surface-3); cursor: pointer; position: relative; }
.dock-fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 3px; background: var(--grad); }
.dock-time { font-size: 0.72rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.dock .icon-btn { width: 34px; height: 34px; }
.dock-close { margin-left: 2px; }

/* ---- Tables / log ---- */
.table-wrap { overflow-x: auto; border-radius: var(--r-lg); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.04em; padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table td.detail { color: var(--text-2); overflow-wrap: anywhere; min-width: 140px; }
.row-bad td { background: rgba(248, 113, 113, 0.05); }
.hide-sm { display: none; }

/* ---- Users ---- */
.user-list { display: flex; flex-direction: column; gap: 8px; }
.user-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--r); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); flex-wrap: wrap; }
.user-row.off { opacity: 0.55; }
.avatar { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-weight: 700; background: var(--grad); color: #fff; flex: none; }
.user-main { flex: 1; min-width: 120px; display: flex; flex-direction: column; }
.user-main .muted { font-size: 0.8rem; }

/* ---- Login ---- */
.login-main { min-height: 100dvh; display: grid; place-items: center; padding: 24px var(--gutter); position: relative; overflow: hidden; }
.login-bg { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(circle at 30% 20%, rgba(26, 143, 196, 0.22), transparent 45%), radial-gradient(circle at 75% 75%, rgba(244, 63, 127, 0.16), transparent 45%), radial-gradient(circle at 60% 35%, rgba(147, 51, 234, 0.18), transparent 50%); }
.login-card { position: relative; width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 16px; padding: 28px 24px; border-radius: 24px; background: rgba(17, 15, 24, 0.82); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); box-shadow: var(--shadow), inset 0 0 0 1px var(--line-2); }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 8px; text-align: center; }
.login-brand h1 { font-size: 1.9rem; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-brand p { color: var(--muted); font-size: 0.9rem; }
.login-note { display: flex; align-items: center; justify-content: center; gap: 6px; color: var(--muted); font-size: 0.76rem; text-align: center; }

/* ---- Breakpoints ---- */
@media (min-width: 640px) {
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .sys { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .device-grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
  .day-head { flex-direction: row; align-items: center; justify-content: space-between; }
  .day-nav { flex: 1; min-width: 0; }
  .day-title { text-align: left; flex: none; min-width: 0; order: 0; }
  .day-title h1 { font-size: 1.45rem; }
  .day-tools { justify-content: flex-end; }
  .hide-sm { display: table-cell; }
  .sheet-wrap { align-items: center; padding: 24px; }
  .sheet { max-width: 480px; border-radius: 20px; }
  .sheet.wide { max-width: 640px; }
}
@media (min-width: 900px) {
  .topnav { display: flex; }
  .tabbar { display: none; }
  .who-name { display: inline; }
  .main { padding-bottom: 48px; }
  body.has-dock .main { padding-bottom: calc(var(--dock-h) + 48px); }
  .dock { bottom: 0; padding-bottom: 16px; }
}
@media (max-width: 420px) {
  .stat { padding: 12px; gap: 10px; }
  .stat-icon { width: 30px; height: 30px; border-radius: 9px; }
  .stat-icon .icon { width: 16px; height: 16px; }
  .stat-value { font-size: 1rem; }
}
@media (max-width: 380px) {
  .brand-sub { display: none; }
  .stat-icon { display: none; }
  .clip-to { display: none; }
  .clip-head { gap: 10px; padding: 12px; }
  .line { gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
