:root {
  --bg: #f4f1ea;
  --fg: #121212;
  --muted: #3a3a3a;
  --card: #fffdf8;
  --line: #121212;
  --accent: #efe6c9;
  --danger: #8b1212;
  --status: 42px;
  --transcript: 36px;
  --dock: 72px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", "Noto Naskh Arabic", "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
}

.page {
  padding: calc(16px + var(--safe-top)) 16px calc(196px + var(--safe-bottom));
  max-width: 720px;
  margin: 0 auto;
}

h1 {
  margin: 0 0 8px;
  font-size: 28px;
  line-height: 1.2;
  font-weight: 750;
}

.lead {
  margin: 0 0 20px;
  font-size: 18px;
  line-height: 1.45;
  color: var(--muted);
}

.label {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 10px;
}

.lang-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.lang-btn,
.btn-main,
.btn-redo {
  appearance: none;
  -webkit-appearance: none;
  border: 3px solid var(--line);
  background: var(--card);
  color: var(--fg);
  font: inherit;
  font-weight: 700;
  border-radius: 16px;
  cursor: pointer;
  width: 100%;
}

.lang-btn {
  min-height: 64px;
  font-size: 26px;
}

.lang-btn[aria-pressed="true"] {
  background: var(--accent);
  box-shadow: inset 0 0 0 2px var(--line);
}

.status {
  margin: 22px 0 8px;
  font-size: var(--status);
  line-height: 1.25;
  font-weight: 750;
  letter-spacing: 0.01em;
}

.error {
  margin: 0 0 16px;
  font-size: 28px;
  line-height: 1.3;
  color: var(--danger);
  font-weight: 700;
}

.turns {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.turn {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
}

.turn-kicker {
  font-size: 18px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 4px;
}

.turn p {
  margin: 0 0 12px;
  font-size: var(--transcript);
  line-height: 1.35;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.turn p:last-child { margin-bottom: 0; }

.rtl { direction: rtl; text-align: right; }

.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px 16px calc(12px + var(--safe-bottom));
  background: linear-gradient(to top, var(--bg) 80%, transparent);
  max-width: 720px;
  margin: 0 auto;
}

.btn-main {
  min-height: var(--dock);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 2px;
  margin-bottom: 10px;
}

.btn-main-zh {
  font-size: 30px;
  line-height: 1.1;
  font-weight: 800;
}

.btn-main-sub {
  font-size: 20px;
  line-height: 1.2;
  font-weight: 700;
}

.btn-redo {
  min-height: 56px;
  font-size: 28px;
}

.btn-main:active,
.btn-redo:active,
.lang-btn:active {
  background: var(--accent);
}

.btn-main:disabled,
.btn-redo:disabled,
.lang-btn:disabled {
  opacity: 0.45;
}

.turn.pending .turn-kicker { color: var(--fg); }


.option-block {
  margin-top: 16px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  width: fit-content;
  max-width: 100%;
}

.toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.toggle-switch {
  position: relative;
  width: 56px;
  height: 32px;
  border: 3px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  flex-shrink: 0;
}

.toggle-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--fg);
}

.toggle input:checked + .toggle-switch {
  background: var(--accent);
}

.toggle input:checked + .toggle-switch::after {
  left: auto;
  right: 2px;
}

.toggle-text {
  line-height: 1.2;
}

.toggle:active .toggle-switch {
  background: var(--accent);
}
