:root {
  color-scheme: dark;
  --bg: #10110e;
  --bg-2: #171910;
  --line: #2d3026;
  --text: #f3f1e6;
  --muted: #a7a894;
  --accent: #d6f25c;
  --accent-ink: #17200a;
  --danger: #ff6b4a;
  --ok: #8ee0b0;
  --warn: #e7c56a;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(900px 420px at 0% -10%, rgba(214, 242, 92, 0.09), transparent 55%),
    var(--bg);
  color: var(--text);
}

button, input, select, textarea { font: inherit; color: inherit; }

button, .device-main {
  cursor: pointer;
}

button, input, select, textarea {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #12140f;
}

button, select, input { padding: 10px 12px; }

button {
  background: #22261c;
}

button:hover { border-color: #4d5342; }

button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .device-main:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
  font-weight: 650;
}

button.danger {
  background: transparent;
  color: var(--danger);
  border-color: #6a3328;
}

button.ghost { background: transparent; }

body.busy { cursor: progress; }
body.busy button { opacity: 0.7; }

.app {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.rail {
  padding: 32px 26px;
  border-right: 1px solid var(--line);
  background: #0c0d0b;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.mark {
  margin: 0;
  font-size: 40px;
  letter-spacing: -0.06em;
  font-weight: 600;
}

.lede, .fine, .muted { color: var(--muted); }

.lede { line-height: 1.45; }

.steps {
  margin: 8px 0 0;
  padding-left: 18px;
  line-height: 1.45;
}

.steps li { margin: 12px 0; }

.fine {
  margin-top: auto;
  font-size: 13px;
  line-height: 1.4;
}

.adb-meta {
  margin: 16px 0 0;
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 12px;
  color: var(--accent);
  word-break: break-word;
}

main {
  min-width: 0;
  padding: 32px 36px 64px;
  max-width: 1180px;
}

.page-head, .discover-bar, .inline, .selection-bar {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

.page-head { align-items: flex-end; margin-bottom: 16px; }

.eyebrow {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 11px;
  color: var(--accent);
}

h1, h2 { margin: 0; font-weight: 560; letter-spacing: -0.04em; }
h1 { font-size: 40px; }
h2 { font-size: 22px; }
#accounts h3 { margin: 4px 0 8px; font-size: 18px; font-weight: 560; }
#password-form { margin-bottom: 28px; }

.section-title { margin: 28px 0 12px; }

.panel {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(23, 25, 16, 0.92);
  box-shadow: var(--shadow);
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 22px;
}

.panel, .stack, .service, .device { min-width: 0; }

.stack, .stack label { display: flex; flex-direction: column; gap: 8px; }
.stack { gap: 12px; }

label { font-size: 13px; color: var(--muted); }
input, select, textarea { width: 100%; background: #10120d; }
textarea { min-height: 72px; resize: vertical; padding: 10px 12px; }

.file-line { position: relative; }
.file-line input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
.file-btn {
  display: inline-flex;
  width: auto;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  background: #171910;
}

.pair-row, .inline { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.pair-row label, .inline label { flex: 1 1 140px; min-width: 0; }
.grow { flex: 2; }

.check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  min-width: auto;
  padding-bottom: 10px;
}
.check input { width: auto; }

.discover-bar { margin-top: 22px; align-items: end; }
.discover-actions { display: flex; flex-direction: column; gap: 8px; }
.rail-form { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 12px; }
.rail-form input, .rail-form button { width: 100%; }
.discover-list, .device-list { display: grid; gap: 10px; margin-top: 14px; }

.service, .device {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #12140f;
}

.device.selected { border-color: var(--accent); }
.device-copy { flex: 1; min-width: 0; }
.book-note, .book-comment { display: block; }
.book-comment { margin-top: 6px; white-space: pre-wrap; }
.book-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.device-main {
  flex: 1;
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 12px;
  align-items: center;
  text-align: left;
  background: transparent;
  border: 0;
  color: inherit;
  padding: 0;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 99px;
  background: var(--ok);
  display: block;
}
.dot.off { background: var(--danger); }

.mono, .pkg-name, #log, .adb-meta { font-family: Consolas, "Cascadia Mono", monospace; }

.workspace { margin-top: 10px; }

.info-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.stat {
  padding: 12px;
  border-radius: 16px;
  background: #12140f;
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 74px;
}
.stat span { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; }
.stat strong { font-size: 16px; font-weight: 560; word-break: break-word; }

.pkg-list {
  max-height: 460px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #10120d;
}

.pkg {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 9px 12px;
  border-bottom: 1px solid #24271e;
}
.pkg:last-child { border-bottom: 0; }
.pkg.is-off .pkg-name { color: var(--muted); text-decoration: line-through; }
.pkg.is-suggested { background: rgba(214, 242, 92, 0.08); box-shadow: inset 3px 0 0 #d6f25c; }
.pkg.is-careful { background: rgba(231, 197, 106, 0.08); box-shadow: inset 3px 0 0 #e7c56a; }
.pkg-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.pkg-name { font-size: 13px; word-break: break-all; }
.pkg-reason { color: #c9c6b6; font-size: 12px; line-height: 1.35; }
.advice-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin: 14px 0;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid #5a6a2c;
  background: rgba(214, 242, 92, 0.08);
}
.advice-bar p { margin: 0; line-height: 1.4; flex: 1 1 280px; min-width: 0; }

.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}
.badge.warn { color: var(--warn); border-color: #6a5a28; }
.badge.advice { color: #d6f25c; border-color: #5a6a2c; }
.badge.careful { color: #e7c56a; border-color: #6a5a28; }

.selection-bar { margin-top: 12px; }

.banner {
  background: #2a2616;
  color: #f0e2a8;
  border: 1px solid #6d6230;
  padding: 12px 14px;
  border-radius: 14px;
  margin-bottom: 16px;
}

.banner p { margin: 0; }

.banner-links, .adb-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-top: 10px;
}

.banner-links a, .adb-links a, button.linkish {
  color: #d6f25c;
  font-weight: 600;
}

button.linkish {
  background: transparent;
  border: 0;
  padding: 0;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
}

button.linkish:disabled { opacity: 0.55; cursor: progress; }

.adb-links { font-size: 13px; }

.rail-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0 18px;
}

.rail-nav a {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}

.rail-nav a:hover { color: var(--accent); }

#connect, #optimize, #lumina { scroll-margin-top: 18px; }

.cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}

.card, .install-box {
  padding: 14px;
  border-radius: 16px;
  background: #12140f;
  border: 1px solid var(--line);
}

.card h3, .install-box h3 {
  margin: 0 0 8px;
  font-size: 16px;
  letter-spacing: -0.03em;
}

.card p, .install-box p, .install-box li { color: var(--muted); line-height: 1.45; }

.card p { margin: 0 0 8px; }
.card p:last-child { margin-bottom: 0; }

.lumina-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(240px, 0.8fr);
  gap: 18px;
  margin-top: 16px;
}

.tv {
  background: #07080a;
  border-radius: 28px;
  padding: 12px 12px 18px;
  border: 1px solid #2a2c24;
}

.tv-screen {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 16px;
  overflow: hidden;
  background: #05060a;
  container-type: size;
}

.tv-screen canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.stage-ui, .stage-sleep {
  position: absolute;
  inset: 0;
  flex-direction: column;
  padding: 2.4% 4.6% 1.4%;
  color: #f4f0e6;
  pointer-events: none;
}

.stage-ui:not([hidden]),
.stage-sleep:not([hidden]) {
  display: flex;
}

.stage-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.stage-greet {
  margin: 0;
  color: #e7c99a;
  font-size: clamp(11px, 1.5vw, 16px);
}

.stage-brand {
  margin: 0;
  font-size: 3.6cqi;
  font-weight: 300;
  letter-spacing: -0.04em;
  line-height: 1;
}

.stage-date, .sleep-date {
  margin: 6px 0 0;
  color: #f4f0e6;
  font-size: clamp(11px, 1.3vw, 15px);
}

.sleep-clock {
  margin: 0;
  font-weight: 300;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.stage-nav {
  display: flex;
  gap: 6px;
  align-items: center;
}

.stage-nav span {
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.08);
  font-size: clamp(10px, 1.2vw, 13px);
}

.stage-hero {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.6cqi;
  margin: 0.4cqi 0 0.2cqi;
}

.flip-clock {
  display: flex;
  align-items: center;
  perspective: 600px;
}

.flip-digit, .flip-colon {
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.flip-digit {
  width: 3.5cqi;
  height: 4.6cqi;
  margin-right: 0.35cqi;
  border-radius: 0.6cqi;
  background: rgba(17, 22, 34, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.1cqi;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.35);
}

.flip-colon {
  margin: 0 0.6cqi 0.8cqi 0;
  font-size: 5.4cqi;
}

.flip-digit.is-flipping {
  animation: flap 0.36s ease;
}

@keyframes flap {
  0% { transform: rotateX(0); }
  45% { transform: rotateX(-90deg); }
  55% { transform: rotateX(90deg); }
  100% { transform: rotateX(0); }
}

.stage-weather { line-height: 1.1; }
.stage-temp {
  margin: 0;
  font-size: 3.4cqi;
  font-weight: 300;
}
.stage-place {
  margin: 4px 0 0;
  color: #e7c99a;
  font-size: clamp(11px, 1.4vw, 16px);
}

.stage-rows { margin-top: 0; }

.row-label {
  margin: 2px 0 4px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #d9d4c6;
}

.cards-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.8cqi;
}

.stage-nav .stage-icon {
  width: 2.6cqi;
  height: 2.6cqi;
  min-width: 28px;
  min-height: 28px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.stage-icon svg { width: 62%; height: 62%; display: block; }

.app-card {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  background: transparent;
  overflow: hidden;
  border-radius: 1.2cqi;
}

.app-icon {
  position: relative;
  inset: auto;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
}

.tone-lime { background: #d6f25c; }
.tone-mint { background: #8ee0b0; }
.tone-gold { background: #e7c56a; }
.tone-sky { background: #9ebfda; }
.tone-sand { background: #e7c98a; }
.tone-clay { background: #c56b58; }
.tone-leaf { background: #48e0a0; }

.stage-hint {
  margin: 4px 0 0;
  color: #c8c2b4;
  font-size: 12px;
}

.stage-sleep {
  align-items: center;
  justify-content: center;
  text-align: center;
}

.sleep-clock { font-size: clamp(56px, 8vw, 108px); }

.sleep-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 9%;
  margin: 0;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-size: clamp(10px, 1.3vw, 14px);
}

.control-label {
  margin: 14px 0 8px;
  font-size: 13px;
  color: var(--muted);
}

.looks { display: flex; flex-wrap: wrap; gap: 8px; }

.look {
  border-radius: 999px;
  padding: 8px 12px;
  background: #171910;
}

.look.is-on {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
  font-weight: 650;
}

.install-box { margin-top: 16px; }
.install-box ol { margin: 8px 0; padding-left: 18px; }
.install-box button { margin-top: 8px; }

#log {
  margin: 0;
  min-height: 120px;
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12.5px;
  line-height: 1.45;
  color: #d9d6c8;
}

.log-panel { margin-top: 28px; }

details.advanced {
  margin-top: 18px;
  color: var(--muted);
}
details.advanced summary { cursor: pointer; }
details.advanced form { margin-top: 12px; }

@media (max-width: 1200px) {
  .split, .lumina-layout, .cards { grid-template-columns: 1fr; }
}

@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .fine { margin-top: 18px; }
  .split { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: 1fr 1fr; }
  main { padding: 22px 16px 48px; max-width: none; }
  .app-card { width: 100%; }
  h1 { font-size: 32px; }
}

@media (max-width: 640px) {
  .split, .info-grid, .page-head, .discover-bar { grid-template-columns: 1fr; display: grid; }
  .device, .service { flex-direction: column; align-items: stretch; }
}

.user-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(23, 25, 16, 0.92);
  box-shadow: var(--shadow);
}

.login-card h1 { margin: 8px 0 12px; font-size: 32px; }
.login-error { min-height: 1.2em; color: #ffb4a8; }
