:root {
  --bg: #0b1218;
  --panel: #101a22;
  --panel-2: #0d151c;
  --line: rgba(150, 212, 218, 0.14);
  --line-strong: rgba(150, 212, 218, 0.34);
  --text: #e8f2f4;
  --muted: #8ba3ad;
  --accent: #45c4bb;
  --accent-strong: #7fe8d8;
  --warm: #ff8d66;
  --mono: ui-monospace, "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
}

* {
  box-sizing: border-box;
  touch-action: manipulation;
  scrollbar-width: thin;
  scrollbar-color: rgba(150, 212, 218, 0.22) transparent;
}

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

body {
  font-family: ui-sans-serif, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-thumb {
  background: rgba(150, 212, 218, 0.22);
  border-radius: 4px;
}
::-webkit-scrollbar-track {
  background: transparent;
}

.app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 10px;
}

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

.topbar {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 0 2px;
}

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

.brand-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(82, 209, 200, 0.7);
}

.brand strong {
  font-size: 14.5px;
  letter-spacing: 0.02em;
}

.brand-tag {
  font-size: 10.5px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 8px;
}

.topbar-meta {
  display: flex;
  gap: 6px;
}

.chip {
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 999px;
  padding: 2px 9px;
  white-space: nowrap;
}

.chip b {
  color: var(--text);
  font-weight: 600;
}

.chip.link {
  color: var(--accent-strong);
  text-decoration: none;
  cursor: pointer;
}

.chip.link:hover {
  border-color: var(--line-strong);
}

/* ---------- columns ---------- */

.cols {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(350px, 5fr) minmax(420px, 7fr);
  gap: 8px;
}

.col {
  min-height: 0;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

/* ---------- left: controls ---------- */

.col-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
}

.section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  margin-bottom: 6px;
}

.section + .section {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.row-buttons {
  display: flex;
  gap: 6px;
}

.btn {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.05);
  transition: background 120ms ease, border-color 120ms ease;
}

.btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.09);
  border-color: var(--line-strong);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.btn-primary {
  color: #04141a;
  font-weight: 600;
  border: 0;
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
}

.btn-ghost {
  background: transparent;
}

.btn.small {
  padding: 2px 9px;
  font-size: 11px;
}

/* recorder strip */

.recorder-card {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 7px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
}

.pulse {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0.7;
}

.rec-main {
  flex: 1 1 auto;
  min-width: 0;
}

.rec-line1 {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.rec-line1 strong {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mono {
  font-family: var(--mono);
}

.rec-line1 .mono {
  font-size: 11.5px;
  color: var(--muted);
  flex: 0 0 auto;
}

#recordHint {
  margin: 1px 0 0;
  font-size: 10.5px;
  color: var(--muted);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meter {
  flex: 0 0 auto;
  display: flex;
  gap: 2px;
  align-items: flex-end;
  height: 16px;
  width: 52px;
}

.meter span {
  flex: 1;
  height: 30%;
  border-radius: 2px;
  background: linear-gradient(180deg, rgba(137, 240, 211, 0.8), rgba(82, 209, 200, 0.2));
  transform-origin: bottom;
}

.dim {
  color: var(--muted);
}

#sourceLabel {
  flex: 0 1 auto;
  max-width: 38%;
  font-size: 10.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recorder-card.is-recording .pulse {
  background: var(--warm);
  opacity: 1;
  animation: pulse 1.5s infinite;
}

.recorder-card.is-recording .meter span {
  animation: meter 1.2s infinite ease-in-out;
}

.recorder-card.is-recording .meter span:nth-child(2) { animation-delay: 90ms; }
.recorder-card.is-recording .meter span:nth-child(3) { animation-delay: 180ms; }
.recorder-card.is-recording .meter span:nth-child(4) { animation-delay: 270ms; }
.recorder-card.is-recording .meter span:nth-child(5) { animation-delay: 360ms; }
.recorder-card.is-recording .meter span:nth-child(6) { animation-delay: 450ms; }

/* dropzone */

.dropzone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 7px;
  padding: 7px 10px;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  cursor: pointer;
  transition: background 120ms ease;
}

.dropzone:hover {
  background: rgba(255, 255, 255, 0.03);
}

.dropzone input {
  display: none;
}

.dropzone-title {
  font-size: 12.5px;
  font-weight: 600;
}

.dropzone .dim {
  font-size: 10.5px;
  white-space: nowrap;
}

#audioPreview {
  display: block;
  width: 100%;
  height: 30px;
  margin-top: 7px;
}

#audioPreview:not([src]) {
  display: none;
}

/* model + fields */

.model-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.model-card {
  text-align: left;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}

.model-card:hover {
  border-color: var(--line-strong);
}

.model-card.active {
  border-color: rgba(82, 209, 200, 0.7);
  background: rgba(82, 209, 200, 0.08);
}

.model-card .mc-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.model-card strong {
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-card .mc-note {
  display: block;
  margin-top: 2px;
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mc-badge {
  flex: 0 0 auto;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
}

.mc-badge.in-gpu {
  color: #04141a;
  border: 0;
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
}

.mc-badge.on-disk {
  border-style: dashed;
}

.field-grid {
  display: grid;
  grid-template-columns: minmax(110px, 4fr) minmax(0, 7fr);
  gap: 6px;
  margin-top: 8px;
}

.field {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.field > span {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12.5px;
  background: rgba(0, 0, 0, 0.2);
  outline: none;
}

.field textarea {
  resize: vertical;
  min-height: 30px;
  line-height: 1.35;
}

.field select:focus,
.field textarea:focus {
  border-color: var(--line-strong);
}

.toggle-row {
  display: flex;
  gap: 16px;
  margin-top: 8px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}

.toggle input {
  margin: 0;
  accent-color: var(--accent);
}

/* run section pinned to bottom of left column */

.section-run {
  margin-top: auto;
}

.btn-accent {
  width: 100%;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  color: #1c0d05;
  border: 0;
  border-radius: 6px;
  background: linear-gradient(135deg, #ff9b68, var(--warm));
}

.btn-accent:hover:not(:disabled) {
  filter: brightness(1.08);
}

.status-line {
  margin: 6px 0 0;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- right: results ---------- */

.col-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
}

.result-summary {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.stat {
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  min-width: 0;
}

.stat span {
  display: block;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  white-space: nowrap;
}

.stat strong {
  display: block;
  margin-top: 1px;
  font-family: var(--mono);
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.transcript-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.transcript-head h3 {
  margin: 0;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
}

.transcript-card {
  flex: 1 1 auto;
  min-height: 110px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  padding: 7px 10px;
}

#transcriptOutput {
  flex: 1 1 auto;
  min-height: 0;
  margin: 5px 0 0;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  color: #f2fbfc;
}

.timestamps-card {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  padding: 7px 10px;
}

.timestamp-table-wrap {
  max-height: 148px;
  overflow-y: auto;
  margin-top: 4px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 3px 8px;
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
}

td {
  padding: 3px 8px;
  font-size: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

td:nth-child(2),
td:nth-child(3) {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--accent-strong);
  white-space: nowrap;
}

.empty-row {
  text-align: center;
  color: var(--muted);
  padding: 12px 8px;
  font-size: 11.5px;
}

.benchmarks {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 6px;
}

.benchmarks:empty {
  display: none;
}

.bench-card {
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
}

.bench-card span {
  display: block;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bench-card strong {
  display: block;
  font-family: var(--mono);
  font-size: 13px;
  margin-top: 1px;
}

.bench-card small {
  display: block;
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 1px;
}

/* ---------- animations ---------- */

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 141, 102, 0.45); }
  70% { box-shadow: 0 0 0 10px rgba(255, 141, 102, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 141, 102, 0); }
}

@keyframes meter {
  0%, 100% { transform: scaleY(0.35); }
  50% { transform: scaleY(1); }
}

/* ---------- fallback for narrow / short screens ---------- */

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .app {
    height: auto;
    min-height: 100vh;
  }

  .cols {
    grid-template-columns: 1fr;
  }

  .col {
    overflow: visible;
  }

  .transcript-card {
    min-height: 240px;
  }

  .result-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
