/* ══════════════════════════════════════════════
   Home screen
   ══════════════════════════════════════════════ */

.home-body {
  align-items: center;
}

.home-hero {
  text-align: center;
  padding: 2.5rem 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.home-logo {
  opacity: 0.9;
}

.home-tagline {
  font-size: 1.1rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ── New Reading CTA ── */

.home-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  max-width: 300px;
  padding: 1.25rem 2rem;
  margin-bottom: 2rem;
  border-radius: var(--radius-lg);
  background: var(--primary);
  color: #fff;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  box-shadow: var(--shadow-md);
  transition:
    transform var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out);
}

.home-cta:active {
  transform: scale(0.97);
  box-shadow: var(--shadow-lg);
}

/* ── Bottom sheet ── */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 90;
  opacity: 0;
  transition: opacity var(--duration-normal) var(--ease-out);
}

.sheet-backdrop.visible {
  opacity: 1;
}

.sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--bg-elevated);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 0.5rem 1.25rem;
  padding-bottom: calc(1.25rem + var(--safe-bottom));
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.15);
  transform: translateY(100%);
  transition: transform var(--duration-normal) var(--ease-out);
}

.sheet.visible {
  transform: translateY(0);
}

.sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin: 0.25rem auto 1rem;
}

.sheet-options {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sheet-option {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border-radius: var(--radius-md);
  text-align: left;
  transition:
    background var(--duration-fast),
    transform var(--duration-fast);
}

.sheet-option:active {
  background: var(--primary-soft);
  transform: scale(0.98);
}

.sheet-option-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: var(--primary-soft);
  color: var(--primary);
}

.sheet-option-text {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.sheet-option-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.sheet-option-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ── Recent history ── */

.recent-history {
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
  padding: 0.5rem 0 2rem;
}

.recent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.625rem;
  padding-left: 0.25rem;
  padding-right: 0.25rem;
}

.recent-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.btn-clear-history {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
  background: none;
  border: none;
  padding: 0.375rem 0.5rem;
  min-height: 44px;
  min-width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color var(--duration-fast);
}

.btn-clear-history:active {
  color: var(--primary-hover);
}

.recent-list {
  display: flex;
  flex-direction: column;
}

.recent-item {
  display: flex;
  align-items: center;
  padding: 0 0.25rem 0 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface-tint);
  border-radius: var(--radius-md);
}

.recent-item:last-child {
  border-bottom: none;
}

.recent-item-play {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  min-width: 0;
  padding: 0.75rem 0.5rem;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  transition: opacity var(--duration-fast);
}

.recent-item-play:active {
  opacity: 0.6;
}

.recent-item-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}

.recent-item-text {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.recent-item-preview {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.recent-item-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  flex-shrink: 0;
  white-space: nowrap;
}

.recent-item-delete {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius-full);
  background: none;
  color: var(--text-muted);
  opacity: 0.5;
  cursor: pointer;
  transition: opacity var(--duration-fast), color var(--duration-fast);
}

.recent-item-delete:active {
  opacity: 1;
  color: var(--danger, #dc2626);
}

/* ── Generic large button (used on paste screen) ── */

.btn-large {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.25rem 2rem;
  border: 2px solid transparent;
  border-radius: var(--radius-lg);
  background: var(--primary);
  color: #fff;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  box-shadow: var(--shadow-md);
  transition:
    transform var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out),
    opacity var(--duration-fast);
}

.btn-large:hover {
  box-shadow: var(--shadow-lg);
}

.btn-large:active {
  transform: scale(0.97);
  opacity: 0.9;
}

/* ── Icon button (back, settings) ── */

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  width: var(--touch-target);
  height: var(--touch-target);
  transition:
    background var(--duration-fast),
    transform var(--duration-fast);
}

.btn-icon:active {
  background: var(--primary-soft);
  transform: scale(0.92);
}

/* Copy success flash */
.btn-icon.copied {
  color: var(--primary);
}


/* ══════════════════════════════════════════════
   Text input (Paste screen)
   ══════════════════════════════════════════════ */

.text-input-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
  justify-content: flex-start;
  padding-top: 1rem;
}

.text-input-area textarea,
.text-input-area .paste-meta,
.text-input-area .paste-actions,
.text-input-area .btn-large {
  width: 100%;
  max-width: 480px;
}


.text-input-area textarea {
  min-height: 120px;
  max-height: 200px;
  padding: 0.875rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  resize: vertical;
  font-size: var(--font-size-base);
  line-height: var(--line-height);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}

.text-input-area textarea:focus {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm), 0 0 0 3px var(--primary-soft);
  outline: none;
}

.text-input-area textarea::placeholder {
  color: var(--text-muted);
}

.paste-meta {
  display: flex;
  justify-content: space-between;
  width: 100%;
  max-width: 480px;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 0 0.25rem;
  margin-top: -0.5rem;
  min-height: 1.2em;
}

.word-count:empty,
.shortcut-hint:empty {
  display: none;
}

.shortcut-hint {
  margin-left: auto;
  opacity: 0.7;
}

.paste-actions {
  display: flex;
  gap: 0.75rem;
}

.btn-paste-clipboard {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex: 1;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  border: 2px solid var(--border);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-elevated);
  transition:
    border-color var(--duration-fast),
    background var(--duration-fast),
    transform var(--duration-fast);
}

.btn-paste-clipboard:active {
  border-color: var(--primary);
  background: var(--primary-soft);
  transform: scale(0.97);
}


/* ══════════════════════════════════════════════
   Reader
   ══════════════════════════════════════════════ */

.btn-icon-sm {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
}

/* Reader loading state */
.reader-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 3rem;
  color: var(--text-muted);
  font-weight: 500;
}

.reader-loading::before {
  content: '';
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.reader-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  padding-left: calc(1.25rem + var(--safe-left));
  padding-right: calc(1.25rem + var(--safe-right));
  font-size: var(--reader-font-size, 1.25rem);
  line-height: var(--reader-line-height, 1.8);
  letter-spacing: var(--reader-letter-spacing, normal);
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
  transition: font-size var(--duration-fast);
}

.reader-content .word {
  display: inline;
  padding: 0.1em 0.05em;
  border-radius: 3px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--duration-fast) var(--ease-out);
}

.reader-content .word.highlight {
  background-color: var(--highlight-color);
  color: var(--highlight-text);
  text-decoration: underline;
  text-decoration-color: var(--primary);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  font-weight: 600;
}


/* ══════════════════════════════════════════════
   Progress bar
   ══════════════════════════════════════════════ */

.progress-bar-track {
  height: 6px;
  background: #E5E7EB;
}

[data-theme="dark"] .progress-bar-track {
  background: #374151;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--primary);
  transition: width 0.15s linear;
}


/* ══════════════════════════════════════════════
   Controls bar
   ══════════════════════════════════════════════ */

.controls-bar {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  padding: 0.875rem 1.25rem;
  padding-bottom: calc(0.875rem + var(--safe-bottom));
  padding-left: calc(1.25rem + var(--safe-left));
  padding-right: calc(1.25rem + var(--safe-right));
  border-top: 1px solid color-mix(in srgb, var(--primary) 8%, var(--border));
  background:
    linear-gradient(var(--surface-tint), var(--surface-tint-strong)),
    var(--bg-elevated);
}

.controls-playback {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
}

.controls-playback button {
  font-size: 1.4rem;
  border-radius: var(--radius-full);
  width: 3rem;
  height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background var(--duration-fast),
    transform var(--duration-fast);
}

.controls-playback button:active {
  background: var(--primary-soft);
  transform: scale(0.9);
}

/* Play/pause button — primary accent */
.btn-play {
  background: var(--primary);
  color: #fff;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-md);
  transition:
    transform var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast);
}

.btn-play:active {
  transform: scale(0.93);
  background: var(--primary-hover);
}

/* Speed selector pills */
/* ── Speed button + popup ── */

.speed-wrapper {
  position: relative;
}

.btn-speed-icon {
  position: relative;
}

.speed-badge {
  position: absolute;
  bottom: 2px;
  right: 0;
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
  pointer-events: none;
}

.speed-popup {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 50%;
  transform: translateX(50%);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0.375rem;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  z-index: 20;
  min-width: 80px;
  animation: popup-in 150ms var(--ease-out);
}

.speed-popup[hidden] {
  display: none;
}

@keyframes popup-in {
  from {
    opacity: 0;
    transform: translateX(50%) translateY(4px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateX(50%) translateY(0) scale(1);
  }
}

.speed-option {
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  min-height: 40px;
  transition: background var(--duration-fast);
}

.speed-option.active {
  background: var(--primary);
  color: #fff;
}

.speed-option:not(.active):active {
  background: var(--primary-soft);
}


/* ══════════════════════════════════════════════
   Camera
   ══════════════════════════════════════════════ */

#screen-camera {
  background: #000;
}

.camera-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  background: #000;
  overflow: hidden;
}

.camera-header {
  background: transparent;
  color: #fff;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  border-bottom: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.camera-header .btn-icon:active {
  background: rgba(255, 255, 255, 0.2);
}

#camera-viewfinder {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Capture button with ring pulse */
.camera-capture-btn {
  position: absolute;
  bottom: calc(2rem + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: 76px;
  height: 76px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.25);
  border: 3px solid rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  transition: transform var(--duration-fast) var(--ease-out);
}

.camera-capture-btn:active {
  transform: translateX(-50%) scale(0.9);
}

.camera-capture-btn:active .capture-circle {
  transform: scale(0.85);
}

.capture-circle {
  display: block;
  width: 60px;
  height: 60px;
  border-radius: var(--radius-full);
  background: #fff;
  transition: transform var(--duration-fast) var(--ease-out);
}

/* Camera overlays */
.camera-error,
.camera-loading {
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  padding: 2.5rem;
  text-align: center;
  color: #fff;
  z-index: 15;
  display: none;
}

.camera-error:not([hidden]) {
  display: flex;
}

.camera-loading:not([hidden]) {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.camera-error {
  font-size: 1.05rem;
  line-height: 1.7;
  background: rgba(0, 0, 0, 0.88);
}

.camera-loading {
  font-size: 1.15rem;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.75);
}

/* CSS-only spinner for camera loading */
.camera-loading::before {
  content: '';
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}


/* ══════════════════════════════════════════════
   Settings
   ══════════════════════════════════════════════ */

.settings-body {
  gap: 0;
  padding: 0 1.25rem 2rem;
  padding-left: calc(1.25rem + var(--safe-left));
  padding-right: calc(1.25rem + var(--safe-right));
  padding-bottom: calc(2rem + var(--safe-bottom));
}

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

.settings-section:last-child {
  border-bottom: none;
}

.settings-section h2 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.settings-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  line-height: 1.55;
}

/* Toggle buttons (Font, Theme) */
.settings-toggle {
  display: flex;
  gap: 0.5rem;
}

.toggle-btn {
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius-full);
  border: 2px solid var(--border);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  min-height: var(--touch-target);
  transition:
    background var(--duration-fast),
    border-color var(--duration-fast),
    color var(--duration-fast);
}

.toggle-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.toggle-btn:not(.active):active {
  border-color: var(--primary);
  color: var(--primary);
}

/* ── Setting button previews ── */
button[data-font="system"] {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

button[data-font="dyslexic"] {
  font-family: 'OpenDyslexic', sans-serif;
  line-height: 1;
  padding-top: 0.625rem;
  padding-bottom: 0.375rem;
}

button[data-reader-size="small"]  { font-size: 0.75rem; }
button[data-reader-size="medium"] { font-size: 0.9rem; }
button[data-reader-size="large"]  { font-size: 1.05rem; }
button[data-reader-size="xl"]     { font-size: 1.2rem; }

button[data-reader-spacing="compact"] { letter-spacing: -0.02em; }
button[data-reader-spacing="default"] { letter-spacing: normal; }
button[data-reader-spacing="spacious"] { letter-spacing: 0.08em; }

/* API key inputs */
.settings-key-row {
  display: flex;
  gap: 0.5rem;
  min-width: 0;
}

.settings-key-row input {
  flex: 1;
  min-width: 0;
  padding: 0.625rem 0.875rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  background: var(--bg-elevated);
  color: var(--text);
  min-height: var(--touch-target);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}

.settings-key-row input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
  outline: none;
}

.btn-save {
  flex-shrink: 0;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  min-height: var(--touch-target);
  transition:
    background var(--duration-fast),
    transform var(--duration-fast);
}

.btn-save:active {
  background: var(--primary-hover);
  transform: scale(0.97);
}

/* Color swatches */
.color-swatches {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.color-swatch-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.color-swatch-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.color-swatch {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius-full);
  background: var(--swatch);
  border: 3px solid transparent;
  padding: 0;
  box-shadow: var(--shadow-sm);
  transition:
    border-color var(--duration-fast),
    transform var(--duration-fast);
  position: relative;
}

.color-swatch:active {
  transform: scale(0.9);
}

.color-swatch.active {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

/* Voice select dropdown */
.settings-select {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  background: var(--bg-elevated);
  color: var(--text);
  min-height: var(--touch-target);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.875rem center;
  padding-right: 2.5rem;
}

.settings-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
  outline: none;
}

.settings-status {
  font-size: 0.95rem;
  padding: 0.5rem 0;
  color: var(--text);
}


/* ══════════════════════════════════════════════
   Status region
   ══════════════════════════════════════════════ */

.status-region {
  text-align: center;
  padding: 0.375rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
}


/* ══════════════════════════════════════════════
   Toast notifications
   ══════════════════════════════════════════════ */

.toast-container {
  position: fixed;
  bottom: calc(8rem + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  pointer-events: none;
  width: calc(100% - 2rem);
  max-width: 400px;
}

.toast {
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  background: var(--text);
  color: var(--bg);
  font-size: 0.9rem;
  font-weight: 500;
  text-align: center;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity var(--duration-normal) var(--ease-out),
    transform var(--duration-normal) var(--ease-out);
  pointer-events: auto;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}


/* ══════════════════════════════════════════════
   Reader title
   ══════════════════════════════════════════════ */

.reader-title {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  padding: 0 0.5rem;
}


/* ══════════════════════════════════════════════
   Sheet close button
   ══════════════════════════════════════════════ */

.sheet-top {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 0.25rem;
}

.sheet-close {
  position: absolute;
  right: -0.5rem;
  top: 0;
}


/* ══════════════════════════════════════════════
   Settings subsections (Reading Display)
   ══════════════════════════════════════════════ */

.settings-subsection {
  margin-bottom: 1rem;
}

.settings-subsection:last-child {
  margin-bottom: 0;
}

.settings-sublabel {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5rem;
}


/* ══════════════════════════════════════════════
   Color swatch checkmark
   ══════════════════════════════════════════════ */

.color-swatch.active::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: var(--radius-full);
  border: 2px solid rgba(255, 255, 255, 0.9);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") no-repeat center center;
}


/* ══════════════════════════════════════════════
   Onboarding tips
   ══════════════════════════════════════════════ */

.onboarding {
  width: 100%;
  max-width: 300px;
  margin: 0 auto;
  padding: 1.25rem;
  background:
    linear-gradient(var(--surface-tint), var(--surface-tint)),
    var(--bg-elevated);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid color-mix(in srgb, var(--primary) 6%, var(--border));
  flex-direction: column;
  gap: 0.875rem;
}

.onboarding:not([hidden]) {
  display: flex;
}

.onboarding-step {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text);
}

.onboarding-num {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
}

.onboarding-dismiss {
  align-self: center;
  padding: 0.5rem 1.5rem;
  border-radius: var(--radius-full);
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

.onboarding-dismiss:active {
  background: var(--primary);
  color: #fff;
}

/* ── Header actions ── */

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

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

/* ── Onboarding dismiss animation ── */

.onboarding.dismissing {
  animation: onboarding-out 300ms var(--ease-out) forwards;
}

@keyframes onboarding-out {
  to {
    opacity: 0;
    transform: translateY(-8px) scale(0.97);
  }
}


/* ══════════════════════════════════════════════
   Help screen
   ══════════════════════════════════════════════ */

.help-body {
  gap: 0;
  padding-bottom: calc(2rem + var(--safe-bottom));
}

.help-section {
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border);
}

.help-section:last-child {
  border-bottom: none;
}

.help-icon-header {
  margin-bottom: 0.625rem;
}

.help-section h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.625rem;
}

.help-text {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.625rem;
  line-height: 1.6;
}

.help-steps {
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.help-steps li {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text);
}

.help-steps li::marker {
  color: var(--primary);
  font-weight: 700;
}

.help-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.help-list li {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text);
  padding-left: 1rem;
  position: relative;
}

.help-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--primary);
}

.help-controls {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.help-control-row {
  display: flex;
  gap: 0.5rem;
  font-size: 0.9rem;
  line-height: 1.6;
}

.help-control-row dt {
  font-weight: 600;
  color: var(--text);
  min-width: 6rem;
  flex-shrink: 0;
}

.help-control-row dd {
  color: var(--text-muted);
}


/* ══════════════════════════════════════════════
   Desktop responsive (768px+)
   ══════════════════════════════════════════════ */

@media (min-width: 768px) {

  /* ── Home: widen CTA and recent history ── */

  .home-hero {
    padding-top: 3.5rem;
    padding-bottom: 2rem;
  }

  .home-logo {
    width: 80px;
    height: 80px;
  }

  .home-tagline {
    font-size: 1.25rem;
  }

  .home-cta {
    max-width: 360px;
    font-size: 1.25rem;
    padding: 1.25rem 2.5rem;
  }

  .recent-history {
    max-width: 480px;
  }

  /* ── Bottom sheet → centered dialog on desktop ── */

  .sheet-backdrop {
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
  }

  .sheet {
    bottom: auto;
    top: 50%;
    left: 50%;
    right: auto;
    transform: translate(-50%, -50%) scale(0.95);
    opacity: 0;
    max-width: 400px;
    width: calc(100% - 2rem);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding-bottom: 1.25rem;
    transition:
      transform var(--duration-normal) var(--ease-out),
      opacity var(--duration-normal) var(--ease-out);
  }

  .sheet.visible {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }

  .sheet-handle {
    display: none;
  }

  /* ── Paste screen: wider textarea ── */

  .text-input-area {
    align-items: center;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
  }

  .text-input-area textarea,
  .text-input-area .paste-meta,
  .text-input-area .paste-actions,
  .text-input-area .btn-large {
    max-width: 100%;
  }

  .text-input-area textarea {
    max-height: 300px;
    min-height: 160px;
  }

  /* ── Settings: constrained width ── */

  .settings-body {
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
  }

  /* ── Controls: constrained width ── */

  .controls-bar {
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
  }

  /* ── Help screen: constrained width ── */

  .help-body {
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
  }
}


/* ══════════════════════════════════════════════
   Hover states (pointer devices only)
   ══════════════════════════════════════════════ */

@media (hover: hover) {

  .home-cta:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
  }

  .btn-large:hover {
    transform: translateY(-1px);
  }

  .btn-icon:hover {
    background: var(--primary-soft);
  }

  .sheet-option:hover {
    background: var(--primary-soft);
  }

  .recent-item:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
  }

  .toggle-btn:not(.active):hover {
    border-color: var(--primary);
    color: var(--primary);
  }

  .speed-option:not(.active):hover {
    background: var(--primary-soft);
  }

  .btn-save:hover {
    background: var(--primary-hover);
  }

  .color-swatch:hover {
    transform: scale(1.1);
  }

  .btn-paste-clipboard:hover {
    border-color: var(--primary);
    color: var(--primary);
  }

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

  .reader-content .word:hover {
    background-color: var(--primary-soft);
    cursor: pointer;
  }

  .sheet-option:hover {
    cursor: pointer;
  }

  .recent-item-play:hover {
    cursor: pointer;
  }

  .speed-option:hover {
    cursor: pointer;
  }

  .btn-play:hover {
    background: var(--primary-hover);
    box-shadow: var(--shadow-lg);
    transform: scale(1.05);
  }
}


/* ══════════════════════════════════════════════
   Large desktop (1024px+)
   ══════════════════════════════════════════════ */

@media (min-width: 1024px) {

  .text-input-area {
    max-width: 720px;
  }

  .text-input-area textarea,
  .text-input-area .paste-meta,
  .text-input-area .paste-actions,
  .text-input-area .btn-large {
    max-width: 600px;
  }

  .text-input-area textarea {
    min-height: 200px;
    max-height: 400px;
  }

  .reader-content {
    max-width: 720px;
  }

  .controls-bar {
    max-width: 720px;
  }

  .settings-body {
    max-width: 680px;
  }

  .help-body {
    max-width: 680px;
  }

  .recent-history {
    max-width: 560px;
  }
}


/* ══════════════════════════════════════════════
   Drag and drop visual feedback
   ══════════════════════════════════════════════ */

.screen.drag-over::after {
  content: 'Drop file here';
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--primary) 8%, var(--bg));
  border: 3px dashed var(--primary);
  border-radius: var(--radius-md);
  margin: 1rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  z-index: 50;
  pointer-events: none;
  animation: drag-pulse 1.5s ease-in-out infinite alternate;
}

@keyframes drag-pulse {
  from { opacity: 0.7; }
  to { opacity: 1; }
}
