:root {
  --bg: #f7f5ef;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --ink: #1c1b18;
  --muted: #6c665b;
  --line: #d8d0c2;
  --accent: #2f735c;
  --accent-strong: #245a49;
  --accent-soft: #dbe9df;
  --blue: #28628f;
  --amber: #b35d1f;
  --shadow: 0 18px 50px rgba(38, 35, 28, 0.12);
  --radius: 8px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background:
    linear-gradient(0deg, rgba(47, 115, 92, 0.06), rgba(47, 115, 92, 0.06)),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

svg {
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.app-shell {
  min-height: 100vh;
  padding: 20px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 16px;
}

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 34px rgba(38, 35, 28, 0.08);
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.2rem;
  line-height: 1.1;
  font-weight: 760;
}

h2 {
  font-size: 0.93rem;
  line-height: 1.2;
  text-transform: uppercase;
  font-weight: 760;
  color: var(--muted);
}

.status-line {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.88rem;
  min-height: 1.25rem;
}

.quick-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(72px, auto));
  gap: 10px;
}

.quick-stats div {
  min-width: 72px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  text-align: right;
}

.quick-stats span {
  display: block;
  font-size: 1rem;
  font-weight: 760;
}

.quick-stats small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(380px, 1fr) minmax(260px, 320px);
  gap: 16px;
  align-items: stretch;
}

.panel {
  min-width: 0;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.source-panel,
.settings-panel {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.source-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.tabs,
.segmented {
  display: grid;
  gap: 4px;
  padding: 4px;
  background: #ece5d8;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.tabs {
  grid-template-columns: repeat(3, 1fr);
}

.tab,
.segment {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 720;
}

.tab.active,
.segment.active {
  background: var(--surface-strong);
  color: var(--ink);
  box-shadow: 0 1px 8px rgba(38, 35, 28, 0.08);
}

.tab-pane {
  min-height: 0;
}

#paste-pane.active {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1 1 auto;
}

.field-label,
.range-block span,
.option-group legend {
  color: var(--muted);
  font-size: 0.79rem;
  font-weight: 760;
  text-transform: uppercase;
}

textarea,
input[type="url"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  color: var(--ink);
  outline: none;
}

textarea {
  min-height: 320px;
  flex: 1 1 auto;
  resize: vertical;
  padding: 12px;
  line-height: 1.5;
}

input[type="url"] {
  min-height: 42px;
  padding: 0 12px;
}

textarea:focus,
input[type="url"]:focus,
input[type="range"]:focus-visible,
button:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 115, 92, 0.18);
  outline: none;
}

.button-row,
.url-row,
.stepper-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.url-row input {
  min-width: 0;
  flex: 1 1 auto;
}

.icon-button,
.icon-text-button,
.play-button {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.icon-button:hover,
.icon-text-button:hover,
.play-button:hover {
  transform: translateY(-1px);
  border-color: #b8ad9d;
}

.icon-button {
  width: 42px;
  flex: 0 0 42px;
  padding: 0;
}

.icon-text-button {
  gap: 8px;
  padding: 0 12px;
  min-width: 0;
  font-weight: 740;
  white-space: nowrap;
}

.icon-button svg,
.icon-text-button svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.icon-text-button.primary,
.play-button {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.icon-text-button.primary:hover,
.play-button:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.icon-text-button.subtle {
  background: var(--accent-soft);
  border-color: #c7dccd;
  color: var(--accent-strong);
}

.icon-text-button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.file-drop {
  min-height: 178px;
  border: 1px dashed #afa594;
  border-radius: var(--radius);
  background: var(--surface-strong);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 22px;
  color: var(--muted);
  text-align: center;
  cursor: pointer;
}

.file-drop svg {
  width: 42px;
  height: 42px;
  color: var(--blue);
}

.file-drop span {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-weight: 720;
}

#file-input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.source-review {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1 1 auto;
}

.review-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.review-title-block {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.review-title-block strong {
  max-width: 100%;
  color: var(--ink);
  font-size: 0.98rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.source-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.source-metrics span {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.source-metrics strong {
  display: block;
  color: var(--ink);
  font-size: 1rem;
}

.source-warning {
  padding: 9px 10px;
  border: 1px solid #dfbe92;
  border-radius: var(--radius);
  background: #fff4df;
  color: #794214;
  font-size: 0.82rem;
  line-height: 1.35;
}

.cleanup-box {
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  display: grid;
  gap: 8px;
}

.cleanup-box legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 760;
  text-transform: uppercase;
}

.mini-toggle {
  min-height: 28px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 650;
}

.mini-toggle input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.review-text {
  min-height: 168px;
  max-height: 280px;
}

.reader-panel {
  padding: 20px;
  display: grid;
  grid-template-rows: minmax(280px, 1fr) auto auto;
  gap: 18px;
}

.reader-frame {
  position: relative;
  min-height: 280px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, transparent calc(50% - 1px), rgba(179, 93, 31, 0.28) calc(50% - 1px), rgba(179, 93, 31, 0.28) calc(50% + 1px), transparent calc(50% + 1px)),
    repeating-linear-gradient(0deg, rgba(47, 115, 92, 0.04) 0 1px, transparent 1px 36px),
    #fffdfa;
}

.context-word {
  position: absolute;
  left: 50%;
  max-width: 72%;
  transform: translateX(-50%);
  color: rgba(108, 102, 91, 0.46);
  font-size: clamp(1rem, 2.2vw, 1.65rem);
  font-weight: 740;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.context-word.previous {
  top: 22%;
}

.context-word.next {
  bottom: 22%;
}

.finish-summary {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(520px, calc(100% - 44px));
  transform: translate(-50%, -50%);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.96);
  box-shadow: 0 18px 48px rgba(38, 35, 28, 0.15);
  display: grid;
  gap: 14px;
  z-index: 3;
}

.finish-summary strong {
  display: block;
  margin-top: 4px;
  font-size: 1.15rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.finish-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.finish-metrics span {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 0.74rem;
  text-transform: uppercase;
}

.finish-metrics strong {
  margin: 0;
  color: var(--ink);
  font-size: 1rem;
}

.finish-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.focus-rail {
  position: absolute;
  left: 50%;
  width: 2px;
  height: 28px;
  transform: translateX(-50%);
  background: var(--amber);
}

.focus-rail.top {
  top: 18px;
}

.focus-rail.bottom {
  bottom: 18px;
}

.word-display {
  max-width: min(820px, 94%);
  min-height: 1.08em;
  display: flex;
  align-items: baseline;
  justify-content: center;
  color: var(--ink);
  font-size: clamp(3.2rem, 8vw, 6.8rem);
  font-weight: 780;
  line-height: 1.05;
  text-align: center;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: keep-all;
  hyphens: none;
  letter-spacing: 0;
}

.word-display.compact {
  font-size: clamp(2.4rem, 6vw, 5.2rem);
}

.word-display.large {
  font-size: clamp(4rem, 10vw, 8rem);
}

.word-left,
.word-focus,
.word-right {
  display: inline-block;
  white-space: pre;
  flex: 0 0 auto;
}

.word-focus {
  color: var(--amber);
}

.countdown-word {
  color: var(--accent);
  font-size: 1.15em;
  font-variant-numeric: tabular-nums;
}

.empty-word {
  color: #aaa092;
  font-size: 0.36em;
  text-transform: uppercase;
}

.progress-area {
  display: grid;
  gap: 8px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 720;
}

.progress-slider,
#wpm-slider {
  width: 100%;
  accent-color: var(--accent);
}

.transport {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.play-button {
  width: 58px;
  height: 58px;
  padding: 0;
  flex: 0 0 58px;
}

.play-button svg {
  width: 24px;
  height: 24px;
}

.range-block {
  display: grid;
  gap: 8px;
}

.section-select {
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  color: var(--ink);
  font: inherit;
  font-weight: 650;
}

.section-select:disabled {
  color: var(--muted);
}

#wpm-output {
  color: var(--accent-strong);
  font-weight: 800;
}

.stepper-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stepper-row .icon-text-button {
  justify-content: center;
}

.option-group {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  display: grid;
  gap: 10px;
}

.option-group legend {
  padding: 0 6px;
}

.toggle-row {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink);
  font-weight: 650;
}

.toggle-row input {
  width: 42px;
  height: 24px;
  margin: 0;
  accent-color: var(--accent);
}

.segmented {
  grid-template-columns: repeat(3, 1fr);
}

.focus-mode .workspace {
  grid-template-columns: minmax(0, 1fr);
}

.focus-mode .source-panel,
.focus-mode .settings-panel {
  display: none;
}

.focus-mode .reader-panel {
  min-height: calc(100vh - 122px);
}

.focus-mode .reader-frame {
  min-height: min(68vh, 680px);
}

.focus-mode .word-display {
  font-size: clamp(4.2rem, 10vw, 9rem);
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: minmax(280px, 360px) minmax(360px, 1fr);
  }

  .settings-panel {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) minmax(260px, 1fr);
    align-items: start;
  }

  .settings-panel .panel-heading {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 10px;
    gap: 10px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .quick-stats {
    width: 100%;
  }

  .quick-stats div {
    text-align: left;
  }

  .workspace,
  .settings-panel {
    grid-template-columns: 1fr;
  }

  .reader-panel {
    grid-row: 1;
    padding: 12px;
    gap: 14px;
  }

  .source-panel {
    grid-row: 2;
  }

  .settings-panel {
    grid-row: 3;
  }

  textarea {
    min-height: 220px;
  }

  .reader-frame {
    min-height: 260px;
  }

  .word-display {
    max-width: 94%;
  }

  .transport {
    gap: 6px;
  }

  .finish-summary {
    width: calc(100% - 28px);
    padding: 12px;
    gap: 10px;
  }

  .finish-summary strong {
    font-size: 0.98rem;
  }

  .finish-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .finish-metrics span {
    padding: 7px 6px;
    font-size: 0.64rem;
  }

  .finish-metrics strong {
    font-size: 0.86rem;
  }

  .finish-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .finish-actions .icon-text-button {
    min-height: 38px;
    padding: 0 8px;
  }

  .context-word {
    max-width: 82%;
  }
}

@media (max-width: 430px) {
  .brand-mark {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
  }

  h1 {
    font-size: 1.05rem;
  }

  .button-row,
  .url-row {
    align-items: stretch;
    flex-direction: column;
  }

  .button-row .icon-button,
  .url-row .icon-text-button {
    width: 100%;
  }

  .icon-text-button {
    justify-content: center;
  }

  .play-button {
    width: 54px;
    height: 54px;
    flex-basis: 54px;
  }

  .source-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .source-actions .icon-text-button {
    padding: 0 8px;
  }

  .transport .icon-button {
    width: 40px;
    flex-basis: 40px;
  }
}
/* Static hosting privacy disclosure. */
.privacy-note {
  max-width: 75rem;
  margin: 1rem auto;
  padding: 0 1.25rem;
  color: var(--muted, #686868);
  font-size: .8rem;
  line-height: 1.5;
}
