/* SCREENPLAY EDITOR CSS */

/* === 1. PAGE LAYOUT === */
body {
  overflow-y: auto;
  overflow-x: hidden;
  height: auto;
  min-height: 100vh;
  display: block;
}

.container {
  max-width: 100%;
  margin: 0;
  padding: 0 0 60px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* === 2. HEADER === */
.header-section {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--bg-glass-panel);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border-glass);
  box-shadow: var(--shadow-glass);
  flex-wrap: wrap;
}

.header-section h2 {
  flex: 1;
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.back-btn {
  background: var(--bg-glass-panel);
  border: 1px solid var(--border-glass);
  color: var(--color-text);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.back-btn:hover {
  background: rgba(90,24,154,0.12);
  border-color: var(--color-primary);
  color: var(--color-primary);
  transform: translateX(-2px);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.header-actions .action-btn {
  padding: 8px 14px;
  font-size: 0.8rem;
  border-radius: 999px;
  gap: 6px;
  white-space: nowrap;
}

.secondary-btn {
  background: var(--bg-glass-panel) !important;
  border: 1px solid var(--border-glass) !important;
  color: var(--color-text) !important;
  box-shadow: none !important;
}

.secondary-btn:hover {
  background: rgba(90,24,154,0.1) !important;
  border-color: var(--color-primary) !important;
  color: var(--color-primary) !important;
}

body.dark .secondary-btn:hover {
  border-color: var(--color-secondary) !important;
  color: var(--color-secondary) !important;
}

#saveBtn {
  background: var(--color-primary) !important;
  color: white !important;
  border: none !important;
  box-shadow: 0 6px 18px rgba(90,24,154,0.35) !important;
}

#saveBtn:hover {
  background: var(--color-dark-purple) !important;
  transform: translateY(-1px);
}

/* === 3. META BAR === */
.meta-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 20px;
  background: var(--bg-glass-panel);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border-glass);
}

.meta-input {
  font-size: 0.82rem;
  color: var(--color-text);
  background: rgba(255,255,255,0.07);
  border-radius: 10px;
  padding: 7px 13px;
  border: 1px solid var(--border-glass);
  white-space: nowrap;
}

.meta-project { flex: 1; min-width: 160px; }

.meta-input strong {
  color: var(--color-primary);
  font-weight: 700;
  margin-right: 4px;
}

body.dark .meta-input strong { color: var(--color-secondary); }

.meta-autosave {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--color-soft-gray);
}

#savedIcon { color: #28a745; }

/* === 4. TOOLBAR === */
.screenplay-toolbar {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  padding: 8px 20px;
  background: var(--bg-glass-panel);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border-glass);
  position: sticky;
  top: 61px;
  z-index: 90;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.toolbar-right {
  margin-left: auto;
}

.toolbar-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-soft-gray);
  margin-right: 4px;
  white-space: nowrap;
}

.toolbar-right .toolbar-label {
  font-size: 0.7rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  opacity: 0.6;
}

.element-type-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border: 1px solid var(--border-glass);
  border-radius: 999px;
  background: var(--bg-glass-panel);
  color: var(--color-soft-gray);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  font-family: inherit;
}

.element-type-btn:hover {
  background: rgba(90,24,154,0.1);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.element-type-btn.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
  box-shadow: 0 4px 12px rgba(90,24,154,0.3);
}

body.dark .element-type-btn:hover {
  border-color: var(--color-secondary);
  color: var(--color-secondary);
}

body.dark .element-type-btn.active {
  background: var(--color-primary);
  color: white;
}

.element-type-shortcut {
  font-size: 0.65rem;
  opacity: 0.6;
  font-family: ui-monospace, monospace;
}

/* === 5. EDITOR SCROLL AREA === */
.script-pad-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-body);
}

.editor-scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 36px 20px 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg-body);
  min-height: 80vh;
  gap: 24px;
}

.editor-scroll-area::-webkit-scrollbar { width: 8px; }
.editor-scroll-area::-webkit-scrollbar-thumb {
  background: rgba(90,24,154,0.2);
  border-radius: 8px;
}
body.dark .editor-scroll-area::-webkit-scrollbar-thumb {
  background: rgba(90,24,154,0.4);
}

/* === 6. SCREENPLAY PAPER === */
.screenplay-paper {
  width: 8.5in;
  max-width: 100%;
  min-height: 11in;
  background: #ffffff;
  color: #1a1a1a;
  padding: 1in 1in 1in 1.5in;
  box-shadow:
    0 2px 4px rgba(0,0,0,0.04),
    0 8px 32px rgba(0,0,0,0.1),
    0 24px 64px rgba(90,24,154,0.06);
  border: 1px solid rgba(0,0,0,0.07);
  border-radius: 3px;
  box-sizing: border-box;
  position: relative;
  font-family: 'Courier Prime', 'Courier New', monospace;
  font-size: 12pt;
  line-height: 1.5;
}

body.dark .screenplay-paper {
  background: #141414;
  color: #e8e8e8;
  border-color: rgba(255,255,255,0.07);
  box-shadow:
    0 2px 4px rgba(0,0,0,0.3),
    0 8px 32px rgba(0,0,0,0.5),
    0 24px 64px rgba(90,24,154,0.1);
}

/* === MADE WITH PREP SIGNATURE === */
.screenplay-paper::after {
  content: "Made with PREP";
  position: absolute;
  bottom: 0.45in;
  right: 0.6in;
  font-family: 'Poppins', 'Montserrat', sans-serif;
  font-size: 8.5pt;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: transparent;
  background: linear-gradient(90deg, rgba(90,24,154,0.28) 0%, rgba(130,60,200,0.18) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  user-select: none;
  pointer-events: none;
}

body.dark .screenplay-paper::after {
  background: linear-gradient(90deg, rgba(160,100,255,0.32) 0%, rgba(200,150,255,0.2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

/* === 7. TITLE PAGE === */
.title-page-paper {
  display: flex;
  align-items: center;
  justify-content: center;
}

.title-page-content {
  text-align: center;
  width: 100%;
  padding-top: 2.5in;
}

.tp-title {
  font-size: 18pt;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.5in;
  outline: none;
  min-height: 1.5em;
}

.tp-subtitle {
  font-size: 12pt;
  margin-bottom: 0.15in;
  outline: none;
  min-height: 1.2em;
}

.tp-author {
  font-size: 14pt;
  font-weight: bold;
  margin-bottom: 1.5in;
  outline: none;
  min-height: 1.2em;
}

.tp-draft, .tp-contact {
  font-size: 11pt;
  color: #555;
  margin-bottom: 0.1in;
  outline: none;
  min-height: 1.2em;
}

body.dark .tp-draft, body.dark .tp-contact { color: #aaa; }

[contenteditable]:empty:before {
  content: attr(data-placeholder);
  color: rgba(150,150,160,0.5);
  pointer-events: none;
}

/* === 8. SCREENPLAY LINES === */
.sp-line {
  position: relative;
  margin-bottom: 0;
  min-height: 1.5em;
}

/* Spacing between element groups */
.sp-scene-heading  { margin-top: 1.5em; margin-bottom: 0; }
.sp-action         { margin-top: 0.75em; margin-bottom: 0.75em; }
.sp-character      { margin-top: 1em; margin-bottom: 0; }
.sp-dialogue       { margin-top: 0; margin-bottom: 0; }
.sp-parenthetical  { margin-top: 0; margin-bottom: 0; }
.sp-transition     { margin-top: 1em; margin-bottom: 1em; }

/* The editable text node inside each line */
.sp-text {
  display: block;
  outline: none;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
  min-height: 1.5em;
  caret-color: var(--color-primary);
  border-radius: 3px;
  padding: 1px 3px;
  transition: background 0.12s ease;
}

body.dark .sp-text { caret-color: var(--color-secondary); }

.sp-text:focus {
  background: rgba(90,24,154,0.04);
  outline: none;
}

body.dark .sp-text:focus { background: rgba(90,24,154,0.12); }

/* Placeholder */
.sp-text[data-placeholder]:empty::before {
  content: attr(data-placeholder);
  color: rgba(150,150,160,0.4);
  pointer-events: none;
  font-style: italic;
}

/* Active line highlight */
.sp-line.sp-active > .sp-text {
  background: rgba(90,24,154,0.05);
}
body.dark .sp-line.sp-active > .sp-text {
  background: rgba(90,24,154,0.14);
}

/* Read-aloud highlight */
.sp-line.sp-reading {
  background: rgba(255, 195, 0, 0.18);
  border-radius: 6px;
  transition: background 0.2s ease;
}
.sp-line.sp-reading > .sp-text {
  background: transparent !important;
}
body.dark .sp-line.sp-reading {
  background: rgba(255, 195, 0, 0.12);
}

/* === 9. ELEMENT TYPE FORMATTING === */

/* Scene Heading */
.sp-scene-heading .sp-text {
  text-transform: uppercase;
  font-weight: bold;
  letter-spacing: 0.03em;
  padding-left: 0;
}

/* Action */
.sp-action .sp-text {
  padding-left: 0;
}

/* Character */
.sp-character .sp-text {
  margin-left: 2.2in;
  text-transform: uppercase;
  font-weight: bold;
  letter-spacing: 0.05em;
  width: fit-content;
  min-width: 2in;
}

/* Dialogue */
.sp-dialogue .sp-text {
  margin-left: 1in;
  margin-right: 1.5in;
}

/* Parenthetical */
.sp-parenthetical .sp-text {
  margin-left: 1.5in;
  margin-right: 2in;
  font-style: italic;
  color: #555;
}
body.dark .sp-parenthetical .sp-text { color: #aaa; }

/* Dual Dialogue */
.sp-dual-block {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75in;
  margin-top: 1em;
  margin-bottom: 1em;
  position: relative;
}
.sp-dual-block .sp-dual-column {
  display: grid;
  gap: 0.3em;
}
.sp-dual-block .sp-character .sp-text,
.sp-dual-block .sp-dialogue .sp-text {
  margin-left: 0;
  margin-right: 0;
}
.sp-dual-block .sp-character .sp-text {
  text-transform: uppercase;
  font-weight: bold;
}
.sp-dual-label {
  position: absolute;
  top: -1.1em;
  left: 0;
  font-size: 0.78rem;
  color: rgba(100,100,120,0.7);
  letter-spacing: 0.03em;
}

.sp-text.sp-dict-match {
  box-shadow: inset 0 0 0 1px rgba(46,125,50,0.18);
}

.dict-input-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}
.custom-dict-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 240px;
  overflow: auto;
}
.custom-dict-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border-glass);
  background: var(--bg-glass-card);
}
.custom-dict-item span {
  word-break: break-word;
  font-size: 0.95rem;
}
.custom-dict-item button {
  min-width: auto;
  padding: 5px 10px;
}

/* === STATS & REPORT MODALS === */

/* Wider modal for report/stats */
.report-modal,
.stats-modal {
  width: min(720px, 96vw) !important;
}

.stats-grid,
.report-grid {
  display: grid;
  gap: 16px;
}

/* Stats cards — 2-column grid */
.stats-grid {
  grid-template-columns: repeat(2, 1fr);
}

.stats-card,
.report-card {
  background: var(--bg-glass-card);
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  padding: 18px 20px;
  transition: box-shadow 0.15s ease;
}

.stats-card:hover {
  box-shadow: 0 4px 20px rgba(90,24,154,0.1);
}

.stats-card h4,
.report-card h4 {
  margin: 0 0 6px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-soft-gray);
}

.stats-card p {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-text);
}

/* Report card heading */
.report-card h4 {
  font-size: 0.82rem;
  color: var(--color-primary);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 7px;
}
body.dark .report-card h4 { color: var(--color-secondary); }

/* ── Character Report Table ── */
.report-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-top: 4px;
  font-size: 0.88rem;
}

/* Sticky header */
.report-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

.report-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-primary);
  background: rgba(90,24,154,0.06);
  border-bottom: 2px solid rgba(90,24,154,0.18);
  white-space: nowrap;
}

body.dark .report-table th {
  color: var(--color-secondary);
  background: rgba(90,24,154,0.14);
  border-bottom-color: rgba(255,195,0,0.2);
}

/* First and last th get rounded corners */
.report-table thead tr th:first-child { border-radius: 10px 0 0 0; }
.report-table thead tr th:last-child  { border-radius: 0 10px 0 0; }

/* Body rows */
.report-table tbody tr {
  transition: background 0.12s ease;
}

.report-table tbody tr:nth-child(even) td {
  background: rgba(90,24,154,0.03);
}
body.dark .report-table tbody tr:nth-child(even) td {
  background: rgba(90,24,154,0.08);
}

.report-table tbody tr:hover td {
  background: rgba(90,24,154,0.08);
}
body.dark .report-table tbody tr:hover td {
  background: rgba(90,24,154,0.18);
}

.report-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-glass);
  color: var(--color-text);
  vertical-align: middle;
}

.report-table tbody tr:last-child td {
  border-bottom: none;
}

/* Character name cell — bold + uppercase */
.report-table td:first-child {
  font-weight: 700;
  font-family: 'Courier Prime', 'Courier New', monospace;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text);
}

/* Numeric cells — tabular figures, right-aligned */
.report-table td:nth-child(2),
.report-table td:nth-child(3) {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--color-primary);
  text-align: right;
  padding-right: 20px;
}
body.dark .report-table td:nth-child(2),
body.dark .report-table td:nth-child(3) {
  color: var(--color-secondary);
}

/* Scenes cell — pill badges */
.report-table td:last-child {
  font-size: 0.8rem;
  color: var(--color-soft-gray);
  max-width: 180px;
}

/* Scrollable table wrapper */
.report-table-wrap {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--border-glass);
}

/* Stats table (top characters) */
.stats-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.88rem;
}

.stats-table th {
  padding: 9px 12px;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-primary);
  background: rgba(90,24,154,0.06);
  border-bottom: 2px solid rgba(90,24,154,0.15);
}
body.dark .stats-table th {
  color: var(--color-secondary);
  background: rgba(90,24,154,0.12);
}

.stats-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-glass);
  color: var(--color-text);
  font-size: 0.85rem;
}
.stats-table tbody tr:last-child td { border-bottom: none; }
.stats-table tbody tr:hover td { background: rgba(90,24,154,0.06); }

body.dark .custom-dict-item {
  background: rgba(40,35,55,0.92);
}

/* Transition */
.sp-transition .sp-text {
  text-align: right;
  text-transform: uppercase;
  font-weight: bold;
  letter-spacing: 0.03em;
}

/* === 10. SCENE NUMBERS === */
.sp-scene-num {
  position: absolute;
  left: -0.9in;
  top: 0;
  font-size: 10pt;
  color: rgba(100,100,120,0.5);
  user-select: none;
  font-family: ui-monospace, 'Courier New', monospace;
  font-weight: normal;
  letter-spacing: 0;
}

body.dark .sp-scene-num { color: rgba(200,200,220,0.3); }

/* CONT'D badge on character */
.sp-contd-badge {
  font-size: 9pt;
  font-weight: normal;
  color: rgba(100,100,120,0.6);
  margin-left: 8px;
  letter-spacing: 0;
  text-transform: none;
  font-style: italic;
}

body.dark .sp-contd-badge { color: rgba(200,200,220,0.4); }

/* MORE / CONT'D page break labels */
.sp-more {
  text-align: center;
  font-style: italic;
  color: rgba(100,100,120,0.6);
  margin: 0.3em 0;
  font-size: 11pt;
  user-select: none;
}

.sp-contd-label {
  margin-left: 2.2in;
  font-style: italic;
  color: rgba(100,100,120,0.6);
  font-size: 11pt;
  user-select: none;
}

/* === 11. PAGE BREAKS === */
.sp-page-header {
  text-align: right;
  font-size: 10pt;
  color: rgba(100,100,120,0.45);
  user-select: none;
  margin-bottom: 0.3em;
  font-family: ui-monospace, 'Courier New', monospace;
  min-height: 1em;
}

body.dark .sp-page-header { color: rgba(200,200,220,0.25); }

.sp-page-break {
  border-top: 1px dashed rgba(90,24,154,0.18);
  margin: 1em 0 0.5em;
  text-align: center;
  position: relative;
}

body.dark .sp-page-break { border-top-color: rgba(255,195,0,0.15); }

.sp-page-break-label {
  position: absolute;
  top: -0.65em;
  left: 50%;
  transform: translateX(-50%);
  background: #ffffff;
  padding: 0 10px;
  font-size: 9pt;
  color: rgba(100,100,120,0.45);
  font-family: ui-monospace, 'Courier New', monospace;
  user-select: none;
  white-space: nowrap;
}

body.dark .sp-page-break-label {
  background: #141414;
  color: rgba(200,200,220,0.25);
}

/* === 12. FIND HIGHLIGHTS === */
mark.sp-highlight {
  background: rgba(255,195,0,0.4);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

mark.sp-highlight-active {
  background: rgba(255,140,0,0.65);
  outline: 2px solid rgba(255,140,0,0.8);
}

body.dark mark.sp-highlight { background: rgba(255,195,0,0.25); }
body.dark mark.sp-highlight-active { background: rgba(255,195,0,0.5); }

/* === 13. AUTOCOMPLETE === */
.auto-complete {
  position: fixed;
  background: var(--bg-glass-card, #fff);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.14), 0 2px 8px rgba(90,24,154,0.1);
  max-height: 220px;
  overflow-y: auto;
  z-index: 2000;
  min-width: 220px;
  padding: 6px;
}

body.dark .auto-complete {
  background: rgba(20,15,35,0.95);
  border-color: rgba(90,24,154,0.4);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.auto-complete-item {
  padding: 8px 13px;
  cursor: pointer;
  border-radius: 8px;
  font-family: 'Courier Prime', 'Courier New', monospace;
  font-size: 0.88rem;
  color: var(--color-text);
  transition: background 0.12s ease;
  margin-bottom: 2px;
}

.auto-complete-item:hover,
.auto-complete-item.selected {
  background: rgba(90,24,154,0.1);
  color: var(--color-primary);
}

body.dark .auto-complete-item:hover,
body.dark .auto-complete-item.selected {
  background: rgba(90,24,154,0.25);
  color: var(--color-secondary);
}

/* === 14. CONTEXT MENU === */
.context-menu {
  position: fixed;
  background: var(--bg-glass-card, #fff);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  border: 1px solid var(--border-glass);
  border-radius: 14px;
  padding: 8px;
  z-index: 3000;
  min-width: 200px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.16);
}

body.dark .context-menu {
  background: rgba(20,15,35,0.97);
  border-color: rgba(90,24,154,0.4);
  box-shadow: 0 12px 40px rgba(0,0,0,0.55);
}

.ctx-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 13px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  text-align: left;
  border-radius: 8px;
  color: var(--color-text);
  transition: background 0.12s ease;
  font-family: inherit;
  margin-bottom: 2px;
}

.ctx-item i { width: 16px; text-align: center; opacity: 0.7; }

.ctx-item:hover { background: rgba(90,24,154,0.1); color: var(--color-primary); }
body.dark .ctx-item:hover { background: rgba(90,24,154,0.22); color: var(--color-secondary); }

.ctx-item.ctx-danger { color: #dc3545; }
.ctx-item.ctx-danger:hover { background: rgba(220,53,69,0.1); color: #dc3545; }

.ctx-item.ctx-active {
  background: rgba(90,24,154,0.1);
  color: var(--color-primary);
  font-weight: 700;
}
body.dark .ctx-item.ctx-active { color: var(--color-secondary); }

.ctx-divider {
  height: 1px;
  background: var(--border-glass);
  margin: 5px 0;
}

/* === 15. FIND & REPLACE PANEL === */
.find-replace-panel {
  position: fixed;
  top: 130px;
  right: 24px;
  z-index: 4000;
  background: var(--bg-glass-card, #fff);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.18);
  width: 360px;
  max-width: calc(100vw - 40px);
  overflow: hidden;
}

body.dark .find-replace-panel {
  background: rgba(20,15,35,0.97);
  border-color: rgba(90,24,154,0.4);
}

.frp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-glass);
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--color-text);
}

.frp-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-soft-gray);
  font-size: 1rem;
  padding: 4px;
  border-radius: 6px;
  transition: color 0.15s;
}
.frp-close:hover { color: var(--color-text); }

.frp-body { padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 10px; }

.frp-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.frp-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-input);
  color: var(--color-text);
  font-size: 0.88rem;
  font-family: ui-monospace, 'Courier New', monospace;
  outline: none;
  transition: border-color 0.15s;
}
.frp-input:focus { border-color: var(--color-primary); }
body.dark .frp-input:focus { border-color: var(--color-secondary); }

.frp-btn {
  padding: 7px 10px;
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  background: var(--bg-glass-panel);
  color: var(--color-text);
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.15s;
  white-space: nowrap;
  font-family: inherit;
}
.frp-btn:hover { background: rgba(90,24,154,0.1); border-color: var(--color-primary); color: var(--color-primary); }

.frp-btn-primary {
  background: var(--color-primary) !important;
  color: white !important;
  border-color: transparent !important;
}
.frp-btn-primary:hover { background: var(--color-dark-purple) !important; }

.frp-count {
  font-size: 0.75rem;
  color: var(--color-soft-gray);
  white-space: nowrap;
  min-width: 40px;
  text-align: right;
}

.frp-check {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.8rem;
  color: var(--color-soft-gray);
  cursor: pointer;
  user-select: none;
}

/* === 16. TITLE PAGE MODAL === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5000;
  padding: 20px;
  /* Override ai_script.css which hides overlays until .visible is added */
  opacity: 1 !important;
  pointer-events: auto !important;
  transition: none !important;
}

.tp-modal {
  width: min(500px, 96vw);
  background: var(--bg-glass-card, #fff);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--border-glass);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.25);
  overflow: hidden;
}

body.dark .tp-modal {
  background: rgba(20,15,35,0.97);
  border-color: rgba(90,24,154,0.4);
}

.tp-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-glass);
}

.tp-modal-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

body.dark .tp-modal-header h3 { color: var(--color-secondary); }

.tp-modal-body {
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 60vh;
  overflow-y: auto;
}

.tp-modal-body label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-soft-gray);
  margin-bottom: -4px;
}

.tp-modal-footer {
  display: flex;
  gap: 10px;
  padding: 16px 22px;
  border-top: 1px solid var(--border-glass);
  justify-content: flex-end;
}

.tp-modal-footer .action-btn {
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 0.85rem;
}

/* === 17. TOAST === */
#toastContainer {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: #1a1a2e;
  color: #fff;
  padding: 11px 22px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  z-index: 9999;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}

#toastContainer.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* === 18. NO PROJECT === */
#noProjectMessage {
  max-width: 500px;
  margin: 80px auto;
  padding: 40px 36px;
  background: var(--bg-glass-card, #fff);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  border: 1px solid var(--border-glass);
  border-radius: 24px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(90,24,154,0.12);
}

#noProjectMessage h3 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--color-primary);
  margin: 0 0 12px;
}

body.dark #noProjectMessage h3 { color: var(--color-secondary); }

#noProjectHint {
  color: var(--color-soft-gray);
  font-size: 0.92rem;
  line-height: 1.7;
  margin: 0 0 22px;
}

/* === 19. LOADER — see /shared/loader.css === */

/* === 20. RESPONSIVE === */
@media (max-width: 900px) {
  .header-section { padding: 10px 14px; }
  .header-section h2 { font-size: 0.95rem; }
  .meta-bar { padding: 8px 14px; }
  .screenplay-toolbar { padding: 7px 14px; top: 56px; }
  .editor-scroll-area { padding: 16px 8px 60px; }

  .screenplay-paper {
    padding: 0.6in 0.5in 0.6in 0.75in;
    font-size: 11pt;
  }

  .sp-character .sp-text { margin-left: 1.2in; }
  .sp-dialogue .sp-text  { margin-left: 0.5in; margin-right: 0.5in; }
  .sp-parenthetical .sp-text { margin-left: 0.8in; margin-right: 0.8in; }
  .sp-scene-num { left: -0.5in; font-size: 9pt; }

  .find-replace-panel { top: auto; bottom: 80px; right: 12px; left: 12px; width: auto; }
}

@media (max-width: 600px) {
  .header-actions .action-btn span { display: none; }
  .header-actions .action-btn { width: 34px; height: 34px; padding: 0; justify-content: center; }
  .element-type-shortcut { display: none; }
  .toolbar-right { display: none; }

  .screenplay-paper {
    padding: 0.4in 0.35in 0.4in 0.5in;
    font-size: 10.5pt;
  }

  .sp-character .sp-text { margin-left: 0.8in; }
  .sp-dialogue .sp-text  { margin-left: 0.3in; margin-right: 0.3in; }
  .sp-parenthetical .sp-text { margin-left: 0.5in; margin-right: 0.5in; }
}

/* === 21. PRINT === */
@media print {
  .header-section,
  .meta-bar,
  .screenplay-toolbar,
  .find-replace-panel,
  .context-menu,
  .auto-complete,
  #toastContainer { display: none !important; }

  body { background: white; }
  .editor-scroll-area { padding: 0; }
  .screenplay-paper {
    box-shadow: none;
    border: none;
    border-radius: 0;
    width: 100%;
    padding: 1in 1in 1in 1.5in;
  }
}

/* ============================================================
   NEW FEATURES CSS
   ============================================================ */

/* === SCENE NAVIGATOR === */
.script-pad-container {
  display: flex;
  flex-direction: row;
  flex: 1;
  overflow: hidden;
}

.editor-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.scene-nav {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-glass-panel);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-right: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 50;
}

.scene-nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-glass);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--color-text);
  flex-shrink: 0;
}

.scene-nav-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-soft-gray);
  font-size: 0.9rem;
  padding: 4px;
  border-radius: 6px;
}
.scene-nav-close:hover { color: var(--color-text); }

.scene-nav-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.scene-nav-list::-webkit-scrollbar { width: 4px; }
.scene-nav-list::-webkit-scrollbar-thumb { background: rgba(90,24,154,0.2); border-radius: 4px; }

.scene-nav-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s ease;
  margin-bottom: 3px;
}

.scene-nav-item:hover { background: rgba(90,24,154,0.08); }
.scene-nav-item.active { background: rgba(90,24,154,0.14); }
body.dark .scene-nav-item:hover  { background: rgba(90,24,154,0.18); }
body.dark .scene-nav-item.active { background: rgba(90,24,154,0.28); }

.scene-nav-num {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--color-primary);
  min-width: 20px;
  padding-top: 1px;
  font-family: ui-monospace, monospace;
}
body.dark .scene-nav-num { color: var(--color-secondary); }

.scene-nav-text {
  font-size: 0.78rem;
  color: var(--color-text);
  line-height: 1.4;
  font-family: 'Courier Prime', 'Courier New', monospace;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.scene-nav-empty {
  padding: 16px 10px;
  font-size: 0.82rem;
  color: var(--color-soft-gray);
  text-align: center;
}

/* === REVISION MODE === */
.sp-revision-mark {
  position: absolute;
  right: -1.1in;
  top: 0;
  font-size: 14pt;
  font-weight: bold;
  user-select: none;
  pointer-events: none;
}

.revision-badge {
  position: fixed;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: var(--bg-glass-card, #fff);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 2px solid #1565C0;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  z-index: 4000;
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
}

.revision-lock-btn {
  padding: 5px 12px;
  border: 1px solid currentColor;
  border-radius: 999px;
  background: none;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
  font-family: inherit;
  transition: all 0.15s;
}
.revision-lock-btn:hover { background: rgba(0,0,0,0.08); }

.revision-exit-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-soft-gray);
  font-size: 1rem;
  padding: 2px 4px;
  border-radius: 4px;
}
.revision-exit-btn:hover { color: var(--color-text); }

/* === IMPORT MODAL === */
.import-drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 32px 20px;
  border: 2px dashed var(--border-color);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--color-soft-gray);
  font-size: 0.9rem;
  text-align: center;
}

.import-drop-zone i { font-size: 2rem; color: var(--color-primary); }
body.dark .import-drop-zone i { color: var(--color-secondary); }

.import-drop-zone:hover,
.import-drop-zone.drag-over {
  border-color: var(--color-primary);
  background: rgba(90,24,154,0.05);
  color: var(--color-text);
}

.import-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(90,24,154,0.06);
  border-radius: 10px;
  border: 1px solid rgba(90,24,154,0.15);
}

.import-preview-header {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--color-text);
}

.import-badge {
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(90,24,154,0.12);
  color: var(--color-primary);
  font-weight: 700;
}
body.dark .import-badge { color: var(--color-secondary); background: rgba(255,195,0,0.12); }

/* === VERSION HISTORY === */
.version-modal { max-width: 560px; }

.version-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-glass);
}
.version-row:last-child { border-bottom: none; }

.version-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }

.version-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.version-time {
  font-size: 0.75rem;
  color: var(--color-soft-gray);
}

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

.version-restore-btn { color: var(--color-primary); font-weight: 600; }
body.dark .version-restore-btn { color: var(--color-secondary); }

.version-delete-btn { color: #dc3545; }
.version-delete-btn:hover { background: rgba(220,53,69,0.1) !important; }

/* === SCRIPT NOTES === */
.notes-panel {
  position: fixed;
  top: 130px;
  right: 24px;
  z-index: 4000;
  background: var(--bg-glass-card, #fff);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.18);
  width: 320px;
  max-width: calc(100vw - 40px);
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body.dark .notes-panel {
  background: rgba(20,15,35,0.97);
  border-color: rgba(90,24,154,0.4);
}

.notes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-glass);
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--color-text);
  flex-shrink: 0;
}

.notes-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.notes-empty {
  font-size: 0.82rem;
  color: var(--color-soft-gray);
  text-align: center;
  padding: 16px 0;
}

.note-row {
  background: rgba(255,195,0,0.08);
  border: 1px solid rgba(255,195,0,0.2);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

body.dark .note-row {
  background: rgba(255,195,0,0.06);
  border-color: rgba(255,195,0,0.15);
}

.note-context {
  font-size: 0.72rem;
  color: var(--color-soft-gray);
  font-family: 'Courier Prime', 'Courier New', monospace;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  padding-bottom: 5px;
}

.note-text {
  font-size: 0.85rem;
  color: var(--color-text);
  outline: none;
  min-height: 1.4em;
  line-height: 1.5;
}

.note-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 2px;
}

.note-time { font-size: 0.7rem; color: var(--color-soft-gray); }

.note-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(220,53,69,0.6);
  font-size: 0.78rem;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.12s;
}
.note-delete-btn:hover { color: #dc3545; }

.notes-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border-glass);
  flex-shrink: 0;
}

.sp-note-indicator {
  position: absolute;
  right: -0.5in;
  top: 0;
  font-size: 9pt;
  color: rgba(255,195,0,0.8);
  cursor: pointer;
  user-select: none;
  transition: color 0.12s;
}
.sp-note-indicator:hover { color: #ffc300; }

/* === CORKBOARD === */
.corkboard-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-body);
  z-index: 6000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.corkboard-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  background: var(--bg-glass-panel);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border-glass);
  font-weight: 700;
  font-size: 1rem;
  color: var(--color-text);
  flex-shrink: 0;
}

.corkboard-hint {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--color-soft-gray);
  margin-left: 4px;
}

.corkboard-grid {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
  align-content: start;
}

.corkboard-card {
  background: #fffde7;
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 6px;
  padding: 16px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.1), 0 1px 3px rgba(0,0,0,0.06);
  cursor: grab;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  position: relative;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

body.dark .corkboard-card {
  background: #2a2510;
  border-color: rgba(255,195,0,0.15);
}

.corkboard-card:hover {
  transform: translateY(-3px) rotate(0.5deg);
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

.corkboard-card.dragging {
  opacity: 0.5;
  cursor: grabbing;
}

.corkboard-card.drag-over {
  outline: 2px dashed var(--color-primary);
  outline-offset: 3px;
}

.card-num {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--color-primary);
  font-family: ui-monospace, monospace;
}
body.dark .card-num { color: var(--color-secondary); }

.card-heading {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #1a1a1a;
  font-family: 'Courier Prime', 'Courier New', monospace;
  line-height: 1.3;
}
body.dark .card-heading { color: #e8e8e8; }

.card-summary {
  font-size: 0.75rem;
  color: #555;
  line-height: 1.5;
  flex: 1;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
}
body.dark .card-summary { color: #aaa; }

.card-meta {
  font-size: 0.7rem;
  color: rgba(90,24,154,0.7);
  font-weight: 600;
  margin-top: auto;
}
body.dark .card-meta { color: rgba(255,195,0,0.7); }

/* === RESPONSIVE ADJUSTMENTS === */
@media (max-width: 900px) {
  .scene-nav { width: 200px; }
  .sp-revision-mark { right: -0.5in; }
  .sp-note-indicator { right: -0.3in; }
  .notes-panel { right: 12px; left: 12px; width: auto; top: auto; bottom: 80px; }
  .corkboard-grid { padding: 16px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
}

/* === SCENE TYPE SELECTOR === */
.scene-type-modal {
  width: min(500px, 96vw);
  max-width: 500px;
  padding: 0;
  border-radius: 16px;
  background: var(--bg-glass-card, #fff);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--border-glass);
  box-shadow: 0 24px 60px rgba(0,0,0,0.25);
  overflow: hidden;
}

.scene-type-header {
  padding: 24px;
  background: linear-gradient(135deg, #5DADE2 0%, #2E86DE 100%);
  color: white;
  text-align: center;
}

.scene-type-header h3 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.scene-type-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 24px;
}

.scene-type-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px 16px;
  border: 2px solid #E8EEF5;
  background: var(--bg-secondary);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  text-decoration: none;
}

.scene-type-btn:hover {
  border-color: #5DADE2;
  background: #EBF5FB;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(93, 173, 226, 0.15);
}

.scene-type-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(93, 173, 226, 0.1);
}

.scene-type-label {
  font-size: 1.1rem;
  font-weight: 700;
  color: #2E86DE;
  letter-spacing: 0.05em;
}

.scene-type-desc {
  font-size: 0.75rem;
  color: var(--color-soft-gray);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

body.dark .scene-type-modal {
  background: rgba(20,15,35,0.97);
  border-color: rgba(90,24,154,0.4);
}

body.dark .scene-type-btn {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.1);
}

body.dark .scene-type-btn:hover {
  background: rgba(93,173,226,0.1);
  border-color: #5DADE2;
}

@media (max-width: 600px) {
  .scene-nav { position: absolute; top: 0; bottom: 0; left: 0; z-index: 200; }
  .revision-badge { bottom: 80px; font-size: 0.78rem; padding: 6px 12px; }
  
  .scene-type-options {
    grid-template-columns: 1fr;
    gap: 10px;
  }
}

/* === READ SPEED POPOVER === */
#readSpeedPopover[hidden] {
  display: none !important;
}

#readSpeedPopover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-glass-card, #fff);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  border: 1px solid var(--border-glass);
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.14), 0 2px 8px rgba(90,24,154,0.1);
  white-space: nowrap;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text);
}

body.dark #readSpeedPopover {
  background: rgba(20,15,35,0.97);
  border-color: rgba(90,24,154,0.4);
  box-shadow: 0 8px 28px rgba(0,0,0,0.5);
}

/* Anchor the popover relative to the Read button wrapper */
.read-aloud-wrapper {
  position: relative;
  display: inline-flex;
}

#readAloudBtn {
  position: static;
}

/* === EXPORT DROPDOWN === */
.export-dropdown-wrapper {
  position: relative;
  display: inline-flex;
}

.export-chevron {
  font-size: 0.6rem !important;
  margin-left: 2px;
  opacity: 0.7;
  transition: transform 0.2s ease;
}

.export-dropdown-wrapper.open .export-chevron {
  transform: rotate(180deg);
}

.export-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: var(--bg-glass-card, #fff);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  border: 1px solid var(--border-glass);
  border-radius: 14px;
  box-shadow: 0 12px 36px rgba(0,0,0,0.16), 0 2px 8px rgba(90,24,154,0.1);
  z-index: 500;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

body.dark .export-dropdown {
  background: rgba(20,15,35,0.97);
  border-color: rgba(90,24,154,0.4);
  box-shadow: 0 12px 36px rgba(0,0,0,0.5);
}

.export-dropdown[hidden] { display: none; }

.export-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 13px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 9px;
  color: var(--color-text);
  font-family: inherit;
  text-align: left;
  transition: background 0.12s ease;
}

.export-option:hover {
  background: rgba(90,24,154,0.09);
  color: var(--color-primary);
}

body.dark .export-option:hover {
  background: rgba(90,24,154,0.22);
  color: var(--color-secondary);
}

.export-option i {
  font-size: 1rem;
  width: 18px;
  text-align: center;
  opacity: 0.8;
  flex-shrink: 0;
}

.export-option-label {
  font-size: 0.88rem;
  font-weight: 600;
  flex: 1;
}

.export-option-desc {
  font-size: 0.72rem;
  color: var(--color-soft-gray);
  white-space: nowrap;
}

.read-speed-popover-label {
  color: var(--color-soft-gray);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#readSpeedSlider {
  -webkit-appearance: none;
  appearance: none;
  width: 90px;
  height: 4px;
  border-radius: 4px;
  background: rgba(90,24,154,0.2);
  outline: none;
  cursor: pointer;
}

#readSpeedSlider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--color-primary);
  cursor: pointer;
  transition: transform 0.12s ease;
}

#readSpeedSlider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

#readSpeedSlider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--color-primary);
  border: none;
  cursor: pointer;
}

body.dark #readSpeedSlider {
  background: rgba(255,195,0,0.15);
}

body.dark #readSpeedSlider::-webkit-slider-thumb,
body.dark #readSpeedSlider::-moz-range-thumb {
  background: var(--color-secondary);
}

#readSpeedLabel {
  min-width: 26px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--color-primary);
}

body.dark #readSpeedLabel {
  color: var(--color-secondary);
}

.read-speed-start-btn {
  padding: 6px 14px !important;
  font-size: 0.78rem !important;
}
