/* =========================================================
   LMS Remote — styles
   Sections:
     1. Design tokens
     2. Base & reset
     3. Shared primitives (buttons, inputs, cards, pills)
     4. Login screen
     5. App shell (sidebar, header, layout)
     6. Devices
     7. Remote control
     8. Right column (shortcuts, apps, history)
     9. Settings & diagnostics
    10. Sensor hub
    11. Dialogs & API reference
    12. Utilities (toast, footer)
    13. Responsive
    14. Motion preference
   ========================================================= */

/* 1. Design tokens ======================================== */
:root {
  /* Fonts */
  --font-sans: Inter, "Segoe UI", Arial, sans-serif;

  /* Neutrals */
  --ink: #132730;
  --ink-body: #202c34;
  --ink-soft: #364952;
  --muted: #78858c;
  --muted-strong: #879298;
  --muted-faint: #91a0a6;
  --line: #e6ebed;
  --line-input: #dce3e6;
  --line-soft: #f0f2f3;
  --bg: #f4f6f7;
  --bg-elevated: #f6f8f8;
  --surface: #fff;

  /* Green scale (consolidated from 11 ad-hoc shades) */
  --green-50:  #edf5f2;
  --green-100: #e5f5ed;
  --green-200: #c1f5e6;
  --green-300: #6bc9b5;
  --green-400: #41b99d;
  --green-450: #49bea4;
  --green-500: #2eab82;
  --green-600: #237e69;
  --green-650: #16836b;
  --green-700: #127c69;
  --green-750: #0d6757;
  --green-800: #356355;
  --green-900: #102c2b;

  /* Semantic accent aliases */
  --accent:        var(--green-700);
  --accent-hover:  var(--green-750);
  --accent-strong: var(--green-650);
  --accent-bright: var(--green-500);
  --accent-soft:   var(--green-50);
  --accent-tint:   var(--green-100);
  --accent-glow:   var(--green-300);
  --accent-ring:   var(--green-400);

  /* Danger */
  --danger:        #af3636;
  --danger-strong: #7d3434;
  --danger-bg:     #fcf0f0;
  --danger-line:   #e7dede;
  --danger-fg:     #9e6262;
  --danger-fg-hover: #a32f2f;
  --danger-soft-fg:  #ae5151;
  --youtube: #e94343;

  /* Sidebar */
  --sidebar-bg:        #13252e;
  --sidebar-bg-alt:    #11232c;
  --sidebar-glow:      #1c4c48;
  --sidebar-fg:        #9bb0b9;
  --sidebar-fg-strong: #dce8eb;
  --sidebar-fg-muted:  #78929c;
  --sidebar-fg-faint:  #7f969f;
  --sidebar-line:      #4a585f;
  --sidebar-active-bg: #263d45;

  /* Sizing */
  --sidebar-w: 226px;
  --tap: 44px;

  /* Radii */
  --r-sm:  7px;
  --r-md:  9px;
  --r-lg: 10px;
  --r-xl: 13px;
  --r-2xl: 14px;
  --r-pill: 30px;

  /* Motion */
  --ease: 180ms ease;

  /* Base */
  font-family: var(--font-sans);
  color: var(--ink-body);
  background: var(--bg);
  font-synthesis: none;
}

/* 2. Base & reset ========================================= */
*, *::before, *::after { box-sizing: border-box; }

body { margin: 0; }

button, input, select, textarea { font: inherit; }
button, a { touch-action: manipulation; }

button { cursor: pointer; }
button:disabled { opacity: .4; cursor: not-allowed; }

button:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--accent-ring);
  outline-offset: 3px;
}

/* Force hidden to win over display:grid/flex utilities */
[hidden] { display: none !important; }

a { color: inherit; text-decoration: none; }

h1, h2, p { margin-top: 0; }
h1 { font-size: 32px; letter-spacing: -1px; margin-bottom: 8px; }
h2 { font-size: 21px; letter-spacing: -.5px; margin: 8px 0 20px; }
p { line-height: 1.6; }

/* 3. Shared primitives ==================================== */

/* Type helpers */
.eyebrow {
  font-size: 10px; font-weight: 750;
  letter-spacing: 1.7px; color: var(--muted-strong);
}

/* Brand */
.brand {
  display: flex; align-items: center; gap: 10px;
  font-size: 27px; font-weight: 700; letter-spacing: -1px;
}
.brand-icon {
  display: grid; place-items: center;
  background: var(--green-450); color: var(--green-900);
  width: 35px; height: 35px; border-radius: var(--r-lg);
  font-size: 22px;
}
.brand-small {
  font-size: 9px; font-weight: 500; letter-spacing: 2px;
  border-left: 1px solid var(--sidebar-line);
  margin-left: 8px; padding-left: 16px;
}

/* Buttons */
.primary,
.outline {
  border: 0; border-radius: var(--r-md);
  padding: 13px 18px;
  min-height: var(--tap);
  font-weight: 650; font-size: 13px;
  transition: background var(--ease), border-color var(--ease), color var(--ease);
}
.primary { background: var(--accent); color: #fff; }
.primary:hover { background: var(--accent-hover); }

.outline {
  border: 1px solid var(--line-input);
  background: var(--surface);
  color: var(--ink-soft);
}
.outline:hover { background: #f1f7f5; }

/* .error carries !important to beat contextual paragraph colors
   (e.g. `.login-card p`). Keep it — removing it silently breaks
   error styling on the login form. */
.error { color: var(--danger) !important; }

/* Pills */
.pill {
  display: inline-block; white-space: nowrap;
  border-radius: 6px; background: var(--line-soft);
  color: #829096; font-size: 10px; padding: 6px 9px;
  font-weight: 650;
}
.pill.online { background: var(--accent-tint); color: var(--accent-strong); }
.device .pill { margin-left: auto; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-2xl);
  padding: 25px;
}
.card-head {
  display: flex; justify-content: space-between;
  gap: 10px; align-items: center;
}
.card-head h2 { margin-bottom: 18px; }

/* Form controls — single source of truth */
label {
  display: block;
  font-size: 12px; font-weight: 650;
  margin: 20px 0 16px;
}
input, select, textarea {
  display: block;
  width: 100%; min-width: 0;
  margin-top: 9px;
  border: 1px solid var(--line-input);
  background: var(--surface);
  border-radius: var(--r-md);
  padding: 13px 14px;
  min-height: 46px;
  color: var(--ink);
  transition: border-color var(--ease), box-shadow var(--ease);
}
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent-glow);
  outline-offset: 1px;
}
textarea { padding: 12px; resize: vertical; }
select   { color: #142832; }

/* 4. Login screen ========================================= */
.login-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--surface);
}
.login-brand {
  background: var(--sidebar-bg-alt);
  color: #fff;
  padding: 60px 10%;
  display: flex; flex-direction: column; justify-content: space-between;
  min-height: 100vh;
  min-height: 100dvh;
  background-image: radial-gradient(ellipse at 100% 90%, var(--sidebar-glow), transparent 65%);
}
.login-brand h1 {
  font-size: clamp(38px, 4.3vw, 67px);
  line-height: 1.1; margin: 26px 0;
}
.login-brand p { color: #acc0c5; font-size: 16px; }
.quiet { font-size: 12px; color: #87a1a8; }

.login-card {
  align-self: center; justify-self: center;
  width: min(430px, 100%);
  padding: 35px;
}
.tag { color: var(--accent); font-size: 10px; letter-spacing: 1.6px; font-weight: 700; }
.login-card h2 { font-size: 30px; margin: 20px 0 12px; }
.login-card p  { color: var(--muted); font-size: 14px; }
.login-note {
  border-top: 1px solid var(--line);
  margin-top: 28px; padding-top: 22px;
  color: var(--muted); font-size: 12px; line-height: 1.7;
}
.login-card .primary {
  width: 100%;
  display: flex; justify-content: space-between;
  margin-top: 25px;
}

/* 5. App shell ============================================ */
.app { display: flex; min-height: 100vh; min-height: 100dvh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: #fff;
  padding: 36px 23px;
  display: flex; flex-direction: column;
  position: fixed; inset: 0 auto 0 0;
}
.side-label {
  font-size: 9px; letter-spacing: 1.2px;
  color: var(--sidebar-fg-faint);
  margin: 56px 0 20px;
}
.nav {
  display: flex; gap: 12px; align-items: center;
  background: none; color: var(--sidebar-fg);
  border: 0; padding: 14px 15px;
  width: 100%; text-align: left;
  border-radius: var(--r-sm);
  margin: 5px 0;
  font-size: 14px;
  transition: background var(--ease), color var(--ease);
}
.nav:hover { color: var(--sidebar-fg-strong); }
.nav.active { background: var(--sidebar-active-bg); color: var(--accent-tint); }

.side-bottom {
  margin-top: auto;
  font-size: 12px; color: var(--sidebar-fg-strong); line-height: 2;
}
.side-bottom small { color: var(--sidebar-fg-muted); margin-left: 14px; }
.green-dot {
  display: inline-block; border-radius: 50%;
  background: var(--accent-bright);
  width: 6px; height: 6px; margin-right: 6px;
}
.logout {
  background: none; border: 0; color: var(--sidebar-fg);
  display: block; padding: 20px 0 0; font-size: 12px;
}

main {
  margin-left: var(--sidebar-w);
  padding: 38px 40px 20px;
  max-width: 1600px;
  width: calc(100% - var(--sidebar-w));
}

header {
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--line);
  padding-bottom: 25px;
}
header .eyebrow { margin-bottom: 10px; }
.header-right {
  display: flex; align-items: center; gap: 18px;
  font-size: 11px; color: var(--muted);
}
.avatar {
  width: 35px; height: 35px;
  background: #e4ecea; border-radius: 50%;
  display: grid; place-items: center;
  color: var(--green-800); font-weight: 700;
}

.section-intro {
  display: flex; justify-content: space-between; align-items: center;
  padding: 24px 0 22px; gap: 12px;
}
.section-intro p { margin: 0; font-size: 13px; color: var(--muted); }
.text-button {
  color: var(--accent); background: none; border: 0;
  font-size: 13px; font-weight: 700; white-space: nowrap;
  min-height: var(--tap);
}

/* 6. Devices ============================================== */
.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px; margin-bottom: 25px;
}
.device {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--r-xl);
  padding: 20px;
  text-align: left; min-width: 0;
  position: relative;
  transition: border-color var(--ease), box-shadow var(--ease);
}
.device.selected {
  border-color: #3b9d87;
  box-shadow: 0 0 0 1px #3b9d871a;
}
.device-top {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 18px;
}
.tv-icon {
  display: grid; place-items: center;
  width: 45px; height: 43px;
  border-radius: var(--r-lg);
  background: var(--accent-soft);
  color: var(--green-600);
  font-size: 25px;
}
.device strong { font-size: 15px; display: block; }
.device small  { font-size: 11px; color: var(--muted); display: block; margin-top: 5px; }
.device-info {
  font-size: 11px; color: #798890; line-height: 1.8;
  overflow-wrap: anywhere;
  border-top: 1px solid var(--line-soft);
  padding-top: 12px;
}

/* Device card overlay controls (delete + API) */
.device-card { position: relative; min-width: 0; }
.device-card > .device { width: 100%; height: 100%; }
#app-view .device-card .device-top { padding-right: 90px; } /* reserve room for both buttons */

.device-delete {
  position: absolute; right: 6px; top: 6px;
  width: 40px; height: 40px;
  border: 0; background: transparent;
  border-radius: var(--r-md);
  font-size: 25px; line-height: 1;
  color: var(--danger-fg);
  transition: background var(--ease), color var(--ease);
}
.device-delete:hover { background: var(--danger-bg); color: var(--danger-fg-hover); }

.device-api-button {
  position: absolute; right: 48px; top: 10px;
  min-height: 32px; padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px; font-weight: 650;
  transition: background var(--ease);
}
.device-api-button:hover { background: var(--green-100); }

.archived-section { margin: 0 0 16px; color: var(--muted); font-size: 13px; }
.archived-section > summary { cursor: pointer; padding: 10px 0; }
.archived-section .outline { margin: 4px 4px 4px 0; }

/* 7. Remote control ======================================= */
.workspace {
  display: grid;
  grid-template-columns: minmax(300px, .85fr) minmax(320px, 1.15fr);
  gap: 24px;
}

.remote {
  width: 235px;
  background: var(--bg-elevated);
  border: 1px solid #e8eeee;
  border-radius: var(--r-pill);
  padding: 21px;
  margin: 15px auto 25px;
  box-shadow: 0 10px 25px #172d3507;
}
.remote button {
  background: #fff;
  border: 1px solid #e5e9eb;
  border-radius: 12px;
  min-height: var(--tap);
  box-shadow: 0 2px 2px #123e2806;
  color: #3e515b;
  font-weight: 600;
  transition: background var(--ease);
}
.remote button:hover { background: #e9f4ef; }

.remote-top {
  display: flex; align-items: center; justify-content: space-between;
}
.remote-top button {
  width: 43px; border-radius: 50%; font-size: 21px;
}
.remote-top .sleep {
  color: var(--danger-soft-fg);
  background: var(--danger-bg);
  border: 0;
}
.remote-top span { font-size: 9px; letter-spacing: 2px; color: #8fa0a7; }

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 52px);
  gap: 4px; margin: 22px 0;
}
.dpad .up    { grid-area: 1 / 2; }
.dpad .left  { grid-area: 2 / 1; }
.dpad .ok    { grid-area: 2 / 2; background: var(--accent); color: #fff; border-color: var(--accent); border-radius: 50%; }
.dpad .right { grid-area: 2 / 3; }
.dpad .down  { grid-area: 3 / 2; }

.remote-row { display: flex; gap: 7px; justify-content: space-between; }
.remote-row button { flex: 1; font-size: 22px; padding: 7px 2px; }
.remote-row small { display: block; font-size: 9px; font-weight: 400; margin-top: 2px; }

.volume {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 19px;
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--line);
}
.volume button { border: 0; box-shadow: none; width: 44px; font-size: 25px; }
.volume span { font-size: 8px; letter-spacing: 1px; color: #8a999f; }
.remote .mute {
  margin-top: 10px; width: 100%;
  background: transparent; box-shadow: none;
  font-size: 10px; border: 0;
}

.hint { font-size: 12px; line-height: 1.7; color: var(--muted); margin: 12px 0; }
.remote-card > .hint { text-align: center; }

.extra-keys { margin: 14px 0; }
.extra-keys button { flex: 1 1 40%; font-size: 12px; padding: 10px; }

/* 8. Right column ========================================= */
.right-column { display: flex; flex-direction: column; gap: 20px; }
.subtle { font-size: 10px; color: var(--muted); }

.app-shortcut {
  display: flex; align-items: center; gap: 14px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  text-align: left;
  padding: 15px;
  transition: background var(--ease);
}
.app-shortcut:hover { background: var(--green-50); }
.app-shortcut > span:last-child { margin-left: auto; color: #89989f; }
.app-shortcut strong { display: block; font-size: 13px; }
.app-shortcut small  { display: block; font-size: 10px; color: var(--muted); margin-top: 4px; }
.youtube-icon {
  color: #fff; background: var(--youtube);
  border-radius: var(--r-md);
  display: grid; place-items: center;
  width: 38px; height: 32px;
}

.inline-form { display: flex; gap: 10px; align-items: end; }
.inline-form label { flex: 1; margin-bottom: 0; min-width: 0; }
.inline-form input { font-size: 12px; }
.inline-form button { margin-bottom: 0; }

.history-card { flex: 1; }
.live-label { font-size: 9px; letter-spacing: 1px; color: #6e8e7d; }
.history-list { max-height: 340px; overflow: auto; }
.history-row {
  border-top: 1px solid #eef1f2;
  padding: 13px 0;
  display: flex; gap: 12px; align-items: start;
  font-size: 12px;
}
.history-row > div { min-width: 0; overflow-wrap: anywhere; }
.history-row .command-icon { background: #f2f5f5; padding: 8px; border-radius: var(--r-sm); }
.history-row small { display: block; color: var(--muted); font-size: 10px; margin-top: 5px; }
.history-row .pill { margin-left: auto; }
.history-row details {
  max-width: 220px; margin-top: 6px;
  overflow-wrap: anywhere;
  font-size: 11px; color: #8f5555;
}
.history-row pre { white-space: pre-wrap; font-size: 10px; }

.reboot {
  background: transparent;
  border: 1px solid var(--danger-line);
  color: var(--danger-fg);
  border-radius: var(--r-lg);
  padding: 13px; font-size: 12px;
  transition: background var(--ease);
}
.reboot:hover { background: var(--danger-bg); }

/* 9. Settings & diagnostics =============================== */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px; margin-top: 25px;
}
.setup-details dt { font-size: 11px; color: var(--muted); margin-top: 22px; }
.setup-details dd { margin: 7px 0; font-size: 14px; overflow-wrap: anywhere; }
.setup-details small { color: var(--muted); }
.download { display: inline-block; margin-top: 15px; }

#diagnostics { margin-top: 25px; }
.check {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

/* 10. Sensor hub ========================================== */
select {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line-input);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: #142832;
}
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset:disabled { opacity: .55; }

.hub-select { margin-bottom: 20px; }
.hub-select label { max-width: 480px; }

.hub-readings {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px; margin-bottom: 24px;
}
.hub-reading { padding: 20px; min-width: 0; }
.hub-reading span { display: block; font-size: 12px; color: #63737a; }
.hub-reading strong { display: block; font-size: 19px; margin-top: 10px; overflow-wrap: anywhere; }

.hub-toggle { display: flex; align-items: center; gap: 12px; margin: 12px 0; }
.hub-toggle input {
  width: 20px; height: 20px;
  min-height: 0; /* override shared input min-height — checkbox must stay compact */
  margin: 0;
  accent-color: var(--accent-bright);
}

.hub-fields-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hub-fields-grid label { min-width: 0; }
.hub-fields-grid input[type=color] { height: 46px; padding: 5px; }

.hub-buttons { display: flex; gap: 10px; flex-wrap: wrap; }
#hub-api code {
  display: block; overflow-wrap: anywhere;
  background: #f1f6f6; padding: 12px; border-radius: var(--r-sm);
}

.hub-scene {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 16px;
  border-top: 1px solid var(--line);
  padding: 12px 0;
}
.hub-scene input[type=color] { height: 46px; padding: 4px; }
.hub-readings > .hint { grid-column: 1 / -1; }

.air-scale { display: flex; gap: 5px; max-width: 330px; }
.air-segment { height: 13px; border-radius: 5px; flex: 1; background: #dfe5e7; }
.air-level-1 { background: var(--accent-strong); }
.air-level-2 { background: #638029; }
.air-level-3 { background: #a66b00; }
.air-level-4 { background: #c64e28; }
.air-level-5 { background: #a53a55; }
.air-level-6 { background: #743c87; }

.advice-main, .advice-room { grid-column: span 2; }
#hub-air-values > details { grid-column: 1 / -1; line-height: 1.6; }
#hub-air-values h2 { margin: 14px 0; }

.event-item {
  border: 1px solid #dce6e3;
  border-left: 4px solid var(--accent-strong);
  border-radius: var(--r-lg);
  background: #f8fbfa;
  padding: 16px;
  margin: 12px 0;
  font-size: 12px;
}
.event-item small { display: block; color: var(--muted); margin-top: 4px; }

#notify-sensor-picker { padding: 12px; background: #f3f7f6; border-radius: var(--r-lg); }

/* 11. Dialogs & API reference ============================= */
#device-api-dialog {
  width: min(530px, calc(100% - 28px));
  max-height: 85vh; overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-2xl);
  padding: 22px;
  color: var(--ink);
}
#device-api-dialog::backdrop { background: #10232b88; }
.api-dialog-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.api-dialog-head h2 { margin: 0; overflow-wrap: anywhere; }
#device-api-dialog label { margin: 14px 0 10px; }
#device-api-dialog select,
#device-api-dialog textarea {
  width: 100%; padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font: inherit;
  margin-top: 8px;
}
#device-api-dialog textarea {
  font-size: 12px;
  overflow-wrap: anywhere;
  resize: vertical;
}

.api-example { margin: 18px 0; }
.api-example strong { font-size: 12px; }
.api-example code {
  display: block;
  background: #f2f6f4;
  padding: 12px;
  border-radius: var(--r-sm);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  font-size: 11px;
  user-select: all;
}

/* 12. Utilities =========================================== */
footer {
  display: flex; justify-content: space-between;
  color: var(--muted-faint); font-size: 10px;
  margin-top: 35px; padding-top: 18px;
  border-top: 1px solid var(--line);
}

#toast {
  position: fixed; left: 50%; bottom: 25px;
  transform: translateX(-50%) translateY(8px);
  z-index: 20;
  background: #163f35; color: #fff;
  border-radius: var(--r-md);
  padding: 15px 22px;
  box-shadow: 0 8px 30px rgb(0 0 0 / 13%);
  font-size: 13px;
  max-width: 90vw;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity var(--ease), transform var(--ease), visibility var(--ease);
}
#toast.show {
  opacity: 1; visibility: visible; pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
#toast.error-toast { background: var(--danger-strong); }

/* Login overrides — single-column, card-styled sign-in */
#login-view {
  grid-template-columns: 1fr;
  background: var(--bg);
  padding: 20px;
}
#login-view .login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-2xl);
  width: min(430px, 100%);
}
#adb-form textarea { width: 100%; font: 13px monospace; resize: vertical; }
#volume-form { flex-wrap: wrap; }
#volume-form label { min-width: 120px; }

/* 13. Compact #app-view workspace ========================= */
#app-view main { padding: 22px 26px 16px; }
#app-view header { padding-bottom: 14px; }
#app-view h1 { font-size: 26px; }
#app-view .section-intro { padding: 14px 0; }
#app-view .section-intro p { display: none; }

#app-view .workspace {
  grid-template-columns: minmax(270px, .8fr) minmax(300px, 1.2fr);
  gap: 16px; align-items: start;
}
#app-view .card { padding: 17px; }
#app-view .right-column { gap: 10px; }
#app-view .settings-grid { gap: 12px; align-items: start; margin-top: 16px; }

#app-view .device-grid { gap: 10px; margin-bottom: 16px; }
#app-view .device { padding: 13px; }
#app-view .device-top { margin-bottom: 0; gap: 10px; }
#app-view .device-info { display: none; }
#app-view .device.selected .device-info { display: block; margin-top: 10px; padding-top: 8px; }
#app-view .tv-icon { width: 32px; height: 32px; font-size: 21px; }

/* Compact disclosure cards */
#app-view .compact-card { padding: 0; min-width: 0; }
#app-view .compact-card > summary {
  cursor: pointer;
  padding: 16px 18px;
  font-size: 14px; font-weight: 650;
  min-height: 48px;
  list-style: none;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
#app-view .compact-card > summary::-webkit-details-marker { display: none; }
#app-view .compact-card > summary::after {
  content: '+'; font-size: 20px; color: var(--accent);
}
#app-view .compact-card[open] > summary::after { content: '−'; }
#app-view .compact-card[open] > summary { border-bottom: 1px solid var(--line); }
#app-view .compact-body { padding: 0 18px 16px; }
#app-view .compact-body > .eyebrow { display: none; }
#app-view .compact-body > .card-head { margin-top: 10px; }

#app-view .remote {
  margin: 6px auto 12px;
  padding: 15px;
  width: 230px;
  border-radius: 22px;
}
#app-view .dpad { grid-template-rows: repeat(3, 46px); margin: 14px 0; }
#app-view .volume { margin-top: 12px; }
#app-view .remote-card h2 { font-size: 18px; margin: 0 0 10px; }
#app-view .remote-card .eyebrow { display: none; }
.remote-extra > summary {
  cursor: pointer;
  font-size: 12px;
  padding: 13px 2px;
  color: var(--accent);
}
#app-view .history-list { max-height: 260px; }
#app-view footer { margin-top: 20px; }

/* 14. Responsive ========================================== */
@media (min-width: 1500px) {
  main { padding: 45px 65px; }
}

@media (max-width: 1100px) {
  .sidebar { width: 185px; padding: 30px 16px; }
  main {
    margin-left: 185px;
    width: calc(100% - 185px);
    padding: 28px 22px;
  }
  .header-right #sync-status { display: none; }
  .workspace { gap: 16px; }
  .card { padding: 20px; }
  .subtle { display: none; }
}

@media (max-width: 900px) {
  .hub-readings { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 800px) {
  .sidebar {
    position: static; width: auto;
    padding: 15px 18px;
    flex-direction: row; align-items: center; justify-content: space-between;
    gap: 14px;
  }
  .sidebar .brand { font-size: 22px; }
  .side-label, .side-bottom { display: none; }
  .sidebar nav { display: flex; gap: 4px; }
  .nav { padding: 12px; font-size: 18px; margin: 0; }
  .nav span { display: none; }

  .app { display: block; }
  main { margin: 0; width: 100%; padding: 23px 18px; }
  h1 { font-size: 27px; }
  .header-right { gap: 10px; }
  .header-right .avatar { display: none; }
  .workspace { grid-template-columns: 1fr 1fr; }
  .card-head { flex-wrap: wrap; }
  .settings-grid { grid-template-columns: 1fr; }

  .login-wrap { grid-template-columns: 1fr; }
  .login-brand { min-height: 240px; padding: 28px; }
  .login-brand h1 { font-size: 34px; margin: 25px 0 10px; }
  .login-brand p, .login-brand .quiet, .login-brand .eyebrow { display: none; }
  .login-card { padding: 28px; max-width: 460px; }
  .login-card h2 { font-size: 27px; }

  /* #app-view specific mobile tweaks */
  #app-view .sidebar { flex-wrap: wrap; padding: 12px 16px; }
  #app-view .sidebar nav { width: 100%; overflow-x: auto; gap: 4px; }
  #app-view .nav {
    font-size: 14px; white-space: nowrap;
    width: auto; flex-shrink: 0; padding: 10px;
  }
  #app-view .nav span { display: inline; font-size: 12px; }
  #app-view main { padding: 18px 14px; }
}

@media (max-width: 620px) {
  .workspace { grid-template-columns: 1fr; }
  .card-head { flex-wrap: nowrap; }
  .device-grid { grid-template-columns: 1fr; }
  .section-intro p { max-width: 220px; }

  /* Make refresh button icon-only on small screens */
  .header-right .outline { font-size: 0; padding: 10px; width: 44px; }
  .header-right .outline::before { content: '↻'; font-size: 22px; }

  .remote { width: 250px; }
  .dpad { grid-template-rows: repeat(3, 57px); }
  .card h2 { font-size: 19px; }

  footer span { max-width: 190px; text-align: right; }
  .inline-form { flex-wrap: wrap; }
  .inline-form label { flex-basis: 100%; }
  .inline-form button { width: 100%; }

  header { padding-bottom: 18px; }
  .history-list { max-height: 400px; }
  .login-brand { min-height: 220px; }
  .check { gap: 12px; }
  .check span:first-child { max-width: 65%; }

  /* #app-view specific */
  #app-view .workspace { grid-template-columns: 1fr; }
  #app-view .settings-grid { grid-template-columns: 1fr; }
  #app-view .compact-card > summary { padding: 14px 16px; }
  #app-view .compact-body { padding: 0 16px 14px; }
  #app-view .device-grid { grid-template-columns: 1fr; }
  #app-view .remote-card > .hint { margin-bottom: 0; }
}

@media (max-width: 600px) {
  .advice-main, .advice-room { grid-column: 1 / -1; }
}

@media (max-width: 450px) {
  .hub-fields-grid { grid-template-columns: 1fr; }
  .hub-reading { padding: 15px; }
  .hub-reading strong { font-size: 20px; }
  .sidebar nav { gap: 0; }
  .sidebar .nav { padding: 10px; }
}

/* 15. Motion preference =================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}#camera-image{display:block;width:100%;max-height:450px;object-fit:contain;background:#101c24;border-radius:10px}#camera-select{padding:10px;border:1px solid var(--line);border-radius:8px}#camera-status{overflow-wrap:anywhere}#camera-api{white-space:pre-wrap;overflow-wrap:anywhere;font-size:12px}#camera-history{white-space:pre-wrap;font-size:12px;line-height:1.8;max-height:260px;overflow:auto}.camera-add{margin-top:16px}#camera-auto{display:inline;width:auto;min-height:0}#cameras .hub-fields-grid input[type=checkbox]{width:auto;min-height:0}#cameras>.section-intro label{margin:0}
