:root {
  --roc-red: #d71920;
  --roc-red-dark: #a80f15;
  --ink: #17202a;
  --muted: #667085;
  --line: #d9dee7;
  --surface: #ffffff;
  --surface-soft: #f6f7f9;
  --focus: #155eef;
  --reader-bg: #ffffff;
  --reader-font-size: 22px;
  --reader-line-height: 1.65;
  --reader-font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #f3f4f6;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: #f3f4f6;
}

button, input, select, textarea { font: inherit; }
button, select, input[type="range"] { cursor: pointer; }

button:focus-visible,
select:focus-visible,
textarea:focus-visible,
input:focus-visible,
.reader-text:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 35%, transparent);
  outline-offset: 2px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(18px, 4vw, 56px);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  color: #fff;
  background: var(--roc-red);
  font-weight: 900;
  font-size: 26px;
  line-height: 1;
}
.brand-kicker { color: var(--roc-red); font-size: 12px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.brand h1 { margin: 1px 0 0; font-size: 21px; line-height: 1.1; }

.privacy-badge,
.status-pill,
.compatibility {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.privacy-badge { padding: 9px 12px; color: #216e45; background: #e9f8ef; }
.privacy-dot { width: 8px; height: 8px; border-radius: 50%; background: #2e9d62; }

.page-shell { width: min(1240px, calc(100% - 32px)); margin: 34px auto 46px; }

.intro {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 28px;
  margin-bottom: 20px;
}
.intro h2 { max-width: 820px; margin: 3px 0 8px; font-size: clamp(26px, 4vw, 38px); line-height: 1.15; }
.intro p { margin: 0; max-width: 820px; color: var(--muted); }
.eyebrow, .panel-label { margin: 0; color: var(--roc-red); font-size: 12px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.compatibility { flex: 0 0 auto; padding: 10px 13px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); }
.compatibility.good { color: #216e45; background: #effaf3; border-color: #b9e8ca; }
.compatibility.bad { color: #912018; background: #fff0ef; border-color: #f3b8b4; }

.workspace { display: grid; grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr); gap: 18px; }
.panel, .settings-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 5px 18px rgba(16, 24, 40, .04);
}
.panel { min-height: 520px; padding: 22px; }
.panel-heading, .settings-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.panel h3, .settings-panel h3 { margin: 2px 0 0; font-size: 20px; }

.button, .icon-button, .primary-play, .theme-option {
  border: 0;
  border-radius: 10px;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
}
button:active { transform: translateY(1px); }
.button { padding: 9px 12px; font-weight: 750; }
.button-ghost { color: var(--ink); background: #f3f4f6; border: 1px solid var(--line); }
.button-ghost:hover { background: #e9ebef; }

#sourceText {
  width: 100%;
  height: 390px;
  resize: vertical;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfbfc;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.55;
}
#sourceText::placeholder { color: #98a2b3; }
.editor-meta { display: flex; flex-wrap: wrap; gap: 9px 18px; margin-top: 11px; color: var(--muted); font-size: 12px; }

.status-pill { padding: 8px 11px; color: #344054; background: #f2f4f7; }
.status-pill.speaking { color: #92400e; background: #fff7dc; }
.status-pill.paused { color: #175cd3; background: #eff8ff; }

.reader-panel { display: flex; flex-direction: column; }
.reader-text {
  flex: 1;
  min-height: 390px;
  max-height: 470px;
  overflow: auto;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--reader-bg);
  font-family: var(--reader-font-family);
  font-size: var(--reader-font-size);
  line-height: var(--reader-line-height);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.reader-text.theme-cream { --reader-bg: #fff9e8; }
.reader-text.theme-blue { --reader-bg: #edf7ff; }
.reader-text mark {
  padding: .04em .08em;
  border-radius: .18em;
  color: inherit;
  background: #ffe873;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
.reader-text .sentence-active { background: rgba(255, 232, 115, .36); border-radius: .2em; }
.reader-text .word-active { background: #ffd21e; border-radius: .2em; }
.empty-state { margin: 0; color: #98a2b3; font-style: italic; }

.transport { display: flex; align-items: center; justify-content: center; gap: 9px; margin-top: 16px; }
.icon-button, .primary-play { min-height: 46px; font-weight: 800; }
.icon-button { width: 46px; color: #344054; background: #f2f4f7; }
.icon-button:hover { background: #e4e7ec; }
.primary-play { min-width: 155px; padding: 0 18px; color: #fff; background: var(--roc-red); }
.primary-play:hover { background: var(--roc-red-dark); }

.settings-panel { margin-top: 18px; padding: 22px; }
.settings-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.setting-card {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fcfcfd;
}
.setting-card > label,
.setting-card legend,
.setting-card strong { display: block; margin-bottom: 10px; font-size: 14px; font-weight: 800; }
.setting-card small { display: block; margin-top: 8px; color: var(--muted); line-height: 1.35; }
.setting-card select { width: 100%; min-height: 42px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--ink); }
.label-row { display: flex; justify-content: space-between; gap: 12px; }
.label-row label { font-size: 14px; font-weight: 800; }
.label-row output { color: var(--roc-red); font-weight: 850; }
.setting-card input[type="range"] { width: 100%; accent-color: var(--roc-red); }
.range-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; }
.theme-card { margin: 0; }
.theme-card legend { padding: 0; }
.theme-options { display: flex; gap: 7px; }
.theme-option { flex: 1; display: grid; place-items: center; gap: 5px; padding: 8px 6px; color: #475467; background: #fff; border: 1px solid var(--line); font-size: 12px; }
.theme-option.active { border-color: var(--roc-red); box-shadow: inset 0 0 0 1px var(--roc-red); color: var(--roc-red); font-weight: 800; }
.theme-swatch { width: 26px; height: 18px; border: 1px solid #d0d5dd; border-radius: 4px; }
.swatch-white { background: #fff; }
.swatch-cream { background: #fff9e8; }
.swatch-blue { background: #edf7ff; }
.switch-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.switch-card strong { margin-bottom: 2px; }
.switch { position: relative; display: inline-block; width: 50px; height: 28px; flex: 0 0 50px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-ui { position: absolute; inset: 0; border-radius: 999px; background: #d0d5dd; transition: .18s; }
.switch-ui::before { content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; border-radius: 50%; background: white; box-shadow: 0 1px 3px rgba(0,0,0,.22); transition: .18s; }
.switch input:checked + .switch-ui { background: var(--roc-red); }
.switch input:checked + .switch-ui::before { transform: translateX(22px); }

.exam-note {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-top: 18px;
  padding: 17px 19px;
  border: 1px solid #b9e8ca;
  border-radius: 14px;
  background: #effaf3;
}
.exam-note-icon { display: grid; place-items: center; width: 28px; height: 28px; flex: 0 0 28px; border-radius: 50%; background: #2e9d62; color: #fff; font-weight: 900; }
.exam-note strong { display: block; margin: 2px 0 3px; }
.exam-note p { margin: 0; color: #47735b; }

footer { padding: 0 20px 30px; text-align: center; color: #7a8492; font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel { min-height: auto; }
}

@media (max-width: 620px) {
  .topbar { align-items: flex-start; padding: 14px 16px; }
  .privacy-badge { display: none; }
  .page-shell { width: min(100% - 20px, 1240px); margin-top: 22px; }
  .intro { display: block; }
  .compatibility { margin-top: 14px; }
  .panel, .settings-panel { padding: 15px; border-radius: 13px; }
  .settings-grid { grid-template-columns: 1fr; }
  #sourceText { height: 270px; }
  .reader-text { min-height: 300px; }
  .primary-play { min-width: 130px; }
  .transport { gap: 5px; }
  .icon-button { width: 42px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
