/* Meraki — dark technical.
   Space Grotesk for display, JetBrains Mono for anything that reads as data.
   One accent. The page itself never scrolls; the transcript does. */

:root {
  --bg: #07090b;
  --bg-tint: #0b0f12;
  --panel: #0e1317;
  --panel-2: #131a1f;
  --line: #1d262c;
  --line-soft: #151d22;
  --text: #e8edf0;
  --text-dim: #8b9aa3;
  --text-faint: #56656e;
  --accent: #e8434a;
  --accent-strong: #d1232c;
  --on-accent: #ffffff;
  --accent-soft: rgba(232, 67, 74, 0.13);
  --ok: #3ddc84;
  --ok-soft: rgba(61, 220, 132, 0.16);
  --bar-idle: #212b31;

  --radius-lg: 16px;
  --display: "Space Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI",
    Roboto, Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", "Cascadia Mono", Menlo,
    Consolas, monospace;
}

* { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  /* Fixed viewport: the transcript scrolls, the controls never leave. */
  height: 100dvh;
  overflow: hidden;
  display: grid;
  /* rule, bar, stage, log, footer. The log takes what is left and scrolls
     inside itself; minmax(0,...) is what allows it to shrink below content. */
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  background: var(--bg);
  color: var(--text);
  font-family: var(--display);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}

/* A single soft light source behind the stage, tinted by state. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(58% 42% at 50% 26%, var(--accent-soft) 0%, transparent 68%),
    linear-gradient(180deg, var(--bg-tint) 0%, var(--bg) 46%);
  opacity: 0.85;
  transition: opacity 900ms ease;
  z-index: 0;
}
body[data-state="listening"]::before,
body[data-state="speaking"]::before { opacity: 1; }

/* Hairline ticks along the very top, like a measuring rule. */
.rule {
  position: relative;
  z-index: 1;
  height: 8px;
  background-image: repeating-linear-gradient(
    90deg,
    var(--line) 0 1px,
    transparent 1px 9px
  );
  opacity: 0.5;
}

/* ---------- top bar ---------- */

.bar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 26px 12px;
}

.brand { display: flex; align-items: center; gap: 11px; }

.brand__mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(232, 67, 74, 0.22);
}
.brand__mark svg { display: block; }

.brand__text { display: flex; flex-direction: column; line-height: 1.2; }

.brand__name {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.02em;
}

.brand__tag {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: 0.02em;
}

.chips { display: flex; align-items: center; gap: 9px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(14, 19, 23, 0.7);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
}
.chip i { color: var(--text-faint); font-style: normal; }
.chip--status { color: var(--text); }

.chip__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-faint);
  transition: background 240ms ease, box-shadow 240ms ease;
}
.chip__dot[data-state="idle"] {
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-soft);
}
.chip__dot[data-state="blocked"] { background: var(--accent); }
.chip__dot[data-state="listening"],
.chip__dot[data-state="speaking"] {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.chip__dot[data-state="thinking"] { background: var(--accent); opacity: 0.55; }
.chip__dot[data-state="connecting"] { animation: blink 1s steps(2) infinite; }

/* Blocked is a state you must act on, so say so in the chip itself. */
.chip--status[data-state="blocked"] {
  color: var(--accent);
  border-color: rgba(232, 67, 74, 0.35);
}

@keyframes blink { 50% { opacity: 0.2; } }

/* ---------- stage ---------- */

.stage {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 10px 24px 16px;
  text-align: center;
}

.stage__eyebrow {
  margin: 0;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

.stage__title {
  margin: 0;
  font-size: clamp(30px, 5.2vw, 52px);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.035em;
}
.stage__title em {
  font-style: normal;
  color: var(--text-faint);
}

.meter {
  width: min(620px, 100%);
  height: 82px;
  display: block;
}

/* ---------- live region ---------- */

.live {
  max-width: 660px;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  /* Reserved, not collapsed. Showing and hiding this shoved the whole page
     down every time Meraki started speaking and back up when it stopped. */
  min-height: 58px;
}

.live__user {
  margin: 0;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-faint);
}
.live__user:empty { display: none; }

.live__reply {
  margin: 0;
  font-size: clamp(17px, 2.3vw, 21px);
  line-height: 1.4;
  letter-spacing: -0.02em;
  color: var(--text);
  text-wrap: balance;
}
.live__reply:empty { display: none; }

/* ---------- mic ---------- */

.controls { display: flex; flex-direction: column; align-items: center; gap: 11px; }

.mic {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 13px 26px 13px 21px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text);
  font-family: var(--display);
  font-size: 14.5px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 200ms ease, background 200ms ease, transform 120ms ease;
}
.mic:hover { border-color: #2c3a42; }
.mic:active { transform: scale(0.985); }
.mic:disabled { opacity: 0.55; cursor: progress; }

.mic[data-active="true"] {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: var(--on-accent);
}

.mic__ring {
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  border: 1px solid var(--accent);
  opacity: 0;
  pointer-events: none;
}
.mic[data-active="true"] .mic__ring { animation: pulse 2.1s ease-out infinite; }

@keyframes pulse {
  0%   { opacity: 0.7; transform: scale(1); }
  100% { opacity: 0;   transform: scale(1.14); }
}

.hint {
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
}

/* ---------- conversation ---------- */

.log {
  position: relative;
  z-index: 1;
  width: min(880px, calc(100% - 48px));
  margin: 0 auto;

  /* minmax(0,1fr) on the row plus min-height:0 here is what lets the body
     shrink and scroll instead of overflowing the viewport. */
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-bottom: 14px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--panel) 0%, rgba(14, 19, 23, 0.62) 100%);
  overflow: hidden;
}

.log__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line-soft);
  flex: none;
}
.log__head h2 {
  margin: 0;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.log__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2px 18px 18px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.log__body::-webkit-scrollbar { width: 9px; }
.log__body::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 99px;
  border: 3px solid var(--panel);
}

.log__empty {
  margin: 0;
  padding: 14px 18px 4px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-faint);
  flex: none;
}

.turn {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 14px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
}
.turn:last-child { border-bottom: 0; }

.turn__who {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding-top: 4px;
}
.turn--assistant .turn__who { color: var(--accent); }

.turn__body {
  margin: 0;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  overflow-wrap: anywhere;
}
.turn--user .turn__body { color: var(--text-dim); }

/* ---------- footer ---------- */

.foot {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 26px 12px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-faint);
}
.foot i { font-style: normal; color: var(--accent); opacity: 0.8; }

/* ---------- buttons ---------- */

.ghost {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease;
}
.ghost:hover { color: var(--text); border-color: #2c3a42; background: var(--panel-2); }

/* ---------- settings sheet ---------- */

.chip--btn {
  cursor: pointer;
  font-family: var(--mono);
  transition: color 160ms ease, border-color 160ms ease;
}
.chip--btn:hover { color: var(--text); border-color: #2c3a42; }
.chip--btn svg { display: block; opacity: 0.8; }

.sheet {
  width: min(440px, calc(100% - 28px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  color: var(--text);
}
.sheet::backdrop { background: rgba(3, 5, 6, 0.76); backdrop-filter: blur(3px); }

.sheet__form { display: flex; flex-direction: column; gap: 15px; padding: 20px; }

.sheet__head { display: flex; align-items: center; justify-content: space-between; }
.sheet__head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.sheet__note,
.sheet__hint {
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-faint);
}
.sheet__hint { padding-top: 13px; border-top: 1px solid var(--line-soft); }

.sheet__actions { display: flex; gap: 10px; align-items: center; }
.sheet__actions .primary { flex: 1; }

.field { display: flex; flex-direction: column; gap: 6px; position: relative; }

.field__label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-dim);
}
.field__label em {
  font-style: normal;
  color: var(--text-faint);
  font-weight: 400;
  font-family: var(--mono);
  font-size: 10.5px;
  margin-left: 6px;
}

.field input {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.02em;
  transition: border-color 160ms ease;
}
.field input:focus { outline: none; border-color: var(--accent); }
.field input::placeholder { color: var(--text-faint); }

.field__get {
  position: absolute;
  top: 1px;
  right: 0;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-faint);
  text-decoration: none;
}
.field__get:hover { color: var(--accent); }

.primary {
  padding: 10px 16px;
  border: 0;
  border-radius: 9px;
  background: var(--accent-strong);
  color: var(--on-accent);
  font-family: var(--display);
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  transition: filter 160ms ease;
}
.primary:hover { filter: brightness(1.1); }

/* ---------- toasts ---------- */

.toasts {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 40;
  pointer-events: none;
}

.toast {
  padding: 10px 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.6);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 220ms ease, transform 220ms ease;
}
.toast.is-in { opacity: 1; transform: translateY(0); }
.toast--error { border-color: rgba(232, 67, 74, 0.45); color: var(--accent); }

/* ---------- responsive ---------- */

@media (max-width: 720px) {
  .bar { padding: 12px 16px 10px; }
  .chip--mono { display: none; }
  .stage { padding: 14px 16px 18px; gap: 14px; }
  .meter { height: 62px; }
  .log { width: calc(100% - 24px); }
  .turn { grid-template-columns: 60px 1fr; gap: 10px; }
  .foot { padding: 9px 16px 10px; }
  .foot span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* Short viewports: drop the headline so the meter and controls still fit. */
@media (max-height: 700px) {
  .stage__title { display: none; }
  .stage__eyebrow { display: none; }
  .stage { gap: 12px; padding-top: 10px; }
  .meter { height: 60px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
