/* CrisperWhisper 2.0 demo — design language ported from nyra-labs.com:
   CW blue primary, hairline borders, mono transcripts, soft card surfaces. */

:root {
  --primary: #2f46ff;
  --primary-soft: rgba(47, 70, 255, 0.1);
  --bg: #f7f7f8;
  --card: #fdfdfd;
  --panel: #ffffff;
  --fg: #16161a;
  --fg-soft: #3f3f46;
  --muted: #71717a;
  --hairline: #e6e6ea;
  --hairline-strong: #d4d4da;
  --rose: #f43f5e;
  --chip-filler-bg: rgba(47, 70, 255, 0.12);
  --chip-filler-fg: #2f46ff;
  --chip-sound-bg: #ece6fb;
  --chip-cutoff-bg: #fde7d4;
  --chip-repetition-bg: #d9edfb;
  --chip-disfluent-bg: #fbdfe5;
  --chip-fg: #26262b;
  --karaoke: rgba(47, 70, 255, 0.2);
  --error-bg: #fef1f3;
  --error-border: #fbcfd8;
  --error-fg: #e11d48;
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #5b6dff;
    --primary-soft: rgba(91, 109, 255, 0.16);
    --bg: #101013;
    --card: #17171b;
    --panel: #1d1d22;
    --fg: #f1f1f3;
    --fg-soft: #c9c9cf;
    --muted: #8b8b93;
    --hairline: #2a2a30;
    --hairline-strong: #3a3a42;
    --chip-filler-bg: rgba(91, 109, 255, 0.22);
    --chip-filler-fg: #93a0ff;
    --chip-sound-bg: rgba(167, 139, 250, 0.22);
    --chip-cutoff-bg: rgba(251, 146, 60, 0.2);
    --chip-repetition-bg: rgba(56, 152, 224, 0.22);
    --chip-disfluent-bg: rgba(244, 63, 94, 0.2);
    --chip-fg: #e8e8ec;
    --karaoke: rgba(91, 109, 255, 0.32);
    --error-bg: rgba(244, 63, 94, 0.1);
    --error-border: rgba(244, 63, 94, 0.35);
    --error-fg: #fb7185;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

.page {
  max-width: 1020px;
  margin: 0 auto;
  padding: 28px 20px 64px;
}

.hidden { display: none !important; }

/* ── masthead ── */

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 44px;
}

.masthead-left { display: flex; align-items: center; gap: 12px; }

.wordmark {
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--fg);
  text-decoration: none;
  font-size: 16px;
}

.masthead-sep {
  width: 1px;
  height: 16px;
  background: var(--hairline-strong);
}

.masthead-model {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.masthead-links { display: flex; gap: 18px; }

.masthead-links a {
  color: var(--fg-soft);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
}

.masthead-links a:hover { color: var(--primary); }

/* ── hero copy ── */

h1 {
  font-size: clamp(30px, 5vw, 44px);
  line-height: 1.08;
  letter-spacing: -0.03em;
  margin: 0 0 16px;
  font-weight: 700;
}

.lede {
  max-width: 720px;
  margin: 0 0 32px;
  color: var(--fg-soft);
  font-size: 15.5px;
}

/* ── demo card ── */

.demo {
  border: 1px solid var(--hairline);
  border-radius: 28px;
  background: var(--card);
  overflow: hidden;
}

.demo-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 20px;
  border-bottom: 1px solid var(--hairline);
}

.demo-status { display: flex; align-items: center; gap: 10px; }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--muted);
}

.dot.live { background: var(--primary); }
.dot.busy { background: var(--primary); animation: pulse 1.2s ease-in-out infinite; }
.dot.rec { background: var(--rose); animation: pulse 1.2s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.demo-status-label {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.demo-head-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.demo-head-controls label { font-size: 12px; color: var(--muted); }

select {
  appearance: none;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--panel);
  color: var(--fg-soft);
  font-size: 12px;
  font-weight: 500;
  padding: 7px 26px 7px 13px;
  outline: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2371717a'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 0 1 1.06.02L10 11.06l3.71-3.83a.75.75 0 1 1 1.08 1.04l-4.25 4.39a.75.75 0 0 1-1.08 0L5.21 8.27a.75.75 0 0 1 .02-1.06Z' clip-rule='evenodd'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 14px;
}

select:focus-visible { border-color: var(--primary); }
select:disabled { opacity: 0.55; cursor: not-allowed; }

.demo-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── buttons ── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: var(--panel);
  color: var(--fg-soft);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, transform 0.15s;
}

.btn svg { width: 16px; height: 16px; }
.btn:hover { color: var(--fg); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  border-color: transparent;
  color: #fff;
}

.btn-primary:hover { color: #fff; transform: scale(1.02); }

.btn-stop {
  background: var(--rose);
  border-color: transparent;
  color: #fff;
}

.btn-stop:hover { color: #fff; }

.rec-time {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.8);
  font-variant-numeric: tabular-nums;
}

.btn-retry {
  height: 32px;
  padding: 0 13px;
  font-size: 12px;
  gap: 6px;
}

.btn-retry svg { width: 14px; height: 14px; }

.btn-retry.attention {
  background: var(--primary);
  border-color: transparent;
  color: #fff;
}

.btn-retry.spinning svg { animation: spin 1s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ── controls row ── */

.controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.meter {
  flex: 1;
  min-width: 160px;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 1px;
  background: var(--panel);
  border-radius: 12px;
  padding: 0 14px;
}

.meter span {
  flex: 1;
  min-height: 6%;
  border-radius: 999px;
  background: rgba(244, 63, 94, 0.8);
  transition: height 75ms;
}

.samples {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  width: 100%;
  min-width: 0;
  padding-top: 2px;
}

.samples-label { font-size: 12px; color: var(--muted); }

.sample-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--panel);
  color: var(--fg-soft);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  padding: 7px 12px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.sample-chip svg { width: 13px; height: 13px; opacity: 0.7; }
.sample-chip:hover { border-color: var(--hairline-strong); color: var(--fg); }
.sample-chip:disabled { opacity: 0.55; cursor: not-allowed; }

.sample-chip.active {
  background: var(--fg);
  border-color: transparent;
  color: var(--bg);
}

.sample-chip.active svg { opacity: 1; }

/* ── error ── */

.error {
  margin: 0;
  border: 1px solid var(--error-border);
  background: var(--error-bg);
  color: var(--error-fg);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 13px;
}

/* ── transport ── */

.transport {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--panel);
  border-radius: 12px;
  padding: 10px 16px;
}

.play-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: none;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s;
}

.play-btn:hover { transform: scale(1.05); }
.play-btn svg { width: 16px; height: 16px; }
#play-icon { transform: translateX(1px); }

.wave {
  flex: 1;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 1px;
  cursor: pointer;
}

.wave span {
  flex: 1;
  min-height: 7%;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 30%, transparent);
  transition: background-color 0.15s;
}

.wave span.played { background: var(--primary); }

.transport-time {
  flex-shrink: 0;
  width: 96px;
  text-align: right;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 560px) {
  .transport-time { display: none; }
}

/* ── output ── */

.output {
  position: relative;
  min-height: 180px;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  background: var(--panel);
}

.output-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 24px;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}

.output-hint .pen {
  font-size: 17px;
  animation: scribble 1.1s ease-in-out infinite;
}

@keyframes scribble {
  0% { transform: translate(0, 0) rotate(0deg); }
  15% { transform: translate(1.5px, 1px) rotate(-14deg); }
  30% { transform: translate(3px, -0.5px) rotate(6deg); }
  45% { transform: translate(1px, 1.2px) rotate(-10deg); }
  60% { transform: translate(3.5px, 0) rotate(8deg); }
  80% { transform: translate(2px, 1px) rotate(-12deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

.column { padding: 20px; }
.column-verbatim { border-bottom: 1px solid var(--hairline); }

.column-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 12px;
}

.column-title {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.column-title-verbatim { color: var(--primary); }

.column-desc { font-size: 11px; color: var(--muted); }

.words {
  margin: 0;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13.5px;
  line-height: 2.1;
  color: var(--fg-soft);
}

.column:not(.column-verbatim) .words { color: var(--fg); }

/* ── words ── */

.word {
  position: relative;
  display: inline-block;
  border-radius: 4px;
  padding: 0 2px;
  border: none;
  background: transparent;
  font: inherit;
  color: inherit;
  animation: word-in 0.25s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes word-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.word.clickable { cursor: pointer; }

.word .fill {
  pointer-events: none;
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  border-radius: 6px;
  background: var(--karaoke);
  opacity: 0;
  transition: opacity 0.3s ease-out;
}

.word.active .fill { opacity: 1; transition-duration: 0.1s; }

.word .txt { position: relative; }

.word.t-filler { background: var(--chip-filler-bg); color: var(--chip-filler-fg); }
.word.t-sound { background: var(--chip-sound-bg); color: var(--chip-fg); }
.word.t-cutoff { background: var(--chip-cutoff-bg); color: var(--chip-fg); }
.word.t-repetition { background: var(--chip-repetition-bg); color: var(--chip-fg); }
.word.t-disfluent { background: var(--chip-disfluent-bg); color: var(--chip-fg); }

.word.t-filler, .word.t-sound, .word.t-cutoff, .word.t-repetition, .word.t-disfluent {
  margin: 0 2px;
  border-radius: 6px;
  padding: 2px 6px;
}

.word.t-correction {
  text-decoration: underline dotted;
  text-decoration-color: color-mix(in srgb, var(--primary) 60%, transparent);
  text-underline-offset: 3px;
}

/* timestamp tooltip */

.word[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translate(-50%, 4px);
  z-index: 10;
  white-space: nowrap;
  border: 1px solid var(--hairline);
  background: var(--card);
  color: var(--fg-soft);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 10px;
  line-height: 1;
  padding: 7px 9px;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease-out, transform 0.2s ease-out;
}

.word[data-tip]:hover::after {
  opacity: 1;
  transform: translate(-50%, 0);
  transition-delay: 0.15s;
}

/* ── legend + meta ── */

.result-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.legend {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--muted);
}

.legend .item { display: flex; align-items: center; gap: 6px; }

.legend .swatch {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.legend .swatch.s-filler { background: var(--chip-filler-bg); }
.legend .swatch.s-sound { background: var(--chip-sound-bg); }
.legend .swatch.s-cutoff { background: var(--chip-cutoff-bg); }
.legend .swatch.s-repetition { background: var(--chip-repetition-bg); }
.legend .swatch.s-disfluent { background: var(--chip-disfluent-bg); }
.legend .swatch.s-correction {
  background: transparent;
  border: 1px dotted var(--primary);
}

.meta {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ── footer ── */

.pagefoot {
  margin-top: 28px;
  color: var(--muted);
  font-size: 13px;
  max-width: 760px;
}

.pagefoot a { color: var(--fg-soft); }
.pagefoot a:hover { color: var(--primary); }
.pagefoot code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
}
