/* The simulator page: one bold thing — the arm of the glasses with its button and LED; the rest stays quiet. */

:root {
  --paper: #eef1ef;
  --panel: #f7f9f8;
  --ink: #1d2731;
  --muted: #5b6873;
  --line: #d3dad8;
  --frame: #262b31;
  --rubber: #d4dade;
  --led: #ffae1a;
  --led-off: #4a4133;
  --alert: #b3261e;
  --user: #245c99;
  --model: #1e6b52;
  --text: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --round: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, sans-serif;
  --code: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #161b20;
    --panel: #1c2228;
    --ink: #e3e8ec;
    --muted: #9aa6b0;
    --line: #2d353d;
    --frame: #3a424b;
    --rubber: #b3bcc2;
    --alert: #ff8a80;
    --user: #8fb8ea;
    --model: #7fd1b0;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.45 var(--text);
}

h1 { margin: 0; font: 600 26px/1.2 var(--round); letter-spacing: -0.01em; }
h2 { margin: 0 0 10px; font: 600 19px/1.3 var(--round); }

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 24px;
  padding: 20px 24px 8px;
}

.cloud { margin: 0; color: var(--muted); }
.cloud.connected::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--model);
}

.banner {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin: 8px 24px 0;
  padding: 10px 14px;
  border-left: 4px solid var(--alert);
  background: color-mix(in srgb, var(--alert) 10%, var(--paper));
}
.banner[hidden] { display: none; }
.banner p { flex: 1; margin: 0; }

button.quiet {
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: none;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.layout {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  grid-template-rows: minmax(220px, 34vh) minmax(320px, 1fr);
  grid-template-areas: "glasses talk" "glasses timeline";
  gap: 20px 36px;
  height: calc(100vh - 80px);          /* a fixed height: the transcript and the timeline scroll inside it */
  padding: 12px 24px 32px;
}
.glasses { grid-area: glasses; min-height: 0; overflow-y: auto; }
.talk-log { grid-area: talk; display: flex; flex-direction: column; min-height: 0; }
.timeline { grid-area: timeline; display: flex; flex-direction: column; min-height: 0; }

/* ── the arm of the glasses ─────────────────────────────────────── */

.temple {
  position: relative;
  display: flex;
  align-items: center;
  gap: 18px;
  height: 56px;
  margin: 16px 0 14px 6px;
  padding: 0 10px 0 34px;
  border-radius: 8px 30px 30px 8px;
  background: var(--frame);
}
.hinge {
  position: absolute;
  top: 14px;
  left: -6px;
  width: 12px;
  height: 28px;
  border-radius: 3px;
  background: var(--frame);
  filter: brightness(1.4);
}

.led {
  flex: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--led-off);
  box-shadow: inset 0 1px 2px rgb(0 0 0 / 0.6);
}
.led[data-state="listening"] { background: var(--led); box-shadow: 0 0 10px 3px color-mix(in srgb, var(--led) 60%, transparent); }
.led[data-state="looking"] { animation: double-flash 1s steps(1) infinite; }
.led[data-state="thinking"],
.led[data-state="understanding"] { animation: blink 1s steps(1) infinite; }
.led[data-state="error"] { animation: blink 0.4s steps(1) infinite; }
.led[data-state="booting"] { animation: blink 0.3s steps(1) infinite; }

@keyframes blink {
  0% { background: var(--led); box-shadow: 0 0 10px 3px color-mix(in srgb, var(--led) 60%, transparent); }
  50% { background: var(--led-off); box-shadow: inset 0 1px 2px rgb(0 0 0 / 0.6); }
}
@keyframes double-flash {
  0%, 20% { background: var(--led); box-shadow: 0 0 10px 3px color-mix(in srgb, var(--led) 60%, transparent); }
  10%, 30% { background: var(--led-off); box-shadow: inset 0 1px 2px rgb(0 0 0 / 0.6); }
}

.talk {
  position: relative;
  overflow: hidden;
  min-width: 156px;
  height: 44px;
  margin-left: auto;
  padding: 0 22px;
  border: 0;
  border-radius: 22px;
  background: var(--rubber);
  color: #1a2127;
  font: 600 17px/1 var(--round);
  box-shadow: inset 0 -3px 0 rgb(0 0 0 / 0.2);
  cursor: pointer;
  touch-action: none;
  user-select: none;
}
.talk::after {           /* fills while the button is held: a full bar is the long press */
  content: "";
  position: absolute;
  inset: 0;
  background: rgb(0 0 0 / 0.14);
  transform: scaleX(0);
  transform-origin: left;
}
.talk.holding::after { transform: scaleX(1); transition: transform 1s linear; }
.talk:active { transform: translateY(1px); box-shadow: inset 0 2px 3px rgb(0 0 0 / 0.3); }
.talk:focus-visible { outline: 3px solid var(--led); outline-offset: 3px; }
.talk:disabled { opacity: 0.6; cursor: default; }

.press-hint, .headphones, .note {
  max-width: 60ch;
  margin: 6px 0;
  color: var(--muted);
  font-size: 13px;
}

.status { margin: 18px 0 2px; font: 600 17px/1.3 var(--round); }
.led-text { margin: 0 0 12px; color: var(--muted); }

.meter { height: 6px; overflow: hidden; border-radius: 3px; background: var(--line); }
.meter-fill { width: 0; height: 100%; background: var(--model); transition: width 0.1s linear; }
.meter-caption {
  display: flex;
  justify-content: space-between;
  margin: 4px 0 16px;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.speaking.on { color: var(--model); font-weight: 600; }

.numbers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
  margin: 0 0 18px;
}
.numbers div { padding-top: 6px; border-top: 1px solid var(--line); }
.numbers dt { color: var(--muted); font-size: 13px; }
.numbers dd { margin: 0; font-size: 17px; font-variant-numeric: tabular-nums; }

.settings fieldset { margin: 0; padding: 12px 0 6px; border: 0; border-top: 1px solid var(--line); }
.settings legend { padding: 0; font: 600 15px/1.3 var(--round); }
.settings label { display: block; margin: 6px 0; }
.settings input[type="range"] { display: block; width: 100%; }
.settings output { color: var(--muted); font-variant-numeric: tabular-nums; }
.file input[type="file"] { display: block; margin-top: 4px; font-size: 13px; }
.scene {
  display: block;
  max-width: 100%;
  max-height: 160px;
  margin: 8px 0 4px;
  border-radius: 6px;
  background: var(--line);
}

/* ── the conversation ──────────────────────────────────────────── */

.transcript {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.line { max-width: 72ch; margin: 0 0 8px; }
.line .who { margin-right: 8px; font-weight: 600; }
.line.user .who { color: var(--user); }
.line.assistant .who { color: var(--model); }
.divider {
  margin: 12px 0 8px;
  padding-top: 6px;
  border-top: 1px dashed var(--line);
  color: var(--muted);
  font-size: 13px;
}
.empty { color: var(--muted); }

/* ── the timeline ──────────────────────────────────────────────── */

.timeline-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 18px; }
.timeline-head h2 { margin-right: auto; }
.violations-count { color: var(--alert); font-weight: 600; }

.entries {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin: 8px 0 0;
  padding: 0;
  border-top: 1px solid var(--line);
  font-size: 13px;
  list-style: none;
}
.entries .empty { padding: 10px 4px; }
.entry { border-bottom: 1px solid var(--line); }
.entry > button {
  display: grid;
  grid-template-columns: 4.5em 6.5em 10.5em minmax(0, 1fr) 5em;
  gap: 8px;
  width: 100%;
  padding: 5px 4px;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-variant-numeric: tabular-nums;
  text-align: left;
  cursor: pointer;
}
.entry > button:focus-visible { outline: 2px solid var(--led); outline-offset: -2px; }
.entry .n, .entry .t, .entry .size { color: var(--muted); }
.entry .size { text-align: right; }
.entry .kind { overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.entry .problems { grid-column: 1 / -1; color: var(--alert); }
.entry.bad .kind { color: var(--alert); }
.entry pre {
  margin: 0 0 8px;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--panel);
  font: 12px/1.45 var(--code);
  white-space: pre-wrap;
  word-break: break-word;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    grid-template-areas: "glasses" "talk" "timeline";
    height: auto;
  }
  .transcript { max-height: 50vh; }
  .entries { max-height: 70vh; }
  .entry > button { grid-template-columns: 4em 6em minmax(0, 1fr) 4.5em; }
  .entry .channel { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .led[data-state] { animation: none; }
  .led[data-state="looking"],
  .led[data-state="thinking"],
  .led[data-state="understanding"],
  .led[data-state="error"],
  .led[data-state="booting"] { background: color-mix(in srgb, var(--led) 55%, var(--led-off)); }
  .talk.holding::after { transition: none; }
  .meter-fill { transition: none; }
}
