/* Companion standalone (car mode). Readable at a glance: big type, 64 px+ targets, high contrast, landscape first.
   Motion: 150 ms smootherstep (the Gyrodex rule), none with Reduce Motion. */
:root {
  --bg: #0f1117; --panel: #161a22; --panel2: #1c212c; --line: #2a303d; --text: #e6e8ee; --muted: #8b93a7;
  --accent: #5eead4; --accent2: #818cf8; --warn: #fbbf24; --bad: #f87171; --ok: #86efac; --rec: #ef4444;
  --dur: 150ms; --ease: linear(0, 0.0051, 0.0355, 0.1035, 0.2099, 0.3466, 0.5, 0.6534, 0.7901, 0.8965, 0.9645, 0.9949, 1);
  --top: env(safe-area-inset-top, 0px); --bot: env(safe-area-inset-bottom, 0px); --left: env(safe-area-inset-left, 0px); --right: env(safe-area-inset-right, 0px);
  --hit: 56px;
}
@supports not (transition-timing-function: linear(0, 1)) { :root { --ease: cubic-bezier(.45, 0, .55, 1); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; } }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 17px/1.3 -apple-system, system-ui, "Segoe UI", sans-serif; overflow: hidden; }
body { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
input, textarea { user-select: text; -webkit-user-select: text; }
button { font: inherit; color: inherit; touch-action: manipulation; }
.boot { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--muted); padding: 24px; text-align: center; }
.boot.err { color: var(--bad); }

.app { position: fixed; inset: 0; display: flex; flex-direction: column; padding: var(--top) var(--right) var(--bot) var(--left); }
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 10px; border-bottom: 1px solid var(--line); }
.grow { flex: 1; }
.chip { flex-shrink: 0; min-height: 44px; min-width: 44px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel2); color: var(--muted); font-size: 15px; white-space: nowrap;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease); }
.chip.icon { min-width: 48px; font-size: 20px; padding: 0; }
.chip.on, .chip[data-s="connected"], .chip[data-s="ok"] { color: var(--accent); border-color: #2c6b5c; }
.chip[data-s="signedOut"], .chip[data-s="off"], .chip[data-s="queued"] { color: var(--warn); border-color: #a16207; }
.chip.upd.ready { color: #0b0d13; background: var(--accent); border-color: var(--accent); animation: glow 1.6s var(--ease) infinite alternate; }
@keyframes glow { to { box-shadow: 0 0 16px rgba(94, 234, 212, .55); } }
.mic { width: 14px; height: 14px; min-height: 0; min-width: 0; padding: 0; border-radius: 50%; background: #3a3f4b; border: 0; }
.mic.on { background: #f59e0b; box-shadow: 0 0 10px rgba(245, 158, 11, .7); }
.mic.rec { background: var(--rec); box-shadow: 0 0 12px rgba(239, 68, 68, .8); }

/* car layout: landscape = three columns, portrait = stacked */
.car { flex: 1; min-height: 0; display: grid; gap: 12px; padding: 12px; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr); grid-template-areas: "now" "talk" "lists"; }
@media (orientation: landscape) {
  .car { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr) minmax(200px, .7fr); grid-template-rows: minmax(0, 1fr); grid-template-areas: "now lists talk"; }
}
section { min-height: 0; border-radius: 20px; background: var(--panel); border: 1px solid var(--line); }
.now { grid-area: now; display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto; gap: 12px; padding: 14px; align-content: center; }
.art { width: 132px; height: 132px; border-radius: 14px; background: var(--panel2) center / cover no-repeat; }
.art.empty::after { content: "♫"; display: flex; height: 100%; align-items: center; justify-content: center; font-size: 48px; color: #3a3f4b; }
.meta { min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.track { font-size: 26px; font-weight: 700; line-height: 1.15; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.artist { font-size: 19px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctx { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .ctx.err { color: var(--warn); }
.transport { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1.3fr 1fr; gap: 10px; }
.tbtn { min-height: 76px; border-radius: 18px; border: 1px solid var(--line); background: var(--panel2); font-size: 34px; transition: transform var(--dur) var(--ease), background var(--dur) var(--ease); }
.tbtn:active { transform: scale(.96); background: #252b38; }
.tbtn.play { background: #134e48; border-color: #2c6b5c; color: #ccfbf1; font-size: 40px; }
@media (orientation: landscape) {
  .now { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto auto; justify-items: center; text-align: center; }
  .art { width: auto; height: 100%; max-height: 40vh; aspect-ratio: 1; }
  .meta { width: 100%; align-items: center; }
  .track { font-size: 24px; }
  .transport { width: 100%; }
}

.lists { grid-area: lists; display: flex; flex-direction: column; overflow: hidden; }
.lhead { display: flex; align-items: center; gap: 8px; padding: 10px 14px 6px; font-size: 18px; }
.plist { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 0 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.prow { display: flex; align-items: center; gap: 12px; min-height: 68px; padding: 6px 10px; border-radius: 14px; border: 0; background: transparent; text-align: left;
  transition: background var(--dur) var(--ease); }
.prow:active, .prow.flash { background: rgba(94, 234, 212, .14); }
.pimg { flex-shrink: 0; width: 54px; height: 54px; border-radius: 10px; background: var(--panel2) center / cover no-repeat; }
.pname { flex: 1; min-width: 0; font-size: 20px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcount { color: var(--muted); font-size: 14px; }
.empty { padding: 24px 12px; color: var(--muted); text-align: center; }

.talk { grid-area: talk; display: flex; flex-direction: column; gap: 10px; padding: 14px; }
.tstate { font-size: 22px; font-weight: 700; color: var(--accent); } .tstate.err { color: var(--warn); font-size: 17px; }
.ttext { font-size: 17px; color: var(--text); max-height: 7.8em; overflow: hidden; line-height: 1.3; }
.tpend { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { min-height: var(--hit); padding: 0 18px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel2); font-size: 18px; }
.pill.undo { border-color: #a16207; color: var(--warn); }
.talkbtn { margin-top: auto; min-height: 120px; flex: 1; max-height: 260px; border-radius: 26px; border: 2px solid #7f1d3a; background: #3a1622; color: #fecdd3;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; touch-action: none;
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
.talkbtn .ti { font-size: 44px; line-height: 1; } .talkbtn .tl { font-size: 24px; font-weight: 700; }
.talkbtn.down { transform: scale(.98); }
.talkbtn[data-phase="recording"] { background: #b91c1c; border-color: #fca5a5; color: #fff; box-shadow: 0 0 28px rgba(239, 68, 68, .5); }
.talkbtn[data-phase="pending"] { background: #134e48; border-color: #2c6b5c; color: #ccfbf1; }
@media (orientation: portrait) { .talkbtn { min-height: 96px; flex: none; } .talk { flex-direction: row; flex-wrap: wrap; align-items: center; } .talk .tstate, .talk .ttext, .talk .tpend { flex: 1 1 100%; } .talkbtn { flex: 1 1 100%; } }

.toast { position: fixed; left: 50%; bottom: calc(var(--bot) + 18px); transform: translate(-50%, 12px); opacity: 0; pointer-events: none; z-index: 30; max-width: 90vw;
  padding: 12px 18px; border-radius: 14px; background: #20263a; border: 1px solid var(--accent2); font-size: 16px; transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease); }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* settings */
.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(8, 9, 13, .96); overflow-y: auto; -webkit-overflow-scrolling: touch; opacity: 0; pointer-events: none; transition: opacity var(--dur) var(--ease); }
.sheet.on { opacity: 1; pointer-events: auto; }
.sbody { max-width: 760px; margin: 0 auto; padding: calc(var(--top) + 12px) calc(var(--right) + 16px) calc(var(--bot) + 24px) calc(var(--left) + 16px); display: flex; flex-direction: column; gap: 12px; }
.shead { display: flex; align-items: center; } .shead h2 { margin: 0; }
.card { padding: 14px; display: flex; flex-direction: column; gap: 10px; } .card.focus { border-color: var(--accent); }
.card h3 { margin: 0; font-size: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.card p { margin: 0; line-height: 1.4; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.muted { color: var(--muted); } .small { font-size: 14px; }
.btn { min-height: 48px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel2); font-size: 16px; }
.btn.primary { background: #134e48; border-color: #2c6b5c; color: #ccfbf1; }
input[type=email], input[type=text], textarea { width: 100%; min-height: 48px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; font-size: 17px; }
.row input[type=text] { width: auto; flex: 1; }
.tog { display: flex; align-items: center; gap: 10px; min-height: 48px; font-size: 17px; }
.tog input { width: 26px; height: 26px; accent-color: var(--accent); }
.warn { color: var(--warn); }
.kv { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
code.sel { font: 15px ui-monospace, "SF Mono", Menlo, monospace; color: var(--accent); user-select: all; -webkit-user-select: all; overflow-wrap: anywhere; }
.diag { margin: 0; max-height: 40vh; overflow: auto; font: 12px/1.35 ui-monospace, "SF Mono", Menlo, monospace; color: var(--muted); white-space: pre-wrap; user-select: text; -webkit-user-select: text; }
.diag:empty { display: none; }
.modes { display: inline-flex; flex-shrink: 0; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.modes button { min-height: 44px; padding: 0 12px; border: 0; background: var(--panel2); color: var(--muted); font-size: 15px; white-space: nowrap; transition: background var(--dur) var(--ease), color var(--dur) var(--ease); }
.modes button.on { background: rgba(94, 234, 212, .16); color: var(--accent); font-weight: 600; }
.card h3 + p { margin-top: -4px; }
.cmds { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: 17px; }
.talkbtn[data-phase="command"] { background: #312e81; border-color: var(--accent2); color: #e0e7ff; }
.ov { position: fixed; inset: 0; z-index: 15; display: flex; flex-direction: column; gap: 12px; background: rgba(8, 9, 13, .95);
  padding: calc(var(--top) + 12px) calc(var(--right) + 16px) calc(var(--bot) + 14px) calc(var(--left) + 16px);
  opacity: 0; pointer-events: none; transition: opacity var(--dur) var(--ease); }
.ov.on { opacity: 1; pointer-events: auto; }
.ov-head { display: flex; align-items: center; gap: 8px; }
.ov-state { font-size: 22px; font-weight: 700; color: var(--accent); }
.ov-text { font-size: 30px; line-height: 1.25; font-weight: 600; overflow-y: auto; max-height: 45vh; user-select: text; -webkit-user-select: text; }
.ov-text:empty { display: none; }
.ov-list { flex: 1; min-height: 0; overflow-y: auto; display: grid; gap: 8px; align-content: start; grid-template-columns: minmax(0, 1fr); }
.ov-list:empty { display: none; }
@media (orientation: landscape) { .ov-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } .ov-text { font-size: 28px; } }
.ov-row { display: flex; align-items: center; gap: 12px; min-height: 68px; padding: 6px 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); text-align: left;
  transition: background var(--dur) var(--ease); }
.ov-row:active { background: rgba(94, 234, 212, .14); }
.ov-n { flex-shrink: 0; width: 40px; height: 40px; border-radius: 50%; background: #134e48; color: #ccfbf1; display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700; }
.ov-meta { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ov-meta b { font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ov-meta span { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ov-hint { color: var(--muted); font-size: 15px; }
