/* Hoca Reader — light default, dark toggle.
   Hoca'nın gold accent'ini iki temada da koruyup okuma yüzeyini
   light tutuyor (reader kitlesi metin odaklı). */

/* `hidden` HTML attribute her zaman gizlesin — author CSS
   `display: flex` (limit-upsell, audio-controls, cta-card vb.)
   UA stylesheet'in `[hidden] { display: none }` kuralını ezdiği
   için ! important şart. Playwright testleri yakaladı. */
[hidden] {
  display: none !important;
}

:root {
  /* Light tema (default) */
  --bg:        #f7f5ef;
  --surface:   #ffffff;
  --border:    #e3dccb;
  --text:      #1c1a14;
  --muted:     #6b6354;
  --gold:      #b48a30;
  --gold-soft: rgba(180,138,48,0.08);
  --amber:     #d99020;
  --danger:    #c03e3e;
  --success:   #2f8f5b;
  --shadow:    0 1px 2px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.06);
  --radius:    10px;
  --font:      "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

[data-theme="dark"] {
  --bg:        #0d1117;
  --surface:   #161b22;
  --border:    #2a3040;
  --text:      #e8dcc8;
  --muted:     #7a8599;
  --gold:      #c9a84c;
  --gold-soft: rgba(201,168,76,0.08);
  --amber:     #f0a500;
  --danger:    #e05555;
  --success:   #4caf7d;
  --shadow:    0 1px 2px rgba(0,0,0,0.2), 0 4px 16px rgba(0,0,0,0.3);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── topbar ─────────────────────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--amber) 0%, var(--gold) 100%);
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.5px;
}

.brand-name {
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.2px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, background 0.15s;
}

.icon-btn:hover {
  border-color: var(--gold);
  background: var(--gold-soft);
}

/* Text-styled icon-btn (lang toggle: gösterilen iki harf "TR"/"EN"). */
.icon-btn-text {
  width: auto;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.4px;
}

/* ── main ───────────────────────────────────────────────────────── */

.container {
  max-width: 680px;
  margin: 0 auto;
  padding: 32px 20px 24px;
}

.title {
  margin: 0 0 6px;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.5px;
}

.subtitle {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 14px;
}

/* ── card ───────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field-row .field { margin-bottom: 16px; }

.field-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.field-actions {
  display: flex;
  gap: 6px;
}

.field-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: var(--muted);
}

.btn-link {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.btn-link:hover {
  border-color: var(--gold);
  color: var(--gold);
  background: var(--gold-soft);
}

.file-icon {
  font-size: 13px;
  line-height: 1;
}

textarea, select, input:not([type="checkbox"]):not([type="radio"]) {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}

/* Checkbox / radio: genel input stilinden muaf tut */
input[type="checkbox"],
input[type="radio"] {
  width: auto;
  padding: 0;
  border: revert;
  background: revert;
  border-radius: 0;
  outline: revert;
  flex-shrink: 0;
}

textarea {
  resize: vertical;
  min-height: 140px;
  line-height: 1.6;
  font-family: var(--font);
}

#text-input[dir="rtl"] {
  text-align: right;
}

textarea:focus, select:focus, input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}

.char-count {
  font-size: 12px;
  color: var(--muted);
}

.field-footer {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 6px;
}

.export-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.export-format-select {
  font-size: 12px;
  padding: 2px 4px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}

.pdf-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
}

.pdf-option input[type="checkbox"] {
  margin: 0;
  cursor: pointer;
}

.action-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.action-row .btn-primary { flex: 1; }

.btn-primary {
  width: 100%;
  padding: 12px 18px;
  background: linear-gradient(135deg, var(--amber) 0%, var(--gold) 100%);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: transform 0.08s, filter 0.15s;
}

.btn-stop {
  padding: 12px 18px;
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.btn-stop:hover {
  background: var(--danger);
  color: #fff;
}

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

.btn-primary:hover { filter: brightness(1.05); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.7; cursor: not-allowed; }

.btn-primary.loading::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: hr-spin 0.75s linear infinite;
  margin-right: 8px;
  vertical-align: -2px;
}

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

/* Faz 10 device test (2026-05-07 gece) — kullanıcı raporu "kitabi
 * okurken loading ekranı olsa". File pick (PDF parse, library_save)
 * sırasında textarea üstünde overlay + spinner. Kullanıcının uzun
 * PDF parse'inde "donmuş mu" hissini önler. */
.textarea-wrap {
  position: relative;
  overflow: hidden;
  contain: layout paint;
}
/* 2026-05-09 — textarea içinde aktif cümle highlight: mirror div tek
 * seferde aynı text'i render eder, aktif cümlenin Range bounding rect'i
 * absolute positioned overlay div'i konumlar (sarı kutu). Mirror text
 * görünmez (color transparent), textarea metni layer'ın üstünde renkli. */
.text-mirror {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  font: inherit;
  font-family: var(--font);
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow: hidden;
  color: transparent;
  pointer-events: none;
  z-index: 1;
  box-sizing: border-box;
}
.text-highlight-overlay {
  position: absolute;
  pointer-events: none;
  z-index: 2;
}
.text-highlight-overlay .highlight-rect {
  position: absolute;
  background: var(--gold-soft);
  border-radius: 3px;
  transition: opacity 0.15s;
}
.textarea-wrap textarea {
  position: relative;
  z-index: 3;
  background: transparent;
}

.file-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  z-index: 5;
}

[data-theme="dark"] .file-loading {
  background: rgba(20, 20, 20, 0.85);
}

.file-loading-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.file-loading .spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: hr-spin 0.75s linear infinite;
}

.btn-loading-cancel {
  padding: 4px 18px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.btn-loading-cancel:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.url-fetch-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 0 4px;
}

.url-fetch-input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
}

.url-fetch-input:focus {
  outline: none;
  border-color: var(--gold);
}

.url-fetch-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 13px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary.btn-sm {
  background: var(--gold);
  color: #fff;
}

.btn-secondary.btn-sm {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.synth-progress {
  margin-top: 10px;
}

.progress-bar {
  height: 4px;
  border-radius: 2px;
  background: var(--gold-soft);
  overflow: hidden;
  position: relative;
}

.progress-fill {
  position: absolute;
  left: 0;
  height: 100%;
  width: 35%;
  background: linear-gradient(90deg, var(--gold) 0%, var(--amber) 100%);
  border-radius: 2px;
  animation: hr-progress 1.2s ease-in-out infinite;
}

/* Determinate mod: backend gerçek progress event gönderdi —
   animasyonu kapat, width'i JS yönetir. */
.progress-fill.determinate {
  animation: none;
  left: 0;
  transition: width 0.2s ease;
}

/* Faz 11 Phase 3.5 (2026-05-09) — synth pozisyon label (cümle X/Y · %Z) */
.synth-position {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
}
.active-sentence-card {
  margin-bottom: 10px;
  padding: 10px 14px;
  background: var(--gold-soft);
  border-left: 3px solid var(--gold);
  border-radius: 6px;
  max-height: 120px;
  overflow-y: auto;
}
.active-sentence-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.active-sentence-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
}

/* Faz 11 Phase 3 — player kontrol panel (slider + ±10/±30 + pause). */
.player-controls {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.seek-slider {
  width: 100%;
  height: 28px;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
}
.seek-slider::-webkit-slider-runnable-track {
  height: 4px;
  background: var(--gold-soft);
  border-radius: 2px;
}
.seek-slider::-moz-range-track {
  height: 4px;
  background: var(--gold-soft);
  border-radius: 2px;
}
.seek-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  margin-top: -7px;
}
.seek-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.seek-slider:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.player-buttons {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-skip,
.btn-pause,
.btn-speed {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  min-width: 48px;
  min-height: 40px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

/* MR-16: küçük ekranda butonlar çok büyük — padding küçült */
@media (max-width: 360px) {
  .btn-skip,
  .btn-pause,
  .btn-speed {
    padding: 6px 8px;
    font-size: 13px;
    min-width: 40px;
    min-height: 36px;
  }
  .btn-speed {
    min-width: 44px;
  }
  .player-buttons {
    gap: 5px;
  }
}
.btn-skip:hover,
.btn-pause:hover,
.btn-speed:hover {
  border-color: var(--gold);
  background: var(--gold-soft);
}
.btn-skip:disabled,
.btn-pause:disabled,
.btn-speed:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn-speed {
  font-variant-numeric: tabular-nums;
  min-width: 56px;
}
.btn-speed.active {
  border-color: var(--gold);
  background: var(--gold-soft);
}
.btn-pause {
  font-size: 18px;
  line-height: 1;
  min-width: 56px;
  background: var(--gold-soft);
  border-color: var(--gold);
}
.btn-pause:hover {
  background: var(--gold);
  color: var(--surface);
}

@keyframes hr-progress {
  0%   { left: -35%; }
  100% { left: 100%; }
}

.status-msg {
  margin: 12px 0 0;
  font-size: 14px;
  min-height: 20px;
  overflow-wrap: break-word;
  word-break: break-all;
}

.status-msg.error { color: var(--danger); }
.status-msg.success { color: var(--success); }
.status-msg.warning { color: var(--amber); }

/* ── audio controls (synth sonrası) ───────────────────────────── */

.audio-controls {
  margin-top: 14px;
  padding: 12px;
  background: var(--gold-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* MR-2: dosya adı — audio player üstünde tek satır */
.audio-filename {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* audio + download yan yana */
.audio-controls .audio-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.audio-controls audio {
  flex: 1;
  height: 36px;
  min-width: 0;
}

/* #57/todo: MP4 video — üstte tam genişlik, bundle viewer slide gibi */
.video-player-full {
  width: 100%;
  max-height: 50vh;
  border-radius: 6px;
  background: #000;
  display: block;
}

.download-btn {
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.download-btn:hover {
  background: var(--gold-soft);
}

@media (max-width: 540px) {
  .audio-controls .audio-row {
    flex-direction: column;
    align-items: stretch;
  }
  .audio-controls audio { width: 100%; }
}

/* ── voice catalog (Faz 2 — Dil ekle paneli) ─────────────────────
   Voice select label'ının yanında "+ Dil ekle" toggle var; click'te
   altta açılan panel hardcoded catalog (HF Piper modelleri) listesini
   gösterir. Yüklü olmayanlarda "İndir" butonu, indirme sırasında
   inline progress bar, biten ses "Yüklü" tag'iyle gösterilir. */

.voice-catalog-toggle {
  /* field-label inline'da görünmesi için reset */
  margin-left: 8px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  font-size: 11px;
  padding: 2px 8px;
}

.voice-catalog {
  margin: 4px 0 16px;
  background: var(--gold-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.voice-catalog-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 10px;
}

.voice-catalog-head strong {
  font-size: 13px;
  font-weight: 600;
}

.voice-catalog-head small {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.voice-catalog-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.voice-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.voice-row .voice-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.voice-row .voice-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.voice-row .voice-meta strong {
  font-size: 13px;
  font-weight: 600;
}

.voice-row .voice-meta small {
  font-size: 11px;
  color: var(--muted);
}

/* Source + license badges — voice name yanında inline rozet */
.voice-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid;
  white-space: nowrap;
}

.voice-badge-system {
  border-color: var(--border);
  color: var(--muted);
  background: transparent;
}

.voice-badge-piper,
.voice-badge-orkhon {
  border-color: var(--gold);
  color: var(--gold);
  background: var(--gold-soft);
}

.voice-badge-nc {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(192, 62, 62, 0.06);
}

.voice-badge-gpl {
  border-color: #b45309;
  color: #b45309;
  background: rgba(180, 83, 9, 0.06);
}

.voice-row .installed-tag-os {
  color: var(--muted);
}

.voice-row .voice-action {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  min-width: 100px;
}

.voice-row .installed-tag {
  font-size: 12px;
  font-weight: 600;
  color: var(--success);
}

.voice-row .btn-download {
  font-size: 12px;
  padding: 4px 12px;
  background: transparent;
  border: 1px solid var(--gold);
  color: var(--gold);
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.voice-row .btn-download:hover {
  background: var(--gold-soft);
}

.voice-row .btn-download:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.voice-row .download-progress {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.voice-row .download-progress .bar {
  height: 4px;
  border-radius: 2px;
  background: var(--gold-soft);
  overflow: hidden;
  position: relative;
}

.voice-row .download-progress .fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--gold) 0%, var(--amber) 100%);
  border-radius: 2px;
  transition: width 0.2s ease;
  width: 0;
}

.voice-row .download-progress small {
  font-size: 11px;
  color: var(--muted);
  text-align: right;
}

.voice-row .orkhon-step-done {
  font-size: 11px;
  font-weight: 600;
  color: var(--success);
}

.voice-row .btn-pick-file {
  border-color: var(--success);
  color: var(--success);
}

.voice-row .btn-pick-file:hover {
  background: rgba(47, 143, 91, 0.1);
}

.voice-row.error .voice-meta small.error-msg {
  color: var(--danger);
}

@media (max-width: 540px) {
  .voice-row {
    flex-direction: column;
    align-items: stretch;
  }
  .voice-row .voice-action {
    align-items: stretch;
    min-width: 0;
  }
  .voice-row .btn-download {
    width: 100%;
  }
}

/* ── limit hit upsell (Faz 3 mini) ───────────────────────────────
   >5000 char text yapıştırıldığında, kullanıcıyı Hoca'ya yönlendiren
   kapatılabilir kart. cta-card pattern'ine benzer ama uyarı tonunda
   (gold-soft bg + amber accent) ve sağ üst köşesinde X. */

.limit-upsell {
  margin-top: 14px;
  background: var(--gold-soft);
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
}

.limit-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  padding-right: 24px; /* dismiss butonu için yer */
}

.limit-text strong {
  font-weight: 600;
  font-size: 14px;
  color: var(--gold);
}

.limit-text span {
  font-size: 13px;
  color: var(--text);
}

.limit-dismiss {
  position: absolute;
  top: 8px;
  right: 10px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  line-height: 1;
}

.limit-dismiss:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text);
}

@media (max-width: 540px) {
  .limit-upsell {
    flex-direction: column;
    align-items: stretch;
  }
  .limit-text { padding-right: 28px; }
}

/* ── Faz 10 MVP — library + resume toast (2026-05-07) ─────────────── */

/* Library: yüklenen kitap listesi. Pattern voice-catalog ile akraba
   ama gold-soft yerine surface — paste-and-hear ana akış üstün, library
   ikincil yardımcı görsel olarak. */

.library {
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.library-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 10px;
}

.library-head strong { font-size: 14px; font-weight: 600; }
.library-head small { font-size: 12px; color: var(--muted); line-height: 1.4; }

.library-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.book-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.book-row .book-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.book-row .book-name {
  font-weight: 600;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: text;
}

.book-row .book-name-input {
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  padding: 2px 6px;
  border: 1px solid var(--gold);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  width: 100%;
  box-sizing: border-box;
  outline: none;
}

.book-row .book-author {
  font-style: italic;
}

.book-row .book-info {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.book-row .book-progress {
  flex-shrink: 0;
  /* 2026-05-07 akşam — kullanıcı raporu "library progress bar yok"
   * (gözlem #9). Aslında render ediliyordu ama 64×4 px ile gözden
   * kaçıyordu. Daha belirgin: 100×6 px + soft shadow ile dikkat çek. */
  height: 6px;
  width: 100px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.book-row .book-progress-fill {
  height: 100%;
  background: var(--gold);
  transition: width 0.2s ease;
}

.book-row .book-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.book-row .book-delete,
.book-row .book-rename {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
}

.book-row .book-delete:hover {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.book-row .book-rename:hover {
  background: var(--gold-soft);
  color: var(--text);
  border-color: var(--gold);
}

/* Resume toast — limit-upsell ile aynı dismissible card pattern.
   `.limit-dismiss` sınıfı X butonu için reuse (HTML zaten kullanıyor). */

.resume-toast {
  margin-top: 14px;
  background: var(--gold-soft);
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
}

.resume-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  padding-right: 24px;
}

.resume-text strong {
  font-weight: 600;
  font-size: 14px;
  color: var(--gold);
}

.resume-text .resume-detail {
  font-size: 13px;
  color: var(--text);
}

@media (max-width: 540px) {
  .book-row {
    flex-wrap: wrap;
  }
  .book-row .book-progress { width: 100%; }
  .resume-toast {
    flex-direction: column;
    align-items: stretch;
  }
  .resume-text { padding-right: 28px; }
}

/* ── cta card ───────────────────────────────────────────────────── */

.cta-card {
  margin-top: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: var(--shadow);
}

.cta-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cta-text strong {
  font-weight: 600;
  font-size: 14px;
}

.cta-text span {
  font-size: 13px;
  color: var(--muted);
}

.btn-secondary {
  padding: 9px 16px;
  background: transparent;
  color: var(--gold);
  border: 1px solid var(--gold);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s;
}

.btn-secondary:hover {
  background: var(--gold-soft);
}

/* ── footer ─────────────────────────────────────────────────────── */

.footer {
  max-width: 680px;
  margin: 24px auto 32px;
  padding: 0 20px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

/* Screen içindeki footer: nav clearance padding'den ÖNCE gelir → boşluk kalkmaz */
.footer.footer-inline {
  margin: 12px auto 8px;
}

.footer a {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px dotted var(--muted);
}

.footer a:hover {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

.footer .dot {
  margin: 0 8px;
}

/* ── responsive ─────────────────────────────────────────────────── */

@media (max-width: 540px) {
  .field-row {
    grid-template-columns: 1fr;
  }
  .cta-card {
    flex-direction: column;
    align-items: stretch;
  }
  .btn-secondary {
    text-align: center;
  }
  .title { font-size: 24px; }
}

/* ── Section navigation (2026-05-12) ─────────────────────────────── */
.section-nav {
  margin-top: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.section-nav-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text);
  text-align: left;
  font-size: 13px;
  font-family: inherit;
}

.section-nav-toggle:hover {
  background: var(--gold-soft);
}

.section-nav-label {
  font-weight: 600;
}

.section-nav-count {
  font-size: 11px;
  color: var(--muted);
  flex: 1;
}

.section-nav-chevron {
  font-size: 10px;
  color: var(--muted);
  transition: transform 0.15s ease;
}

.section-nav-toggle[aria-expanded="true"] .section-nav-chevron {
  transform: rotate(180deg);
}

.section-nav-list {
  list-style: none;
  margin: 0;
  padding: 0 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 220px;
  overflow-y: auto;
}

.section-nav-item button {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-nav-item button:hover {
  background: var(--gold-soft);
  color: var(--gold);
}

.section-nav-item button:active {
  transform: scale(0.98);
}

.section-nav-item .section-idx {
  font-size: 11px;
  color: var(--muted);
  min-width: 20px;
  text-align: right;
  flex-shrink: 0;
}

/* ── Faz 16.B bundle viewer (2026-05-19) ───────────────────────── */

.bundle-viewer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  /* #53: safe-area-inset-top → Android status bar + notch altında kalmaz */
  padding: calc(12px + env(safe-area-inset-top, 0px)) 12px 12px;
  /* hcr24: tam ekran overlay — kullanıcı text-box + form ve diğer ana
     ekran içeriği görmesin. Topbar (z-index:10) üstüne çıkar; bottom-nav
     (z-index:100) üstte kalır (tab geçişi). */
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 50;
  padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
}

.bundle-viewer[hidden] {
  display: none;
}

.bundle-viewer-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.bundle-close {
  font-size: 18px;
  padding: 2px 8px;
  flex-shrink: 0;
}

.bundle-title {
  flex: 1;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bundle-progress {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  flex-shrink: 0;
  background: var(--gold-soft);
  padding: 2px 10px;
  border-radius: 12px;
}

.bundle-slide-container {
  width: 100%;
  background: var(--surface);
  border-radius: 8px;
  flex: 1;
  min-height: 120px;
  display: block;    /* flex yerine block — wrap zaten %100 genişlik alıyor */
  position: relative;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  line-height: 0;
}

/* hcr28: pointer overlay — img üstüne tam oturur, pointer-events yok */
.bundle-pointer-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Zoom wrapper — img + canvas birlikte scale edilir */
.bundle-zoom-wrap {
  position: relative;
  transform-origin: top left;
  transition: transform 0.12s ease-out;
  display: block;   /* inline-block baseline boşluğunu kaldır */
  line-height: 0;   /* img altı boşluk sıfırla */
  cursor: grab;
  width: 100%;
}
.bundle-zoom-wrap:active { cursor: grabbing; }

.bundle-slide-img {
  width: 100%;
  height: auto;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

/* Tam ekran mod */
.bundle-viewer--fullscreen .bundle-slide-container {
  position: fixed;
  inset: 0;
  z-index: 200;
  border-radius: 0;
  border: none;
  background: #000;
}
.bundle-viewer--fullscreen .bundle-zoom-wrap {
  min-width: 100%;
}

.bundle-narration {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  padding: 6px 4px;
  /* hcr29: flex-shrink:0 → slide container büyüdüğünde narration ezilmez */
  flex-shrink: 0;
  max-height: 5em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

/* #47 Read-along highlight */
.bundle-cue { transition: background 0.15s; }
.bundle-cue-active { background: rgba(255, 220, 0, 0.35); border-radius: 2px; }

/* Thumbnail rail — yatay scroll, lazy load */
.bundle-thumb-rail {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 0;
  flex-shrink: 0;
  scrollbar-width: thin;
  scroll-snap-type: x mandatory;
}

.bundle-thumb {
  flex-shrink: 0;
  width: 56px;
  height: 40px;
  border-radius: 4px;
  border: 2px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  object-fit: cover;
  scroll-snap-align: start;
  transition: border-color 0.15s;
}

.bundle-thumb.active {
  border-color: var(--gold);
}

/* Resim yoksa (SCORM/ReadAlong) numara göster */
.bundle-thumb-num {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 4px;
  border: 2px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 11px;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  scroll-snap-align: start;
  transition: border-color 0.15s;
}

.bundle-thumb-num.active {
  border-color: var(--gold);
  color: var(--gold);
  font-weight: 600;
}

.bundle-search-wrap {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bundle-search-input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
}

.bundle-search-results {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 140px;
  overflow-y: auto;
}

.bundle-search-result {
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--border);
}

.bundle-search-result:hover {
  border-color: var(--gold);
}

.bundle-search-result strong {
  color: var(--gold);
  font-size: 11px;
  margin-right: 6px;
}

.bundle-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-shrink: 0;
}

.bundle-play {
  min-width: 90px;
}

.bundle-stop {
  min-width: 90px;
}

/* ── 3-screen navigation (2026-05-19 hcr23) ──────────────────── */

/* Her screen <main> scrollable, bottom-nav + sistem nav bar altında kayar.
   env(safe-area-inset-bottom): Android gesture bar / iOS home indicator /
   donanım tuş alanı için; viewport-fit=cover ile aktif olur. */
.screen {
  padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  overflow-x: hidden; /* yatay kaymayı engelle */
}

.screen[hidden] {
  display: none !important;
}

/* Screen başlıkları (kitaplık / ayarlar) */
.screen-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--text);
}

.screen-hint {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 14px;
}

/* Library empty state */
.library-empty {
  font-size: 13px;
  color: var(--muted);
  padding: 24px 0;
  text-align: center;
}

.library-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 0 4px;
}

.lib-page-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 16px;
  cursor: pointer;
  color: var(--fg);
  line-height: 1;
}

.lib-page-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.lib-page-info {
  font-size: 13px;
  color: var(--muted);
  min-width: 48px;
  text-align: center;
}

/* ── Bottom nav ───────────────────────────────────────────────── */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  /* height: auto + padding-bottom = sistem nav bar'ın üstüne çıkar */
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: none;
  border: none;
  padding: 6px 4px;
  cursor: pointer;
  color: var(--muted);
  font-family: inherit;
  font-size: 11px;
  position: relative;
  transition: color 0.15s;
}

.tab-btn.active {
  color: var(--gold);
}

.tab-icon {
  font-size: 18px;
  line-height: 1;
}

.tab-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.tab-badge {
  position: absolute;
  top: 6px;
  right: calc(50% - 16px);
  background: var(--gold);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

/* ── Voice chip (main screen) ─────────────────────────────────── */

.voice-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  padding: 5px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  width: fit-content;
  max-width: 100%;
}

.voice-chip-label {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 240px;
}

.voice-chip-btn {
  background: none;
  border: none;
  padding: 0 2px;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
  flex-shrink: 0;
}

.voice-chip-btn:hover {
  color: var(--gold);
}

/* ── Settings screen ──────────────────────────────────────────── */

.settings-section {
  margin-bottom: 20px;
}

.settings-section-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 10px;
}

/* Options in settings: checkbox + label + hint stacked */
.pdf-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  width: 100%; /* overflow'u engelle */
  box-sizing: border-box;
}

.pdf-option:last-child {
  border-bottom: none;
}

.pdf-option input[type="checkbox"] {
  margin: 3px 0 0;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}

/* Açıklama div'i: min-width:0 flexbox overflow sorununu çözer */
.pdf-option > div {
  min-width: 0;
  flex: 1;
}

.option-hint {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
  font-weight: 400;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* Settings field-row: dar ekranda üst üste yığılır */
#screen-settings .field-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* #58 Arka plan müziği paneli */
#bg-music-panel {
  padding: 8px 0 4px;
}

.bg-music-file-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.bg-music-name {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
}

.bg-music-volume-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.bg-volume-label {
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
}

.bg-volume-slider {
  flex: 1;
  height: 4px;
  accent-color: var(--gold);
}

.bg-volume-pct {
  font-size: 11px;
  color: var(--muted);
  min-width: 32px;
  text-align: right;
}

/* ── About section ────────────────────────────────────────────── */
.settings-about {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: 8px;
}

.about-app-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 10px;
}

.about-oss-label {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 6px;
}

.about-oss-list {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.about-link {
  color: var(--gold);
  text-decoration: none;
}
.about-link:hover { text-decoration: underline; }

.about-source-link {
  display: inline-block;
  font-size: 12px;
  color: var(--gold);
  text-decoration: none;
}
.about-source-link:hover { text-decoration: underline; }

/* Footer sits above bottom-nav */
.footer {
  padding-bottom: calc(68px + env(safe-area-inset-bottom, 0px));
}

/* ── Desktop & Tablet Layout (≥768px) ─────────────────────────────────────── */
@media (min-width: 768px) {
  /* Bottom nav → gizle, yerine sol sidebar nav gelecek */
  .bottom-nav { display: none; }

  /* App kök: flex row */
  body {
    display: flex;
    flex-direction: row;
    min-height: 100dvh;
    overflow: hidden;
  }

  /* Sol sidebar nav */
  .sidebar-nav {
    display: flex;
    flex-direction: column;
    width: 200px;
    min-width: 160px;
    max-width: 220px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 16px 0;
    flex-shrink: 0;
    height: 100dvh;
    position: sticky;
    top: 0;
  }

  /* Sağ içerik alanı: tüm ekranlar aynı anda DOM'da, tab geçişi hide/show */
  .screen-wrap {
    flex: 1;
    overflow-y: auto;
    height: 100dvh;
  }

  .screen {
    padding-bottom: 32px; /* bottom-nav padding'i artık gereksiz */
    max-width: 860px;
    margin: 0 auto;
  }

  .container {
    max-width: 860px;
    padding: 32px 40px 24px;
  }

  /* Header sağ tarafa taşın */
  .app-header {
    max-width: 860px;
    margin: 0 auto;
  }
}

/* Tablet orta boy (768–1024px): sidebar daha dar */
@media (min-width: 768px) and (max-width: 1024px) {
  .sidebar-nav {
    width: 64px;
    min-width: 64px;
  }
  .sidebar-nav .tab-label { display: none; }
  .sidebar-nav .tab-icon { font-size: 22px; }
}

/* Desktop geniş (≥1025px): tam sidebar */
@media (min-width: 1025px) {
  .sidebar-nav { width: 200px; }
}

/* Sidebar nav buton stilleri (desktop) */
@media (min-width: 768px) {
  .sidebar-nav .tab-btn {
    flex-direction: row;
    justify-content: flex-start;
    gap: 10px;
    padding: 12px 20px;
    font-size: 14px;
    border-radius: 8px;
    margin: 2px 8px;
    width: calc(100% - 16px);
  }

  .sidebar-nav .tab-btn.active {
    background: var(--gold-soft);
    color: var(--gold);
    font-weight: 600;
  }

  .sidebar-nav .tab-icon {
    font-size: 18px;
    flex-shrink: 0;
  }

  /* Tablet: sadece ikon */
  @media (max-width: 1024px) {
    .sidebar-nav .tab-btn {
      justify-content: center;
      padding: 12px;
    }
  }
}

/* Topbar nav (desktop ≥768px) — sidebar yerine */
.topbar-nav {
  display: none; /* JS ile gösterilir */
  align-items: center;
  gap: 4px;
  flex: 1;
  justify-content: center;
}

@media (min-width: 768px) {
  .topbar-nav .tab-btn {
    flex-direction: row;
    gap: 6px;
    padding: 6px 14px;
    font-size: 14px;
    border-radius: 8px;
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-family: inherit;
  }
  .topbar-nav .tab-btn.active {
    background: var(--gold-soft);
    color: var(--gold);
    font-weight: 600;
  }
  .topbar-nav .tab-btn:hover:not(.active) {
    background: var(--surface);
    color: var(--text);
  }
  .topbar-nav .tab-icon { font-size: 15px; }
  .topbar-nav .tab-label { display: inline; }
}
