:root {
  --bg: #f7f6f3;
  --surface: #ffffff;
  --surface-2: #efede8;
  --text: #1c1b19;
  --muted: #6b6860;
  --border: #dcd9d2;
  --accent: #1f5fbf;
  --accent-text: #ffffff;
  --selected: #e4ecf9;
  --playing: #d6e4fb;
  --warn-bg: #fff3d6;
  --warn-text: #6b4a00;
  --warn-border: #e8c46a;
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141412;
    --surface: #1e1e1b;
    --surface-2: #2a2a26;
    --text: #ecebe6;
    --muted: #a19e94;
    --border: #3a3934;
    --accent: #7aa8f0;
    --accent-text: #0e1a2e;
    --selected: #1f2a3b;
    --playing: #24364f;
    --warn-bg: #3a2e10;
    --warn-text: #f3d68a;
    --warn-border: #7a6120;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 17px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
}

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

/* ---- sticky control bar ---- */
.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px 12px;
  padding-top: max(10px, env(safe-area-inset-top));
  display: grid;
  gap: 8px;
}

.bar-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.title-row { justify-content: space-between; }

h1 { font-size: 1.1rem; margin: 0; }

.chip {
  min-height: 40px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  white-space: nowrap;
}
.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
.chip.primary { font-weight: 600; }

.speed { display: flex; align-items: center; gap: 10px; width: 100%; }
.speed span { color: var(--muted); font-size: 0.9rem; min-width: 3.2em; }
.speed input { flex: 1; min-width: 0; accent-color: var(--accent); height: 32px; }
.speed output { font-variant-numeric: tabular-nums; min-width: 3.2em; text-align: right; }

/* Language and voice side by side; voice names are long, so it gets more room. */
.selects { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 8px; }
.field { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.field span { color: var(--muted); font-size: 0.8rem; }
.field select {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  text-overflow: ellipsis;
}

.warning {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--warn-bg);
  color: var(--warn-text);
  border: 1px solid var(--warn-border);
  font-size: 0.92rem;
}
.warning.flash { animation: flash 0.6s ease 2; }
@keyframes flash { 50% { filter: brightness(1.25); transform: scale(1.01); } }

/* ---- sentence list ---- */
main { padding: 12px 16px 32px; max-width: 720px; margin: 0 auto; }

.status { margin: 0 0 8px; color: var(--muted); font-size: 0.9rem; min-height: 1.2em; }

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  scroll-margin-top: 240px;
}
.row[aria-selected="true"] { background: var(--selected); border-color: var(--accent); }
.row.playing { background: var(--playing); }

.play {
  flex: none;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 1.3rem;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.play:disabled { opacity: 0.4; cursor: not-allowed; }

.texts { flex: 1; min-width: 0; display: grid; gap: 4px; }
.texts p { margin: 0; overflow-wrap: anywhere; }
.src { color: var(--muted); font-size: 0.95rem; }
.tgt { font-size: 1.15rem; font-weight: 500; }

.concealed {
  filter: blur(7px);
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
  background: var(--surface-2);
  border-radius: 6px;
}
.concealed:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; filter: blur(5px); }

.hint { color: var(--muted); font-size: 0.8rem; text-align: center; margin-top: 20px; }
@media (hover: none) { .hint { display: none; } }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
