/* ============================================================
   ScriptMate — Stylesheet
   Mobile-first, dark/light mode via prefers-color-scheme
   ============================================================ */

/* ── Reset & Base ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  /* Light mode tokens */
  --bg: #ffffff;
  --bg-secondary: #f5f5f7;
  --bg-card: #ffffff;
  --bg-card-hover: #f0f0f5;
  --border: #e0e0e5;
  --text: #1c1c1e;
  --text-secondary: #6e6e73;
  --text-muted: #aeaeb2;
  --accent: #007aff;
  --accent-light: #e8f0fe;
  --user-line-bg: #f0f4ff;
  --user-line-border: #b8caff;
  --scene-bg: #f5f5f7;
  --scene-text: #5e5ce6;
  --action-text: #6e6e73;
  --cue-text: #007aff;
  --reveal-bg: #ffffff;
  --tag-bg: #e8f0fe;
  --tag-text: #3a6ed4;
  --mode-bar-bg: #f5f5f7;
  --mode-active-bg: #ffffff;
  --mode-active-shadow: 0 1px 4px rgba(0,0,0,0.12);
  --modal-bg: #ffffff;
  --modal-scrim: rgba(0,0,0,0.4);
  --shadow-card: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --header-bg: rgba(255,255,255,0.85);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);

  --font-size-base: 17px;
  --font-size-small: 15px;
  --font-size-large: 20px;

  --radius: 12px;
  --radius-sm: 8px;
  --tap-min: 44px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0f0f;
    --bg-secondary: #1c1c1e;
    --bg-card: #1c1c1e;
    --bg-card-hover: #2c2c2e;
    --border: #2c2c2e;
    --text: #f5f5f7;
    --text-secondary: #aeaeb2;
    --text-muted: #6e6e73;
    --accent: #0a84ff;
    --accent-light: #0a2440;
    --user-line-bg: #0d1e38;
    --user-line-border: #1d3a6a;
    --scene-bg: #1c1c1e;
    --scene-text: #7d7aff;
    --action-text: #8e8e93;
    --cue-text: #0a84ff;
    --reveal-bg: #1c1c1e;
    --tag-bg: #0a2440;
    --tag-text: #6bb0ff;
    --mode-bar-bg: #1c1c1e;
    --mode-active-bg: #2c2c2e;
    --mode-active-shadow: 0 1px 4px rgba(0,0,0,0.4);
    --modal-bg: #1c1c1e;
    --modal-scrim: rgba(0,0,0,0.6);
    --shadow-card: 0 1px 3px rgba(0,0,0,0.4);
    --header-bg: rgba(15,15,15,0.85);
  }
}

html {
  height: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: var(--font-size-base);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100%;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Font size classes applied to body */
body.font-small { --font-size-base: 15px; }
body.font-medium { --font-size-base: 17px; }
body.font-large { --font-size-base: 20px; }

/* ── Screens ── */
.screen {
  display: none;
  flex-direction: column;
  min-height: 100dvh;
  min-height: 100vh;
  padding-top: var(--safe-top);
}

.screen.active {
  display: flex;
}

/* ── App Header ── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  padding-top: calc(12px + var(--safe-top));
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: calc(var(--tap-min) + 24px + var(--safe-top));
}

/* When screen has safe-top already applied, header doesn't double-add */
.screen .app-header {
  padding-top: 12px;
  min-height: calc(var(--tap-min) + 24px);
}

.app-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
}

.screen-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  flex: 1;
}

/* ── Buttons ── */
.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--tap-min);
  height: var(--tap-min);
  border: none;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.15s;
  flex-shrink: 0;
}

.btn-icon:active { background: var(--border); }
.btn-icon svg { width: 24px; height: 24px; }

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 16px;
  font-size: 17px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: opacity 0.15s;
  min-height: var(--tap-min);
}

.btn-primary:active { opacity: 0.8; }

.btn-text {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  font-size: 17px;
  font-weight: 600;
  color: var(--accent);
  background: transparent;
  border: none;
  cursor: pointer;
  min-height: var(--tap-min);
  border-radius: var(--radius-sm);
}

.btn-text:active { opacity: 0.6; }

.btn-text-sm {
  font-size: 14px;
  font-weight: 500;
  color: var(--accent);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  min-height: 32px;
}

.btn-text-sm:active { opacity: 0.6; }

/* ── Library Screen ── */
.library-main {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
}

.script-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.script-card {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: background 0.15s;
  position: relative;
  gap: 12px;
  min-height: 72px;
}

.script-card:active { background: var(--bg-card-hover); }

.script-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--accent);
}

.script-card-icon svg { width: 22px; height: 22px; }

.script-card-info {
  flex: 1;
  min-width: 0;
}

.script-card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.script-card-meta {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.script-card-delete {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 50%;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}

.script-card-delete:active {
  background: #ff3b301a;
  color: #ff3b30;
}

.script-card-delete svg { width: 18px; height: 18px; }

/* ── Empty state ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 24px;
  gap: 12px;
  flex: 1;
}

.empty-icon {
  width: 80px;
  height: 80px;
  color: var(--text-muted);
  opacity: 0.5;
}

.empty-icon svg { width: 100%; height: 100%; }

.empty-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-secondary);
}

.empty-sub {
  font-size: 15px;
  color: var(--text-muted);
  max-width: 260px;
  line-height: 1.4;
}

.empty-state .btn-primary {
  margin-top: 8px;
  width: auto;
  padding: 14px 28px;
}

/* ── PWA Banner ── */
.pwa-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  padding-bottom: calc(12px + var(--safe-bottom));
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  font-size: 14px;
  color: var(--text-secondary);
}

/* ── Upload Screen ── */
.upload-main {
  flex: 1;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.upload-options {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.upload-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 32px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
  text-align: center;
  color: var(--text);
  font-family: inherit;
  box-shadow: var(--shadow-card);
}

.upload-card:active { background: var(--bg-card-hover); }

.upload-card svg {
  width: 48px;
  height: 48px;
  color: var(--accent);
  opacity: 0.8;
}

.upload-card-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
}

.upload-card-sub {
  font-size: 14px;
  color: var(--text-secondary);
}

.upload-progress {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 32px;
  color: var(--text-secondary);
  font-size: 15px;
}

.upload-error {
  padding: 16px;
  background: #ff3b301a;
  border: 1px solid #ff3b3040;
  border-radius: var(--radius-sm);
  color: #ff3b30;
  font-size: 15px;
  line-height: 1.5;
}

/* Spinner */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ── Paste Screen ── */
.paste-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 8px;
  overflow-y: auto;
}

.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0 4px;
}

.text-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 17px;
  font-family: inherit;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
  min-height: var(--tap-min);
  margin-bottom: 8px;
}

.text-input:focus { border-color: var(--accent); }

.text-area {
  width: 100%;
  flex: 1;
  min-height: 300px;
  padding: 14px 16px;
  font-size: 15px;
  font-family: 'Menlo', 'SF Mono', 'Courier New', monospace;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  resize: none;
  line-height: 1.6;
  transition: border-color 0.15s;
}

.text-area:focus { border-color: var(--accent); }

/* ── Character Screen ── */
.character-main {
  flex: 1;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

.section-label {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.hint-text {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.character-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.character-chip {
  padding: 10px 18px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
  min-height: var(--tap-min);
  display: flex;
  align-items: center;
  font-family: inherit;
}

.character-chip.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.character-chip:active { opacity: 0.7; }

.character-actions {
  margin-top: 8px;
}

/* ── Rehearsal Screen ── */
.rehearsal-header {
  gap: 0;
}

.rehearsal-header-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
}

.rehearsal-header-center .screen-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  flex: none;
}

.character-badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--tag-text);
  background: var(--tag-bg);
  padding: 2px 8px;
  border-radius: 100px;
  letter-spacing: 0.3px;
  margin-top: 2px;
}

/* ── Mode Bar ── */
.mode-bar {
  display: flex;
  background: var(--mode-bar-bg);
  padding: 6px;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: calc(44px + 24px);  /* below header */
  z-index: 90;
}

.mode-tab {
  flex: 1;
  padding: 10px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  min-height: var(--tap-min);
}

.mode-tab.active {
  background: var(--mode-active-bg);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--mode-active-shadow);
}

/* ── Scene Bar ── */
.scene-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: calc(44px + 24px + var(--tap-min));
  z-index: 89;
}

.scene-label-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  flex: 1;
  justify-content: center;
  min-height: var(--tap-min);
}

.scene-label-btn:active { background: var(--border); }

/* ── Reveal Bar ── */
.reveal-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  padding: 4px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

/* ── Rehearsal Content ── */
.rehearsal-main {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding-bottom: calc(32px + var(--safe-bottom));
}

/* Scene heading */
.block-scene {
  font-size: 13px;
  font-weight: 700;
  color: var(--scene-text);
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 24px 0 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.block-scene:first-child {
  padding-top: 8px;
}

/* Action line */
.block-action {
  font-size: var(--font-size-base);
  color: var(--action-text);
  line-height: 1.6;
  padding: 4px 0 12px;
  font-style: italic;
}

/* Dialogue block */
.block-dialogue {
  margin-bottom: 20px;
}

.dialogue-character {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.dialogue-text {
  font-size: var(--font-size-base);
  line-height: 1.6;
  color: var(--text);
}

/* User's own dialogue */
.block-dialogue.is-user {
  background: var(--user-line-bg);
  border-left: 3px solid var(--user-line-border);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 10px 14px;
  margin-left: -4px;
}

.block-dialogue.is-user .dialogue-character {
  color: var(--accent);
}

/* Cue text */
.dialogue-text.is-cue {
  color: var(--cue-text);
  font-family: 'Menlo', 'SF Mono', 'Courier New', monospace;
  font-size: calc(var(--font-size-base) * 0.95);
  letter-spacing: 0.5px;
  cursor: pointer;
  padding: 4px 0;
  border-radius: 4px;
  transition: background 0.1s;
}

.dialogue-text.is-cue:active { background: var(--accent-light); }

/* Hidden text (test mode) */
.dialogue-text.is-hidden {
  cursor: pointer;
}

.reveal-placeholder {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  background: var(--bg-secondary);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-muted);
  font-style: normal;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 36px;
  user-select: none;
}

.reveal-placeholder:active {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

/* Parenthetical */
.dialogue-parenthetical {
  font-size: calc(var(--font-size-base) * 0.9);
  color: var(--text-secondary);
  font-style: italic;
  line-height: 1.5;
  margin-bottom: 2px;
}

/* ── Modals ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--modal-scrim);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  animation: fadeIn 0.2s ease;
}

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

.modal-sheet {
  width: 100%;
  background: var(--modal-bg);
  border-radius: 20px 20px 0 0;
  padding: 12px 0 calc(24px + var(--safe-bottom));
  max-height: 80vh;
  overflow-y: auto;
  animation: slideUp 0.25s cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-sheet--small {
  max-height: 40vh;
}

.modal-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 16px;
}

.modal-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  padding: 0 20px 12px;
  border-bottom: 1px solid var(--border);
}

.modal-list {
  padding: 8px 0;
}

.modal-item {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  font-size: 17px;
  color: var(--text);
  cursor: pointer;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  min-height: var(--tap-min);
  gap: 12px;
  transition: background 0.1s;
}

.modal-item:active { background: var(--bg-card-hover); }

.modal-item.active-scene {
  color: var(--accent);
  font-weight: 600;
}

.modal-item-num {
  font-size: 13px;
  color: var(--text-muted);
  min-width: 24px;
}

/* Font size options */
.font-size-options {
  display: flex;
  gap: 12px;
  padding: 16px 20px;
}

.font-size-btn {
  flex: 1;
  padding: 12px;
  font-size: 15px;
  font-weight: 500;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  min-height: var(--tap-min);
  transition: all 0.15s;
}

.font-size-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.font-size-btn:active { opacity: 0.7; }

/* ── Utilities ── */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
}

/* Smooth transitions for mode changes */
.rehearsal-main .block-dialogue {
  transition: background 0.2s;
}

/* ── Upload tip ── */
.upload-tip {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  padding: 4px 4px 0;
}

/* ── Review Text screen ── */
.review-text-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 12px;
  overflow-y: auto;
}

.review-text-actions {
  display: flex;
  gap: 8px;
}

.review-text-area {
  flex: 1;
  min-height: 280px;
  font-size: 13px;
  line-height: 1.6;
}

.btn-outline-sm {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  font-size: 15px;
  font-weight: 500;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  min-height: var(--tap-min);
  transition: background 0.15s;
}

.btn-outline-sm:active {
  background: var(--accent-light);
}

/* ── Review Blocks screen ── */
.review-blocks-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 12px;
  overflow-y: auto;
  padding-bottom: calc(24px + var(--safe-bottom));
}

.skip-link {
  align-self: flex-start;
  padding-left: 0;
  color: var(--text-secondary);
}

.blocks-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.block-review-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  box-shadow: var(--shadow-card);
  position: relative;
}

.block-review-text {
  flex: 1;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  min-width: 0;
  word-break: break-word;
}

.block-type-badge {
  flex-shrink: 0;
  padding: 3px 9px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: opacity 0.15s;
  white-space: nowrap;
}

.block-type-badge:active { opacity: 0.7; }

/* Badge colours */
.badge-scene    { background: #5e5ce620; color: var(--scene-text); }
.badge-character { background: #ff9f0a20; color: #b86800; }
.badge-dialogue { background: var(--bg-secondary); color: var(--text-secondary); border: 1px solid var(--border); }
.badge-action   { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.badge-parenthetical { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }

@media (prefers-color-scheme: dark) {
  .badge-character { background: #ff9f0a20; color: #ffb340; }
}

/* Block type dropdown */
.block-type-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 150;
  background: var(--modal-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  overflow: hidden;
  margin-top: 4px;
  min-width: 140px;
  animation: fadeIn 0.1s ease;
}

.block-type-option {
  display: block;
  width: 100%;
  padding: 12px 16px;
  font-size: 15px;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  min-height: var(--tap-min);
  transition: background 0.1s;
}

.block-type-option:active { background: var(--bg-card-hover); }
.block-type-option.selected { color: var(--accent); font-weight: 600; }

/* ── MY LINES mode ── */

/* Counter bar */
.mylines-counter-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* MY LINES feed entries */
.mylines-entry {
  margin-bottom: 28px;
}

.mylines-context {
  margin-bottom: 8px;
}

.mylines-context-block {
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  border-left: 2px solid var(--border);
}

.mylines-context-block + .mylines-context-block {
  border-top: 1px solid var(--border);
  border-radius: 0;
}

.mylines-context-block:last-child {
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.mylines-context-char {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.mylines-context-text {
  font-size: calc(var(--font-size-base) * 0.9);
  color: var(--text-secondary);
  line-height: 1.5;
}

.mylines-user-block {
  background: var(--user-line-bg);
  border: 1px solid var(--user-line-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.mylines-user-char {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}

.mylines-user-text {
  font-size: var(--font-size-base);
  line-height: 1.6;
  color: var(--text);
}

.mylines-user-text.is-cue {
  color: var(--cue-text);
  font-family: 'Menlo', 'SF Mono', 'Courier New', monospace;
  font-size: calc(var(--font-size-base) * 0.95);
  letter-spacing: 0.5px;
  cursor: pointer;
}

.mylines-user-text.is-hidden {
  cursor: pointer;
}

/* Show more context button */
.mylines-more-btn {
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px 0;
  font-family: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.mylines-more-btn:active { color: var(--text-secondary); }

/* Expanded context */
.mylines-expanded-context {
  margin-bottom: 8px;
}

/* Current line highlight */
.mylines-entry.is-current .mylines-user-block {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
}

/* Divider between entries */
.mylines-divider {
  height: 1px;
  background: var(--border);
  margin: 0 0 28px;
  opacity: 0.5;
}

/* Completion screen */
.mylines-done {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 24px;
  gap: 12px;
  flex: 1;
}

.mylines-done-emoji {
  font-size: 56px;
  line-height: 1;
}

.mylines-done-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.mylines-done-sub {
  font-size: 15px;
  color: var(--text-secondary);
}

.mylines-done .btn-primary {
  width: auto;
  padding: 14px 28px;
  margin-top: 8px;
}

/* MY LINES prev/next nav bar */
.mylines-nav {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  padding-bottom: calc(12px + var(--safe-bottom));
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.mylines-nav-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  min-height: var(--tap-min);
  transition: background 0.15s;
}

.mylines-nav-btn:active { background: var(--bg-card-hover); }
.mylines-nav-btn:disabled { opacity: 0.35; cursor: default; }
.mylines-nav-btn svg { width: 20px; height: 20px; }

.mylines-nav-btn--next {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.mylines-nav-btn--next:active { opacity: 0.85; background: var(--accent); }
.mylines-nav-btn--next:disabled { background: var(--accent); }

/* Rehearsal main needs padding-bottom adjustment when mylines-nav is shown */
.rehearsal-main.has-mylines-nav {
  padding-bottom: 0;
}

/* ── v1.2 Rehearsal header actions ── */
.rehearsal-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* Edit mode button */
.btn-edit-mode {
  color: var(--accent);
  font-weight: 600;
}

.btn-edit-mode.is-editing {
  color: var(--accent);
  background: var(--accent-light);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
}

/* Favourites star button in header */
.btn-fav {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 50%;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.btn-fav .star-svg { width: 20px; height: 20px; }

.btn-fav.is-on {
  color: #ff9f0a;
}

.btn-fav:active { background: var(--border); }

/* Filter label banner */
.filter-label {
  padding: 6px 16px;
  background: var(--accent-light);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
  text-align: center;
}

/* ── Scene indicator (sticky below header) ── */
.scene-indicator {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: calc(44px + 24px);
  z-index: 89;
}

.scene-indicator-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px 8px;
  min-height: var(--tap-min);
  font-family: inherit;
  overflow: hidden;
}

.scene-indicator-label span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scene-indicator-label:active { background: var(--border); }

/* ── Display mode bar (bottom cycle button) ── */
.display-mode-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  padding-bottom: calc(10px + var(--safe-bottom));
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.display-mode-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 28px;
  font-size: 15px;
  font-weight: 600;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 100px;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
  min-height: var(--tap-min);
  min-width: 140px;
  transition: all 0.15s;
}

.display-mode-btn.mode-cue {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

.display-mode-btn.mode-hidden {
  background: var(--bg-secondary);
  border-color: var(--border);
  color: var(--text-muted);
}

.display-mode-btn:active { opacity: 0.7; }

/* ── Star button on user dialogue lines ── */
.star-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 50%;
  color: var(--text-muted);
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.star-btn:active { background: var(--border); }

.star-btn .star-empty { display: block; }
.star-btn .star-filled { display: none; color: #ff9f0a; }

.star-btn.is-starred .star-empty { display: none; }
.star-btn.is-starred .star-filled { display: block; }

.star-btn svg { width: 18px; height: 18px; }

/* User dialogue block in full view — room for star */
.block-dialogue.is-user {
  position: relative;
  padding-right: 44px;
}

.block-dialogue.is-user .star-btn {
  position: absolute;
  top: 6px;
  right: 4px;
}

/* Edit mode badges on blocks */
.edit-mode-badge {
  display: inline-block;
  margin-top: 6px;
  vertical-align: top;
  cursor: pointer;
}

.block-scene .edit-mode-badge,
.block-action .edit-mode-badge {
  display: block;
  margin-top: 6px;
}

.block-dialogue .edit-mode-badge {
  display: block;
  margin-top: 4px;
}

/* ── Cover page section ── */
.cover-bar {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}

.cover-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
  min-height: var(--tap-min);
  text-align: left;
  gap: 8px;
}

.cover-toggle-btn:active { background: var(--border); }

.cover-toggle-chevron {
  font-size: 11px;
  transition: transform 0.2s;
}

.cover-bar.is-expanded .cover-toggle-chevron {
  transform: rotate(180deg);
}

.cover-content {
  display: none;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  white-space: pre-wrap;
  font-family: 'Menlo', 'SF Mono', 'Courier New', monospace;
  border-top: 1px solid var(--border);
}

.cover-bar.is-expanded .cover-content {
  display: block;
}

/* ── Scene list — user dot ── */
.scene-user-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  margin-left: auto;
}

/* ── Scene modal title row (with close button) ── */
.modal-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 12px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-title-row .modal-title {
  padding: 0;
  border-bottom: none;
  flex: 1;
}

.modal-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.15s;
}

.modal-close-btn:active { background: var(--border); }
.modal-close-btn svg { width: 18px; height: 18px; }

/* ── My Lines filtered view user-block header row ── */
.mylines-user-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.mylines-user-header .mylines-user-char {
  margin-bottom: 0;
}

/* ── Hint toast ── */
.hint-toast {
  position: fixed;
  bottom: calc(80px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.75);
  color: #fff;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 100px;
  white-space: nowrap;
  z-index: 300;
  pointer-events: none;
  animation: toastFadeIn 0.2s ease;
}

@keyframes toastFadeIn {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
