/* Car desk: Tesla-style dark cards with a touch of Apple glass, tuned to be read at a glance from the driver's seat. */
:root {
  --base: #121316;
  --wash-1: #3e6ae1;
  --glass: rgba(38, 40, 44, 0.74);
  --glass-strong: rgba(60, 63, 68, 0.78);
  --edge: rgba(255, 255, 255, 0.09);
  --shine: rgba(255, 255, 255, 0.10);
  --shade: rgba(0, 0, 0, 0.45);
  --text: #f4f4f4;
  --muted: #a2a4a8;
  --hairline: rgba(255, 255, 255, 0.09);
  --listen: #e82127;  /* mic is live (Tesla red) */
  --think: #f5a623;   /* working on it */
  --speak: #3e6ae1;   /* talking back (Tesla blue) */
  --idle: #b6b8bc;
  --switch-on: #3e6ae1;
  --primary: #3e6ae1;
  --blur: blur(22px) saturate(140%);
  --r-panel: 22px;
  --r-control: 14px;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --base: #e9eaec;
    --wash-1: #3e6ae1;
    --glass: rgba(255, 255, 255, 0.84);
    --glass-strong: rgba(244, 244, 246, 0.95);
    --edge: rgba(23, 26, 32, 0.07);
    --shine: rgba(255, 255, 255, 0.9);
    --shade: rgba(23, 26, 32, 0.08);
    --text: #171a20;
    --muted: #5c5e62;
    --hairline: rgba(23, 26, 32, 0.09);
    --listen: #e31937;
    --think: #c77700;
    --speak: #3e6ae1;
    --idle: #5c5e62;
    --switch-on: #3e6ae1;
    --primary: #3e6ae1;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  color: var(--text);
  font-size: 20px;
  line-height: 1.4;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(70vmax 50vmax at 0% 0%, color-mix(in srgb, var(--wash-1) 9%, transparent), transparent 70%),
    var(--base);
  background-attachment: fixed;
}
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }

/* The glass material: frosted fill, bright top edge, soft lift. */
.glass, .bar, .left, .right, .confirm, .type, .cams, .login form {
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--edge);
  box-shadow:
    inset 0 1px 0 var(--shine),
    inset 0 -1px 1px rgba(255, 255, 255, 0.06),
    0 18px 50px var(--shade);
}

/* Floating top bar */
.bar {
  display: flex;
  align-items: center;
  gap: 18px;
  margin: 16px 20px 0;
  padding: 10px 12px 10px 26px;
  border-radius: 18px;
  flex-wrap: wrap;
}
.bar h1 { font-size: 21px; font-weight: 600; margin: 0 auto 0 0; letter-spacing: -0.01em; }
.bar h1 .ver { font-size: 15px; font-weight: 500; color: var(--muted); margin-left: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 17px; }
.chip::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--hairline); }
.chip.on::before { background: var(--switch-on); box-shadow: 0 0 10px var(--switch-on); }
.spend { color: var(--muted); font-size: 16px; font-variant-numeric: tabular-nums; }
.ghost, .later li button, .type button {
  background: var(--glass-strong);
  border: 1px solid var(--edge);
  box-shadow: inset 0 1px 0 var(--shine);
  border-radius: var(--r-control);
  min-height: 48px;
  padding: 0 22px;
  font-weight: 600;
}

/* Two glass panes: talk button on the driver's side, words on the right */
.desk {
  display: grid;
  grid-template-columns: minmax(320px, 0.85fr) 1.4fr;
  gap: 20px;
  padding: 20px;
  min-height: calc(100vh - 190px);
}
.left, .right { border-radius: var(--r-panel); padding: 30px; }
.left { display: flex; flex-direction: column; align-items: center; gap: 20px; }
.right { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

/* The talk button: a glass orb lit from inside by the state color */
.talk {
  --level: 0;
  --tone: var(--idle);
  position: relative;
  width: min(280px, 60vw);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid var(--edge);
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 32% 22%, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0) 42%),
    radial-gradient(circle at 50% 60%, color-mix(in srgb, var(--tone) 22%, transparent), transparent 70%),
    var(--glass-strong);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow:
    inset 0 2px 1px var(--shine),
    inset 0 -10px 30px color-mix(in srgb, var(--tone) 22%, transparent),
    0 0 calc(18px + var(--level) * 60px) color-mix(in srgb, var(--tone) calc(18% + var(--level) * 50%), transparent),
    0 20px 50px var(--shade);
  transition: box-shadow 140ms linear, background 200ms ease;
}
.talk::after {
  content: "";
  position: absolute;
  inset: -12px;
  border-radius: 50%;
  border: 3px solid var(--tone);
  opacity: calc(0.35 + var(--level) * 0.8);
  transform: scale(calc(1 + var(--level) * 0.06));
  transition: transform 80ms linear, opacity 80ms linear;
}
.talk svg { width: 32%; height: 32%; fill: var(--tone); filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.25)); }
.talk[data-mode="listening"] { --tone: var(--listen); }
.talk[data-mode="thinking"] { --tone: var(--think); }
.talk[data-mode="speaking"] { --tone: var(--speak); }
.talk[data-mode="thinking"]::after { animation: breathe 1.4s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: 0.9; transform: scale(1.04); } }

.status { font-size: 30px; font-weight: 700; text-align: center; margin: 0; letter-spacing: -0.01em; }
.hint { color: var(--muted); text-align: center; margin: -12px 0 0; font-size: 18px; }

/* iOS-style switch */
.toggle {
  display: flex;
  align-items: center;
  gap: 14px;
  background: none;
  border: none;
  padding: 8px 4px;
  min-height: 52px;
  font-size: 19px;
  text-align: left;
}
.toggle .track {
  width: 64px; height: 38px; border-radius: 19px; flex: none; position: relative;
  background: rgba(120, 120, 128, 0.36);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: background 180ms ease;
}
.toggle .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 32px; height: 32px; border-radius: 50%;
  background: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25), 0 1px 1px rgba(0, 0, 0, 0.12);
  transition: transform 180ms ease;
}
.toggle[aria-checked="true"] .track { background: var(--switch-on); }
.toggle[aria-checked="true"] .track::after { transform: translateX(26px); }

/* Conversation */
.heard { color: var(--muted); font-size: 21px; margin: 0; min-height: 1.4em; overflow-wrap: anywhere; }
.reply {
  font-size: 34px;
  line-height: 1.3;
  font-weight: 500;
  letter-spacing: -0.012em;
  margin: 0;
  max-width: 34em;
  overflow-wrap: anywhere;
}
.reply.empty { color: var(--muted); font-weight: 400; }

.notice {
  background: color-mix(in srgb, var(--think) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--think) 45%, transparent);
  padding: 14px 20px;
  border-radius: 14px;
  font-size: 19px;
}
.notice p { margin: 0 0 6px; }
.notice p:last-child { margin: 0; }

/* Send-this sheet */
.confirm {
  border-radius: 18px;
  padding: 24px 26px;
  background: color-mix(in srgb, var(--think) 4%, var(--glass));
  border-color: color-mix(in srgb, var(--think) 50%, var(--edge));
}
.confirm h2 { margin: 0 0 12px; font-size: 26px; letter-spacing: -0.01em; }
.confirm dl { margin: 0 0 12px; display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; }
.confirm dt { color: var(--muted); }
.confirm dd { margin: 0; overflow-wrap: anywhere; }
.confirm .body {
  white-space: pre-wrap;
  max-height: 180px;
  overflow-y: auto;
  border-top: 1px solid var(--hairline);
  padding-top: 12px;
  margin-bottom: 18px;
  overflow-wrap: anywhere;
}
.confirm .actions { display: flex; gap: 14px; flex-wrap: wrap; }
.big {
  min-height: 64px;
  padding: 0 38px;
  border-radius: var(--r-control);
  font-size: 22px;
  font-weight: 600;
  border: 1px solid var(--edge);
}
.big.go {
  background: var(--primary);
  border-color: color-mix(in srgb, #fff 35%, var(--primary));
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.big.stop { background: var(--glass-strong); box-shadow: inset 0 1px 0 var(--shine); }

/* Background jobs in progress */
.working { width: 100%; max-width: 440px; }
.working h2 { font-size: 20px; margin: 0 0 8px; color: var(--muted); font-weight: 500; }
.working ul { list-style: none; margin: 0; padding: 0; }
.working li {
  display: flex; align-items: center; gap: 12px; padding: 10px 0;
  border-top: 1px solid var(--hairline); font-size: 18px; overflow-wrap: anywhere;
}
.working li::before {
  content: ""; flex: none; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--primary); border-right-color: transparent; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* To-do list */
.later { width: 100%; max-width: 440px; margin-top: auto; }
.later h2 { font-size: 20px; margin: 0 0 8px; color: var(--muted); font-weight: 500; }
.later ul { list-style: none; margin: 0; padding: 0; }
.later li {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-top: 1px solid var(--hairline); font-size: 18px;
}
.later li span { flex: 1; overflow-wrap: anywhere; }
.later li button { min-height: 44px; padding: 0 18px; font-size: 16px; flex: none; }
.later .empty { color: var(--muted); font-size: 17px; margin: 0; }

/* Typing bar, for when parked */
.type {
  display: flex;
  gap: 10px;
  margin: 0 20px 20px;
  padding: 8px;
  border-radius: 18px;
}
.type input {
  flex: 1;
  min-width: 0;
  font: inherit;
  color: var(--text);
  background: transparent;
  border: none;
  padding: 0 18px;
  min-height: 52px;
}
.type input::placeholder { color: var(--muted); }
.type input:focus { outline: none; }
.type:focus-within { border-color: color-mix(in srgb, var(--primary) 70%, var(--edge)); }
.type button { min-height: 52px; padding: 0 28px; }

/* Cameras */
.cams { margin: 20px; padding: 22px 24px 26px; border-radius: var(--r-panel); }
.cams-head { display: flex; align-items: center; gap: 12px; }
.cams-head h2 { margin: 0 auto 0 0; font-size: 26px; font-weight: 600; }
.cams-note { color: var(--muted); font-size: 17px; margin: 6px 0 16px; }
.cam-grid { --cols: 2; --rows: 1; display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 14px; }
.cam {
  position: relative;
  padding: 0;
  border: 1px solid var(--edge);
  border-radius: 14px;
  overflow: hidden;
  background: #000;
  aspect-ratio: 16 / 9;
  max-height: calc((100vh - 300px) / var(--rows));
  width: 100%;
}
.cam img { display: block; width: 100%; height: 100%; object-fit: cover; }
.cam img:not([src]) { visibility: hidden; }
.cam span {
  position: absolute; left: 12px; bottom: 10px;
  background: rgba(0, 0, 0, 0.6); color: #fff;
  padding: 4px 12px; border-radius: 10px; font-size: 17px; font-weight: 600;
}
.cam .err {
  position: absolute; inset: 0; margin: 0; display: grid; place-items: center;
  padding: 16px; color: #e6e6e6; font-size: 17px; text-align: center; background: rgba(0, 0, 0, 0.55);
}
.cam-grid.single .cam img { object-fit: contain; }

/* Phones and narrow windows: stack everything */
@media (max-width: 820px) {
  body { font-size: 18px; }
  .bar { margin: 12px 12px 0; padding: 10px 10px 10px 20px; gap: 10px; border-radius: 26px; }
  .desk { grid-template-columns: 1fr; gap: 14px; padding: 14px 12px; min-height: 0; }
  .left, .right { padding: 22px 18px; border-radius: 28px; }
  .reply { font-size: 26px; }
  .status { font-size: 24px; }
  .type { margin: 0 12px 14px; }
  .later, .working { max-width: none; }
  .cams { margin: 12px; padding: 18px 14px; }
  .cam-grid { grid-template-columns: 1fr; }
  .cam { max-height: none; }
}

/* Respect "reduce transparency" and "reduce motion": solid panes, no animation. */
@media (prefers-reduced-transparency: reduce) {
  .glass, .bar, .left, .right, .confirm, .type, .cams, .login form, .talk {
    -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--base);
  }
}
@media (prefers-reduced-motion: reduce) {
  .talk::after, .talk, .toggle .track, .toggle .track::after, .working li::before { transition: none; animation: none !important; }
}

/* Login: car-style keypad */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.login form {
  width: min(440px, 100%);
  display: grid;
  gap: 16px;
  padding: 34px 32px;
  border-radius: 24px;
  justify-items: center;
  text-align: center;
}
.login h1 { margin: 0; font-size: 28px; letter-spacing: -0.01em; }
.login p { margin: 0; color: var(--muted); }
.pin-shown {
  font-size: 34px; letter-spacing: 0.5em; min-height: 52px; width: 100%;
  display: grid; place-items: center; padding-left: 0.5em;
}
.keys { display: grid; grid-template-columns: repeat(3, 96px); gap: 14px; justify-content: center; }
.keys button {
  width: 96px; height: 76px; border-radius: 16px; font-size: 32px; font-weight: 400;
  background: var(--glass-strong);
  border: 1px solid var(--edge);
  box-shadow: inset 0 1px 0 var(--shine);
}
.keys button:active { background: var(--glass); transform: scale(0.97); }
.keys .word { font-size: 17px; font-weight: 600; }
.keys .unlock { background: var(--primary); color: #fff; border-color: color-mix(in srgb, #fff 35%, var(--primary)); }
.login .error { color: var(--listen); min-height: 1.4em; font-weight: 600; }

[hidden] { display: none !important; }
