:root {
  --bg: #fbfbfd;
  --fg: #1d1d1f;
  --fg-2: #6e6e73;
  --fg-3: #86868b;
  --int: #a1a1a6;
  --glass: rgb(255 255 255 / .68);
  --line: rgb(0 0 0 / .08);
  --hover: rgb(0 0 0 / .05);
  --shadow: 0 12px 40px rgb(0 0 0 / .07), 0 2px 6px rgb(0 0 0 / .04);
  --blue: #0071e3;
  --red: #ff3b30;
  --green: #1a8a3c;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", "Segoe UI", Inter, Roboto, system-ui, sans-serif;
  --dock-bottom: max(22px, env(safe-area-inset-bottom));
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000;
    --fg: #f5f5f7;
    --fg-2: #a1a1a6;
    --fg-3: #8e8e93;
    --int: #636366;
    --glass: rgb(32 32 34 / .62);
    --line: rgb(255 255 255 / .1);
    --hover: rgb(255 255 255 / .08);
    --shadow: 0 12px 40px rgb(0 0 0 / .55), 0 2px 6px rgb(0 0 0 / .3);
    --blue: #2997ff;
    --red: #ff453a;
    --green: #30d158;
  }
}

/* Speaker colors: Apple system hues, deepened in light mode so names stay readable. */
[data-c="0"] { --c: #0066cc; }
[data-c="1"] { --c: #c4520a; }
[data-c="2"] { --c: #1a8a3c; }
[data-c="3"] { --c: #d1264f; }
[data-c="4"] { --c: #8944c7; }
[data-c="5"] { --c: #0f7c96; }
[data-c="6"] { --c: #4e4cc9; }
[data-c="7"] { --c: #8f6b3e; }
[data-c="8"] { --c: #c41f1f; }
[data-c="9"] { --c: #00857a; }
@media (prefers-color-scheme: dark) {
  [data-c="0"] { --c: #4ba3ff; }
  [data-c="1"] { --c: #ffa53d; }
  [data-c="2"] { --c: #44d36a; }
  [data-c="3"] { --c: #ff5b7a; }
  [data-c="4"] { --c: #c879f5; }
  [data-c="5"] { --c: #5fd0e6; }
  [data-c="6"] { --c: #8a88ff; }
  [data-c="7"] { --c: #c9a57a; }
  [data-c="8"] { --c: #ff6b61; }
  [data-c="9"] { --c: #5ee0d0; }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--fg);
  font: 400 17px/1.47 var(--font);
  letter-spacing: -.011em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

button { font: inherit; color: inherit; }

svg {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ------------------------------------------------------------------ background */

#waves {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* ------------------------------------------------------------------ transcript */

#scroller {
  position: fixed;
  inset: 0;
  z-index: 1;
  overflow: hidden auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(transparent 56px, #000 164px, #000 calc(100% - 170px), transparent calc(100% - 60px));
  mask-image: linear-gradient(transparent 56px, #000 164px, #000 calc(100% - 170px), transparent calc(100% - 60px));
}
#scroller::-webkit-scrollbar { display: none; }

#transcript {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  width: min(100%, 780px);
  margin: 0 auto;
  padding: 168px 32px calc(24vh + 64px);
  font-size: clamp(18px, 15px + .55vw, 23px);
  line-height: 1.55;
  letter-spacing: -.014em;
}

.line {
  margin: 0 0 .8em;
  overflow-wrap: anywhere;
  text-wrap: pretty;
  animation: rise .7s var(--ease) both;
}
.line.still { animation: none; }

.tag {
  margin-right: .1em;
  color: var(--c, var(--fg-2));
  font-weight: 600;
  white-space: nowrap;
}
.tag i { font-style: normal; font-weight: 400; opacity: .4; }
.prov .tag { opacity: .7; }
.int { color: var(--int); }

.divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: .6em 0 1.6em;
  color: var(--fg-3);
  font-size: 13px;
  letter-spacing: 0;
  animation: rise .7s var(--ease) both;
}
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ------------------------------------------------------------------ speakers */

#speakers {
  position: fixed;
  inset: 0 0 auto;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: max(18px, env(safe-area-inset-top)) 24px 0;
  pointer-events: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 34px;
  padding: 0 4px 0 13px;
  border: .5px solid var(--line);
  border-radius: 999px;
  background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  box-shadow: var(--shadow);
  pointer-events: auto;
  animation: pop .5s var(--ease) both;
}

.chip .dot {
  width: 8px;
  height: 8px;
  margin-right: 3px;
  border-radius: 50%;
  background: var(--c);
  transition: box-shadow .5s var(--ease), transform .5s var(--ease);
}
.chip.talking .dot {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 24%, transparent);
  transform: scale(1.12);
}

.chip .nm, .chip input {
  height: 26px;
  padding: 0 9px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--fg);
  font: 500 13.5px/26px var(--font);
  letter-spacing: -.005em;
}
.chip .nm { cursor: text; transition: background-color .2s; }
.chip .nm:hover { background: var(--hover); }
.chip .nm:focus-visible { outline: 2px solid var(--blue); }
.chip input {
  min-width: 8ch;
  max-width: 220px;
  field-sizing: content;
  background: var(--hover);
  outline: none;
}
.chip input::placeholder { color: var(--fg-3); }

/* ------------------------------------------------------------------ empty state */

#empty {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
  pointer-events: none;
  transition: opacity .6s var(--ease), transform .6s var(--ease), filter .6s var(--ease), visibility .6s;
}
#empty.gone { opacity: 0; transform: translateY(-12px); filter: blur(6px); visibility: hidden; }
#empty h1 {
  margin: 0;
  font: 600 clamp(30px, 22px + 2vw, 46px)/1.08 var(--font);
  letter-spacing: -.03em;
}
#empty[data-kind="idle"] h1 { animation: breathe 3.6s ease-in-out infinite; }
#empty.gone h1 { animation: none; }
#empty p { max-width: 460px; margin: 0; color: var(--fg-2); }
#empty:not([data-kind="idle"]):not([data-kind="paused"]) .link { display: none; }

.link {
  padding: 4px 8px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--blue);
  font-size: 15px;
  cursor: pointer;
  pointer-events: auto;
}
.link:hover { text-decoration: underline; }

/* ------------------------------------------------------------------ dock */

#dock {
  position: fixed;
  left: 50%;
  bottom: var(--dock-bottom);
  z-index: 4;
  translate: -50% 0;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 5px;
  border: .5px solid var(--line);
  border-radius: 999px;
  background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  backdrop-filter: saturate(180%) blur(24px);
  box-shadow: var(--shadow);
  animation: dock .8s var(--ease) both;
}

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 40px;
  min-width: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -.01em;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .2s, color .2s, transform .25s var(--ease);
}
.btn.icon { width: 40px; padding: 0; }
.btn:hover { background: var(--hover); }
.btn:active { transform: scale(.93); }
.btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.btn svg { position: relative; }

.sep { width: 1px; height: 20px; margin: 0 4px; background: var(--line); }

/* microphone: red while listening, with a halo that follows the input level */
#mic .off, #mic[aria-pressed="false"] .on { display: none; }
#mic[aria-pressed="false"] .off { display: block; }
#mic[aria-pressed="true"] { color: var(--red); }
#mic::before {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--red) 15%, transparent);
  opacity: 0;
  transform: scale(calc(.72 + var(--lvl, 0) * .42));
  transition: opacity .3s;
}
#mic[aria-pressed="true"]::before { opacity: 1; }

#sys[aria-pressed="true"] { color: var(--blue); background: color-mix(in srgb, var(--blue) 13%, transparent); }
#sys.nudge::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  animation: nudge 1.8s var(--ease) 4;
}

#copy .i-check, #copy.done .i-copy { display: none; }
#copy.done .i-check { display: block; }
#copy.done { color: var(--green); }

#clear .lbl { display: none; }
#clear.armed { width: auto; padding: 0 14px 0 12px; color: var(--red); background: color-mix(in srgb, var(--red) 12%, transparent); }
#clear.armed .lbl { display: inline; }

#status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 0;
  overflow: hidden;
  opacity: 0;
  color: var(--fg-2);
  font-size: 13px;
  white-space: nowrap;
  transition: max-width .5s var(--ease), opacity .3s, padding .5s var(--ease);
}
#status.show { max-width: min(48vw, 440px); padding: 0 10px 0 14px; opacity: 1; }
#status.error { color: var(--red); }
#status span { overflow: hidden; text-overflow: ellipsis; }
#status .spin {
  width: 12px;
  height: 12px;
  flex: none;
  border: 1.6px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .9s linear infinite;
}

.pill {
  position: fixed;
  left: 50%;
  bottom: calc(var(--dock-bottom) + 64px);
  z-index: 4;
  translate: -50% 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 14px 0 10px;
  border: .5px solid var(--line);
  border-radius: 999px;
  background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  animation: rise .4s var(--ease) both;
}
.pill svg { width: 15px; height: 15px; }

/* ------------------------------------------------------------------ drop overlay */

#drop {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--bg) 58%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  backdrop-filter: blur(18px) saturate(140%);
  animation: fade .25s var(--ease) both;
}
#drop .zone {
  display: grid;
  justify-items: center;
  gap: 6px;
  width: min(560px, 84vw);
  padding: 64px 32px;
  border: 1.5px dashed color-mix(in srgb, var(--blue) 55%, transparent);
  border-radius: 32px;
  background: color-mix(in srgb, var(--blue) 5%, transparent);
  text-align: center;
  pointer-events: none;
  animation: pop .4s var(--ease) both;
}
#drop svg { width: 44px; height: 44px; margin-bottom: 8px; color: var(--blue); stroke-width: 1.6; }
#drop strong { font-size: 28px; font-weight: 600; letter-spacing: -.025em; }
#drop span { color: var(--fg-2); }

/* ------------------------------------------------------------------ motion */

@keyframes rise { from { opacity: 0; transform: translateY(16px); filter: blur(6px); } }
@keyframes pop { from { opacity: 0; transform: scale(.86); } }
@keyframes fade { from { opacity: 0; } }
@keyframes dock { from { opacity: 0; transform: translateY(24px) scale(.96); } }
@keyframes breathe { 50% { opacity: .5; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes nudge {
  from { box-shadow: 0 0 0 0 color-mix(in srgb, var(--blue) 45%, transparent); }
  to { box-shadow: 0 0 0 12px transparent; }
}

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

@media (max-width: 560px) {
  #transcript { padding-inline: 20px; }
  #copy .lbl { display: none; }
  #copy { width: 40px; padding: 0; }
}
