:root,
[data-theme="light"] {
  --bg: #f0ebe3;
  --bg-elevated: #faf7f2;
  --bg-input: #ffffff;
  --text: #3a3632;
  --text-muted: #7a746b;
  --border: #ddd6cb;
  --accent: #c45d3e;
  --accent-hover: #a84d32;
  --focal: #c45d3e;
  --progress-bg: #ddd6cb;
  --progress-fill: #c45d3e;
  --shadow: rgba(58, 54, 50, 0.08);
  --shadow-sm: 0 1px 2px rgba(58, 54, 50, 0.05), 0 1px 0 rgba(255, 255, 255, 0.6) inset;
  --shadow-md: 0 1px 2px rgba(58, 54, 50, 0.04), 0 8px 24px -12px rgba(58, 54, 50, 0.18);
  --shadow-lg: 0 2px 4px rgba(58, 54, 50, 0.04), 0 24px 48px -24px rgba(58, 54, 50, 0.28);
  --reader-bg: #faf7f2;
  --guide: rgba(196, 93, 62, 0.25);
  --select-bg: rgba(196, 93, 62, 0.08);
  --ring: rgba(196, 93, 62, 0.22);
}

[data-theme="dark"] {
  --bg: #1e1c1a;
  --bg-elevated: #2a2724;
  --bg-input: #33302c;
  --text: #e8e4dc;
  --text-muted: #9a948a;
  --border: #3d3934;
  --accent: #d4846a;
  --accent-hover: #e09980;
  --focal: #d4846a;
  --progress-bg: #3d3934;
  --progress-fill: #d4846a;
  --shadow: rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25), 0 1px 0 rgba(255, 255, 255, 0.04) inset;
  --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 28px -12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 2px 4px rgba(0, 0, 0, 0.3), 0 28px 56px -24px rgba(0, 0, 0, 0.6);
  --reader-bg: #252320;
  --guide: rgba(212, 132, 106, 0.3);
  --select-bg: rgba(212, 132, 106, 0.12);
  --ring: rgba(212, 132, 106, 0.3);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-optical-sizing: auto;
}

body {
  font-family: 'IBM Plex Sans', -apple-system, sans-serif;
  background: var(--bg);
  background-image: radial-gradient(ellipse 80% 50% at 50% -10%, var(--bg-elevated), transparent 70%);
  background-repeat: no-repeat;
  color: var(--text);
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
}

::selection {
  background: var(--select-bg);
  color: var(--text);
}

:where(button, a, input, textarea, select, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

h1, h2, h3, .logo, .home-headline, .doc-title, .finder-title, .finish-heading {
  font-feature-settings: "kern", "liga", "onum" 0;
}

.app {
  max-width: 680px;
  margin: 0 auto;
  padding: 1.5rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 2.5rem;
}

.app:has(.panel-home:not(.hidden)) .header {
  margin-bottom: 1.75rem;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex: 1;
  min-width: 0;
}

.header-back {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  color: var(--text-muted);
}

.header-back:hover {
  color: var(--text);
  background: var(--bg-input);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-speed-link {
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--accent);
  background: none;
  border: none;
  padding: 0.375rem 0.5rem;
  margin-right: 0.125rem;
  cursor: pointer;
  white-space: nowrap;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}

.header-speed-link:hover {
  color: var(--accent-hover);
  background: var(--select-bg);
}

@media (max-width: 380px) {
  .header-speed-link {
    font-size: 0.75rem;
    padding: 0.375rem 0.25rem;
    margin-right: 0;
  }
}

.header-home-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  margin-left: -0.625rem;
  margin-right: 0.875rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: background 0.2s, color 0.2s, transform 0.15s, box-shadow 0.2s;
}

.header-home-btn:hover {
  background: var(--bg-input);
  color: var(--text);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.settings-wrap {
  position: relative;
}

.settings-popover {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  z-index: 10;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
  box-shadow: var(--shadow-lg);
  min-width: 10rem;
}

.settings-popover .field-label {
  margin-bottom: 0.625rem;
}

.settings-popover .accent-picker {
  flex-wrap: wrap;
}

.logo {
  font-family: 'Newsreader', Georgia, serif;
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.logo-link {
  color: inherit;
  text-decoration: none;
}

.logo-link:hover {
  color: var(--accent);
}

.accent-picker {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.accent-swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--swatch);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.accent-swatch:hover {
  transform: scale(1.15);
}

.accent-swatch[aria-pressed="true"] {
  border-color: var(--text);
  box-shadow: 0 0 0 1px var(--bg);
}

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

.theme-toggle {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  box-shadow: var(--shadow-sm);
  transition: background 0.2s, color 0.2s, transform 0.15s, box-shadow 0.2s;
}

.theme-toggle:hover {
  background: var(--bg-input);
  color: var(--text);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

[data-theme="light"] .icon-moon,
[data-theme="dark"] .icon-sun { display: none; }

/* Home / input panel - one vertical rhythm (1.25rem between blocks) */
.panel-home {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding-top: 0;
}

.panel-home > .home-hero,
.panel-home > .resume-banner,
.panel-home > .home-entry,
.panel-home > .examples,
.panel-home > .home-secondary,
.panel-home > .footer-links {
  margin: 0;
}

.home-hero {
  margin-bottom: 0;
}

.home-headline {
  font-family: 'Newsreader', Georgia, serif;
  font-size: clamp(1.875rem, 5vw, 2.5rem);
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0 0 0.5rem;
  max-width: 22ch;
}

.home-lead {
  font-size: 1rem;
  line-height: 1.55;
  color: var(--text-muted);
  max-width: 36ch;
  margin: 0;
}

.home-peek {
  margin-top: 0.25rem;
}

.home-peek-display {
  position: relative;
  background: var(--reader-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  height: 4.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.home-peek-display .focal-guide {
  height: 50%;
}

.home-peek-display .word-container {
  position: relative;
  inset: unset;
  padding: 0;
  font-size: 1.125rem;
  color: var(--text-muted);
  white-space: normal;
  text-align: center;
}

.home-peek-display .word-container .focal {
  color: var(--text);
  font-weight: 500;
}

.home-entry {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.375rem;
  margin-bottom: 0;
  box-shadow: var(--shadow-md);
  transition: box-shadow 0.25s, border-color 0.25s;
}

.home-entry:focus-within {
  box-shadow: var(--shadow-lg);
}

.home-field-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.home-entry .link-form {
  margin-bottom: 0;
}

.home-entry .file-drop-label {
  margin: 1rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.8125rem;
  line-height: 1.5;
  text-align: left;
}

.home-entry .status {
  margin: 0.5rem 0 0;
  min-height: 0;
}

.home-entry .status:not(:empty) {
  min-height: 1.25rem;
}

.home-entry.dragover {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--select-bg);
}

.panel-home .examples {
  margin-bottom: 0;
  padding-top: 0;
  border-top: none;
}

.panel-home .examples-label,
.panel-home .history-title {
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.home-nudges {
  display: contents;
}

.home-nudges .install-banner {
  margin-bottom: 0;
}

.home-more-actions {
  display: block;
  margin: 0;
}

.panel-home .home-more-btn {
  padding: 0;
  font-size: 0.875rem;
  line-height: 1.4;
}

.panel-home .home-secondary {
  margin-top: 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  gap: 1rem;
}

.panel-home .history-wrap {
  margin: 0;
}

.panel-home .footer-links {
  margin-top: 0;
  padding-top: 1.25rem;
}

.panel-home .resume-banner {
  margin-bottom: 0;
}

.file-drop-link {
  font: inherit;
  font-size: inherit;
  color: var(--accent);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.file-drop-link:hover {
  color: var(--accent-hover);
}

.examples {
  margin-bottom: 1.25rem;
  padding-top: 0.25rem;
  border-top: 1px solid var(--border);
}

.examples-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.625rem;
}

.example-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.example-chip {
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.5rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, background 0.15s, transform 0.15s, box-shadow 0.15s;
}

.example-chip:hover {
  border-color: var(--accent);
  background: var(--select-bg);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.install-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.875rem 1rem;
  margin-bottom: 1.25rem;
  background: var(--select-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.install-text {
  font-size: 0.875rem;
  color: var(--text);
  margin: 0;
  flex: 1;
  min-width: 10rem;
}

.install-actions {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}

.footer-links {
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  text-align: left;
  font-size: 0.8125rem;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--accent);
}

.resume-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.875rem 1rem;
  background: var(--select-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 1rem;
}

.resume-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  margin-bottom: 0.15rem;
}

.resume-title {
  font-size: 0.9375rem;
  font-weight: 500;
}

.resume-actions { display: flex; gap: 0.25rem; flex-shrink: 0; }

.history-wrap {
  margin-top: 0.75rem;
}

.recent-dropdown {
  position: relative;
  display: inline-block;
}

.recent-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.recent-chevron {
  transition: transform 0.15s;
  opacity: 0.65;
}

.recent-toggle-open .recent-chevron {
  transform: rotate(180deg);
}

.recent-menu {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  z-index: 10;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.35rem;
  box-shadow: var(--shadow-lg);
  min-width: min(280px, 90vw);
}

.recent-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin: 0;
  padding: 0;
}

.recent-item {
  display: block;
  width: 100%;
  box-sizing: border-box;
  background: transparent;
  border: none;
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-family: inherit;
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-item:hover {
  background: var(--bg-input);
  color: var(--text);
}

.finder-settings {
  margin: 0.75rem 0 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.finder-title {
  font-family: 'Newsreader', Georgia, serif;
  font-size: 1.375rem;
  font-weight: 500;
  margin-bottom: 0.75rem;
}

.finder-desc {
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 1.5rem;
  font-size: 0.9375rem;
}

.finder-wpm {
  text-align: center;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 1rem;
  font-variant-numeric: tabular-nums;
}

.finder-display {
  margin-bottom: 1.5rem;
  cursor: default;
}

.finder-score {
  font-family: 'Newsreader', Georgia, serif;
  font-size: 3rem;
  font-weight: 500;
  color: var(--accent);
  margin-bottom: 0.5rem;
  font-variant-numeric: tabular-nums;
}

.finder-fact {
  color: var(--text-muted);
  font-size: 0.9375rem;
  line-height: 1.6;
  max-width: 30rem;
  margin: 0 auto 1.25rem;
}

.finder-result .finder-desc {
  margin-bottom: 1.25rem;
}

.finder-result .btn-secondary {
  margin-top: 0.5rem;
}

.finder-result .btn-text {
  display: block;
  margin: 0.75rem auto 0;
}

.tagline {
  font-size: 1.125rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

.file-drop {
  margin-top: 1rem;
  padding: 1.25rem;
  border: 2px dashed var(--border);
  border-radius: 12px;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
}

.file-drop.dragover {
  border-color: var(--accent);
  background: var(--select-bg);
}

.file-drop-label {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 0.625rem;
}

.link-form { margin-bottom: 0.75rem; }

.link-row {
  display: flex;
  gap: 0.75rem;
}

.link-row input {
  flex: 1;
  padding: 0.875rem 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-input);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03) inset;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.link-row input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--ring);
}

.link-row input::placeholder { color: var(--text-muted); }

.status {
  font-size: 0.875rem;
  color: var(--text-muted);
  min-height: 1.25rem;
}

.home-secondary {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.home-secondary .text-fallback {
  margin-top: 0;
}

.text-toggle { margin-top: 1rem; }

.text-fallback {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.text-fallback textarea {
  width: 100%;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-input);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9375rem;
  line-height: 1.6;
  resize: vertical;
}

.text-fallback textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--ring);
}

/* Select panel */
.panel-select {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 7rem);
}

.select-header {
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.back-link { padding-left: 0; margin-bottom: 0.625rem; }

.select-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.share-link-highlight {
  color: var(--accent);
  font-weight: 600;
}

.share-link-btn {
  flex-shrink: 0;
  margin-top: 0.125rem;
  color: var(--text-muted);
}

.share-link-btn:hover {
  color: var(--accent);
}

.doc-title {
  font-family: 'Newsreader', Georgia, serif;
  font-size: 1.375rem;
  font-weight: 500;
  line-height: 1.35;
}

.select-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  flex: 1;
}

.select-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.125rem 1.25rem;
  box-shadow: var(--shadow-sm);
}

.select-footer {
  margin-top: auto;
  padding-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.speed-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.875rem;
}

.speed-value {
  font-family: 'Newsreader', Georgia, serif;
  font-size: 1.125rem;
  font-weight: 500;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.select-speed input[type="range"] {
  display: block;
  width: 100%;
  margin-bottom: 0.75rem;
  -webkit-appearance: none;
  height: 5px;
  background: var(--border);
  border-radius: 3px;
}

.select-speed input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 1px 4px var(--shadow);
}

.select-speed .wpm-presets {
  justify-content: center;
}

.hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: 0;
}

.field-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.page-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.page-row input[type="number"] {
  width: 4.5rem;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-input);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  text-align: center;
}

.page-row input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }

.page-sep, .page-total {
  font-size: 0.9375rem;
  color: var(--text-muted);
}

.section-picker-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.section-picker-head .field-label {
  margin-bottom: 0.25rem;
}

.section-picker-hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.section-picker .picker-actions {
  flex-shrink: 0;
}

.section-picker .section-list {
  margin: 0;
}

.select-status {
  margin: 0 0 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  min-height: 0;
}

.select-status:empty {
  display: none;
}

.select-status.error-msg {
  color: var(--error, #c0392b);
}

.picker-actions { display: flex; gap: 0.25rem; }

.section-list {
  list-style: none;
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  margin: 0;
  padding: 0;
}

.section-item {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.section-item:has(input:checked) {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--select-bg);
}

.section-label {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.75rem 0.875rem;
  cursor: pointer;
  flex: 1;
  min-width: 0;
}

.section-read {
  flex-shrink: 0;
  margin-right: 0.5rem;
  opacity: 1;
}

@media (hover: hover) {
  .section-read { opacity: 0; }
  .section-item:hover .section-read { opacity: 1; }
}

.section-label input { accent-color: var(--accent); flex-shrink: 0; width: 1rem; height: 1rem; }

.section-title {
  flex: 1;
  font-size: 0.9375rem;
  line-height: 1.3;
}

.section-words {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.select-more {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
}

.select-more summary {
  padding: 0.75rem 1rem;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  user-select: none;
}

.select-more > .checkbox-label {
  display: flex;
  padding: 0 1rem 0.625rem;
}

.select-more > .checkbox-label:last-of-type {
  padding-bottom: 0.75rem;
}

.select-more .preview-wrap {
  margin: 0 0 0.75rem;
  border: none;
  border-top: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
}

.preview-wrap {
  margin-bottom: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
}

.preview-wrap summary {
  padding: 0.75rem 1rem;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  user-select: none;
}

.preview-hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
  padding: 0 1rem 0.5rem;
}

.preview {
  padding: 0 1rem 1rem;
  font-family: 'Newsreader', Georgia, serif;
  font-size: 0.9375rem;
  line-height: 1.7;
  max-height: 200px;
  overflow-y: auto;
  user-select: text;
}

.preview::selection {
  background: var(--select-bg);
  color: var(--text);
}

.select-stats {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0 0.125rem;
}

.word-count {
  font-size: 0.9375rem;
  color: var(--text);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.time-estimate {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.wpm-presets {
  display: flex;
  gap: 0.375rem;
}

.preset {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.625rem;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.preset:hover { color: var(--text); }

.preset.active {
  background: var(--select-bg);
  border-color: var(--accent);
  color: var(--accent);
}

.quick-settings {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.inline-control {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex: 1;
  min-width: 180px;
}

.inline-control label {
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
}

.inline-control input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  height: 5px;
  background: var(--border);
  border-radius: 3px;
}

.inline-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
}

.inline-control span {
  font-size: 0.8125rem;
  font-weight: 500;
  min-width: 2rem;
  font-variant-numeric: tabular-nums;
}

.font-control {
  min-width: 120px;
  flex: 0 1 auto;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.8125rem;
  white-space: nowrap;
}

.checkbox-label input { accent-color: var(--accent); }

/* Buttons */
.btn {
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s, transform 0.12s, box-shadow 0.2s, color 0.2s;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 88%, #fff) 0%, var(--accent) 100%);
  color: #fff;
  padding: 0.875rem 1.5rem;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.18) inset, 0 1px 2px rgba(0, 0, 0, 0.08), 0 6px 16px -6px color-mix(in srgb, var(--accent) 65%, transparent);
  letter-spacing: 0.005em;
}

.btn-primary:hover {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-hover) 100%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.14) inset, 0 2px 4px rgba(0, 0, 0, 0.08), 0 10px 22px -8px color-mix(in srgb, var(--accent) 75%, transparent);
  transform: translateY(-1px);
}

.btn-primary:active { transform: translateY(0) scale(0.99); }

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.5rem 1rem;
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover { background: var(--bg-input); box-shadow: var(--shadow-md); }

.btn-text {
  background: none;
  color: var(--text-muted);
  padding: 0.5rem;
  font-size: 0.875rem;
}

.btn-text:hover { color: var(--text); }

.btn-sm { font-size: 0.8125rem; padding: 0.25rem 0.5rem; }

.btn-start {
  width: 100%;
  font-size: 1rem;
  padding: 1rem;
}

.btn-icon {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
}

.btn-icon:hover { background: var(--bg-input); box-shadow: var(--shadow-md); }

.btn-play {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.hidden { display: none !important; }

.error-msg { color: var(--accent); }

/* Reader */
.reader {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
}

.app.reading-focus .header {
  display: none;
}

.app.reading-focus .reader {
  min-height: 80vh;
}

.reader.focus-mode .reader-controls,
.reader.focus-mode .reader-meta {
  display: none;
}

.reader.focus-mode .progress-text {
  display: none;
}

.reader.focus-mode .reader-progress {
  margin-bottom: 0.75rem;
}

.reader.focus-mode .progress-bar {
  height: 3px;
}

.reader.focus-mode .reader-display {
  border: none;
  background: var(--bg);
  background-image: none;
  box-shadow: none;
  flex: 1;
  min-height: 55vh;
  height: auto;
  margin-bottom: 0.75rem;
}

.reader.focus-mode .reader-play-bar {
  margin-bottom: 0;
}

.reader-display.focus-expand {
  animation: displayExpand 0.45s ease-out;
}

@keyframes displayExpand {
  from {
    transform: scale(0.94);
    opacity: 0.7;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.reader-play-bar {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-bottom: 1.25rem;
}

.reader-display {
  position: relative;
  width: 100%;
  background: var(--reader-bg);
  background-image: radial-gradient(ellipse 70% 90% at 50% 50%, color-mix(in srgb, var(--bg-input) 60%, transparent), transparent 100%);
  border-radius: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(255, 255, 255, 0.35) inset;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 2rem;
  overflow: hidden;
  cursor: pointer;
  user-select: none;
  transition: min-height 0.4s ease-out, background 0.3s, border-color 0.3s;
  container-type: inline-size;
}

.finish-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: rgba(250, 247, 242, 0.92);
  z-index: 2;
  pointer-events: none;
  padding: 1rem;
}

[data-theme="dark"] .finish-overlay {
  background: rgba(37, 35, 32, 0.92);
}

[data-theme="dark"] .reader-display {
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(255, 255, 255, 0.03) inset;
}

.finish-overlay .btn,
.finish-overlay .finish-actions {
  pointer-events: auto;
}

.finish-heading {
  font-family: 'Newsreader', Georgia, serif;
  font-size: 1.25rem;
  font-weight: 500;
}

.finish-stats {
  font-size: 0.875rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}

.finish-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.focal-guide {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 2px;
  height: 60%;
  background: var(--guide);
  pointer-events: none;
  border-radius: 1px;
}

.word-container {
  font-family: 'Newsreader', Georgia, serif;
  font-size: calc(var(--reader-font-size, 2.5) * 1.25rem);
  transform-origin: center center;
  font-weight: 400;
  letter-spacing: 0.02em;
  white-space: nowrap;
  position: absolute;
  inset: 0;
  padding: 0 1rem;
  max-width: 100%;
}

.word-container.no-focal {
  display: flex;
  align-items: center;
  justify-content: center;
}

.word-container:not(.no-focal) {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}

.word-container.word-enter {
  animation: wordIn 0.08s ease-out;
}

@keyframes wordIn {
  from { opacity: 0.3; }
  to { opacity: 1; }
}

.word-container.word-exit {
  animation: wordOut 0.45s ease-out forwards;
}

@keyframes wordOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

.finish-overlay.finish-in {
  animation: finishIn 0.4s ease-out;
}

@keyframes finishIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.word-container .before {
  color: var(--text);
  text-align: right;
}

.word-container .after {
  color: var(--text);
  text-align: left;
}

.word-container .focal {
  color: var(--focal);
  font-weight: 500;
}

.reader-progress {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.progress-bar {
  flex: 1;
  height: 6px;
  background: var(--progress-bg);
  border-radius: 999px;
  overflow: hidden;
  cursor: pointer;
}

.progress-fill {
  height: 100%;
  background: var(--progress-fill);
  border-radius: 999px;
  transition: width 0.15s ease;
  width: 0%;
}

.progress-text {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  min-width: 5rem;
  text-align: right;
}

.reader-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  width: 100%;
  margin-bottom: 1rem;
}

.reader-meta {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  justify-content: center;
}

.reader-speed {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.btn-icon.btn-sm {
  width: 32px;
  height: 32px;
  font-size: 1.125rem;
  line-height: 1;
}

.time-left {
  font-variant-numeric: tabular-nums;
}

.reader-settings {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

@media (max-width: 480px) {
  .app { padding: 1rem; }
  .header-home-btn {
    margin-left: -0.375rem;
    margin-right: 0.75rem;
  }
  .link-row { flex-direction: column; }
  .reader-display { height: 160px; }
  .quick-settings { flex-direction: column; align-items: stretch; }
  .reader-settings { flex-direction: column; align-items: stretch; }
}
