:root {
  --bg: #07090d;
  --panel: #0e131b;
  --line: #1b2531;
  --ink: #e6edf3;
  --dim: #6b7a8d;
  --cyan: #34e3ff;
  --amber: #ffb547;
  --green: #43e08a;
  --mono: "Consolas", "SFMono-Regular", ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  overflow: hidden;
}

/* faint technical grid */
body::before {
  content: "";
  position: fixed; inset: 0;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 46px 46px;
  opacity: 0.18;
  pointer-events: none;
}

#app { height: 100vh; display: flex; flex-direction: column; position: relative; }

/* top bar */
#bar {
  display: flex; align-items: center; gap: 18px;
  padding: 22px 34px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(14,19,27,0.9), rgba(14,19,27,0));
}
#status { letter-spacing: 5px; font-size: 20px; color: var(--dim); font-weight: 700; }
#clock { margin-left: auto; color: var(--dim); letter-spacing: 3px; font-size: 20px; }

/* status orb */
#orb {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--dim);
  box-shadow: 0 0 0 0 transparent;
  transition: background .25s ease, box-shadow .25s ease;
}
#app[data-state="idle"]      #orb { background: #2a3a48; }
#app[data-state="listening"] #orb { background: var(--green); animation: pulse 1.1s infinite; }
#app[data-state="thinking"]  #orb { background: var(--amber); animation: pulse 0.7s infinite; }
#app[data-state="speaking"]  #orb { background: var(--cyan);  animation: pulse 0.9s infinite; }

#app[data-state="idle"]      #status::after { content: ""; }
#app[data-state="listening"] #status::after { content: " // LISTENING"; color: var(--green); }
#app[data-state="thinking"]  #status::after { content: " // THINKING"; color: var(--amber); }
#app[data-state="speaking"]  #status::after { content: " // SPEAKING"; color: var(--cyan); }

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 currentColor; }
  70%  { box-shadow: 0 0 0 16px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* stage + views */
#stage { flex: 1; position: relative; }
.view {
  position: absolute; inset: 0;
  display: none;
  padding: 40px 48px;
  flex-direction: column;
}
.view.active { display: flex; }

/* idle */
/* safe center: vertically center when it fits, but fall back to top-align (no clipping)
   when the music bar shrinks the stage - otherwise the device cards get cut off. */
#idle { align-items: center; justify-content: safe center; gap: 14px; overflow-y: auto; }
.wordmark {
  font-size: clamp(40px, 6vw, 96px);
  font-weight: 800;
  letter-spacing: 10px;
  color: var(--ink);
  text-shadow: 0 0 50px rgba(52,227,255,0.25);
}
.tagline { color: var(--dim); font-size: clamp(16px, 2vw, 26px); letter-spacing: 2px; }
.tagline b { color: var(--cyan); }

/* device status tiles (idle view) */
.dev-grid {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 16px;
  width: 100%; max-width: 980px; margin-top: 14px;
}
.dev-tile {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 15px 20px; min-width: 230px; flex: 0 1 280px;
  display: flex; flex-direction: column; gap: 8px;
}
.dev-head { display: flex; align-items: center; gap: 10px; }
.dev-dot { width: 11px; height: 11px; border-radius: 50%; background: #44505f; flex: none;
           transition: background .3s, box-shadow .3s; }
.dev-dot.online  { background: var(--green); box-shadow: 0 0 10px rgba(67,224,138,.55); }
.dev-name { font-size: 18px; font-weight: 700; letter-spacing: 1px; color: var(--ink); }
.dev-type { margin-left: auto; font-size: 11px; color: var(--dim);
            text-transform: uppercase; letter-spacing: 1px; }
.dev-line { font-size: 14px; color: var(--dim); display: flex; gap: 8px; }
.dev-line .k { min-width: 56px; color: var(--dim); }
.dev-line .v { color: var(--ink); }
.dev-line .v.app { color: var(--cyan); }
.dev-line .v.off { color: var(--dim); }
.dev-tile.pc { border-color: rgba(52,227,255,0.5); flex: 0 1 340px; }
.dev-line .v.play { color: var(--amber); }
#music-liked { max-height: 260px; overflow-y: auto; }

/* radar */
#radar { padding: 0; }
#radar-frame { width: 100%; height: 100%; border: 0; }
.overlay-label {
  position: absolute; top: 24px; left: 28px;
  background: rgba(7,9,13,0.78);
  border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 8px;
  letter-spacing: 3px; color: var(--cyan); font-size: 20px;
}

/* card */
#card-title { color: var(--cyan); letter-spacing: 3px; font-size: clamp(28px, 4vw, 56px); margin-bottom: 24px; }
#card-body { color: var(--ink); font-size: clamp(20px, 2.6vw, 34px); line-height: 1.5; white-space: pre-wrap; }

/* stats */
#stats-title { color: var(--cyan); letter-spacing: 3px; font-size: clamp(28px, 4vw, 56px); margin-bottom: 30px; }
#stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 24px; }
.tile {
  position: relative;
  background: linear-gradient(160deg, #131b27 0%, #0b0f17 100%);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 26px 30px 24px;
  overflow: hidden;
}
.tile::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: linear-gradient(180deg, var(--cyan), #1d7e94);
}
.tile .l {
  color: var(--dim); letter-spacing: 3px; text-transform: uppercase; font-size: 15px;
}
.tile .v {
  font-size: clamp(46px, 7vw, 92px); font-weight: 800; line-height: 0.95; margin-top: 12px;
  color: var(--ink); text-shadow: 0 0 28px rgba(52, 227, 255, 0.22);
}
.tile .s { color: var(--green); margin-top: 12px; font-size: 18px; letter-spacing: 1px; }
.tile .s:empty { display: none; }

/* Spotify mini-player - in the layout flow (above the caption/input, no overlap) */
#music {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 34px; border-top: 1px solid var(--line);
  background: var(--panel);
}
#music.hidden { display: none; }
#music-art { width: 50px; height: 50px; border-radius: 8px; object-fit: cover; background: #0b0f17; }
.music-meta { min-width: 120px; flex: 1; max-width: 50%; }
#music-track { color: var(--ink); font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#music-artist { color: var(--dim); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.music-btns { display: flex; gap: 4px; margin-left: auto; }
.music-btns button {
  background: none; border: none; color: var(--ink); font-size: 22px; cursor: pointer;
  padding: 6px 10px; border-radius: 8px; line-height: 1;
}
.music-btns button:hover { background: rgba(67, 224, 138, 0.12); }
.music-btns button.active { color: var(--green); }
.music-vol { display: flex; align-items: center; gap: 6px; margin-left: 6px; }
.music-vol .vol-icon { color: var(--dim); font-size: 15px; }
#music-vol-slider { width: 96px; accent-color: var(--cyan); cursor: pointer; }

/* Music panel (search + liked + playlists), same overlay as settings */
#music-panel {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(4, 6, 9, 0.82); display: flex; align-items: center; justify-content: center;
}
#music-panel.hidden { display: none; }
#music-search {
  width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  color: var(--ink); font-family: var(--mono); font-size: 20px; padding: 12px 14px; margin-bottom: 16px;
}
#music-results, #music-playlists { max-height: 26vh; overflow-y: auto; margin-bottom: 14px; }
.mrow {
  display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 8px; cursor: pointer;
}
.mrow:hover { background: #141b25; }
.mrow img { width: 36px; height: 36px; border-radius: 5px; object-fit: cover; background: #0b0f17; }
.mrow .mtitle { color: var(--ink); font-size: 17px; }
.mrow .msub { color: var(--dim); font-size: 14px; }
.music-quick { margin: 8px 0 16px; }
.music-quick button, #music-close {
  background: var(--bg); border: 1px solid var(--cyan); color: var(--cyan);
  font-family: var(--mono); font-size: 17px; padding: 10px 18px; border-radius: 10px; cursor: pointer;
}
.music-sub { color: var(--dim); letter-spacing: 2px; text-transform: uppercase; font-size: 14px; margin: 6px 0; }

/* caption strip (overlay; does not replace the main view) */
#caption {
  padding: 14px 34px;
  border-top: 1px solid var(--line);
  display: flex; gap: 22px; align-items: baseline;
  font-size: clamp(16px, 1.9vw, 26px);
}
#caption.hidden { display: none; }
#cap-you { color: var(--dim); }
#cap-you::before { content: "you  "; color: #3a4a58; letter-spacing: 2px; }
#cap-cortex { color: var(--cyan); }
#cap-cortex:not(:empty)::before { content: "cortex  "; color: #2a5563; letter-spacing: 2px; margin-left: 8px; }

/* input bar */
#inputbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 34px; border-top: 1px solid var(--line);
  background: var(--panel);
}
#inputbar .prompt { color: var(--cyan); font-size: 22px; }
#cmd {
  flex: 1; background: transparent; border: 0; outline: none;
  color: var(--ink); font-family: var(--mono); font-size: clamp(16px, 1.9vw, 24px);
  cursor: text;
}
#cmd::placeholder { color: #3a4a58; }
/* let the pointer/caret show in the input even though the kiosk hides the cursor */
#inputbar, #inputbar * { cursor: auto; }

/* settings gear + panel */
#gear {
  margin-left: 18px; background: none; border: none; color: var(--dim);
  font-size: 24px; cursor: pointer; transition: color .2s, transform .3s;
}
#gear:hover { color: var(--cyan); transform: rotate(45deg); }
#music-open {
  margin-left: 18px; background: none; border: none; color: var(--dim);
  font-size: 22px; cursor: pointer; transition: color .2s;
}
#music-open:hover { color: var(--green); }

#settings {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(4, 6, 9, 0.82);
  display: flex; align-items: center; justify-content: center;
}
#settings.hidden { display: none; }
#settings .panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 34px 38px; width: min(560px, 90vw);
}
#settings h2 { color: var(--cyan); letter-spacing: 3px; margin-bottom: 24px; font-size: 28px; }
.srow {
  display: flex; align-items: center; gap: 12px;
  font-size: 20px; color: var(--ink); margin-bottom: 18px;
}
.srow input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--cyan); cursor: pointer; }
.srow input[type="time"], .srow select {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  color: var(--ink); font-family: var(--mono); font-size: 20px; padding: 8px 12px; cursor: pointer;
}
.remote-block { flex-direction: column; align-items: stretch; gap: 8px;
  border-top: 1px solid var(--line); padding-top: 16px; }
.remote-block > label { display: flex; align-items: center; gap: 12px; }
.remote-status { font-family: var(--mono); font-size: 15px; color: var(--dim); padding-left: 34px; }
.remote-qr-btn { align-self: flex-start; margin-left: 34px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  color: var(--ink); font-family: var(--mono); font-size: 15px; padding: 7px 14px; cursor: pointer; }
#remote-qr { margin-left: 34px; color: var(--dim); font-size: 14px; }
#remote-qr img { width: 200px; height: 200px; background: #fff; padding: 8px; border-radius: 8px; display: block; }
.qr-url { font-family: var(--mono); font-size: 12px; color: var(--dim); word-break: break-all; margin-top: 6px; max-width: 320px; }

.sactions { display: flex; gap: 14px; margin-top: 12px; }
.sactions button {
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  color: var(--ink); font-family: var(--mono); font-size: 18px; padding: 10px 22px; cursor: pointer;
}
#brief-save { border-color: var(--cyan); color: var(--cyan); }
.sactions button:hover { background: #141b25; }
#settings-status { color: var(--green); margin-top: 16px; min-height: 22px; font-size: 16px; }

/* brand footer */
#brand {
  padding: 14px 34px; border-top: 1px solid var(--line);
  color: var(--dim); letter-spacing: 6px; font-size: 14px; text-align: right;
  cursor: pointer; transition: color .2s;
}
#brand:hover { color: var(--cyan); }

/* ---------------------------------------------------------------------------
   Phone layout. The dashboard's default sizing is tuned for a TV/PC kiosk read
   from across the room; on a handset (the remote URL) it's oversized. This block
   only applies at narrow widths, so the TV/PC view is untouched. Goals: compact
   spacing, one tile per row, full-bleed panels, comfortable tap targets, and
   >=16px inputs so iOS Safari doesn't zoom the page when you focus a field.
   --------------------------------------------------------------------------- */
@media (max-width: 640px) {
  /* use the dynamic viewport height so the bottom bar isn't hidden behind the
     phone browser's address bar */
  #app { height: 100dvh; }
  body::before { background-size: 30px 30px; }

  #bar { gap: 9px; padding: 11px 14px; }
  #orb { width: 15px; height: 15px; }
  #status { font-size: 13px; letter-spacing: 2px; }
  #clock { font-size: 13px; letter-spacing: 1px; }
  #music-open, #gear { margin-left: 8px; font-size: 20px; padding: 4px; }

  .view { padding: 16px 14px; }
  #idle { gap: 9px; }
  .wordmark { font-size: 34px; letter-spacing: 5px; text-shadow: 0 0 30px rgba(52,227,255,0.25); }
  .tagline { font-size: 14px; letter-spacing: 1px; }

  /* one full-width tile per row (the TV uses a wrapping multi-column grid) */
  .dev-grid { gap: 10px; margin-top: 8px; }
  .dev-tile, .dev-tile.pc { flex: 1 1 100%; min-width: 0; width: 100%; padding: 12px 14px; }
  .dev-name { font-size: 16px; }
  .dev-line { font-size: 13px; }

  /* briefing stats + cards */
  #card-title, #stats-title { font-size: 25px; letter-spacing: 2px; margin-bottom: 16px; }
  #card-body { font-size: 16px; }
  /* single column so long values (e.g. a 6-figure crypto price) never clip */
  #stats-grid { grid-template-columns: 1fr; gap: 10px; }
  .tile { padding: 14px 16px; border-radius: 14px; }
  .tile .l { font-size: 12px; letter-spacing: 2px; }
  .tile .v { font-size: 34px; }
  .tile .s { font-size: 14px; }

  /* music mini-player: wrap so 7 buttons + volume don't overflow a narrow row */
  #music { flex-wrap: wrap; gap: 9px; padding: 9px 14px; }
  #music-art { width: 42px; height: 42px; }
  .music-meta { max-width: none; flex: 1 1 55%; }
  #music-track { font-size: 15px; }
  #music-artist { font-size: 13px; }
  .music-btns { gap: 2px; margin-left: auto; }
  .music-btns button { font-size: 20px; padding: 6px 7px; }
  .music-vol { flex: 1 1 100%; margin-left: 0; }
  #music-vol-slider { width: 100%; }

  /* settings + music overlays: nearly full-bleed and scrollable */
  #settings .panel, #music-panel .panel {
    width: 94vw; max-height: 88vh; overflow-y: auto; padding: 20px 18px; border-radius: 14px;
  }
  #settings h2, #music-panel h2 { font-size: 22px; margin-bottom: 16px; }
  .srow { font-size: 16px; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
  .srow input[type="time"], .srow select { font-size: 16px; padding: 7px 10px; }
  .sactions button { font-size: 16px; padding: 10px 16px; }
  #music-search { font-size: 16px; padding: 11px 12px; }
  .mrow .mtitle { font-size: 15px; }
  .mrow .msub { font-size: 13px; }
  .music-quick button, #music-close { font-size: 15px; padding: 9px 14px; }
  #remote-qr img { width: 168px; height: 168px; }
  .qr-url { max-width: 100%; }

  /* caption + command input + brand */
  #caption { padding: 10px 14px; gap: 12px; font-size: 14px; }
  #inputbar { padding: 10px 14px; gap: 8px; }
  #inputbar .prompt { font-size: 18px; }
  #cmd { font-size: 16px; }            /* 16px = no iOS zoom-on-focus */
  #brand { padding: 10px 14px; font-size: 11px; letter-spacing: 3px; }
}
