:root {
  color-scheme: light;
  --paper: #fbfaf7;
  --ink: #171511;
  --muted: #6e665b;
  --line: #ddd6ca;
  --panel: #ffffff;
  --teal: #007f78;
  --teal-dark: #005b56;
  --amber: #ba6f00;
  --rose: #b43c52;
  --shadow: 0 18px 48px rgba(39, 32, 21, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
select,
input {
  font: inherit;
}

.app-shell {
  width: min(100%, 760px);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px max(22px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: auto auto minmax(250px, 1fr) auto auto auto;
  gap: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--teal-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: 1.75rem;
  line-height: 1.1;
  letter-spacing: 0;
}

.status-pill {
  min-width: 76px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 11px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.68);
  text-align: center;
  font-size: 0.82rem;
  white-space: nowrap;
}

.status-pill.active {
  color: #fff;
  border-color: var(--teal);
  background: var(--teal);
}

.status-pill.error {
  color: #fff;
  border-color: var(--rose);
  background: var(--rose);
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.controls label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  background: var(--panel);
}

.toggle-row {
  align-items: center;
  grid-template-columns: 1fr auto;
  justify-items: stretch;
  min-width: 78px;
}

.mic-row {
  grid-column: 1 / -1;
  grid-template-columns: 1fr;
}

.mic-hint {
  grid-column: 1 / -1;
  margin: -3px 0 0;
  border: 1px solid rgba(0, 127, 120, 0.28);
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--teal-dark);
  background: rgba(0, 127, 120, 0.08);
  font-size: 0.8rem;
  font-weight: 750;
  line-height: 1.35;
}

.mic-hint.warning {
  border-color: rgba(180, 60, 82, 0.34);
  color: var(--rose);
  background: rgba(180, 60, 82, 0.08);
}

.toggle-row input {
  width: 44px;
  height: 24px;
  margin: 0;
  accent-color: var(--teal);
}

.tts-note {
  grid-column: 1 / -1;
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.stage {
  min-height: 250px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.94)),
    radial-gradient(circle at 16% 12%, rgba(0, 127, 120, 0.16), transparent 32%),
    radial-gradient(circle at 84% 88%, rgba(186, 111, 0, 0.16), transparent 30%);
  box-shadow: var(--shadow);
}

.stage-label {
  margin: 0 0 14px;
  color: var(--amber);
  font-size: 0.86rem;
  font-weight: 800;
}

.translation {
  min-height: 132px;
  display: flex;
  align-items: center;
  color: var(--ink);
  font-size: clamp(2rem, 10vw, 4.8rem);
  font-weight: 850;
  line-height: 1.08;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.original {
  min-height: 44px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.session-bar {
  display: grid;
  grid-template-columns: 1fr 50px 50px;
  gap: 8px;
}

button {
  min-height: 50px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}

button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(0, 127, 120, 0.28);
  outline-offset: 2px;
}

.primary-action {
  color: #fff;
  background: var(--teal);
  font-weight: 850;
}

.primary-action.listening {
  background: var(--rose);
}

.primary-action.blocked {
  background: var(--rose);
}

.icon-action {
  color: var(--ink);
  border-color: var(--line);
  background: var(--panel);
  font-size: 1.2rem;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.metrics div {
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.72);
}

.metrics .level-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-content: center;
  gap: 7px 10px;
}

.metrics span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.metrics strong {
  font-size: 1.15rem;
}

.level-meter {
  grid-column: 1 / -1;
  height: 7px;
  border-radius: 999px;
  overflow: hidden;
  background: #ece6dc;
}

.level-meter div {
  width: 0%;
  height: 100%;
  min-height: 0;
  border: 0;
  border-radius: 999px;
  padding: 0;
  background: var(--teal);
}

.transcript-list {
  display: grid;
  gap: 8px;
  padding-bottom: 8px;
}

.transcript-item {
  border-left: 4px solid var(--teal);
  border-radius: 8px;
  padding: 11px 12px;
  background: var(--panel);
}

.transcript-item p {
  margin: 0;
  line-height: 1.4;
}

.transcript-item .line-translation {
  color: var(--ink);
  font-weight: 750;
}

.transcript-item .line-original {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.transcript-item .line-meta {
  margin-top: 7px;
  color: var(--amber);
  font-size: 0.76rem;
  font-weight: 750;
}

@media (max-width: 430px) {
  .app-shell {
    padding-left: 12px;
    padding-right: 12px;
  }

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

  .toggle-row {
    grid-column: 1 / -1;
    grid-template-columns: 1fr auto;
    justify-items: stretch;
  }

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