/* ═══════════════════════════════════════════════════════════
   ScreenplayAI — Collaborative Writing Platform
   Aesthetic: "Millennial's $1.2M Home"
   Restoration Hardware × Aesop × Kinfolk
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@300;400;500&family=Playfair+Display:ital,wght@0,400;0,600;1,400&display=swap');

:root {
  /* ── Surfaces ── */
  --bg-primary: #0a0a0a;
  --bg-secondary: #111111;
  --bg-tertiary: #171717;
  --bg-surface: #1a1a1a;
  --bg-elevated: #222222;
  --bg-editor: #0d0d0d;

  /* ── Text ── */
  --text: #f5f5f5;
  --text-secondary: #e5e5e5;
  --text-muted: #999999;
  --text-dim: #8a8a8a;
  --text-faint: #4a4a4a;

  /* ── Accent: Sage Green ── */
  --sage: #87A878;
  --sage-muted: #6B8F5E;
  --sage-light: #A3B899;
  --sage-faint: rgba(135, 168, 120, 0.08);
  --sage-glow: rgba(135, 168, 120, 0.15);

  /* ── Secondary: Warm Stone ── */
  --stone: #B8A99A;
  --stone-muted: #9A8D80;
  --stone-faint: rgba(184, 169, 154, 0.1);

  /* ── Semantic ── */
  --success: #87A878;
  --danger: #C4746E;
  --danger-faint: rgba(196, 116, 110, 0.12);
  --warning: #C4A94D;
  --warning-faint: rgba(196, 169, 77, 0.1);

  /* ── Borders ── */
  --border: #1f1f1f;
  --border-subtle: #181818;
  --border-hover: #2a2a2a;
  --border-active: #333333;

  /* ── Typography ── */
  --font-display: 'Playfair Display', Georgia, serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;

  /* ── Layout ── */
  --sidebar-width: 240px;
  --chat-width: 480px;

  /* ── Motion ── */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --duration-fast: 150ms;
  --duration-normal: 250ms;
  --duration-slow: 400ms;
}

/* ═══════════════════════════════════════════════════════════
   LIGHT THEME — "Warm Ink"
   Cream paper, warm stone accents, amber highlights
   Based on Notes & Writing App palette from UI/UX Pro Max
   ═══════════════════════════════════════════════════════════ */

[data-theme="light"] {
  /* ── Surfaces ── */
  --bg-primary: #FAFAF7;
  --bg-secondary: #F5F5F0;
  --bg-tertiary: #EEEEE8;
  --bg-surface: #FFFFFF;
  --bg-elevated: #FFFFFF;
  --bg-editor: #FFFFF8;

  /* ── Text ── */
  --text: #1a1a1a;
  --text-secondary: #2d2d2d;
  --text-muted: #44494f;
  --text-dim: #5a6069;
  --text-faint: #7d838c;

  /* ── Accent: Sage Green (darkened for light bg) ── */
  --sage: #4d7c3f;
  --sage-muted: #3d6b32;
  --sage-light: #6b9a5c;
  --sage-faint: rgba(77, 124, 63, 0.08);
  --sage-glow: rgba(77, 124, 63, 0.12);

  /* ── Secondary: Warm Stone ── */
  --stone: #78716C;
  --stone-muted: #57534E;
  --stone-faint: rgba(120, 113, 108, 0.08);

  /* ── Semantic ── */
  --success: #16a34a;
  --danger: #dc2626;
  --danger-faint: rgba(220, 38, 38, 0.08);
  --warning: #d97706;
  --warning-faint: rgba(217, 119, 6, 0.08);

  /* ── Borders ── */
  --border: #d4d4cf;
  --border-subtle: #e5e5e0;
  --border-hover: #b8b8b2;
  --border-active: #a3a39e;

  color-scheme: light;
}

/* Light mode overrides for specific components */
[data-theme="light"] ::selection {
  background: rgba(77, 124, 63, 0.2);
  color: #1a1a1a;
}

[data-theme="light"] ::-webkit-scrollbar-thumb {
  background: #c4c4bf;
}

[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
  background: #a3a39e;
}

/* Light mode CodeMirror overrides */
[data-theme="light"] .cm-editor {
  background-color: #FFFFF8 !important;
  color: #1a1a1a !important;
}
[data-theme="light"] .cm-content {
  caret-color: #1a1a1a !important;
}
[data-theme="light"] .cm-cursor {
  border-left-color: #1a1a1a !important;
}
[data-theme="light"] .cm-activeLine {
  background-color: rgba(0, 0, 0, 0.03) !important;
}
[data-theme="light"] .cm-sp-scene-heading {
  color: #1a1a1a !important;
}
[data-theme="light"] .cm-sp-action {
  color: #2d2d2d !important;
}
[data-theme="light"] .cm-sp-character {
  color: #4d7c3f !important;
}
[data-theme="light"] .cm-sp-dialogue {
  color: #2d2d2d !important;
}
[data-theme="light"] .cm-sp-parenthetical {
  color: #6b7280 !important;
}
[data-theme="light"] .cm-sp-transition {
  color: #6b7280 !important;
}
[data-theme="light"] .cm-sp-note {
  color: #78716C !important;
  background: rgba(120, 113, 108, 0.08) !important;
}
[data-theme="light"] .cm-selectionBackground,
[data-theme="light"] .cm-editor.cm-focused .cm-selectionBackground {
  background-color: rgba(77, 124, 63, 0.15) !important;
}
[data-theme="light"] .cm-tooltip-autocomplete {
  background-color: #fff !important;
  border-color: #e5e5e0 !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1) !important;
}
[data-theme="light"] .cm-tooltip-autocomplete ul li {
  color: #2d2d2d !important;
}
[data-theme="light"] .cm-tooltip-autocomplete ul li[aria-selected] {
  background-color: rgba(77, 124, 63, 0.1) !important;
  color: #4d7c3f !important;
}

/* Light mode page centering */
[data-theme="light"] .editor-area.page-centered .editor-body {
  background: #EEEEE8;
}
[data-theme="light"] .editor-area.page-centered .editor-wrapper {
  background: #FFFFF8;
  border-color: #e5e5e0;
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.01em;
}

#app { height: 100vh; display: flex; flex-direction: column; }

/* ── Selection ── */
::selection {
  background: var(--sage-glow);
  color: var(--text);
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-faint); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ── Focus ── */
:focus-visible {
  outline: 1.5px solid var(--sage);
  outline-offset: 2px;
}

.btn:focus-visible,
.btn-icon:focus-visible,
.view-btn:focus-visible,
.font-size-btn:focus-visible {
  outline: 2px solid var(--sage);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--sage-faint);
}

.binder-item:focus-visible {
  outline: 2px solid var(--sage);
  outline-offset: -2px;
  background: var(--sage-faint);
}

.corkboard-card:focus-visible {
  outline: 2px solid var(--sage);
  outline-offset: 2px;
}

.editor-tab:focus-visible {
  outline: 2px solid var(--sage);
  outline-offset: -2px;
}

/* ── Active Line Highlight (dark mode) ── */
.cm-activeLine {
  background-color: rgba(255, 255, 255, 0.02) !important;
}

/* ═══════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════ */

.btn {
  padding: 8px 18px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-family: var(--font-sans);
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: all var(--duration-fast) var(--ease-out);
  line-height: 1.4;
}

.btn-primary {
  background: var(--sage);
  color: #0a0a0a;
}
.btn-primary:hover {
  background: var(--sage-light);
}

.btn-secondary {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-hover);
}
.btn-secondary:hover {
  color: var(--text);
  border-color: var(--border-active);
  background: var(--bg-surface);
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
}
.btn-ghost:hover {
  color: var(--text-muted);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(196, 116, 110, 0.2);
}
.btn-danger:hover {
  background: var(--danger-faint);
}

.btn-small { padding: 4px 10px; font-size: 12px; }
.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  padding: 6px;
  min-width: 32px;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color var(--duration-fast) var(--ease-out);
}
.btn-icon:hover { color: var(--text-muted); }

/* ── SVG Icon base ── */
.icon {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 1.5;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
  vertical-align: middle;
}
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 20px; height: 20px; }

/* ═══════════════════════════════════════════════════════════
   INPUTS
   ═══════════════════════════════════════════════════════════ */

input, textarea, select {
  background: var(--bg-primary);
  color: var(--text);
  border: 1px solid var(--border-hover);
  border-radius: 4px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: var(--font-sans);
  width: 100%;
  outline: none;
  transition: border-color var(--duration-fast) var(--ease-out);
  letter-spacing: -0.01em;
}

input::placeholder, textarea::placeholder {
  color: var(--text-faint);
}

input:focus, textarea:focus, select:focus {
  border-color: var(--sage-muted);
}

/* ═══════════════════════════════════════════════════════════
   AUTH SCREENS
   ═══════════════════════════════════════════════════════════ */

.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: var(--bg-primary);
  position: relative;
}

/* Subtle texture grain */
.auth-container::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(135, 168, 120, 0.03) 0%, transparent 60%);
  pointer-events: none;
}

.auth-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 48px;
  width: 400px;
  max-width: 90vw;
  position: relative;
  z-index: 1;
}

.auth-card h1 {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 400;
  margin-bottom: 4px;
  color: var(--text);
  letter-spacing: -0.02em;
}

.auth-card .subtitle {
  color: var(--text-dim);
  margin-bottom: 32px;
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.02em;
}

.auth-card .logo {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  margin-bottom: 32px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 500;
}

.auth-card .btn-primary {
  width: 100%;
  padding: 12px;
  font-size: 13px;
  margin-top: 8px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.auth-card .toggle-link {
  display: block;
  text-align: center;
  margin-top: 24px;
  color: var(--text-dim);
  font-size: 13px;
}

.auth-card .toggle-link a {
  color: var(--sage);
  cursor: pointer;
  text-decoration: none;
  transition: color var(--duration-fast);
}

.auth-card .toggle-link a:hover {
  color: var(--sage-light);
}

.auth-error {
  background: var(--danger-faint);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 13px;
  margin-bottom: 20px;
  display: none;
  border: 1px solid rgba(196, 116, 110, 0.15);
}

/* ═══════════════════════════════════════════════════════════
   DASHBOARD
   ═══════════════════════════════════════════════════════════ */

.dashboard {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.dashboard-header .logo {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

/* Version badge — small monospaced "v0.0.1" stamped next to every logo so
   the writer (and anyone debugging a deploy) can see at a glance which
   build is running. The slot inherits the logo's caps + letter-spacing,
   so the badge has to explicitly reset both. */
.app-version-slot { display: inline-flex; }
.app-version-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 6px;
  border: 1px solid var(--border-subtle, var(--border));
  border-radius: 999px;
  background: var(--bg-elevated, var(--bg-surface));
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  vertical-align: middle;
  user-select: none;
}

.dashboard-header .user-info {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--text-dim);
  font-size: 13px;
}

.dashboard-content {
  flex: 1;
  overflow-y: auto;
  padding: 48px 32px;
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
}

.dashboard-content h2 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 400;
  margin-bottom: 32px;
  letter-spacing: -0.02em;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.project-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 24px;
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-out);
}

.project-card:hover {
  border-color: var(--border-active);
  background: var(--bg-surface);
}

.project-card h3 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 400;
  margin-bottom: 10px;
  letter-spacing: -0.01em;
}

.project-card .meta {
  color: var(--text-dim);
  font-size: 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.project-card .role-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--sage-faint);
  color: var(--sage);
  font-weight: 500;
}

/* "Adapting…" pill: shown on cards whose pipeline is mid-flight. Click reopens
   the adaptation modal so the writer can watch progress without entering the
   project. Animated dot reinforces "still working." */
.project-card .adapting-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border: 1px solid rgba(135, 168, 120, 0.3);
  border-radius: 999px;
  background: var(--sage-faint);
  color: var(--sage);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background var(--duration-fast), border-color var(--duration-fast);
}
.project-card .adapting-pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--sage);
  animation: pulse-dot 1.6s ease-in-out infinite;
}
.project-card .adapting-pill:hover {
  background: rgba(135, 168, 120, 0.18);
  border-color: rgba(135, 168, 120, 0.5);
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* Danger variant of btn-icon: tints red on hover. Used for the trash icon
   on project cards. */
.btn-icon-danger:hover {
  color: var(--danger, #c4746e);
  background: rgba(192, 57, 43, 0.08);
}

/* ═══════════════════════════════════════════════════════════
   WORKSPACE LAYOUT
   ═══════════════════════════════════════════════════════════ */

.workspace {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.workspace-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  min-height: 44px;
}

.workspace-header .left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.workspace-header .logo {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  cursor: pointer;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  transition: color var(--duration-fast);
}

.workspace-header .logo:hover {
  color: var(--text-muted);
}

.workspace-header .project-title {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 400;
}

.workspace-header .right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.workspace-header .right .btn-ghost {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 4px;
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.workspace-header .right .btn-ghost:hover {
  color: var(--text-muted);
  background: var(--bg-surface);
}

.header-divider {
  width: 1px;
  height: 16px;
  background: var(--border);
  margin: 0 4px;
  flex-shrink: 0;
}

.header-dropdown {
  position: relative;
  display: inline-flex;
}

.header-dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-hover);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  padding: 4px 0;
  min-width: 180px;
  z-index: 1000;
  animation: fadeIn var(--duration-fast) var(--ease-out);
}

.dropdown-item {
  padding: 7px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--duration-fast);
}

.dropdown-item:hover {
  background: var(--sage-faint);
  color: var(--sage);
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.workspace-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width);
  min-width: 180px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Sidebar tab switcher */
.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-tab {
  flex: 1;
  background: none;
  border: none;
  padding: 8px 0;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  cursor: pointer;
  transition: all var(--duration-fast);
  border-bottom: 2px solid transparent;
}

.sidebar-tab:hover {
  color: var(--text-muted);
  background: var(--bg-tertiary);
}

.sidebar-tab.active {
  color: var(--sage);
  border-bottom-color: var(--sage);
}

.sidebar-tab-panel {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.sidebar-tab-panel.active {
  display: flex;
}

.sidebar-files-toolbar {
  display: flex;
  gap: 4px;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border-subtle);
  justify-content: flex-end;
}

.sidebar-resize-handle {
  width: 5px;
  cursor: col-resize;
  background: transparent;
  flex-shrink: 0;
  transition: background var(--duration-fast);
}
.sidebar-resize-handle:hover,
.sidebar-resize-handle:active {
  background: var(--sage-muted);
}

.sidebar-section {
  border-bottom: 1px solid var(--border);
}

.sidebar-section-header {
  padding: 12px 16px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  transition: color var(--duration-fast);
}

.sidebar-section-header:hover { color: var(--text-muted); }

.sidebar-section-body {
  overflow-y: auto;
}

.file-item {
  padding: 6px 16px 6px 20px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
  transition: all var(--duration-fast) var(--ease-out);
  white-space: nowrap;
}

.file-item:hover {
  color: var(--text-muted);
  background: rgba(255,255,255, 0.02);
}

.file-item.active {
  color: var(--text);
  background: var(--sage-faint);
  border-left: 2px solid var(--sage);
}

.file-icon {
  font-size: 13px;
  flex-shrink: 0;
  color: var(--text-faint);
  width: 16px;
  text-align: center;
}

.file-item.active .file-icon { color: var(--sage-muted); }

.file-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-delete-btn {
  opacity: 0;
  font-size: 16px;
  line-height: 1;
  padding: 0 4px;
  border-radius: 3px;
  cursor: pointer;
  flex-shrink: 0;
  color: var(--text-dim);
  transition: opacity 0.15s ease;
}
.file-item:hover .file-delete-btn { opacity: 0.4; }
.file-delete-btn:hover { opacity: 1 !important; color: #f66; }

.file-context-menu {
  position: fixed;
  background: var(--bg-tertiary, #2a2a2a);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 0;
  min-width: 140px;
  z-index: 9999;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.ctx-item {
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
}
.ctx-item:hover { background: rgba(255,255,255,0.06); }
.ctx-danger { color: #f66; }
.ctx-danger:hover { background: rgba(255,80,80,0.1); }

.undo-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-tertiary, #2a2a2a);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 9999;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  animation: toast-in 0.2s ease-out;
}
.undo-toast-btn {
  background: var(--sage, #7c9a72);
  color: #fff;
  border: none;
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
}
.undo-toast-btn:hover { filter: brightness(1.15); }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Main editor area ── */
.main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-editor);
}

.editor-tabs {
  display: flex;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  min-height: 36px;
}

.editor-tab {
  padding: 8px 16px;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  border-right: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: all var(--duration-fast) var(--ease-out);
  font-weight: 400;
}

.editor-tab:hover { color: var(--text-muted); }

.editor-tab.active {
  color: var(--text);
  background: var(--bg-editor);
  border-bottom: 1.5px solid var(--sage);
}

.editor-tab .close {
  font-size: 14px;
  opacity: 0.3;
  transition: opacity var(--duration-fast);
  line-height: 1;
}
.editor-tab .close:hover { opacity: 0.8; color: var(--danger); }

.editor-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.editor-wrapper {
  height: 100%;
  overflow: auto;
  padding: 0;
  position: relative;
}

/* Fountain editor textarea */
.fountain-editor {
  width: 100%;
  min-height: 100%;
  background: var(--bg-editor);
  color: var(--text-secondary);
  border: none;
  padding: 32px 40px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  outline: none;
  tab-size: 4;
  white-space: pre-wrap;
  letter-spacing: 0;
  font-weight: 400;
}

/* Screenplay mode: center the text area, constrain width like a page */
.screenplay-mode-active .fountain-editor {
  max-width: 680px;
  margin: 0 auto;
}

/* CodeMirror container — fills the editor wrapper */
.cm-editor-container {
  height: 100%;
  overflow: hidden;
}

.cm-editor-container .cm-editor {
  height: 100%;
}

.cm-editor-container .cm-scroller {
  overflow: auto;
}

/* Centered screenplay page mode — simulates 8.5" page at 96 DPI (816px)
   Left margin: 1.5" (144px), Right margin: 1.0" (96px)
   Text area: 6.0" (576px) = 60 chars of Courier 12pt */
.editor-area.page-centered .editor-body {
  background: #060606;
  justify-content: center;
}

.editor-area.page-centered .editor-wrapper {
  max-width: 816px;
  background: #111;
  border-left: 1px solid #1f1f1f;
  border-right: 1px solid #1f1f1f;
  box-shadow: 0 0 40px rgba(0,0,0,0.5);
}

/* ═══════════════════════════════════════════════════════════
   E-INK / PAPER MODE — toggleable warm paper aesthetic
   ═══════════════════════════════════════════════════════════ */

.editor-area.eink-mode .editor-wrapper {
  background: #f5f0e8;
}

.editor-area.eink-mode .fountain-editor {
  background: #f5f0e8;
  color: #1a1410;
}

.editor-area.eink-mode .cm-editor {
  background-color: #f5f0e8 !important;
  color: #1a1410 !important;
}

.editor-area.eink-mode .cm-content {
  caret-color: #1a1410 !important;
}

.editor-area.eink-mode .cm-cursor {
  border-left-color: #1a1410 !important;
}

.editor-area.eink-mode .cm-activeLine {
  background-color: rgba(0, 0, 0, 0.04) !important;
}

.editor-area.eink-mode .cm-sp-scene-heading {
  color: #1a1410 !important;
  font-weight: 700 !important;
}

.editor-area.eink-mode .cm-sp-character {
  color: #3d5a2e !important;
}

.editor-area.eink-mode .cm-sp-dialogue {
  color: #2a2420 !important;
}

.editor-area.eink-mode .cm-sp-parenthetical {
  color: #5a5248 !important;
}

.editor-area.eink-mode .cm-sp-transition {
  color: #5a5248 !important;
}

.editor-area.eink-mode .cm-sp-action {
  color: #2a2420 !important;
}

.editor-area.eink-mode .cm-sp-note {
  color: #78716C !important;
  background: rgba(120, 113, 108, 0.08) !important;
}

.editor-area.eink-mode .cm-selectionBackground,
.editor-area.eink-mode .cm-editor.cm-focused .cm-selectionBackground {
  background-color: rgba(77, 124, 63, 0.15) !important;
}

/* Reduce chrome in eink mode */
.editor-area.eink-mode .editor-status {
  background: #eee8dc;
  border-top-color: #ddd5c8;
  color: #5a5248;
}

.editor-area.eink-mode .editor-status .font-size-btn {
  color: #5a5248;
  border-color: #ddd5c8;
}

.editor-area.eink-mode .editor-status .editor-meta,
.editor-area.eink-mode .editor-status span {
  color: #78716c;
}

/* Page-centered + eink combo */
.editor-area.eink-mode.page-centered .editor-body {
  background: #e8e0d4;
}

.editor-area.eink-mode.page-centered .editor-wrapper {
  background: #f5f0e8;
  border-color: #ddd5c8;
  box-shadow: 0 2px 20px rgba(0,0,0,0.08);
}

/* E-Ink toggle button active state */
.eink-toggle.active {
  background: var(--sage-faint);
  color: var(--sage);
  border-color: var(--sage-muted);
}

/* ═══════════════════════════════════════════════════════════
   VIEW TRANSITIONS — crossfade between binder/corkboard/outliner
   ═══════════════════════════════════════════════════════════ */

.corkboard-container,
.outliner-container {
  transition: opacity var(--duration-normal) var(--ease-in-out);
}

.corkboard-container.view-entering,
.outliner-container.view-entering {
  animation: viewFadeIn var(--duration-normal) var(--ease-out);
}

@keyframes viewFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════════════════════════
   SIDEBAR SECTION COLLAPSE ANIMATION
   ═══════════════════════════════════════════════════════════ */

.sidebar-section-body {
  transition: max-height var(--duration-normal) var(--ease-out),
              opacity var(--duration-fast) var(--ease-out);
}

.sidebar-section-body.collapsed {
  max-height: 0 !important;
  opacity: 0;
  overflow: hidden;
}

/* ═══════════════════════════════════════════════════════════
   EMPTY STATE HINT — shown when a new fountain file is opened
   ═══════════════════════════════════════════════════════════ */

.editor-empty-hint {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: var(--text-dim);
  z-index: 2;
  max-width: 420px;
  pointer-events: none;
  opacity: 0.8;
}

.editor-empty-hint h3 {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.editor-empty-hint code {
  background: var(--bg-elevated);
  padding: 2px 8px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--sage);
}

.editor-empty-hint kbd {
  background: var(--bg-elevated);
  border: 1px solid var(--border-hover);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 12px;
}

.editor-empty-hint p {
  margin: 8px 0;
  font-size: 13px;
  line-height: 1.6;
}

/* ═══════════════════════════════════════════════════════════
   KEYBOARD SHORTCUTS MODAL
   ═══════════════════════════════════════════════════════════ */

.shortcuts-modal {
  max-width: 480px;
}

.shortcuts-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin: 16px 0;
}

.shortcut-group h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 8px;
  font-weight: 500;
}

.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.shortcut-row kbd {
  background: var(--bg-elevated);
  border: 1px solid var(--border-hover);
  padding: 2px 8px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  min-width: 32px;
  text-align: center;
}

/* Markdown rendered preview */
.md-preview {
  width: 100%;
  min-height: 100%;
  background: var(--bg-editor);
  color: var(--text-secondary);
  padding: 32px 40px;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.8;
  overflow-y: auto;
  max-width: 800px;
}
.md-preview h1, .md-preview h2, .md-preview h3 {
  font-family: 'Playfair Display', serif;
  color: var(--text);
  margin: 1.5em 0 0.6em;
  line-height: 1.3;
}
.md-preview h1 { font-size: 1.8em; border-bottom: 1px solid var(--border); padding-bottom: 0.3em; }
.md-preview h2 { font-size: 1.4em; border-bottom: 1px solid var(--border-subtle); padding-bottom: 0.25em; }
.md-preview h3 { font-size: 1.15em; }
.md-preview p { margin: 0.8em 0; }
.md-preview strong { color: var(--text); font-weight: 600; }
.md-preview em { color: var(--stone); }
.md-preview ul, .md-preview ol { padding-left: 1.5em; margin: 0.6em 0; }
.md-preview li { margin: 0.3em 0; }
.md-preview li::marker { color: var(--sage-muted); }
.md-preview code {
  background: var(--bg-elevated);
  padding: 0.15em 0.4em;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.9em;
  color: var(--sage-light);
}
.md-preview pre {
  background: var(--bg-tertiary);
  padding: 16px;
  border-radius: 6px;
  overflow-x: auto;
  border: 1px solid var(--border);
}
.md-preview pre code { background: none; padding: 0; }
.md-preview blockquote {
  border-left: 3px solid var(--sage-muted);
  padding-left: 16px;
  margin: 1em 0;
  color: var(--text-muted);
  font-style: italic;
}
.md-preview hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2em 0;
}
.md-preview a { color: var(--sage); text-decoration: none; }
.md-preview a:hover { text-decoration: underline; }
.md-preview del { color: var(--text-dim); }

/* Font size controls */
.font-size-btn {
  background: var(--bg-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-family: var(--font-sans);
  transition: all 0.15s ease;
}
.font-size-btn:hover {
  color: var(--text);
  border-color: var(--border-hover);
  background: var(--bg-tertiary);
}
.editor-meta {
  color: var(--text-dim);
  font-size: 11px;
  min-width: 32px;
  text-align: center;
}

/* Fountain syntax highlighting overlay — must match .fountain-editor exactly */
.fountain-highlighted {
  width: 100%;
  min-height: 100%;
  box-sizing: border-box;
  padding: 32px 40px;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Screenplay indentation: proportional to 60-char screenplay page
   Character ~37%, Dialogue ~17%, Parenthetical ~27%, Transition right */

.fountain-highlighted .scene-heading {
  color: var(--text);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.fountain-highlighted .character {
  color: var(--sage);
  text-transform: uppercase;
  margin-left: 37%;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.fountain-highlighted .dialogue {
  margin-left: 17%;
  margin-right: 20%;
  color: var(--text-secondary);
}

.fountain-highlighted .parenthetical {
  color: var(--text-dim);
  font-style: italic;
  margin-left: 27%;
  margin-right: 30%;
}

.fountain-highlighted .transition {
  color: var(--text-muted);
  text-align: right;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.fountain-highlighted .note {
  color: var(--stone);
  background: var(--stone-faint);
  padding: 2px 6px;
  border-radius: 3px;
}

.fountain-highlighted .section {
  color: var(--text);
  font-size: 18px;
  font-weight: 600;
  margin-top: 8px;
  letter-spacing: 0.02em;
}

.fountain-highlighted .synopsis-line {
  color: var(--text-faint);
  font-style: italic;
}

.fountain-highlighted .centered {
  text-align: center;
}

.fountain-highlighted .page-break {
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* Editor status bar */
.editor-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 16px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 400;
  letter-spacing: 0.01em;
}

.editor-status .save-status {
  display: flex;
  align-items: center;
  gap: 6px;
}
.editor-status .save-status.saving { color: var(--warning); }
.editor-status .save-status.saved { color: var(--sage-muted); }

/* ═══════════════════════════════════════════════════════════
   CHAT PANEL
   ═══════════════════════════════════════════════════════════ */

.chat-resize-handle {
  width: 6px;
  cursor: col-resize;
  background: var(--border-hover);
  flex-shrink: 0;
  position: relative;
  z-index: 5;
  transition: background var(--duration-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Grip dots in the center */
.chat-resize-handle::after {
  content: '··';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  writing-mode: vertical-lr;
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--text-faint);
  pointer-events: none;
}

/* Wider invisible hit area so it's easy to grab */
.chat-resize-handle::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: -8px;
  right: -8px;
  cursor: col-resize;
}

.chat-resize-handle:hover,
.chat-resize-handle.dragging {
  background: var(--sage-muted);
}

.chat-resize-handle:hover::after,
.chat-resize-handle.dragging::after {
  color: white;
}

.chat-panel {
  width: var(--chat-width);
  min-width: 280px;
  max-width: 1200px;
  flex-shrink: 0;
  background: var(--bg-tertiary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.chat-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-message {
  max-width: 90%;
  position: relative;
}

.msg-delete-btn {
  position: absolute;
  bottom: 4px;
  right: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--duration-fast), color var(--duration-fast), background var(--duration-fast);
  padding: 0;
}

.chat-message:hover .msg-delete-btn {
  opacity: 1;
}

.msg-delete-btn:hover {
  color: var(--error, #c0392b);
  background: rgba(192, 57, 43, 0.08);
}

.chat-message .author {
  font-size: 11px;
  color: var(--sage);
  font-weight: 500;
  margin-bottom: 3px;
  letter-spacing: 0.02em;
}

.chat-message .text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
  background: var(--bg-surface);
  padding: 10px 14px;
  border-radius: 6px;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  min-width: 0;
  max-width: 100%;
  border: 1px solid var(--border);
}

.chat-message .text p { margin: 0; }
.chat-message .text p + p { margin-top: 6px; }

.chat-message .text pre,
.chat-message .text code {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  max-width: 100%;
  box-sizing: border-box;
}
.chat-message .text pre {
  background: var(--bg-tertiary);
  padding: 8px 10px;
  border-radius: 4px;
  font-size: 11.5px;
  line-height: 1.45;
  margin: 6px 0;
  overflow-x: auto;
}
.chat-message .text ul,
.chat-message .text ol {
  padding-left: 1.2em;
  margin: 4px 0;
}
.chat-message .text li { margin: 2px 0; }

.chat-message .time {
  font-size: 10px;
  color: var(--text-faint);
  margin-top: 4px;
}

.chat-message.own .text {
  background: var(--sage-faint);
  border-color: rgba(135, 168, 120, 0.12);
}

.chat-message .file-ref {
  font-size: 11px;
  color: var(--stone);
  cursor: pointer;
  margin-top: 3px;
  transition: color var(--duration-fast);
}

.chat-message .file-ref:hover { color: var(--stone-muted); text-decoration: underline; }

.chat-typing {
  padding: 4px 16px;
  font-size: 11px;
  color: var(--text-faint);
  font-style: italic;
  min-height: 20px;
}

.chat-input-area {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.chat-input-area textarea {
  flex: 1;
  resize: none;
  min-height: 36px;
  max-height: 100px;
  padding: 8px 14px;
  font-size: 13px;
  border-radius: 6px;
  background: var(--bg-surface);
  border-color: var(--border);
}

/* Bot mode toggle */
.bot-toggle {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s ease;
}
.bot-toggle:hover {
  border-color: var(--border-hover);
  color: var(--text-muted);
}
.bot-toggle.active {
  background: var(--sage-faint);
  border-color: var(--sage-muted);
  color: var(--sage);
}
.bot-toggle.active .bot-toggle-icon {
  font-weight: 700;
}
.bot-toggle-icon {
  font-size: 11px;
  font-family: var(--font-sans);
  font-weight: 600;
  letter-spacing: -0.02em;
}
.bot-mode-hint {
  font-size: 11px;
  color: var(--sage);
  padding: 0 4px;
  animation: fadeIn 0.15s ease;
}

/* File @ autocomplete */
.file-autocomplete {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin: 0 16px;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.3);
}
.ac-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.1s ease;
}
.ac-item:hover, .ac-item.active {
  background: var(--sage-faint);
}
.ac-item .file-icon { font-size: 12px; flex-shrink: 0; }
.ac-name { color: var(--text); }
.ac-path { color: var(--text-dim); font-size: 11px; margin-left: auto; }

.chat-input-area textarea:focus {
  border-color: var(--sage-muted);
}

.chat-input-area .btn {
  border-radius: 6px;
  padding: 8px 16px;
}

/* ═══════════════════════════════════════════════════════════
   PRESENCE BAR
   ═══════════════════════════════════════════════════════════ */

.presence-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 4px 16px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  font-size: 11px;
  min-height: 28px;
  overflow-x: auto;
}

.presence-user {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  color: var(--text-dim);
}

.presence-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--sage);
}

.presence-user .file-info { color: var(--text-faint); }

/* ═══════════════════════════════════════════════════════════
   VERSION HISTORY PANEL
   ═══════════════════════════════════════════════════════════ */

.version-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.version-panel-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

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

.version-item {
  padding: 12px 14px;
  border-radius: 4px;
  cursor: pointer;
  margin-bottom: 2px;
  transition: background var(--duration-fast) var(--ease-out);
}

.version-item:hover { background: rgba(255,255,255, 0.02); }

.version-item.selected {
  background: var(--sage-faint);
  border: 1px solid rgba(135, 168, 120, 0.15);
}

.version-item .version-meta {
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
}

.version-item .version-label {
  font-size: 11px;
  color: var(--stone);
  margin-top: 3px;
}

.version-item .version-author {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.version-diff {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  overflow-y: auto;
  max-height: 50%;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
}

.diff-add {
  background: rgba(135, 168, 120, 0.1);
  color: var(--sage);
}
.diff-del {
  background: var(--danger-faint);
  color: var(--danger);
  text-decoration: line-through;
}
.diff-equal { color: var(--text-dim); }

/* ═══════════════════════════════════════════════════════════
   MARKDOWN PANEL
   ═══════════════════════════════════════════════════════════ */

.markdown-panel {
  padding: 32px 40px;
  overflow-y: auto;
  height: 100%;
}

.markdown-panel h1, .markdown-panel h2, .markdown-panel h3 {
  margin-top: 20px;
  margin-bottom: 10px;
  font-family: var(--font-display);
  font-weight: 400;
}
.markdown-panel h1 {
  font-size: 24px;
  color: var(--text);
  letter-spacing: -0.02em;
}
.markdown-panel h2 {
  font-size: 20px;
  color: var(--text-secondary);
}
.markdown-panel h3 {
  font-size: 16px;
  color: var(--sage);
  font-family: var(--font-sans);
  font-weight: 500;
}
.markdown-panel p {
  margin-bottom: 10px;
  line-height: 1.7;
  color: var(--text-secondary);
}
.markdown-panel ul, .markdown-panel ol { margin-left: 20px; margin-bottom: 10px; }
.markdown-panel li { margin-bottom: 4px; line-height: 1.6; color: var(--text-secondary); }

.markdown-panel blockquote {
  border-left: 2px solid var(--sage-muted);
  padding-left: 16px;
  color: var(--text-dim);
  margin: 12px 0;
  font-style: italic;
}

.markdown-panel code {
  background: var(--bg-surface);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 13px;
  font-family: var(--font-mono);
  color: var(--stone);
}

.markdown-panel strong { color: var(--text); font-weight: 600; }
.markdown-panel em { color: var(--sage); font-style: italic; }

.markdown-panel hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

/* ═══════════════════════════════════════════════════════════
   BINDER (Scrivener-style outline)
   ═══════════════════════════════════════════════════════════ */

.binder-section {
  flex: 1;
  overflow-y: auto;
}

.binder-item {
  padding: 3px 6px 3px 8px;
  font-size: 13px;
  cursor: grab;
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-dim);
  transition: all var(--duration-fast) var(--ease-out);
  border-left: 2px solid transparent;
  user-select: none;
  min-height: 26px;
}
.binder-item:active { cursor: grabbing; }

.binder-item:hover {
  color: var(--text-muted);
  background: rgba(255,255,255, 0.02);
}

.binder-item.active {
  color: var(--text);
  background: var(--sage-faint);
  border-left-color: var(--sage);
}

.binder-item.act-separator {
  font-weight: 500;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  padding: 14px 16px 8px;
  border-bottom: 1px solid var(--border);
  border-left: none;
  cursor: default;
}

.binder-item.sequence {
  font-weight: 500;
  color: var(--text-muted);
  padding-left: 20px;
  font-size: 13px;
}

.binder-item.scene { padding-left: 32px; }

.binder-item.note {
  padding-left: 32px;
  color: var(--stone-muted);
  font-style: italic;
  font-size: 12px;
}

.binder-item .color-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.binder-item .item-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.binder-item .item-handle {
  cursor: grab;
  color: var(--text-faint);
  font-size: 10px;
  opacity: 0;
  transition: opacity var(--duration-fast);
}

.binder-item:hover .item-handle { opacity: 1; }

.binder-item.sortable-ghost { opacity: 0.3; }
.binder-item.sortable-chosen { background: var(--sage-faint); }

.binder-add-btn {
  padding: 4px 10px;
  font-size: 11px;
  color: var(--text-faint);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color var(--duration-fast);
  flex-shrink: 0;
}
.binder-add-btn:hover { color: var(--sage); }

/* Color labels */
.color-draft { background: var(--text-dim); }
.color-revision { background: var(--stone); }
.color-locked { background: var(--sage); }
.color-cut { background: var(--danger); }

/* ═══════════════════════════════════════════════════════════
   MODALS
   ═══════════════════════════════════════════════════════════ */

.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-hover);
  border-radius: 8px;
  padding: 32px;
  width: 420px;
  max-width: 90vw;
}

.modal h3 {
  margin-bottom: 20px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 20px;
  letter-spacing: -0.01em;
}

.modal .form-group { margin-bottom: 16px; }

.modal .modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* Settings tabs (Profile / API). Underlined-active style — light, doesn't
   compete with the form fields below. */
.settings-tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 14px;
  margin-bottom: -1px; /* overlap the tabs container's bottom border */
  font: inherit;
  font-size: 13px;
  color: var(--text-faint);
  cursor: pointer;
  transition: color var(--duration-fast), border-color var(--duration-fast);
}
.settings-tab-btn:hover { color: var(--text-muted); }
.settings-tab-btn.active {
  color: var(--text);
  border-bottom-color: var(--sage);
  font-weight: 500;
}

/* ═══════════════════════════════════════════════════════════
   BOT MESSAGES & PROPOSALS
   ═══════════════════════════════════════════════════════════ */

.chat-message.bot .author {
  color: var(--text-dim);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.chat-message.bot .text {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-left: 2px solid var(--sage-muted);
  color: var(--text-secondary);
  max-width: 100%;
  font-size: 14px;
  line-height: 1.65;
}

.chat-message.bot .text p {
  color: var(--text-secondary);
  max-width: 60ch;
}

.chat-message.bot .text p + p {
  margin-top: 10px;
}

/* Restrained heading scale for side-panel context */
.chat-message.bot .text h1 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin: 20px 0 8px;
  letter-spacing: -0.01em;
}

.chat-message.bot .text h2 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 18px 0 6px;
  letter-spacing: -0.01em;
}

.chat-message.bot .text h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 14px 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.chat-message.bot .text h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 12px 0 4px;
}

.chat-message.bot .text code {
  background: var(--bg-surface);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--sage-light);
  border: 1px solid var(--border-subtle);
}

.chat-message.bot .text pre {
  background: var(--bg-surface);
  padding: 12px 16px;
  border-radius: 4px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  margin: 10px 0;
  border: 1px solid var(--border-subtle);
}

.chat-message.bot .text pre code {
  background: none;
  padding: 0;
  border: none;
  color: var(--text-secondary);
}

.chat-message.bot .text strong { color: var(--text); }
.chat-message.bot .text em { color: var(--text-secondary); font-style: italic; }
.chat-message.bot .text ul, .chat-message.bot .text ol {
  margin-left: 18px;
  margin-top: 6px;
  margin-bottom: 10px;
}
.chat-message.bot .text li {
  margin-bottom: 5px;
  max-width: 60ch;
}
.chat-message.bot .text li li {
  margin-bottom: 3px;
}

/* Blockquotes for reference callouts */
.chat-message.bot .text blockquote {
  border-left: 2px solid var(--sage-muted);
  padding: 4px 12px;
  margin: 8px 0;
  color: var(--text-muted);
  font-size: 13px;
}

/* Horizontal rules as section dividers */
.chat-message.bot .text hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* Streaming cursor */
.bot-cursor {
  display: inline-block;
  color: var(--sage);
  animation: blink 1s step-end infinite;
  font-weight: 300;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Proposal cards */
.proposal-card {
  margin: 10px 0;
  border: 1px solid var(--border-hover);
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-secondary);
}

.proposal-card.accepted {
  border-color: rgba(135, 168, 120, 0.3);
}

.proposal-card.dismissed {
  opacity: 0.5;
}

.proposal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}

.proposal-file {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--sage);
}

.proposal-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}

.proposal-preview {
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-dim);
  max-height: 120px;
  overflow: hidden;
  white-space: pre-wrap;
  margin: 0;
  background: transparent;
}

.proposal-actions {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
}

.proposal-accepted-label {
  font-size: 11px;
  color: var(--sage);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.proposal-dismissed-label {
  font-size: 11px;
  color: var(--text-dim);
  font-style: italic;
}

/* ═══════════════════════════════════════════════════════════
   FILE UPLOAD
   ═══════════════════════════════════════════════════════════ */

.upload-dropzone {
  border: 1.5px dashed var(--border-hover);
  border-radius: 6px;
  padding: 32px 20px;
  text-align: center;
  color: var(--text-dim);
  transition: all var(--duration-fast) var(--ease-out);
  cursor: pointer;
}

.upload-dropzone.dragover {
  border-color: var(--sage);
  background: var(--sage-faint);
  color: var(--sage);
}

.upload-dropzone-text {
  font-size: 13px;
}

.upload-browse-link {
  color: var(--sage);
  cursor: pointer;
  text-decoration: underline;
}

.file-tree-dragover {
  background: var(--sage-faint) !important;
  outline: 1.5px dashed var(--sage);
  outline-offset: -2px;
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════ */

/* Mobile tab bar — hidden on desktop */
.mobile-tab-bar { display: none; }

@media (max-width: 768px) {
  :root { --sidebar-width: 0px; --chat-width: 0px; }

  /* Hide desktop layout elements */
  .sidebar { display: none; }
  .chat-panel { display: none; }
  .chat-resize-handle { display: none; }

  /* Full-width main content */
  .main-content { flex: 1; min-width: 0; }

  /* Show bottom tab bar */
  .mobile-tab-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 6px 0;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
  }

  .mobile-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 0;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 10px;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-tab:active { transform: scale(0.95); }
  .mobile-tab.active { color: var(--sage); }
  .mobile-tab.active svg { stroke: var(--sage); }

  /* Make workspace body fill screen minus header and tab bar */
  .workspace-body {
    padding-bottom: 60px;
  }

  /* When chat tab active, fill the screen */
  .chat-panel[style*="display: flex"] {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 60px;
    width: 100% !important;
    max-width: none;
    z-index: 50;
    border-left: none;
  }

  /* When files tab active, fill the screen */
  .sidebar[style*="display: flex"] {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 60px;
    width: 100% !important;
    max-width: none;
    z-index: 50;
    border-right: none;
  }

  /* Compact header for mobile */
  .workspace-header {
    padding: 8px 12px;
    flex-wrap: wrap;
    gap: 4px;
  }
  .workspace-header .right {
    gap: 4px;
  }
  .workspace-header .btn {
    padding: 4px 8px;
    font-size: 11px;
  }

  .fountain-editor,
  .fountain-highlighted,
  .md-preview {
    padding: 16px 16px;
  }

  .auth-card {
    padding: 32px 24px;
  }

  .dashboard-content {
    padding: 24px 16px;
  }

  /* Larger touch targets for chat input */
  .chat-input-area textarea {
    min-height: 44px;
    font-size: 16px; /* prevents iOS auto-zoom */
  }

  .bot-toggle {
    width: 44px;
    height: 44px;
  }

  /* Larger file items for touch */
  .file-item {
    padding: 12px 16px 12px 20px;
    font-size: 14px;
    min-height: 44px;
  }

  /* Larger + button for adding files */
  .sidebar-section-header .btn-icon {
    font-size: 20px !important;
    padding: 8px !important;
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* Autocomplete fills width on mobile */
  .file-autocomplete {
    margin: 0 8px;
  }
}

/* ═══════════════════════════════════════════════════════════
   BOTTOM SHEET (mobile menu)
   ═══════════════════════════════════════════════════════════ */

.bottom-sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.bottom-sheet {
  width: 100%;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-hover);
  border-radius: 16px 16px 0 0;
  padding: 8px 0 max(16px, env(safe-area-inset-bottom));
  animation: slideUp var(--duration-normal) var(--ease-out);
}

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

.bottom-sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--text-faint);
  margin: 4px auto 12px;
}

.bottom-sheet-items {
  padding: 0 8px;
}

.bottom-sheet-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 15px;
  font-family: var(--font-sans);
  cursor: pointer;
  text-align: left;
  transition: background var(--duration-fast);
  -webkit-tap-highlight-color: transparent;
}

.bottom-sheet-item:active {
  background: var(--bg-surface);
}

.bottom-sheet-item svg {
  flex-shrink: 0;
  color: var(--text-dim);
}

.bottom-sheet-item.danger {
  color: var(--danger);
}
.bottom-sheet-item.danger svg {
  color: var(--danger);
}

.bottom-sheet-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 16px;
}

/* ═══════════════════════════════════════════════════════════
   UTILITIES
   ═══════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════
   ONBOARDING WIZARD
   ═══════════════════════════════════════════════════════════ */

.wizard-modal {
  width: 520px;
}

.wizard-progress {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-bottom: 6px;
}

.wizard-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
  transition: all var(--duration-fast);
}
.wizard-dot.active {
  background: var(--sage);
  transform: scale(1.3);
}
.wizard-dot.done {
  background: var(--sage-muted);
}

.wizard-step-label {
  text-align: center;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 16px;
}

/* Project card layout for rename button */
.project-card-main {
  cursor: pointer;
  flex: 1;
}

.project-card {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.project-card-actions {
  padding-top: 2px;
  opacity: 0;
  transition: opacity var(--duration-fast);
}
.project-card:hover .project-card-actions {
  opacity: 1;
}

/* Settings gear — inline in headers */
.settings-gear {
  color: var(--text-dim);
  transition: color var(--duration-fast);
  padding: 6px;
}
.settings-gear:hover { color: var(--text-muted); }

/* Settings gear — fixed position on auth page */
.settings-gear-fixed {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 8px;
  z-index: 2;
  transition: color var(--duration-fast);
}
.settings-gear-fixed:hover { color: var(--text-muted); }

.hidden { display: none !important; }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.text-muted { color: var(--text-muted); }
.text-small { font-size: 12px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }

/* ═══════════════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════════════ */

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.version-panel {
  animation: slideInRight var(--duration-normal) var(--ease-out);
}

.modal {
  animation: fadeIn var(--duration-normal) var(--ease-out);
}

.project-card {
  animation: fadeIn var(--duration-normal) var(--ease-out);
  animation-fill-mode: both;
}

.project-card:nth-child(1) { animation-delay: 0ms; }
.project-card:nth-child(2) { animation-delay: 50ms; }
.project-card:nth-child(3) { animation-delay: 100ms; }
.project-card:nth-child(4) { animation-delay: 150ms; }
.project-card:nth-child(5) { animation-delay: 200ms; }
.project-card:nth-child(6) { animation-delay: 250ms; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ═══════════════════════════════════════════════════════════
   EDITOR TOOLBAR
   ═══════════════════════════════════════════════════════════ */

/* Editor toolbar removed — export/view buttons moved to workspace header */

.editor-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.editor-status-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ═══════════════════════════════════════════════════════════
   SCREENPLAY MODE — ELEMENT INDICATOR
   ═══════════════════════════════════════════════════════════ */

.element-indicator {
  display: none;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--sage);
  background: var(--sage-faint);
  cursor: pointer;
  user-select: none;
  transition: all var(--duration-fast);
  letter-spacing: 0.02em;
}

.element-indicator:hover {
  background: var(--sage-glow);
}

.screenplay-toggle {
  font-size: 11px !important;
}
.screenplay-toggle.active {
  color: var(--sage) !important;
  border-color: var(--sage-muted) !important;
  background: var(--sage-faint) !important;
}

.element-menu-popup {
  position: fixed;
  z-index: 1000;
  background: var(--bg-elevated);
  border: 1px solid var(--border-hover);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  padding: 4px 0;
  min-width: 160px;
  animation: fadeIn var(--duration-fast) var(--ease-out);
}

.element-menu-item {
  padding: 7px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--duration-fast);
}

.element-menu-item:hover {
  background: var(--sage-faint);
  color: var(--sage);
}

/* ═══════════════════════════════════════════════════════════
   CHARACTER AUTOCOMPLETE
   ═══════════════════════════════════════════════════════════ */

.autocomplete-dropdown {
  position: absolute;
  z-index: 100;
  background: var(--bg-elevated);
  border: 1px solid var(--border-hover);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  max-height: 200px;
  overflow-y: auto;
  min-width: 180px;
}

.autocomplete-item {
  padding: 6px 12px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-secondary);
  transition: background var(--duration-fast);
}

.autocomplete-item:hover,
.autocomplete-item.active {
  background: var(--sage-faint);
  color: var(--sage);
}

/* ═══════════════════════════════════════════════════════════
   SCENE NAVIGATOR
   ═══════════════════════════════════════════════════════════ */

.scene-nav-panel {
  width: 220px;
  min-width: 180px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
  animation: slideInRight var(--duration-normal) var(--ease-out);
}

.scene-nav-header {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.scene-nav-item {
  padding: 6px 12px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  transition: all var(--duration-fast);
  display: flex;
  gap: 8px;
}

.scene-nav-item:hover {
  background: var(--sage-faint);
  color: var(--text);
}

.scene-nav-num {
  color: var(--text-dim);
  font-size: 10px;
  min-width: 20px;
}

.scene-nav-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════
   SPLIT EDITOR / REFERENCE PANEL
   ═══════════════════════════════════════════════════════════ */

.split-reference-panel {
  width: 40%;
  min-width: 250px;
  max-width: 60%;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.split-ref-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-tertiary);
}

.split-ref-header select {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 3px 6px;
  border-radius: 4px;
  font-size: 12px;
}

.split-ref-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
}

.split-resize-handle {
  width: 4px;
  cursor: col-resize;
  background: var(--border);
  transition: background var(--duration-fast);
  flex-shrink: 0;
}

.split-resize-handle:hover {
  background: var(--sage-muted);
}

/* ═══════════════════════════════════════════════════════════
   COMPOSITION / ZEN MODE
   ═══════════════════════════════════════════════════════════ */

.composition-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  background: #0a0a0a;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.composition-toolbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 36px;
  background: rgba(10, 10, 10, 0.95);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 10001;
  opacity: 0;
  transition: opacity 0.3s;
}

.composition-overlay:hover .composition-toolbar,
.composition-toolbar:hover {
  opacity: 1;
}

.composition-toolbar .text-muted {
  font-size: 12px;
}

.composition-editor {
  width: 100%;
  max-width: 700px;
  flex: 1;
  margin-top: 36px;
  padding: 40px 24px;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 16px;
  line-height: 1.8;
  resize: none;
  outline: none;
}

/* ═══════════════════════════════════════════════════════════
   CORKBOARD
   ═══════════════════════════════════════════════════════════ */

.corkboard-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-tertiary);
}

.corkboard-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.corkboard-surface {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.corkboard-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-secondary);
}

.corkboard-breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
  margin-right: auto;
}

.breadcrumb-item {
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  transition: all var(--duration-fast);
}

.breadcrumb-item:hover {
  background: var(--bg-surface);
  color: var(--text);
}

.breadcrumb-sep {
  color: var(--text-faint);
  font-size: 10px;
}

.corkboard-filters {
  display: flex;
  gap: 6px;
}

.corkboard-filters select {
  background: var(--bg-surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
}

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

.corkboard-size-slider {
  width: 80px;
  height: 4px;
  accent-color: var(--sage);
  cursor: pointer;
  opacity: 0.6;
  transition: opacity var(--duration-fast);
}

.corkboard-size-slider:hover {
  opacity: 1;
}

/* Folder card styling — same size as scene cards, visually distinct */
.corkboard-card-folder {
  border-style: dashed !important;
  justify-content: center;
  align-items: center;
  text-align: center;
  cursor: pointer;
}

.corkboard-card-folder .corkboard-card-header {
  flex-direction: column;
  gap: 4px;
}

.corkboard-card-folder .corkboard-card-icon {
  font-size: 24px;
}

.corkboard-card-folder .corkboard-card-body {
  display: none;
}

.corkboard-child-count {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
}

.corkboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 8px;
}

.corkboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--card-min-width, 240px), 1fr));
  gap: 14px;
}

.corkboard-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  cursor: pointer;
  transition: all var(--duration-fast);
  position: relative;
  aspect-ratio: 5 / 3;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.corkboard-card:hover {
  border-color: var(--border-active);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transform: translateY(-1px);
}

.corkboard-card.corkboard-dragging {
  opacity: 0.4;
}

.corkboard-card.corkboard-drop-target {
  border-color: var(--sage);
  box-shadow: 0 0 0 2px var(--sage-faint), 0 4px 12px rgba(0, 0, 0, 0.3);
}

.corkboard-card-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  flex-shrink: 0;
}

.corkboard-card-icon {
  font-size: 14px;
  flex-shrink: 0;
}

.corkboard-card-title {
  font-weight: 600;
  font-size: 13px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: text;
  outline: none;
  border-radius: 2px;
  padding: 0 2px;
}

.corkboard-card-title:focus {
  background: var(--bg-surface);
  white-space: normal;
  text-overflow: clip;
}

.corkboard-card-synopsis {
  flex: 1;
  width: 100%;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 12px;
  line-height: 1.5;
  resize: none;
  outline: none;
  padding: 0;
  overflow-y: auto;
}

.corkboard-card-synopsis::placeholder {
  color: var(--text-faint);
  font-style: italic;
}

.corkboard-card-synopsis:focus {
  color: var(--text-secondary);
}

.corkboard-card-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  flex-shrink: 0;
  font-size: 10px;
}

.corkboard-card.active {
  border-color: var(--sage);
}

.card-color-stripe {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  border-radius: 6px 0 0 6px;
}

.card-title {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
  padding-left: 8px;
}

.card-synopsis {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  padding-left: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding-left: 8px;
}

.card-type-icon {
  font-size: 12px;
}

.card-status-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  background: var(--bg-surface);
  color: var(--text-muted);
}

.card-status-badge.status-first_draft { background: var(--sage-faint); color: var(--sage); }
.card-status-badge.status-revised { background: var(--warning-faint); color: var(--warning); }
.card-status-badge.status-polished { background: rgba(135, 168, 120, 0.2); color: var(--sage-light); }
.card-status-badge.status-locked { color: var(--stone); }
.card-status-badge.status-cut { background: var(--danger-faint); color: var(--danger); }

/* Stacked corkboard: group by parent */
.corkboard-stack {
  margin-bottom: 16px;
}

.corkboard-stack-header {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border-subtle);
}

/* ═══════════════════════════════════════════════════════════
   OUTLINER TABLE
   ═══════════════════════════════════════════════════════════ */

.outliner-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-secondary);
}

.outliner-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.outliner-table-wrap {
  flex: 1;
  overflow: auto;
}

.outliner-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.outliner-table th {
  position: sticky;
  top: 0;
  background: var(--bg-tertiary);
  padding: 8px 10px;
  text-align: left;
  font-weight: 500;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  white-space: nowrap;
}

.outliner-table th:hover {
  color: var(--text);
}

.outliner-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.outliner-table tr:hover td {
  background: var(--sage-faint);
}

.outliner-table tr.active td {
  background: var(--sage-faint);
}

.outliner-synopsis {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  cursor: text;
}

.outliner-synopsis:focus {
  outline: 1px solid var(--sage);
  background: var(--bg-surface);
  white-space: normal;
}

.outliner-status-select {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 11px;
}

.outliner-footer {
  position: sticky;
  bottom: 0;
  background: var(--bg-tertiary);
  padding: 6px 10px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  gap: 16px;
}

/* ═══════════════════════════════════════════════════════════
   BINDER VIEW SWITCHER & STATUS BADGES
   ═══════════════════════════════════════════════════════════ */

.binder-view-switcher {
  display: flex;
  gap: 2px;
  padding: 3px 8px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.view-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--text-dim);
  padding: 4px 10px 3px;
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--duration-fast);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.view-btn-icon {
  font-size: 14px;
  line-height: 1;
}

.view-btn-label {
  font-size: 9px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.view-btn:hover { color: var(--text-muted); background: var(--bg-elevated); }
.view-btn.active { color: var(--sage); background: var(--sage-faint); }

/* ── Quick-add popup ── */
.binder-add-popup {
  position: fixed;
  z-index: 1000;
  background: var(--bg-elevated);
  border: 1px solid var(--border-hover);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  padding: 4px 0;
  min-width: 140px;
  animation: fadeIn var(--duration-fast) var(--ease-out);
}

.binder-add-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all var(--duration-fast);
}

.binder-add-option:hover {
  background: var(--sage-faint);
  color: var(--sage);
}

.binder-add-option .file-icon {
  font-size: 14px;
  width: 18px;
  text-align: center;
}

/* ── Binder separator items ── */
.binder-item.binder-separator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  margin-top: 2px;
  border-top: 1px solid var(--border-hover);
  background: var(--bg-tertiary);
  min-height: 24px;
}

.separator-label {
  flex: 1;
  font-family: var(--font-display);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Binder drag-and-drop indicators ── */
.binder-item.dragging {
  opacity: 0.4;
}

.binder-item.drop-into {
  background: var(--sage-faint) !important;
  outline: 2px dashed var(--sage);
  outline-offset: -2px;
  border-radius: 4px;
}

.binder-item.drop-above {
  box-shadow: 0 -2px 0 0 var(--sage);
}

/* ── Binder add-child button (+) on folders ── */
.binder-add-child-btn {
  opacity: 0;
  font-size: 13px;
  line-height: 1;
  padding: 2px 4px;
  cursor: pointer;
  color: var(--sage);
  flex-shrink: 0;
  transition: opacity 0.15s;
  font-weight: 600;
}
.binder-item:hover .binder-add-child-btn { opacity: 0.5; }
.binder-add-child-btn:hover { opacity: 1 !important; }

/* ── Binder delete button (X) ── */
.binder-delete-btn {
  opacity: 0;
  font-size: 14px;
  line-height: 1;
  padding: 2px 4px;
  cursor: pointer;
  color: var(--text-dim);
  flex-shrink: 0;
  transition: opacity 0.15s, color 0.15s;
}
.binder-item:hover .binder-delete-btn { opacity: 0.4; }
.binder-delete-btn:hover { opacity: 1 !important; color: var(--danger); }

/* ── Inline title editing ── */
.item-title.editing {
  outline: 1px solid var(--sage);
  background: var(--bg-surface);
  padding: 1px 4px;
  border-radius: 3px;
  min-width: 60px;
}

/* ── Corkboard separator dividers ── */
.corkboard-separator {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  width: 100%;
  cursor: pointer;
}

.corkboard-separator-line {
  flex: 1;
  border-top: 2px solid var(--border-hover);
}

.corkboard-separator-label {
  font-family: var(--font-display);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  white-space: nowrap;
  user-select: none;
}

.binder-status-badge {
  font-family: var(--font-mono);
  font-size: 8px;
  padding: 2px 6px;
  border-radius: 8px;
  margin-left: auto;
  margin-right: 4px;
  white-space: nowrap;
  background: var(--bg-surface);
  color: var(--text-dim);
  letter-spacing: 0.02em;
}

.binder-status-badge.status-first_draft { background: var(--sage-faint); color: var(--sage); }
.binder-status-badge.status-revised { background: var(--warning-faint); color: var(--warning); }
.binder-status-badge.status-polished { color: var(--sage-light); }
.binder-status-badge.status-locked { color: var(--stone); }
.binder-status-badge.status-cut { background: var(--danger-faint); color: var(--danger); }

/* ═══════════════════════════════════════════════════════════
   COLLECTIONS
   ═══════════════════════════════════════════════════════════ */

#collections-section .sidebar-section-body {
  max-height: 150px;
  overflow-y: auto;
}

.collection-item {
  padding: 5px 12px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--duration-fast);
}

.collection-item:hover { background: var(--sage-faint); color: var(--text); }
.collection-item.active { color: var(--sage); background: var(--sage-faint); }

.collection-item .collection-delete {
  margin-left: auto;
  opacity: 0;
  color: var(--text-dim);
  cursor: pointer;
}
.collection-item:hover .collection-delete { opacity: 1; }

.collection-add-btn {
  padding: 5px 12px;
  font-size: 11px;
  color: var(--text-dim);
  cursor: pointer;
  transition: color var(--duration-fast);
}
.collection-add-btn:hover { color: var(--sage); }

/* ═══════════════════════════════════════════════════════════
   SPRINT TIMER
   ═══════════════════════════════════════════════════════════ */

.sprint-timer-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 12px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  min-height: 0;
}

.sprint-timer-bar:empty {
  display: none;
}

.sprint-timer-bar.active {
  border-bottom-color: var(--sage-muted);
  animation: sprintPulse 2s ease-in-out infinite;
}

@keyframes sprintPulse {
  0%, 100% { border-bottom-color: var(--sage-muted); }
  50% { border-bottom-color: var(--sage); }
}

.sprint-time {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--sage);
  min-width: 50px;
}

.sprint-stat {
  color: var(--text-muted);
  font-size: 11px;
}

.sprint-btn {
  background: var(--sage-faint);
  border: 1px solid var(--sage-muted);
  color: var(--sage);
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  transition: all var(--duration-fast);
}

.sprint-btn:hover {
  background: var(--sage);
  color: var(--bg-primary);
}

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

/* ═══════════════════════════════════════════════════════════
   REVISION TRACKING
   ═══════════════════════════════════════════════════════════ */

.revision-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  min-height: 0;
}

.revision-bar:empty { display: none; }

.revision-bar:not(:empty) {
  min-height: 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  font-size: 11px;
}

.revision-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  border: 1px solid rgba(255,255,255,0.2);
}

.revision-label {
  color: var(--text-muted);
  font-size: 11px;
}

/* Revision colors */
.rev-blue { background: #5B9BD5; }
.rev-pink { background: #FF91A4; }
.rev-yellow { background: #FFD700; }
.rev-green { background: #77DD77; }
.rev-goldenrod { background: #DAA520; }
.rev-buff { background: #F0DC82; }
.rev-salmon { background: #FA8072; }
.rev-cherry { background: #DE3163; }
.rev-tan { background: #D2B48C; }

#revision-indicator .revision-color-dot {
  width: 8px;
  height: 8px;
}

/* ═══════════════════════════════════════════════════════════
   STATISTICS MODAL
   ═══════════════════════════════════════════════════════════ */

.stats-modal {
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  text-align: center;
}

.stat-value {
  font-size: 24px;
  font-weight: 600;
  color: var(--sage);
  font-family: var(--font-mono);
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stats-bar {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg-surface);
  margin: 8px 0;
}

.stats-bar-segment {
  transition: width var(--duration-normal);
}

.stats-bar-dialogue { background: var(--sage); }
.stats-bar-action { background: var(--stone); }

.character-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.character-table th {
  text-align: left;
  padding: 6px 8px;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
}

.character-table td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.character-table tr:hover td {
  background: var(--sage-faint);
}

/* ═══════════════════════════════════════════════════════════
   BREAKDOWN MODAL
   ═══════════════════════════════════════════════════════════ */

.breakdown-modal {
  max-width: 700px;
  max-height: 80vh;
  overflow-y: auto;
}

.breakdown-scene {
  margin-bottom: 16px;
}

.breakdown-scene-heading {
  font-weight: 600;
  font-size: 13px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.breakdown-category {
  margin-bottom: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.breakdown-cat-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  width: 70px;
  flex-shrink: 0;
}

.breakdown-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  border: 1px solid;
}

.breakdown-tag .tag-delete {
  cursor: pointer;
  opacity: 0.6;
  font-size: 10px;
}
.breakdown-tag .tag-delete:hover { opacity: 1; }

/* Breakdown category colors */
.tag-cast { background: rgba(135,168,120,0.15); border-color: #87A878; color: #87A878; }
.tag-extras { background: rgba(107,143,94,0.15); border-color: #6B8F5E; color: #6B8F5E; }
.tag-props { background: rgba(184,169,154,0.15); border-color: #B8A99A; color: #B8A99A; }
.tag-wardrobe { background: rgba(196,169,77,0.15); border-color: #C4A94D; color: #C4A94D; }
.tag-vehicles { background: rgba(102,102,102,0.15); border-color: #666; color: #888; }
.tag-sfx { background: rgba(196,116,110,0.15); border-color: #C4746E; color: #C4746E; }
.tag-vfx { background: rgba(155,142,196,0.15); border-color: #9B8EC4; color: #9B8EC4; }
.tag-makeup { background: rgba(212,160,160,0.15); border-color: #D4A0A0; color: #D4A0A0; }
.tag-animals { background: rgba(160,196,160,0.15); border-color: #A0C4A0; color: #A0C4A0; }
.tag-music { background: rgba(122,160,196,0.15); border-color: #7AA0C4; color: #7AA0C4; }
.tag-sound { background: rgba(74,122,155,0.15); border-color: #4A7A9B; color: #4A7A9B; }
.tag-other { background: rgba(136,136,136,0.15); border-color: #888; color: #888; }

/* ═══════════════════════════════════════════════════════════
   SCRIVENINGS MODE
   ═══════════════════════════════════════════════════════════ */

.scrivenings-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  margin: 8px 0;
  border-top: 1px dashed var(--border-hover);
  color: var(--text-dim);
  font-size: 11px;
  user-select: none;
}

.scrivenings-file-label {
  background: var(--bg-surface);
  padding: 1px 6px;
  border-radius: 3px;
  font-family: var(--font-sans);
}

/* Full Draft mode panels (extends scrivenings internals) */
.scrivenings-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.scrivenings-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 12px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.scrivenings-title {
  font-weight: 600;
  color: var(--sage);
}

.scrivenings-editor-wrap {
  flex: 1;
  position: relative;
  min-height: 0;
}

.scrivenings-textarea {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
}

.scrivenings-labels {
  position: absolute;
  top: 0; left: 0;
  pointer-events: none;
  z-index: 2;
}

.scrivenings-label {
  position: absolute;
  left: 4px;
  background: var(--sage-faint);
  color: var(--sage);
  font-size: 10px;
  padding: 0 5px;
  border-radius: 3px;
  font-family: var(--font-sans);
}

.scrivenings-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 12px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-dim);
}

/* ═══════════════════════════════════════════════════════════
   PAGE COUNT IN STATUS BAR
   ═══════════════════════════════════════════════════════════ */

#page-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}

/* ═══════════════════════════════════════════════════════════
   FILTER BAR (for corkboard/outliner)
   ═══════════════════════════════════════════════════════════ */

.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-bar select {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
}

.filter-bar .filter-clear {
  font-size: 11px;
  color: var(--text-dim);
  cursor: pointer;
  text-decoration: underline;
}
.filter-bar .filter-clear:hover { color: var(--sage); }

/* ═══════════════════════════════════════════════════════════
   DRAGGABLE CARDS
   ═══════════════════════════════════════════════════════════ */

.corkboard-card[draggable="true"] {
  cursor: grab;
}

.corkboard-card[draggable="true"]:active {
  cursor: grabbing;
}

.corkboard-card.drag-over {
  border-color: var(--sage);
  background: var(--sage-faint);
}

/* ═══════════════════════════════════════════════════════════
   EXPORT OPTIONS MODAL TWEAKS
   ═══════════════════════════════════════════════════════════ */

.modal input[type="checkbox"] {
  accent-color: var(--sage);
  margin-right: 8px;
}

.modal label:has(input[type="checkbox"]) {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: 13px;
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE: HIDE TOOLBAR OVERFLOW
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .editor-toolbar {
    overflow-x: auto;
    flex-wrap: nowrap;
  }
  .toolbar-btn {
    font-size: 10px;
    padding: 3px 6px;
  }
  .scene-nav-panel {
    width: 100%;
    max-height: 200px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .split-reference-panel {
    display: none !important;
  }
  .corkboard-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Source panel badges */
.badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge-grey  { background: var(--surface-2, #2a2a2a); color: var(--text-muted, #999); }
.badge-yellow{ background: rgba(212, 175, 55, 0.15); color: #d4af37; }
.badge-blue  { background: rgba(135, 168, 200, 0.18); color: #87a8c8; }
.badge-green { background: var(--sage-faint, rgba(135,168,120,0.15)); color: var(--sage, #87a878); }
.source-chapter:hover { background: var(--surface-hover, rgba(255,255,255,0.04)); }
.source-chapter.focused { background: var(--surface-hover, rgba(255,255,255,0.06)); border-left: 2px solid var(--accent, #d4af37); }

/* Adaptation modal */
.adaptation-overlay { z-index: 1000; }
.adaptation-modal { max-width: 640px; width: 90vw; }
.adaptation-header { margin-bottom: 12px; }
.adaptation-body { min-height: 40px; }

/* Step checklist — shows the full pipeline so the writer can see what's
   done, what's running, and what's still ahead. Active step has a sage
   spinner; done steps have a green check; pending steps are dimmed. */
.adapt-checklist {
  list-style: none;
  margin: 12px 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.adapt-step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px;
  border-radius: 6px;
  transition: background var(--duration-fast);
}
.adapt-step-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  flex-shrink: 0;
  color: var(--text-faint);
  background: transparent;
}
.adapt-step-text { flex: 1; min-width: 0; }
.adapt-step-label {
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 500;
}
.adapt-step-sub {
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Pending: muted, hollow circle (already the base state). */
.adapt-step-pending .adapt-step-label { color: var(--text-faint); }

/* Done: filled green circle with white check. Label is a touch brighter
   than pending so completed work feels real. */
.adapt-step-done .adapt-step-icon {
  background: var(--sage);
  border-color: var(--sage);
  color: var(--bg-primary, #0a0a0a);
}
.adapt-step-done .adapt-step-label { color: var(--text-muted); }

/* Active: sage outline + spinner. Background tint so the current step
   reads at a glance. */
.adapt-step-active {
  background: var(--sage-faint);
}
.adapt-step-active .adapt-step-icon {
  border-color: var(--sage);
  background: transparent;
}
.adapt-step-active .adapt-step-label { color: var(--sage); font-weight: 600; }

.adapt-step-spinner {
  width: 12px;
  height: 12px;
  border: 1.5px solid var(--sage);
  border-top-color: transparent;
  border-radius: 50%;
  animation: adapt-spin 0.9s linear infinite;
}
@keyframes adapt-spin {
  to { transform: rotate(360deg); }
}

/* Error: red ring + X glyph. Done steps before the error stay green. */
.adapt-step-error .adapt-step-icon {
  border-color: var(--danger);
  color: var(--danger);
  background: transparent;
}
.adapt-step-error .adapt-step-label { color: var(--danger); }
.adaptation-body .progress-bar {
  height: 6px;
  background: var(--surface-2, #2a2a2a);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 8px;
}
.adaptation-body .progress-fill {
  height: 100%;
  background: var(--accent, #d4af37);
  transition: width 0.3s ease;
}
.intention-q { margin: 14px 0; }
.intention-q label { display: block; font-weight: 600; margin-bottom: 4px; }
.intention-q textarea {
  width: 100%;
  margin-top: 6px;
  padding: 8px;
  background: var(--surface-2, #1f1f1f);
  border: 1px solid var(--border, #333);
  border-radius: 4px;
  color: inherit;
  font: inherit;
  resize: vertical;
}
.treatment-preview {
  max-height: 50vh;
  overflow-y: auto;
  padding: 12px;
  background: var(--surface-2, #1a1a1a);
  border-radius: 4px;
  margin-top: 8px;
  line-height: 1.6;
}
.treatment-preview p { margin: 0 0 12px 0; }
.error-pre {
  background: var(--surface-2, #1a1a1a);
  padding: 8px;
  border-radius: 4px;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 200px;
  overflow-y: auto;
}

/* Project-kind card grid (new-project modal) */
.project-kind-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 6px;
}
.project-kind-card {
  text-align: left;
  padding: 12px 14px;
  background: var(--surface-2, #1f1f1f);
  border: 1px solid var(--border, #333);
  border-radius: 6px;
  cursor: pointer;
  color: inherit;
  font: inherit;
  transition: border-color 0.15s, background 0.15s;
}
.project-kind-card:hover {
  border-color: var(--accent, #d4af37);
  background: var(--surface-hover, #252525);
}
.project-kind-card.selected {
  border-color: var(--accent, #d4af37);
  background: rgba(212, 175, 55, 0.08);
}
.project-kind-card .kind-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 2px;
}
.project-kind-card .kind-desc {
  font-size: 12px;
  color: var(--text-muted, #999);
  line-height: 1.3;
}
@media (max-width: 480px) {
  .project-kind-grid { grid-template-columns: 1fr; }
}
