/* ==========================================================================
   Atelier TV Companion Web App (PWA) — Editorial 8-Theme Design System
   Matches AtelierTheme.java verbatim across all 8 Atelier OS themes.
   Mobile-first for iPhone & Android standalone PWA + crisp Desktop layout.
   ========================================================================== */

:root,
body[data-theme="atelier"] {
  --bg: #F6F2EA;
  --bg-bot: #EBE4D7;
  --surface: #FFFFFF;
  --surface-2: #F2ECE1;
  --surface-3: #E8E0D2;
  --ink: #1C1917;
  --ink-inv: #FAF7F2;
  --muted: #756D66;
  --accent: #B85233;
  --accent-ink: #FAF7F2;
  --accent-soft: rgba(184, 82, 51, 0.11);
  --accent-line: rgba(184, 82, 51, 0.30);
  --line: rgba(28, 25, 23, 0.10);
  --line-strong: rgba(28, 25, 23, 0.18);
  --nav-bg: rgba(246, 242, 234, 0.90);
  --shadow-sm: 0 2px 10px rgba(28, 25, 23, 0.05);
  --shadow-md: 0 10px 28px rgba(28, 25, 23, 0.07);
  --ok: #2D7D50;
  --ok-soft: rgba(45, 125, 80, 0.12);
  --warn: #B96B1B;
  --warn-soft: rgba(185, 107, 27, 0.13);
  --live: #C93E2B;
  --live-soft: rgba(201, 62, 43, 0.12);
  --btn-dark-bg: #1C1917;
  --btn-dark-ink: #FAF7F2;
}

body[data-theme="velvet"] {
  --bg: #1A1613;
  --bg-bot: #0E0C0A;
  --surface: #221D19;
  --surface-2: #2B241F;
  --surface-3: #342B24;
  --ink: #F5F1EA;
  --ink-inv: #161310;
  --muted: #A69D91;
  --accent: #D6A55C;
  --accent-ink: #161310;
  --accent-soft: rgba(214, 165, 92, 0.14);
  --accent-line: rgba(214, 165, 92, 0.38);
  --line: rgba(255, 248, 238, 0.10);
  --line-strong: rgba(255, 248, 238, 0.20);
  --nav-bg: rgba(20, 17, 14, 0.92);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 12px 30px rgba(0, 0, 0, 0.38);
  --ok: #5EC284;
  --ok-soft: rgba(94, 194, 132, 0.15);
  --warn: #E8A653;
  --warn-soft: rgba(232, 166, 83, 0.15);
  --live: #EF6B58;
  --live-soft: rgba(239, 107, 88, 0.16);
  --btn-dark-bg: #F5F1EA;
  --btn-dark-ink: #161310;
}

body[data-theme="midnight"] {
  --bg: #131D2F;
  --bg-bot: #090E18;
  --surface: #18243A;
  --surface-2: #1F2F4B;
  --surface-3: #283C5E;
  --ink: #EDF2F8;
  --ink-inv: #0B1320;
  --muted: #93A5BE;
  --accent: #6EA8E5;
  --accent-ink: #0B1320;
  --accent-soft: rgba(110, 168, 229, 0.15);
  --accent-line: rgba(110, 168, 229, 0.40);
  --line: rgba(226, 238, 255, 0.11);
  --line-strong: rgba(226, 238, 255, 0.22);
  --nav-bg: rgba(13, 21, 35, 0.92);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.30);
  --shadow-md: 0 12px 30px rgba(0, 0, 0, 0.42);
  --ok: #5EC284;
  --ok-soft: rgba(94, 194, 132, 0.15);
  --warn: #E8A653;
  --warn-soft: rgba(232, 166, 83, 0.15);
  --live: #EF6B58;
  --live-soft: rgba(239, 107, 88, 0.16);
  --btn-dark-bg: #EDF2F8;
  --btn-dark-ink: #0B1320;
}

body[data-theme="forest"] {
  --bg: #13241C;
  --bg-bot: #09120D;
  --surface: #182E23;
  --surface-2: #203C2E;
  --surface-3: #294B3A;
  --ink: #EEF2EC;
  --ink-inv: #101812;
  --muted: #99AA9E;
  --accent: #C9A45C;
  --accent-ink: #101812;
  --accent-soft: rgba(201, 164, 92, 0.15);
  --accent-line: rgba(201, 164, 92, 0.38);
  --line: rgba(236, 246, 238, 0.11);
  --line-strong: rgba(236, 246, 238, 0.21);
  --nav-bg: rgba(13, 27, 20, 0.92);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.30);
  --shadow-md: 0 12px 30px rgba(0, 0, 0, 0.40);
  --ok: #64C98B;
  --ok-soft: rgba(100, 201, 139, 0.15);
  --warn: #E8A653;
  --warn-soft: rgba(232, 166, 83, 0.15);
  --live: #EF6B58;
  --live-soft: rgba(239, 107, 88, 0.16);
  --btn-dark-bg: #EEF2EC;
  --btn-dark-ink: #101812;
}

body[data-theme="burgundy"] {
  --bg: #28131A;
  --bg-bot: #12080B;
  --surface: #301821;
  --surface-2: #3D1F2A;
  --surface-3: #4B2634;
  --ink: #F6ECEF;
  --ink-inv: #1A0C11;
  --muted: #B69AA3;
  --accent: #D9A07E;
  --accent-ink: #1A0C11;
  --accent-soft: rgba(217, 160, 126, 0.15);
  --accent-line: rgba(217, 160, 126, 0.40);
  --line: rgba(255, 238, 243, 0.12);
  --line-strong: rgba(255, 238, 243, 0.22);
  --nav-bg: rgba(29, 13, 19, 0.92);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.32);
  --shadow-md: 0 12px 30px rgba(0, 0, 0, 0.44);
  --ok: #64C98B;
  --ok-soft: rgba(100, 201, 139, 0.15);
  --warn: #E8A653;
  --warn-soft: rgba(232, 166, 83, 0.15);
  --live: #F27260;
  --live-soft: rgba(242, 114, 96, 0.16);
  --btn-dark-bg: #F6ECEF;
  --btn-dark-ink: #1A0C11;
}

body[data-theme="monochrome"] {
  --bg: #1B1B1D;
  --bg-bot: #0B0B0D;
  --surface: #212124;
  --surface-2: #2B2B2F;
  --surface-3: #36363B;
  --ink: #F5F5F7;
  --ink-inv: #121214;
  --muted: #9E9EA8;
  --accent: #EAEAEF;
  --accent-ink: #121214;
  --accent-soft: rgba(234, 234, 239, 0.12);
  --accent-line: rgba(234, 234, 239, 0.34);
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.22);
  --nav-bg: rgba(18, 18, 20, 0.92);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.34);
  --shadow-md: 0 12px 30px rgba(0, 0, 0, 0.46);
  --ok: #64C98B;
  --ok-soft: rgba(100, 201, 139, 0.15);
  --warn: #E8A653;
  --warn-soft: rgba(232, 166, 83, 0.15);
  --live: #EF6B58;
  --live-soft: rgba(239, 107, 88, 0.16);
  --btn-dark-bg: #F5F5F7;
  --btn-dark-ink: #121214;
}

body[data-theme="sandstone"] {
  --bg: #F3E9DD;
  --bg-bot: #E6D8C6;
  --surface: #FFFBF6;
  --surface-2: #EFE2D2;
  --surface-3: #E4D3BE;
  --ink: #29211B;
  --ink-inv: #FAF5EE;
  --muted: #766658;
  --accent: #A94B2B;
  --accent-ink: #FAF5EE;
  --accent-soft: rgba(169, 75, 43, 0.11);
  --accent-line: rgba(169, 75, 43, 0.32);
  --line: rgba(41, 33, 27, 0.11);
  --line-strong: rgba(41, 33, 27, 0.20);
  --nav-bg: rgba(243, 233, 221, 0.92);
  --shadow-sm: 0 2px 10px rgba(41, 33, 27, 0.05);
  --shadow-md: 0 10px 28px rgba(41, 33, 27, 0.08);
  --ok: #2D7D50;
  --ok-soft: rgba(45, 125, 80, 0.12);
  --warn: #B46519;
  --warn-soft: rgba(180, 101, 25, 0.13);
  --live: #C93E2B;
  --live-soft: rgba(201, 62, 43, 0.12);
  --btn-dark-bg: #29211B;
  --btn-dark-ink: #FAF5EE;
}

body[data-theme="pebble"] {
  --bg: #EBF2E8;
  --bg-bot: #F5ECE1;
  --surface: #FFFFFF;
  --surface-2: #E6ECE2;
  --surface-3: #DAE3D5;
  --ink: #2B2A27;
  --ink-inv: #FAF6EC;
  --muted: #677064;
  --accent: #D66E36;
  --accent-ink: #FAF6EC;
  --accent-soft: rgba(214, 110, 54, 0.12);
  --accent-line: rgba(214, 110, 54, 0.34);
  --line: rgba(45, 51, 43, 0.11);
  --line-strong: rgba(45, 51, 43, 0.20);
  --nav-bg: rgba(235, 242, 232, 0.92);
  --shadow-sm: 0 2px 10px rgba(43, 42, 39, 0.05);
  --shadow-md: 0 10px 28px rgba(43, 42, 39, 0.07);
  --ok: #2D7D50;
  --ok-soft: rgba(45, 125, 80, 0.12);
  --warn: #B96B1B;
  --warn-soft: rgba(185, 107, 27, 0.13);
  --live: #C93E2B;
  --live-soft: rgba(201, 62, 43, 0.12);
  --btn-dark-bg: #2B2A27;
  --btn-dark-ink: #FAF6EC;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  min-height: 100%;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-bot) 100%) fixed;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background 0.22s ease, color 0.18s ease;
}

body {
  padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px));
}

body.no-nav {
  padding-bottom: max(28px, env(safe-area-inset-bottom, 16px));
}

button, input, select, textarea {
  font-family: inherit;
  color: inherit;
}

button {
  border: none;
  background: none;
  cursor: pointer;
  transition: transform 0.09s ease, background 0.14s ease, border-color 0.14s ease, opacity 0.14s ease;
}

button:active {
  transform: scale(0.97);
}

.hidden {
  display: none !important;
}

/* ── Top Header ──────────────────────────────────────────────────────────── */

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--nav-bg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
  padding: max(12px, calc(env(safe-area-inset-top, 0px) + 8px)) 16px 12px;
}

.header-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-block {
  min-width: 0;
}

.brand-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 24px;
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--ink);
}

.brand-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
  max-width: 52vw;
}

.status-chip .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}

.status-chip.online .dot { background: var(--ok); }
.status-chip.standby .dot { background: var(--warn); }
.status-chip span.chip-lbl {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Main Container ──────────────────────────────────────────────────────── */

.app-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px 24px;
}

.remote-col {
  max-width: 440px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ── Editorial Cards & Typography ────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.card-compact {
  padding: 14px 16px;
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.section-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.section-hint {
  font-size: 12px;
  color: var(--muted);
}

.serif-h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 26px;
  font-weight: 400;
  letter-spacing: -0.015em;
  line-height: 1.18;
  color: var(--ink);
}

.serif-h3 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1.22;
}

.body-copy {
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
}

/* ── Buttons & Inputs ────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 18px;
  border-radius: 14px;
  font-size: 14.5px;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn-dark {
  background: var(--btn-dark-bg);
  border-color: var(--btn-dark-bg);
  color: var(--btn-dark-ink);
}

.btn-ghost {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--ink);
}

.btn-danger {
  background: var(--live-soft);
  border-color: transparent;
  color: var(--live);
}

.btn-sm {
  padding: 8px 13px;
  font-size: 13px;
  border-radius: 11px;
}

.btn-block {
  width: 100%;
}

.field {
  width: 100%;
  background: var(--surface-2);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 13px 15px;
  font-size: 15px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

.field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field-code {
  text-align: center;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.22em;
  font-variant-numeric: tabular-nums;
  padding: 15px 14px;
}

.field-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

textarea.field {
  min-height: 92px;
  resize: vertical;
}

/* ── Toast / Feedback Bar ────────────────────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(92px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(12px);
  z-index: 60;
  max-width: calc(100vw - 32px);
  background: var(--btn-dark-bg);
  color: var(--btn-dark-ink);
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

body.no-nav .toast {
  bottom: max(24px, env(safe-area-inset-bottom, 16px));
}

/* ── Segmented Control & Filter Pills ────────────────────────────────────── */

.seg {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  padding: 4px;
  border-radius: 14px;
  border: 1px solid var(--line);
}

.seg-btn {
  flex: 1;
  padding: 9px 10px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
}

.seg-btn.on {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.pill-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.pill-row::-webkit-scrollbar { display: none; }

.pill {
  flex: 0 0 auto;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}

.pill.on {
  background: var(--btn-dark-bg);
  border-color: var(--btn-dark-bg);
  color: var(--btn-dark-ink);
}

.pill.accent-on {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent);
}

/* ── Welcome / Onboarding Screen ─────────────────────────────────────────── */

.welcome-wrap {
  max-width: 440px;
  margin: 18px auto 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.welcome-hero {
  text-align: center;
  padding: 12px 6px 4px;
}

.brand-mark {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  margin: 0 auto 14px;
  background: #1C1917;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
}

.inline-msg {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--accent);
  min-height: 20px;
  text-align: center;
}

.inline-msg.err { color: var(--live); }
.inline-msg.ok { color: var(--ok); }

/* ── Handheld Remote Shell ───────────────────────────────────────────────── */

.remote-shell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 18px 16px 16px;
  user-select: none;
  -webkit-user-select: none;
}

.util-row, .media-row {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.u-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 14px;
  padding: 13px 8px;
  font-size: 13.5px;
  font-weight: 600;
}

.u-btn.home {
  background: var(--btn-dark-bg);
  border-color: var(--btn-dark-bg);
  color: var(--btn-dark-ink);
}

.dpad-ring {
  position: relative;
  width: 232px;
  height: 232px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1.5px solid var(--line-strong);
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.06), var(--shadow-md);
  margin: 2px 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.dp-btn {
  position: absolute;
  background: transparent;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.dp-btn:active, .dp-btn.held {
  background: var(--accent-soft);
  color: var(--accent);
}

.dp-up    { top: 4px; left: 50%; transform: translateX(-50%); width: 88px; height: 64px; border-radius: 44px 44px 16px 16px; }
.dp-down  { bottom: 4px; left: 50%; transform: translateX(-50%); width: 88px; height: 64px; border-radius: 16px 16px 44px 44px; }
.dp-left  { left: 4px; top: 50%; transform: translateY(-50%); width: 64px; height: 88px; border-radius: 44px 16px 16px 44px; }
.dp-right { right: 4px; top: 50%; transform: translateY(-50%); width: 64px; height: 88px; border-radius: 16px 44px 44px 16px; }
.dp-up:active { transform: translateX(-50%) scale(0.95); }
.dp-down:active { transform: translateX(-50%) scale(0.95); }
.dp-left:active { transform: translateY(-50%) scale(0.95); }
.dp-right:active { transform: translateY(-50%) scale(0.95); }

.dp-ok {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 86px;
  height: 86px;
  border-radius: 50%;
  background: var(--btn-dark-bg);
  color: var(--btn-dark-ink);
  font-size: 16px;
  font-weight: 700;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.dp-ok .hint {
  font-size: 9px;
  font-weight: 600;
  opacity: 0.68;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.dp-ok:active {
  transform: translate(-50%, -50%) scale(0.94);
  background: var(--accent);
  color: var(--accent-ink);
}

.m-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 14px;
  padding: 12px 6px;
  font-size: 13px;
  font-weight: 600;
}

.m-btn.play {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

/* Auto-keyboard bar */
.kbd-card {
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.kbd-card.active-input {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-sm);
}

.kbd-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 10px;
  border-radius: 999px;
}

.kbd-row {
  display: flex;
  gap: 8px;
}

.kbd-row .field {
  flex: 1;
  padding: 11px 14px;
}

/* TV Care collapsible drawer */
.care-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.care-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.stat-box {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 8px;
  text-align: center;
}

.stat-box .v {
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stat-box .k {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.quick-act {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 13px 14px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.quick-act.dark {
  background: var(--btn-dark-bg);
  border-color: var(--btn-dark-bg);
  color: var(--btn-dark-ink);
}

.quick-act.accent {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.quick-act .t { font-size: 14px; font-weight: 700; }
.quick-act .s { font-size: 11.5px; opacity: 0.78; }

/* ── Sports Tab ──────────────────────────────────────────────────────────── */

.league-group {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.league-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 16px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.league-name {
  font-size: 14.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--live);
  display: inline-block;
}

.count-tag {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-2);
  padding: 3px 9px;
  border-radius: 999px;
}

.match-list {
  border-top: 1px solid var(--line);
}

.match-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.match-item:last-child { border-bottom: none; }

.match-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.badge-live { background: var(--live-soft); color: var(--live); }
.badge-replay { background: var(--ok-soft); color: var(--ok); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-muted { background: var(--surface-2); color: var(--muted); }

.match-title {
  font-size: 15.5px;
  font-weight: 700;
  line-height: 1.28;
  color: var(--ink);
}

.match-score {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.ch-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 2px;
}

.ch-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 11px;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink);
}

.ch-btn.primary {
  background: var(--btn-dark-bg);
  border-color: var(--btn-dark-bg);
  color: var(--btn-dark-ink);
}

.ch-btn.readonly {
  cursor: default;
}

.ch-btn .qtag {
  font-size: 10.5px;
  font-weight: 700;
  opacity: 0.78;
}

/* ── Library, Requests, Tickets & Announcements ──────────────────────────── */

.vod-card {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  align-items: center;
}

.vod-poster {
  width: 50px;
  height: 74px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--surface-3);
  flex-shrink: 0;
}

.vod-meta {
  flex: 1;
  min-width: 0;
}

.vod-title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.25;
}

.vod-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.list-row:last-child { border-bottom: none; padding-bottom: 2px; }
.list-row:first-child { padding-top: 2px; }

.announce-item {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.announce-item:last-child { border-bottom: none; }

.announce-date {
  font-size: 11.5px;
  color: var(--muted);
  margin-bottom: 6px;
}

.announce-body {
  font-size: 14px;
  line-height: 1.52;
  color: var(--ink);
  white-space: pre-wrap;
}

/* Ticket chat */
.chat-bubble {
  padding: 11px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.45;
  max-width: 88%;
}

.chat-bubble.user {
  align-self: flex-end;
  background: var(--accent);
  color: var(--accent-ink);
}

.chat-bubble.admin {
  align-self: flex-start;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink);
}

.chat-bubble.system {
  align-self: center;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  padding: 4px 8px;
}

/* ── Theme Picker Grid (Exact 8 Atelier Themes) ──────────────────────────── */

.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
}

.theme-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 11px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: var(--surface-2);
  text-align: left;
}

.theme-opt.on {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.theme-swatch {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  border: 1px solid rgba(128, 128, 128, 0.25);
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 4px;
  flex-shrink: 0;
}

.theme-swatch i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: block;
}

.theme-opt .tn { font-size: 13px; font-weight: 700; color: var(--ink); line-height: 1.15; }
.theme-opt .tm { font-size: 11px; color: var(--muted); }

/* ── QR & Family Invite Box ──────────────────────────────────────────────── */

.qr-frame {
  background: #FFFFFF;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--line);
  width: fit-content;
  margin: 0 auto;
}

.qr-frame img {
  display: block;
  width: 196px;
  height: 196px;
  border-radius: 6px;
}

/* ── Bottom Navigation Bar ───────────────────────────────────────────────── */

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  background: var(--nav-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--line);
  padding: 7px 10px max(10px, env(safe-area-inset-bottom, 10px));
}

.bottom-nav-inner {
  max-width: 560px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.nav-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 4px;
  border-radius: 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.nav-item.on {
  color: var(--accent);
}

.nav-item svg {
  width: 22px;
  height: 22px;
}

.nav-dot {
  position: absolute;
  top: 4px;
  right: calc(50% - 16px);
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

/* ── Empty / Loading States ──────────────────────────────────────────────── */

.empty-box {
  text-align: center;
  padding: 28px 16px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.loader-bar {
  text-align: center;
  padding: 28px 12px;
  color: var(--muted);
  font-size: 13.5px;
}

/* ── Install Banner ──────────────────────────────────────────────────────── */

.install-steps {
  background: var(--surface-2);
  border: 1px solid var(--accent-line);
  border-radius: 16px;
  padding: 14px 15px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.install-steps ol {
  padding-left: 18px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink);
}

@media (min-width: 680px) {
  .theme-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ── Detect Fire Stick, Offline Banner & QR-to-Remote Handoff ────────────── */

.detect-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.detect-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 13px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.detect-item-info {
  min-width: 0;
  flex: 1;
}

.detect-item-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--ink);
}

.detect-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  flex-shrink: 0;
}

.detect-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin: 2px 0;
}

.detect-divider::before,
.detect-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.offline-banner {
  background: var(--surface);
  border: 1px solid var(--accent-line);
  border-radius: 16px;
  padding: 14px 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-sm);
}

.offline-banner-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.offline-banner-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.handoff-pulse-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.handoff-pulse {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  box-shadow: 0 0 0 0 var(--accent-line);
  animation: atelierPulse 1.8s ease-out infinite;
}

@keyframes atelierPulse {
  0%   { box-shadow: 0 0 0 0 var(--accent-line); }
  70%  { box-shadow: 0 0 0 10px rgba(0, 0, 0, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 0, 0, 0); }
}
