:root {
  color-scheme: dark;
  --bg: #080b0f;
  --surface: #11161d;
  --surface-strong: #171e27;
  --surface-soft: #0d1117;
  --text: #f7fafc;
  --muted: #94a3b8;
  --subtle: #64748b;
  --line: #263241;
  --primary: #2dd4bf;
  --primary-active: #5eead4;
  --primary-text: #04221f;
  --danger: #fb7185;
  --amber: #fbbf24;
  --shadow: 0 22px 70px rgb(0 0 0 / 0.34);
}

* {
  box-sizing: border-box;
}

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

body {
  background:
    radial-gradient(circle at 12% 0%, rgb(45 212 191 / 0.16), transparent 34%),
    linear-gradient(180deg, #0b1016 0%, var(--bg) 52%, #05070a 100%);
  color: var(--text);
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  appearance: none;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  min-height: 52px;
  padding: 0 18px;
  transition:
    background-color 140ms ease,
    border-color 140ms ease,
    color 140ms ease,
    opacity 140ms ease,
    transform 140ms ease;
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.app-shell {
  display: grid;
  grid-template-rows: max-content minmax(0, 1fr) max-content;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  max-width: 900px;
  padding:
    max(16px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  row-gap: 14px;
}

.top-bar {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  min-height: 62px;
}

.eyebrow {
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin-bottom: 3px;
  text-transform: uppercase;
}

h1 {
  font-size: 1.45rem;
  line-height: 1.15;
  margin: 0;
}

.status-pill {
  align-items: center;
  background: rgb(148 163 184 / 0.11);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 0.9rem;
  font-weight: 800;
  min-height: 34px;
  padding: 0 12px;
  white-space: nowrap;
}

.status-pill.is-live {
  background: rgb(45 212 191 / 0.14);
  border-color: rgb(45 212 191 / 0.42);
  color: var(--primary-active);
}

.status-pill.is-starting {
  background: rgb(251 191 36 / 0.12);
  border-color: rgb(251 191 36 / 0.38);
  color: var(--amber);
}

.login-panel[hidden] {
  display: none;
}

.login-panel {
  background: rgb(17 22 29 / 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.content-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.login-form {
  display: grid;
  gap: 10px;
}

.login-form label,
.strip-label {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.login-row {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) 112px;
}

.login-row input {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  min-height: 52px;
  min-width: 0;
  padding: 0 16px;
}

.stage {
  display: grid;
  flex: 1 1 auto;
  gap: 12px;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
}

.source-strip {
  align-items: center;
  background: rgb(17 22 29 / 0.72);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 14px;
  justify-content: space-between;
  min-height: 72px;
  padding: 12px 14px;
}

.source-strip p {
  color: var(--muted);
  font-size: 1rem;
  font-weight: 650;
  line-height: 1.35;
  margin: 2px 0 0;
  max-height: 2.7em;
  overflow: hidden;
}

.language-hint {
  background: rgb(45 212 191 / 0.13);
  border: 1px solid rgb(45 212 191 / 0.34);
  border-radius: 999px;
  color: var(--primary-active);
  flex: 0 0 auto;
  font-size: 0.78rem;
  font-weight: 900;
  padding: 7px 10px;
}

.source-controls {
  align-items: center;
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.ignore-toggle {
  align-items: center;
  background: rgb(148 163 184 / 0.08);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 850;
  gap: 6px;
  min-height: 32px;
  padding: 0 10px;
  white-space: nowrap;
}

.ignore-toggle input {
  accent-color: var(--primary);
  height: 14px;
  margin: 0;
  width: 14px;
}

.transcript {
  background: rgb(17 22 29 / 0.76);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-height: 0;
  overflow-y: auto;
  padding: 20px;
  scroll-behavior: smooth;
}

.empty-state {
  align-items: center;
  color: var(--subtle);
  display: flex;
  font-size: 2.9rem;
  font-weight: 850;
  height: 100%;
  line-height: 1.18;
}

.translation-line {
  border-bottom: 1px solid rgb(148 163 184 / 0.14);
  padding: 0 0 22px;
}

.translation-line + .translation-line {
  padding-top: 24px;
}

.translation-line:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.translation-line p {
  font-size: 3.35rem;
  font-weight: 850;
  line-height: 1.2;
  margin: 0;
  overflow-wrap: anywhere;
}

.translation-line.is-partial p::after {
  color: var(--primary);
  content: "▋";
  font-weight: 700;
  margin-left: 3px;
}

.source-inline {
  color: var(--subtle);
  font-size: 0.92rem;
  font-weight: 650;
  line-height: 1.35;
  margin-bottom: 9px;
  overflow-wrap: anywhere;
}

.source-inline:empty {
  display: none;
}

.control-bar {
  align-self: end;
  background: rgb(8 11 15 / 0.72);
  border: 1px solid rgb(148 163 184 / 0.18);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  padding: 10px;
}

.audio-meter {
  background: rgb(13 17 23 / 0.82);
  border: 1px solid rgb(148 163 184 / 0.16);
  border-radius: 8px;
  height: 58px;
  overflow: hidden;
  position: relative;
}

.audio-meter canvas {
  display: block;
  height: 100%;
  width: 100%;
}

.audio-meter-meta {
  align-items: center;
  display: flex;
  gap: 10px;
  inset: 0;
  justify-content: space-between;
  pointer-events: none;
  position: absolute;
  padding: 0 12px;
}

.audio-meter-meta span {
  color: rgb(247 250 252 / 0.72);
  font-size: 0.78rem;
  font-weight: 850;
  text-shadow: 0 1px 8px rgb(0 0 0 / 0.55);
}

#sessionInfo {
  color: rgb(94 234 212 / 0.82);
  min-width: 0;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.button-row {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr) minmax(0, 0.82fr);
}

.control-button {
  background: var(--surface-strong);
  border: 1px solid var(--line);
  color: var(--muted);
  font-weight: 850;
  min-width: 0;
}

.primary {
  background: var(--primary);
  border: 1px solid transparent;
  color: var(--primary-text);
}

.primary:hover:not(:disabled) {
  background: var(--primary-active);
}

#stopButton {
  color: var(--danger);
}

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

@media (max-width: 640px) {
  .app-shell {
    padding:
      max(12px, env(safe-area-inset-top))
      max(12px, env(safe-area-inset-right))
      max(12px, env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left));
    row-gap: 10px;
  }

  .top-bar {
    min-height: 56px;
  }

  h1 {
    font-size: 1.18rem;
  }

  .status-pill {
    font-size: 0.82rem;
    min-height: 32px;
    padding: 0 10px;
  }

  .login-panel {
    padding: 14px;
  }

  .login-row {
    grid-template-columns: 1fr;
  }

  .stage {
    gap: 10px;
  }

  .source-strip {
    align-items: flex-start;
    min-height: 64px;
    padding: 10px 12px;
  }

  .source-controls {
    align-items: flex-end;
    flex-direction: column;
    gap: 6px;
  }

  .ignore-toggle {
    font-size: 0.72rem;
    min-height: 28px;
    padding: 0 8px;
  }

  .source-strip p {
    font-size: 0.92rem;
  }

  .transcript {
    padding: 18px;
  }

  .empty-state {
    align-items: flex-start;
    font-size: 2.25rem;
    padding-top: 4px;
  }

  .translation-line {
    padding-bottom: 18px;
  }

  .translation-line + .translation-line {
    padding-top: 18px;
  }

  .translation-line p {
    font-size: 2.5rem;
    line-height: 1.24;
  }

  .control-bar {
    gap: 8px;
    padding: 8px;
  }

  .audio-meter {
    height: 48px;
  }

  .button-row {
    gap: 8px;
    grid-template-columns: minmax(0, 1.24fr) minmax(0, 1fr) minmax(0, 0.72fr);
  }

  button {
    min-height: 50px;
    padding: 0 10px;
  }
}

@media (max-width: 360px) {
  .translation-line p {
    font-size: 2.18rem;
  }

  .empty-state {
    font-size: 2rem;
  }
}
