:root {
  color-scheme: light;
  --bg: #eef2ef;
  --panel: rgba(255, 255, 255, 0.94);
  --panel-strong: #f8faf9;
  --line: rgba(42, 69, 57, 0.14);
  --text: #1f2b25;
  --muted: #64736c;
  --mint: #187d59;
  --mint-dark: #e7f2ec;
  --cyan: #397b8c;
  --red: #bd4b55;
  --shadow: 0 10px 28px rgba(34, 54, 45, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--text);
  background:
    radial-gradient(circle at 15% -5%, rgba(54, 142, 102, 0.08), transparent 34rem),
    radial-gradient(circle at 90% 12%, rgba(63, 130, 147, 0.06), transparent 28rem),
    var(--bg);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.45; }

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 0 max(32px, env(safe-area-inset-bottom));
}

.topbar, .card-heading, .button-row, .switch-row {
  display: flex;
  align-items: center;
}

.topbar { justify-content: space-between; margin-bottom: 20px; gap: 16px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.65rem, 4vw, 2.6rem); letter-spacing: -0.04em; }
h2 { margin-bottom: 0; font-size: 1.25rem; }
.eyebrow { margin-bottom: 5px; color: var(--mint); font-size: 0.68rem; font-weight: 800; letter-spacing: 0.16em; }

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.78);
}
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #819087; }
.status[data-state="live"] .status-dot { background: var(--mint); box-shadow: 0 0 0 5px rgba(24, 125, 89, 0.1); animation: pulse 1.5s infinite; }
.status[data-state="error"] .status-dot { background: var(--red); }
@keyframes pulse { 50% { opacity: 0.55; } }

.card {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.controls {
  display: grid;
  grid-template-columns: 1.2fr 1.2fr 0.8fr auto;
  gap: 11px;
  align-items: end;
  padding: 15px;
}

label { display: grid; gap: 7px; color: var(--muted); font-size: 0.82rem; }
input, select {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  color: var(--text);
  background: #fafcfb;
}
input:focus, select:focus { border-color: var(--mint); box-shadow: 0 0 0 3px rgba(24, 125, 89, 0.1); }
.switch-row { justify-content: space-between; min-height: 44px; padding: 0 4px; gap: 12px; }
.switch-row input { width: 44px; accent-color: var(--mint); }
.button-row { gap: 8px; }

button {
  min-height: 44px;
  padding: 0 15px;
  border: 0;
  border-radius: 12px;
  color: var(--text);
  font-weight: 750;
}
.primary { color: #fff; background: var(--mint); }
.danger { color: #fff; background: var(--red); }
.secondary { border: 1px solid rgba(24, 125, 89, 0.24); background: var(--mint-dark); }
.ghost { min-height: 36px; padding: 0 10px; color: var(--muted); background: transparent; }
.ghost:hover { color: var(--text); background: rgba(29, 53, 42, 0.05); }

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 12px 0;
}
.metrics div { padding: 9px 13px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255, 255, 255, 0.82); }
.metrics span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 0.72rem; }
.metrics strong { font-variant-numeric: tabular-nums; }

.transcripts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.transcript-card { min-height: min(50vh, 560px); padding: 16px; }
.source-card { border-top: 3px solid var(--cyan); }
.translation-card { border-top: 3px solid var(--mint); background: linear-gradient(160deg, #fbfdfc, #f3f8f5); }
.card-heading { justify-content: space-between; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.transcript {
  height: calc(min(50vh, 560px) - 76px);
  overflow: auto;
  padding: 12px 2px;
  font-size: clamp(0.98rem, 1.65vw, 1.22rem);
  line-height: 1.48;
  white-space: pre-wrap;
  overscroll-behavior: contain;
}
.translation { font-size: clamp(1.04rem, 1.85vw, 1.34rem); }
.placeholder { color: #87958e; font-style: italic; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 14px; }
.actions p { flex: 1 1 320px; margin: 0; color: var(--muted); font-size: 0.78rem; text-align: right; }
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  z-index: 10;
  max-width: calc(100% - 32px);
  padding: 11px 15px;
  border-radius: 999px;
  color: #fff;
  background: var(--mint);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: 180ms ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 850px) {
  .controls { grid-template-columns: 1fr 1fr; }
  .transcripts { grid-template-columns: 1fr; }
  .transcript-card { min-height: 38vh; }
  .transcript { height: calc(38vh - 72px); }
}

@media (max-width: 560px) {
  .shell { width: min(100% - 20px, 1180px); padding-top: max(14px, env(safe-area-inset-top)); }
  .topbar { align-items: flex-start; }
  .status { padding: 7px 9px; font-size: 0.78rem; }
  .controls { grid-template-columns: 1fr; padding: 12px; }
  .button-row button { flex: 1; }
  .metrics { position: sticky; top: max(6px, env(safe-area-inset-top)); z-index: 4; }
  .metrics div { padding: 9px 10px; }
  .metrics strong { font-size: 0.86rem; }
  .transcript-card { min-height: 36vh; padding: 13px; border-radius: 16px; }
  .transcript { height: calc(36vh - 66px); padding-top: 9px; }
  .actions p { text-align: left; }
}
