/* ============================================================
   FLOW WRITER  ·  layout shell
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body {
  background:
    radial-gradient(ellipse 90% 60% at 15% 0%, rgba(20,184,154,0.10) 0%, transparent 55%),
    radial-gradient(ellipse 70% 50% at 100% 100%, rgba(62,240,226,0.08) 0%, transparent 55%),
    var(--bg-base);
  color: var(--fg-2);
  font-family: var(--font-sans);
  overflow: hidden;
}

.app {
  height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr 320px;
  grid-template-rows: 52px 1fr 36px;
  grid-template-areas:
    "topbar topbar topbar"
    "left   center right"
    "status status status";
  gap: 0;
  transition: grid-template-columns var(--dur-slow) var(--ease-out);
}
.app.focus-mode { grid-template-columns: 0 1fr 0; }
.app.focus-mode .pane { opacity: 0; pointer-events: none; transform: translateX(-8px); }
.app.focus-mode .pane.right { transform: translateX(8px); }

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  grid-area: topbar;
  display: flex; align-items: center; gap: var(--space-4);
  padding: 0 var(--space-5);
  background: rgba(7, 14, 26, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
  z-index: 30;
}
.brand {
  display: flex; align-items: center; gap: var(--space-3);
  color: var(--fg-1); text-decoration: none;
}
.brand-tile {
  width: 28px; height: 28px;
  border-radius: 7px;
  background: var(--grad-brand-deep);
  box-shadow: var(--glow-teal-sm), var(--shadow-inset);
  display: grid; place-items: center;
  font-family: var(--font-mono); font-weight: 700;
  font-size: 10px; color: #fff; letter-spacing: 0.04em;
}
.brand-title {
  font-family: var(--font-display); font-weight: 700;
  font-size: 14px; letter-spacing: 0.06em;
}
.brand-title .accent { color: var(--accent-2); }
.back-link {
  font-size: var(--fs-xs); color: var(--fg-3);
  letter-spacing: var(--tracking-wide);
  text-decoration: none;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  transition: all var(--dur-fast) var(--ease-out);
}
.back-link:hover {
  color: var(--accent-2);
  border-color: var(--border-accent);
  background: rgba(20,184,154,0.06);
}
.topbar-center {
  flex: 1; display: flex; align-items: center; justify-content: center;
  gap: var(--space-3);
}
.scene-pill {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: 6px 14px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  background: rgba(20,41,63,0.45);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-3);
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}
.scene-pill:hover { border-color: var(--border-accent); color: var(--fg-2); }
.scene-pill .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 8px var(--accent-2);
}
.topbar-right { display: flex; align-items: center; gap: var(--space-2); }
.icon-btn {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--fg-3);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
  font-size: 14px;
}
.icon-btn:hover {
  color: var(--accent-2);
  border-color: var(--border-accent);
  background: rgba(20,184,154,0.06);
  box-shadow: var(--glow-teal-sm);
}
.icon-btn.active {
  color: var(--accent-2);
  border-color: var(--border-accent);
  background: rgba(20,184,154,0.10);
  box-shadow: var(--glow-teal-sm);
}

/* ============================================================
   PANES
   ============================================================ */
.pane {
  overflow: hidden auto;
  transition: opacity var(--dur-slow) var(--ease-out), transform var(--dur-slow) var(--ease-out);
  scrollbar-width: thin;
  scrollbar-color: var(--navy-700) transparent;
}
.pane::-webkit-scrollbar { width: 6px; }
.pane::-webkit-scrollbar-thumb { background: var(--navy-700); border-radius: 3px; }
.pane::-webkit-scrollbar-track { background: transparent; }

.pane.left  { grid-area: left;  border-right: 1px solid var(--border-subtle); padding: var(--space-5) var(--space-4); position: relative; }
.pane.right { grid-area: right; border-left:  1px solid var(--border-subtle); padding: var(--space-5) var(--space-4); position: relative; }

/* ---------- Pane dividers (resizable) ---------- */
.pane-divider {
  position: relative;
  z-index: 40;
  cursor: col-resize;
  background: transparent;
  transition: background var(--dur-fast);
}
.pane-divider:hover,
.pane-divider.dragging {
  background: rgba(20,184,154,0.15);
}
.pane-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2px;
  height: 24px;
  border-radius: 1px;
  background: var(--fg-4);
  opacity: 0.3;
  transition: opacity var(--dur-fast), background var(--dur-fast);
}
.pane-divider:hover::after,
.pane-divider.dragging::after {
  opacity: 0.8;
  background: var(--accent-2);
}
/* Left divider sits between left pane and center */
.pane-divider.left {
  grid-area: left;
  justify-self: end;
  width: 6px;
  margin-right: -3px;
}
/* Right divider sits between center and right pane */
.pane-divider.right {
  grid-area: right;
  justify-self: start;
  width: 6px;
  margin-left: -3px;
}

.section-eyebrow {
  font-family: var(--font-display);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--accent-2);
  font-weight: 600;
  margin: 0 0 var(--space-3) 0;
  display: flex; align-items: center; justify-content: space-between;
}
.section-eyebrow .count {
  font-family: var(--font-mono);
  color: var(--fg-4);
  letter-spacing: 0.04em;
  font-weight: 400;
}
.section-eyebrow + .section-eyebrow { margin-top: var(--space-6); }

/* Project switcher */
.project-switcher {
  display: flex; align-items: center; gap: var(--space-2);
  padding: 8px 10px;
  background: var(--grad-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-3);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}
.project-switcher:hover { border-color: var(--border-accent); }
.project-switcher .label {
  flex: 1;
  font-size: 13px;
  color: var(--fg-1);
  font-weight: 500;
}
.project-switcher .chev { color: var(--fg-4); font-size: 10px; }

.branch-row {
  display: flex; align-items: center; gap: var(--space-2);
  margin-bottom: var(--space-5);
}
.branch-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: rgba(20,184,154,0.10);
  border: 1px solid var(--border-accent);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-2);
  box-shadow: var(--glow-teal-sm);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
  position: relative;
}
.branch-chip:hover {
  background: rgba(20,184,154,0.18);
  box-shadow: var(--glow-teal-md);
}
.branch-chip .glyph { color: var(--accent-2); }
.branch-add {
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border-line);
  background: transparent;
  color: var(--fg-3);
  font-size: 11px;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}
.branch-add:hover { color: var(--accent-2); border-color: var(--border-accent); border-style: solid; }

/* Branch selector dropdown */
.branch-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 220px;
  background: var(--grad-card);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg), var(--glow-teal-sm);
  z-index: 50;
  padding: 6px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.branch-dropdown.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.branch-dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-2);
  transition: all var(--dur-fast) var(--ease-out);
}
.branch-dropdown-item:hover {
  background: rgba(20,184,154,0.08);
  color: var(--fg-1);
}
.branch-dropdown-item.active {
  background: rgba(20,184,154,0.12);
  border: 1px solid var(--border-accent);
  color: var(--accent-2);
}
.branch-dropdown-item .branch-meta {
  color: var(--fg-4);
  font-size: 10px;
}
.branch-dropdown-divider {
  height: 1px;
  background: var(--border-line);
  margin: 4px 6px;
}
.branch-dropdown-action {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-3);
  transition: all var(--dur-fast) var(--ease-out);
}
.branch-dropdown-action:hover {
  background: rgba(20,184,154,0.06);
  color: var(--fg-1);
}
.branch-dropdown-action.danger {
  color: var(--danger-red);
}
.branch-dropdown-action.danger:hover {
  background: rgba(255,93,115,0.08);
}

/* File tree */
.tree { list-style: none; padding: 0; margin: 0; }
.tree-folder { margin-bottom: 2px; }
.tree-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--fg-2);
  transition: all var(--dur-fast) var(--ease-out);
  border: 1px solid transparent;
  position: relative;
}
.tree-item:hover { background: rgba(20,184,154,0.06); color: var(--fg-1); }
.tree-item.active {
  background: rgba(20,184,154,0.10);
  border-color: var(--border-accent);
  color: var(--fg-1);
  box-shadow: var(--glow-teal-sm);
}
.tree-item.active::before {
  content: ""; position: absolute; left: -10px; top: 6px; bottom: 6px;
  width: 2px; background: var(--accent-2); border-radius: 2px;
  box-shadow: 0 0 6px var(--accent-2);
}
.tree-icon { width: 14px; text-align: center; font-size: 11px; color: var(--accent-2); opacity: 0.8; }
.tree-folder > .tree-item > .tree-icon { color: var(--fg-3); }
.tree-folder.open > .tree-item .caret { transform: rotate(90deg); }
.caret {
  color: var(--fg-4); font-size: 9px;
  transition: transform var(--dur-fast) var(--ease-out);
  margin-left: -4px;
}
.tree-children {
  list-style: none; padding: 0 0 0 16px; margin: 4px 0 0 0;
  border-left: 1px dashed var(--border-subtle);
  overflow: hidden;
  max-height: 1000px;
  transition: max-height var(--dur-slow) var(--ease-out), opacity var(--dur-slow) var(--ease-out);
}
.tree-folder:not(.open) > .tree-children { max-height: 0; opacity: 0; margin-top: 0; }
.tree-children .tree-item { font-size: 12.5px; }
.file-type-doc { color: var(--accent-2); }
.file-type-note { color: var(--accent-2); }
.file-type-char { color: var(--electric-violet); }
.file-type-map { color: var(--warn-amber); }

/* Drag and Drop Tree */

.tree-item:active { cursor: grabbing; }
.tree-item.dragging {
  opacity: 0.4;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.tree-item.drop-before {
  border-top: 2px solid var(--accent-2);
}
.tree-item.drop-after {
  border-bottom: 2px solid var(--accent-2);
}
.tree-item.drop-into {
  background: rgba(20,184,154,0.12);
  box-shadow: inset 0 0 0 1px var(--accent-2);
}
.tree-container.drag-over {
  border: 2px dashed var(--accent-2);
  border-radius: var(--radius-md);
}

/* Tree context menu */
.tree-context-menu {
  position: absolute;
  min-width: 160px;
  background: var(--grad-card);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 50;
  padding: 4px;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.96);
  transition: opacity var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.tree-context-menu.open {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}
.tree-context-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-2);
  transition: all var(--dur-fast) var(--ease-out);
}
.tree-context-item:hover {
  background: rgba(20,184,154,0.08);
  color: var(--fg-1);
}
.tree-context-item.danger {
  color: var(--danger-red);
}
.tree-context-item.danger:hover {
  background: rgba(255,93,115,0.08);
}

/* Tree add button */
.tree-add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: 6px;
  margin-top: var(--space-2);
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border-line);
  background: transparent;
  color: var(--fg-4);
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
  width: 100%;
}
.tree-add-btn:hover {
  color: var(--accent-2);
  border-color: var(--border-accent);
  border-style: solid;
  background: rgba(20,184,154,0.06);
}

/* Commit history list */
.commit-list {
  margin-top: var(--space-3);
  max-height: 180px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--navy-700) transparent;
}
.commit-list::-webkit-scrollbar { width: 4px; }
.commit-list::-webkit-scrollbar-thumb { background: var(--navy-700); border-radius: 2px; }
.commit-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-3);
  transition: all var(--dur-fast) var(--ease-out);
  border-left: 2px solid transparent;
}
.commit-item:hover {
  background: rgba(20,184,154,0.06);
  border-left-color: var(--accent-2);
  color: var(--fg-2);
}
.commit-item .commit-msg {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.commit-item .commit-time {
  color: var(--fg-4);
  font-size: 10px;
  flex-shrink: 0;
}
.commit-item .commit-delta {
  font-size: 10px;
  flex-shrink: 0;
}
.commit-item .commit-delta.positive { color: var(--pulse-green); }
.commit-item .commit-delta.negative { color: var(--danger-red); }
.commit-item .commit-delta.neutral { color: var(--fg-4); }

/* ============================================================
   CENTER  ·  editor
   ============================================================ */
.center {
  grid-area: center;
  display: flex; flex-direction: column;
  overflow: hidden;
  position: relative;
}
.scene-banner {
  margin: var(--space-5) auto 0 auto;
  width: min(720px, calc(100% - var(--space-7)));
  padding: var(--space-4) var(--space-5);
  background: var(--grad-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md), var(--shadow-inset);
  position: relative;
  transition: opacity var(--dur-slow) var(--ease-out), transform var(--dur-slow) var(--ease-out), max-height var(--dur-slow) var(--ease-out), padding var(--dur-slow) var(--ease-out), margin var(--dur-slow) var(--ease-out);
  max-height: 200px;
  overflow: hidden;
}
.scene-banner.collapsed { max-height: 0; padding-top: 0; padding-bottom: 0; margin-top: 0; opacity: 0; border-color: transparent; }
.scene-banner-eyebrow {
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-2);
  margin-bottom: 6px;
}
.scene-banner-eyebrow .source { color: var(--accent-2); font-weight: 600; }
.scene-banner .scene-goal {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 500;
  color: var(--fg-1);
  line-height: 1.4;
  letter-spacing: -0.005em;
}
.scene-banner .scene-goal em {
  font-style: normal;
  background: linear-gradient(180deg, transparent 65%, rgba(20,184,154,0.25) 65%, rgba(20,184,154,0.25) 100%);
  padding: 0 2px;
}
.scene-banner .scene-goal-placeholder {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-4);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out);
}
.scene-banner .scene-goal-placeholder:hover {
  color: var(--accent-2);
}
.scene-banner .scene-goal-placeholder .plus {
  opacity: 0;
  transition: opacity var(--dur-fast);
}
.scene-banner .scene-goal-placeholder:hover .plus {
  opacity: 1;
}

/* Scene goal states */
.scene-goal-wrap {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
}
.scene-goal {
  cursor: pointer;
  flex: 1;
}
.scene-goal:hover {
  opacity: 0.9;
}
.scene-goal.completed {
  text-decoration: line-through;
  opacity: 0.5;
}
.scene-goal .pin {
  font-size: 10px;
  color: var(--accent-2);
  margin-left: 4px;
}
.scene-goal-check {
  background: transparent;
  border: 1px solid var(--border-line);
  border-radius: var(--radius-sm);
  color: var(--fg-4);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 6px;
  line-height: 1;
  transition: all var(--dur-fast) var(--ease-out);
  flex-shrink: 0;
  margin-top: 2px;
}
.scene-goal-check:hover {
  border-color: var(--accent-2);
  color: var(--accent-2);
}
.scene-goal-check.checked {
  background: rgba(20,184,154,0.15);
  border-color: var(--accent-2);
  color: var(--accent-2);
}
.scene-goal-check.hidden {
  display: none;
}
.scene-banner-collapse {
  position: absolute; top: 10px; right: 12px;
  background: transparent; border: 0; color: var(--fg-4);
  cursor: pointer; font-size: 14px; line-height: 1;
  padding: 4px; border-radius: 4px;
}
.scene-banner-collapse:hover { color: var(--accent-2); }

.editor-wrap {
  flex: 1; overflow: auto;
  padding: var(--space-6) var(--space-7);
  scrollbar-width: thin;
  scrollbar-color: var(--navy-700) transparent;
  position: relative;
}
.editor-wrap::-webkit-scrollbar { width: 8px; }
.editor-wrap::-webkit-scrollbar-thumb { background: var(--navy-700); border-radius: 4px; }

.editor {
  display: block;
  width: 100%;
  max-width: var(--editor-width, 720px);
  margin: 0 auto;
  min-height: 100%;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--fg-1);
  font-family: var(--font-serif, 'Iowan Old Style', 'Charter', Georgia, serif);
  font-size: var(--editor-fs, 18px);
  line-height: var(--editor-lh, 1.7);
  resize: none;
  padding: var(--space-4) 0 50vh 0;
  caret-color: var(--accent-2);
  letter-spacing: 0.005em;
}
.editor::placeholder { color: var(--fg-4); font-style: italic; }
.editor::selection { background: rgba(20,184,154,0.30); color: var(--fg-1); }

/* Family modifiers — driven by data-family on .center */
.center[data-family="serif"]   { --font-serif: 'Iowan Old Style', Charter, Georgia, serif; }
.center[data-family="georgia"] { --font-serif: Georgia, serif; }
.center[data-family="times"]   { --font-serif: 'Times New Roman', Times, serif; }
.center[data-family="garamond"]{ --font-serif: Garamond, 'EB Garamond', serif; }
.center[data-family="sans"]    { --font-serif: 'Space Grotesk', system-ui, sans-serif; }
.center[data-family="mono"]    { --font-serif: 'JetBrains Mono', ui-monospace, monospace; }

/* Typewriter mode: pad top so caret line stays centered */
.center.typewriter .editor-wrap { padding-top: 35vh; padding-bottom: 50vh; }

/* Flow nudge */
.nudge {
  position: absolute;
  left: 50%;
  bottom: var(--space-6);
  transform: translateX(-50%) translateY(8px);
  background: rgba(7,14,26,0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-accent);
  box-shadow: var(--glow-teal-md);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  font-size: 13px;
  color: var(--fg-2);
  display: flex; align-items: center; gap: 10px;
  max-width: 520px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-slow) var(--ease-out), transform var(--dur-slow) var(--ease-out);
  z-index: 20;
}
.nudge.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.nudge .icon {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgba(20,184,154,0.18);
  display: grid; place-items: center;
  font-size: 12px;
  color: var(--accent-2);
  flex-shrink: 0;
}
.nudge .msg { line-height: 1.4; }
.nudge .msg em { color: var(--accent-2); font-style: normal; }
.nudge button {
  background: transparent; border: 0; color: var(--fg-4);
  cursor: pointer; font-size: 14px;
  padding: 2px 6px; border-radius: 4px;
}
.nudge button:hover { color: var(--accent-2); }

/* ============================================================
   RIGHT PANE  ·  tags + format
   ============================================================ */
.tag-row {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: var(--space-3);
}
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 11px;
  border: 1px solid var(--border-subtle);
  background: rgba(20,41,63,0.45);
  color: var(--fg-2);
  cursor: default;
  transition: all var(--dur-fast) var(--ease-out);
}
.tag.auto { color: var(--accent-2); border-color: rgba(20,184,154,0.25); background: rgba(20,184,154,0.08); }
.tag.manual { color: var(--fg-2); }
.tag.manual .close { cursor: pointer; color: var(--fg-4); transition: color var(--dur-fast); }
.tag.manual .close:hover { color: var(--danger-red); }
.tag.suggest {
  color: var(--fg-4);
  border-style: dashed;
  cursor: pointer;
}
.tag.suggest:hover { color: var(--accent-2); border-color: var(--border-accent); border-style: solid; background: rgba(20,184,154,0.06); }

.tag-add {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 11px;
  border: 1px dashed var(--border-line);
  background: transparent;
  color: var(--fg-4);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}
.tag-add:hover { color: var(--accent-2); border-color: var(--border-accent); border-style: solid; }
.tag-add input {
  background: transparent; border: 0; outline: 0;
  color: var(--fg-1); font-family: var(--font-mono); font-size: 11px;
  width: 80px;
}

/* Format groups */
.fmt-group { margin-bottom: var(--space-5); }
.fmt-label {
  font-size: 11px;
  color: var(--fg-3);
  margin-bottom: 6px;
  display: flex; align-items: center; justify-content: space-between;
}
.fmt-label .val {
  font-family: var(--font-mono);
  color: var(--accent-2);
  font-size: 11px;
}
.seg {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: rgba(10,20,35,0.5);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}
.seg button {
  flex: 1;
  padding: 6px 8px;
  border: none;
  background: transparent;
  color: var(--fg-3);
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
  border-radius: var(--radius-xs);
  transition: all var(--dur-fast) var(--ease-out);
}
.seg button:hover { color: var(--fg-2); }
.seg button.on {
  background: var(--grad-brand);
  color: #fff;
}

/* Slider */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: rgba(20,41,63,0.6);
  border-radius: var(--radius-pill);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: var(--glow-teal-sm);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: var(--glow-teal-sm);
  cursor: pointer;
  border: none;
}

/* Mode toggle (Flow / Focus / Typewriter) */
.mode-row {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.mode-btn {
  flex: 1;
  padding: 8px;
  background: rgba(10,20,35,0.5);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--fg-3);
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.mode-btn:hover {
  border-color: var(--border-accent);
  color: var(--fg-2);
}
.mode-btn.on,
.mode-btn.active {
  background: rgba(20,184,154,0.12);
  border-color: var(--border-accent);
  color: var(--accent-2);
  box-shadow: var(--glow-teal-sm);
}
.mode-btn .kbd {
  font-size: 9px;
  color: var(--fg-4);
  background: rgba(7,14,26,0.6);
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 4px;
}

/* Export */
.export-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
}
.export-btn {
  background: var(--grad-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
  color: var(--fg-2);
  font-family: var(--font-mono);
}
.export-btn:hover {
  border-color: var(--border-accent);
  box-shadow: var(--glow-teal-sm);
  transform: translateY(-1px);
}
.export-btn .ext { font-size: 14px; font-weight: 600; color: var(--accent-2); }
.export-btn .lbl { font-size: 10px; color: var(--fg-3); text-transform: uppercase; letter-spacing: 0.06em; }

/* ============================================================
   STATUS BAR
   ============================================================ */
.status {
  grid-area: status;
  display: flex; align-items: center;
  background: rgba(7,14,26,0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border-subtle);
  padding: 0 var(--space-5);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-3);
  letter-spacing: 0.04em;
  gap: var(--space-4);
  z-index: 30;
}
.status .item { display: flex; align-items: center; gap: 6px; }
.status .item .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--fg-4);
}
.status .item.flow .dot { background: var(--pulse-green); box-shadow: 0 0 6px var(--pulse-green); animation: pulse 2s infinite; }
.status .item.idle .dot { background: var(--warn-amber); }
.status .item.saving .dot { background: var(--accent-2); animation: pulse 1s infinite; }
.status .item.saved .dot { background: var(--accent-2); box-shadow: 0 0 6px var(--accent-2); }
.status .item.branch { color: var(--accent-2); }
.status .grow { flex: 1; }
.status .kbd-hint {
  color: var(--fg-4);
  display: flex; align-items: center; gap: 6px;
}
.status .kbd-hint kbd {
  background: rgba(7,14,26,0.6);
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 10px;
  color: var(--fg-3);
}

/* ---------- Save indicator ---------- */
.save-indicator { display: inline-flex; align-items: center; gap: 4px; }
.save-indicator .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--success-green);
  box-shadow: 0 0 4px var(--success-green);
  transition: all var(--dur-fast);
}
.save-indicator.saving .dot {
  background: var(--warn-amber);
  box-shadow: 0 0 4px var(--warn-amber);
  animation: pulse-dot 1s ease infinite;
}
.save-indicator.unsaved .dot {
  background: var(--danger-red);
  box-shadow: 0 0 4px var(--danger-red);
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

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

/* ============================================================
   MODAL  ·  command palette + branch creator + shortcuts
   ============================================================ */
.modal-scrim {
  position: fixed; inset: 0;
  background: rgba(4,8,16,0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: grid; place-items: start center;
  padding-top: 12vh;
  z-index: 100;
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-out);
}
.modal-scrim.show { opacity: 1; pointer-events: auto; }
/* DEBUG: force dashboard visible */


.modal {
  width: min(560px, 92vw);
  background: var(--grad-card);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg), var(--glow-teal-md);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg), var(--glow-teal-sm);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  overflow: hidden;
  transform: translateY(-8px) scale(0.98);
  transition: transform var(--dur-base) var(--ease-out);
}
.modal-scrim.show .modal { transform: translateY(0) scale(1); }
.modal-head {
  border-bottom: 1px solid var(--border-subtle);
  padding: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.modal-head h3 {
  font-family: var(--font-display);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  color: var(--fg-1);
  margin: 0;
}
.modal-body { padding: var(--space-4); }
.modal-body p { margin: 0 0 var(--space-4) 0; color: var(--fg-3); font-size: 13px; line-height: 1.6; }
.modal-body input[type=text] {
  width: 100%;
  padding: 10px 14px;
  background: rgba(7,14,26,0.5);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-sm);
  color: var(--fg-1);
  font-family: var(--font-mono);
  font-size: 13px;
  outline: 0;
  transition: all var(--dur-fast) var(--ease-out);
}
.modal-body input[type=text]:focus {
  border-color: var(--border-accent);
  box-shadow: var(--glow-teal-sm);
}
.modal-body input[type=checkbox] {
  margin-right: 8px;
  accent-color: var(--accent-2);
}
.modal-body .checkbox-label {
  display: flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-2);
  margin-top: var(--space-3);
  cursor: pointer;
}
.modal-body .parent-info {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-4);
  margin-bottom: var(--space-3);
}
.modal-body .word-delta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent-2);
  margin-top: var(--space-3);
}
.modal-body .commit-preview {
  background: rgba(7,14,26,0.5);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  margin-top: var(--space-3);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-3);
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
}
.modal-foot {
  border-top: 1px solid var(--border-subtle);
  padding: var(--space-4);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  background: rgba(7,14,26,0.4);
}
.modal .btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--fg-3);
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}
.modal .btn:hover {
  border-color: var(--border-accent);
  color: var(--fg-1);
  background: rgba(20,184,154,0.06);
}
.modal .btn.primary {
  background: var(--grad-brand);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--glow-teal-sm);
}
.modal .btn.primary:hover {
  box-shadow: var(--glow-teal-md);
  transform: translateY(-1px);
}
.btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: var(--font-display);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-line);
  background: transparent;
  color: var(--fg-2);
  transition: all var(--dur-fast) var(--ease-out);
}
.btn:hover { color: var(--fg-1); border-color: var(--border-accent); }
.btn.primary {
  background: var(--grad-brand-deep);
  color: #fff;
  border-color: transparent;
  box-shadow: var(--glow-teal-sm), var(--shadow-inset);
}
.btn.primary:hover { box-shadow: var(--glow-teal-md); }
.btn.danger {
  color: var(--danger-red);
  border-color: rgba(255,93,115,0.35);
}
.btn.danger:hover {
  background: rgba(255,93,115,0.10);
  border-color: var(--danger-red);
}

/* Command palette list */
.cmd-results { max-height: 320px; overflow-y: auto; }
.cmd-results::-webkit-scrollbar { width: 6px; }
.cmd-results::-webkit-scrollbar-thumb { background: var(--navy-700); border-radius: 3px; }
.cmd-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 10px 18px;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: all var(--dur-fast) var(--ease-out);
}
.cmd-item:hover, .cmd-item.sel {
  background: rgba(20,184,154,0.08);
  border-left-color: var(--accent-2);
}
.cmd-item .ic {
  width: 24px; height: 24px;
  border-radius: 6px;
  display: grid; place-items: center;
  background: rgba(20,184,154,0.08);
  color: var(--accent-2);
  font-size: 12px;
}
.cmd-item .label { flex: 1; font-size: 13px; color: var(--fg-1); }
.cmd-item .kbd {
  font-family: var(--font-mono); font-size: 10px;
  color: var(--fg-4);
  background: rgba(7,14,26,0.6);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
}

/* Shortcut sheet */
.sc-grid {
  display: grid; grid-template-columns: 1fr auto;
  gap: 10px 24px;
  font-size: 13px;
}
.sc-grid .lbl { color: var(--fg-2); }
.sc-grid .keys {
  display: flex; gap: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
}
.sc-grid kbd {
  background: rgba(7,14,26,0.6);
  border: 1px solid var(--border-subtle);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 2px 8px;
  color: var(--accent-2);
  min-width: 18px;
  text-align: center;
}

/* ============================================================
   SPRINT TIMER (Section 3.2)
   ============================================================ */
.sprint-section {
  background: rgba(10,20,35,0.4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}
.sprint-card {
  background: rgba(7,14,26,0.5);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}
.sprint-card.idle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.sprint-time-display {
  font-family: var(--font-display);
  font-size: 28px;
  color: var(--fg-1);
  text-align: center;
  letter-spacing: 0.1em;
  margin: var(--space-3) 0;
}
.sprint-time-display.running {
  color: var(--accent-2);
  text-shadow: 0 0 12px rgba(20,184,154,0.3);
}
.sprint-duration-select {
  display: flex;
  gap: 4px;
  justify-content: center;
}
.sprint-dur-btn {
  padding: 5px 10px;
  background: transparent;
  border: 1px solid var(--border-line);
  border-radius: var(--radius-sm);
  color: var(--fg-3);
  font-family: var(--font-mono);
  font-size: 10px;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}
.sprint-dur-btn:hover { color: var(--fg-1); border-color: var(--border-accent); }
.sprint-dur-btn.on {
  background: rgba(20,184,154,0.12);
  border-color: var(--border-accent);
  color: var(--accent-2);
}
.sprint-controls-row {
  display: flex;
  gap: 6px;
  justify-content: center;
  width: 100%;
}
.sprint-btn {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-family: var(--font-display);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-line);
  background: transparent;
  color: var(--fg-2);
  transition: all var(--dur-fast) var(--ease-out);
  flex: 1;
  text-align: center;
}
.sprint-btn:hover { color: var(--fg-1); border-color: var(--border-accent); }
.sprint-btn.primary {
  background: var(--grad-brand-deep);
  color: #fff;
  border-color: transparent;
  box-shadow: var(--glow-teal-sm), var(--shadow-inset);
}
.sprint-btn.primary:hover { box-shadow: var(--glow-teal-md); }
.sprint-btn.danger {
  color: var(--danger-red);
  border-color: rgba(255,93,115,0.35);
}
.sprint-btn.danger:hover {
  background: rgba(255,93,115,0.10);
  border-color: var(--danger-red);
}
.sprint-progress {
  height: 6px;
  background: var(--navy-700);
  border-radius: 3px;
  overflow: hidden;
  margin: 8px 0;
}
.sprint-progress-fill {
  height: 100%;
  background: var(--grad-brand);
  border-radius: 3px;
  transition: width 1s linear;
  box-shadow: var(--glow-teal-sm);
}
.sprint-phase-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-2);
  text-align: center;
  margin-bottom: 4px;
}
.sprint-stats-row {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-4);
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  margin-top: 6px;
}

/* ============================================================
   DAILY TARGET (Section 3.4)
   ============================================================ */
.daily-target-section { margin-bottom: var(--space-5); }
.daily-target-bar {
  height: 6px;
  background: rgba(20,41,63,0.6);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin: var(--space-2) 0;
}
.daily-target-fill {
  height: 100%;
  background: var(--grad-brand);
  border-radius: var(--radius-pill);
  transition: width var(--dur-slow) var(--ease-out);
  box-shadow: var(--glow-teal-sm);
}
.daily-target-fill.complete {
  background: linear-gradient(90deg, var(--teal-500), var(--pulse-green));
  box-shadow: 0 0 12px rgba(74,222,128,0.4);
}
.daily-target-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-3);
  text-align: right;
}
.daily-target-celebrate {
  font-family: var(--font-display);
  font-size: 11px;
  color: var(--pulse-green);
  text-align: center;
  margin-top: var(--space-2);
  animation: fade-in var(--dur-normal) var(--ease-out);
}

@keyframes targetPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.02); }
}

/* ============================================================
   STATS MODAL (Section 3.3)
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.stat-card {
  background: rgba(7,14,26,0.5);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}
.stat-value {
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--fg-1);
}
.stat-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-4);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-top: 4px;
}
.stats-section-title {
  font-family: var(--font-display);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-2);
  margin: var(--space-4) 0 var(--space-3) 0;
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
}
.stats-week-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  height: 120px;
  padding: var(--space-3) 0;
}
.stats-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.stats-bar-track {
  width: 100%;
  flex: 1;
  background: var(--navy-700);
  border-radius: 3px;
  position: relative;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}
.stats-bar-fill {
  width: 100%;
  background: linear-gradient(180deg, var(--teal-500), var(--teal-700));
  border-radius: 2px 2px 0 0;
  min-height: 4px;
  transition: height var(--dur-slow) var(--ease-out);
}
.stats-bar-fill.today {
  background: linear-gradient(180deg, var(--accent-2), var(--accent-1));
  box-shadow: 0 0 8px rgba(20,184,154,0.3);
}
.stats-bar-label {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--fg-4);
  text-transform: uppercase;
}
.stats-bar-value {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--fg-3);
}
.stats-branch-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stats-branch-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
  background: rgba(7,14,26,0.3);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 11px;
}
.stats-branch-name {
  color: var(--fg-2);
}
.stats-branch-wc {
  color: var(--accent-2);
}

/* ============================================================
   BRANCH COMPARISON MODAL
   ============================================================ */

.compare-selectors {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.compare-select-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.compare-select-row label {
  width: 80px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-4);
  flex-shrink: 0;
}

.compare-select-row select {
  flex: 1;
  padding: 8px 12px;
  background: rgba(7,14,26,0.5);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-sm);
  color: var(--fg-1);
  font-family: var(--font-mono);
  font-size: 12px;
  outline: 0;
  transition: all var(--dur-fast) var(--ease-out);
}

.compare-select-row select:focus {
  border-color: var(--border-accent);
  box-shadow: var(--glow-teal-sm);
}

.compare-panes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.compare-pane {
  background: rgba(7,14,26,0.5);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px;
  max-height: 400px;
  overflow: auto;
}

.compare-pane-header {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-4);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.compare-pane-content {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--fg-2);
  line-height: 1.6;
  white-space: pre-wrap;
}

.compare-diff-summary {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-3);
  margin-bottom: 12px;
  padding: 8px 12px;
  background: rgba(20,184,154,0.06);
  border-radius: var(--radius-sm);
}

/* ============================================================
   CROSS-BRANCH SEARCH
   ============================================================ */

.search-input {
  width: 100%;
  padding: 10px 14px;
  background: rgba(7,14,26,0.5);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-sm);
  color: var(--fg-1);
  font-family: var(--font-mono);
  font-size: 13px;
  margin-bottom: var(--space-3);
  outline: 0;
  transition: all var(--dur-fast) var(--ease-out);
}
.search-input:focus {
  border-color: var(--border-accent);
  box-shadow: var(--glow-teal-sm);
}
.search-results {
  max-height: 400px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.search-result {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: all var(--dur-fast) var(--ease-out);
}
.search-result:hover {
  background: rgba(20, 184, 154, 0.06);
  border-left-color: var(--accent-2);
}
.search-result mark {
  background: rgba(20, 184, 154, 0.25);
  color: var(--fg-1);
  padding: 1px 3px;
  border-radius: 2px;
  font-weight: 500;
}

/* File Import Drop Zone */
#tree.file-drag-over {
  border: 2px dashed var(--accent-2);
  border-radius: var(--radius-md);
  background: rgba(20, 184, 154, 0.04);
  position: relative;
}
#tree.file-drag-over::after {
  content: 'Drop .txt or .md files here';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent-2);
  background: rgba(7, 14, 26, 0.9);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-accent);
  pointer-events: none;
  z-index: 10;
}

/* ============================================================
   AI ASSISTANT (Phase 4)
   ============================================================ */

.ai-panel {
  background: rgba(7,14,26,0.5);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}
.ai-panel .section-title {
  font-family: var(--font-display);
  font-size: 12px;
  color: var(--accent-2);
  letter-spacing: 0.08em;
}
.ai-config-input {
  width: 100%;
  padding: 8px 12px;
  background: rgba(7,14,26,0.5);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-sm);
  color: var(--fg-1);
  font-family: var(--font-mono);
  font-size: 12px;
  outline: 0;
  transition: all var(--dur-fast) var(--ease-out);
}
.ai-config-input:focus {
  border-color: var(--border-accent);
  box-shadow: var(--glow-teal-sm);
}
select.ai-config-input {
  cursor: pointer;
  appearance: auto;
}
.ai-suggestion-btn {
  background: rgba(20,184,154,0.1);
  border: 1px solid var(--border-accent);
  color: var(--accent-2);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}
.ai-suggestion-btn:hover {
  background: rgba(20,184,154,0.2);
  box-shadow: var(--glow-teal-sm);
}

/* Inline ghost text */
.ai-ghost-text {
  position: absolute;
  pointer-events: none;
  color: var(--fg-4);
  font-style: italic;
  z-index: 10;
  font-family: var(--font-sans);
  font-size: var(--editor-fs, 18px);
  line-height: var(--editor-lh, 1.7);
  white-space: pre-wrap;
  word-break: break-word;
  animation: fade-in var(--dur-fast) var(--ease-out);
}

/* ============================================================
   SHORTCUTS CHEAT SHEET
   ============================================================ */
.shortcuts-body { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.shortcuts-group h4 { font-family: var(--font-display); font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent-2); margin-bottom: var(--space-3); }
.shortcuts-row { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; border-bottom: 1px solid var(--border-subtle); font-size: 12px; }
.shortcuts-row kbd { background: var(--bg-2); border: 1px solid var(--border-subtle); border-radius: 4px; padding: 2px 6px; font-family: var(--font-mono); font-size: 10px; color: var(--fg-1); }
.shortcuts-row span { color: var(--fg-3); }
@media (max-width: 768px) { .shortcuts-body { grid-template-columns: 1fr; } }

/* ============================================================
   RIGHT PANE TABS
   ============================================================ */
.right-pane-tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: rgba(10,20,35,0.5);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-4);
}
.right-pane-tab {
  flex: 1;
  padding: 6px 8px;
  border: none;
  background: transparent;
  color: var(--fg-3);
  font-family: var(--font-mono);
  font-size: 10px;
  cursor: pointer;
  border-radius: var(--radius-xs);
  transition: all var(--dur-fast);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.right-pane-tab:hover {
  color: var(--fg-2);
  background: rgba(20,184,154,0.06);
}
.right-pane-tab.active {
  background: var(--grad-brand);
  color: #fff;
  box-shadow: var(--glow-teal-sm);
}
.right-pane-section {
  display: none;
  padding-top: var(--space-2);
}
.right-pane-section.active {
  display: block;
  animation: fade-in var(--dur-fast) var(--ease-out);
}

/* ============================================================
   FOCUS MODE WORD COUNT RING
   ============================================================ */
.focus-word-ring { position: fixed; bottom: 24px; right: 24px; width: 80px; height: 80px; z-index: 50; opacity: 0; transition: opacity var(--dur-slow); pointer-events: none; filter: drop-shadow(0 0 8px rgba(20,184,154,0.3)); }
.app.focus-mode .focus-word-ring { opacity: 1; }
.focus-word-ring svg { transform: rotate(-90deg); }
.focus-word-ring circle.track { fill: none; stroke: rgba(20,41,63,0.8); stroke-width: 4; }
.focus-word-ring circle.progress { fill: none; stroke: var(--accent-2); stroke-width: 4; stroke-linecap: round; transition: stroke-dashoffset var(--dur-slow); filter: drop-shadow(0 0 4px var(--accent-2)); }
.focus-word-ring .ring-label { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-mono); font-size: 14px; font-weight: 700; color: var(--fg-1); }







/* ============================================================
   BRANCH NAME EDIT (inline rename)
   ============================================================ */
.branch-name-edit { background: var(--bg-2); border: 1px solid var(--accent-2); border-radius: var(--radius-sm); color: var(--fg-1); font-family: var(--font-mono); font-size: 12px; padding: 2px 6px; width: 140px; outline: none; }
.branch-name { cursor: text; border-bottom: 1px dashed transparent; transition: border-color var(--dur-fast); }
.branch-name:hover { border-bottom-color: var(--fg-4); }

/* ============================================================
   SMOOTH CSS ANIMATIONS (Phase 5a)
   ============================================================ */

/* Tree item hover lift */



/* Modal entrance animation */
@keyframes modal-in {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-scrim.show .modal {
  animation: modal-in var(--dur-normal) var(--ease-out);
}

/* Tag hover glow effect */
.tag { transition: box-shadow var(--dur-fast), transform var(--dur-fast); }
.tag:hover { box-shadow: var(--glow-teal-sm); }

/* Branch chip pulse on active branch change */


/* Mobile graceful */
@media (max-width: 920px) {
  .app { grid-template-columns: 0 1fr 0; }
  .app .pane { display: none; }
  .compare-panes { grid-template-columns: 1fr; }
}

/* ============================================================
   ONBOARDING TUTORIAL
   ============================================================ */

.onboarding-overlay {
  position: fixed;
  bottom: 44px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 900;
  width: min(420px, 90vw);
  animation: tutorial-slide-up 0.5s var(--ease-out) 0.8s both;
}

@keyframes tutorial-slide-up {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.onboarding-card {
  background: var(--grad-card);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-md);
  padding: 18px 22px;
  box-shadow: var(--shadow-lg), var(--glow-teal-sm);
  position: relative;
  cursor: pointer;
  transition: box-shadow var(--dur-fast) var(--ease-out);
}

.onboarding-card:hover {
  box-shadow: var(--shadow-lg), var(--glow-teal-md);
}

.onboarding-card h4 {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-2);
  margin: 0 0 6px 0;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.onboarding-card p {
  font-size: 13px;
  color: var(--fg-2);
  line-height: 1.5;
  margin: 0;
}

.onboarding-card .tutorial-dismiss {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--fg-4);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 14px;
  transition: all var(--dur-fast);
}

.onboarding-card .tutorial-dismiss:hover {
  background: rgba(20,184,154,0.1);
  color: var(--accent-2);
}

.onboarding-progress {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  justify-content: center;
}

.onboarding-progress .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border-subtle);
  transition: all var(--dur-fast);
}

.onboarding-progress .dot.active {
  background: var(--accent-2);
  box-shadow: var(--glow-teal-sm);
  width: 18px;
  border-radius: var(--radius-pill);
}

/* Light theme */
html[data-theme="light"] .onboarding-card {
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}

/* ═══════════════════════════════════════════════════════════════
   VOICE TO TEXT — Mic Button
   ═══════════════════════════════════════════════════════════════ */

#btnVoice {
  position: relative;
  transition: all var(--dur-fast);
}
#btnVoice.listening {
  color: var(--accent-2);
  animation: mic-pulse 1.5s ease-in-out infinite;
}
#btnVoice.listening::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 1.5px solid var(--accent-2);
  animation: mic-ring 1.5s ease-out infinite;
}
@keyframes mic-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}
@keyframes mic-ring {
  0% { transform: scale(0.8); opacity: 1; }
  100% { transform: scale(1.6); opacity: 0; }
}
/* Light theme */
html[data-theme="light"] #btnVoice.listening {
  color: var(--teal-600);
}
html[data-theme="light"] #btnVoice.listening::after {
  border-color: var(--teal-500);
}

/* ============================================================
   MOBILE RESPONSIVENESS
   ============================================================ */

.hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--fg-2);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
}

.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--grad-surface);
  border-top: 1px solid var(--border-subtle);
  padding: 4px 0;
  z-index: 100;
  justify-content: space-around;
}

.mobile-nav button {
  background: none;
  border: none;
  color: var(--fg-2);
  font-size: 18px;
  padding: 8px 16px;
  cursor: pointer;
  transition: color var(--dur-fast);
}

.mobile-nav button:hover, .mobile-nav button.active {
  color: var(--accent-2);
}



/* ============================================================
   ANALYTICS DASHBOARD (Section 4.3)
   ============================================================ */

.analytics-section { margin-bottom: var(--space-4); }
.analytics-score {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(20,184,154,0.08);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-2);
}
.analytics-score .value {
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--accent-2);
}
.word-frequency-bar {
  height: 4px;
  background: var(--navy-700);
  border-radius: 2px;
  overflow: hidden;
}
.word-frequency-bar .fill {
  height: 100%;
  background: var(--accent-2);
  border-radius: 2px;
}
.analytics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.analytics-card {
  background: rgba(7,14,26,0.5);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}
.analytics-card .value {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--fg-1);
}
.analytics-card .label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-4);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-top: 4px;
}
.word-frequency-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-2);
}
.word-frequency-row .word {
  width: 100px;
  flex-shrink: 0;
}
.word-frequency-row .bar-wrap {
  flex: 1;
  height: 4px;
  background: var(--navy-700);
  border-radius: 2px;
  overflow: hidden;
}
.word-frequency-row .bar-fill {
  height: 100%;
  background: var(--accent-2);
  border-radius: 2px;
  transition: width 420ms var(--ease-out);
}
.word-frequency-row .count {
  width: 30px;
  text-align: right;
  color: var(--fg-4);
  flex-shrink: 0;
}
.character-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.character-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 11px;
  border: 1px solid var(--border-subtle);
  background: rgba(20,41,63,0.45);
  color: var(--fg-2);
}
.character-chip .count {
  color: var(--accent-2);
}
.sentiment-bar {
  height: 6px;
  background: var(--navy-700);
  border-radius: 3px;
  overflow: hidden;
  display: flex;
}
.sentiment-bar .pos {
  background: var(--pulse-green);
  height: 100%;
  transition: width 420ms var(--ease-out);
}
.sentiment-bar .neg {
  background: var(--danger-red);
  height: 100%;
  transition: width 420ms var(--ease-out);
}
.sentiment-labels {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-4);
  margin-top: 4px;
}

@media (min-width: 769px) and (max-width: 1024px) {
  #app {
    grid-template-columns: 220px 1fr;
  }
  .right-pane {
    display: none;
  }
  .center {
    grid-column: 2;
  }
}

/* ============================================================
   PHASE 5a — Desktop Polish (Legolas)
   ============================================================ */

/* ── Keyboard Shortcut Cheat Sheet ── */







/* ── Tabbed Right Pane ── */

/* Note: .right-pane-tab styles are defined in the RIGHT PANE section above */




/* ── Inline Branch Rename ── */




/* ── Save Indicator States ── */






/* ── Focus Mode Word Count Ring ── */













/* ── Pane Dividers (Resizable) ── */






/* ═══════════════════════════════════════════════════════════════
   PHASE 5b — MOBILE POLISH
   Touch D&D, viewport fix, 44px targets, bottom sheets
   ═══════════════════════════════════════════════════════════════ */

/* Touch drag ghost */
.drag-ghost {
  background: var(--bg-glass);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(8px);
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--fg-2);
  pointer-events: none;
}

/* Prevent scroll during tree drag on touch */
.tree.dragging-active {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* Ensure tree items have enough touch target */


/* ── Swipe Actions on Tree Items ── */
.tree-item-wrap {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-sm);
}
.tree-item-wrap .tree-item {
  border-radius: 0; /* inner item gets no radius since wrap has it */
}
.tree-item-swipe-actions {
  position: absolute; right: 0; top: 0; bottom: 0;
  display: flex; align-items: center; gap: 0;
  transform: translateX(100%);
  transition: transform var(--dur-fast);
  z-index: 5;
}
.tree-item-wrap.swiped .tree-item-swipe-actions { transform: translateX(0); }
.tree-item-wrap.swiped .tree-item {
  transform: translateX(-120px);
  transition: transform var(--dur-fast);
}

.swipe-btn {
  width: 60px; height: 100%;
  display: grid; place-items: center;
  border: none;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  transition: all var(--dur-fast);
}
.swipe-btn.delete { background: var(--danger-red); color: #fff; }
.swipe-btn.duplicate { background: var(--accent-2); color: #030c1c; }
.swipe-btn.rename { background: var(--warn-amber); color: #030c1c; }

.swipe-btn.delete:hover { background: #ff3d5a; }



/* ── Mobile File Picker Button ── */
.mobile-import-btn {
  display: none;
  width: calc(100% - 16px);
  margin: 8px;
  padding: 10px;
  background: rgba(10,20,35,0.5);
  border: 1px dashed var(--border-line);
  border-radius: var(--radius-sm);
  color: var(--fg-4);
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
  transition: all var(--dur-fast);
  align-items: center;
  gap: 8px;
}

.mobile-import-btn:hover {
  border-color: var(--border-accent);
  color: var(--accent-2);
  background: rgba(20,184,154,0.06);
}

/* Mobile bottom sheets */


/* Onboarding overlay */












.onboarding-nav .btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--fg-3);
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
  transition: all var(--dur-fast);
}

.onboarding-nav .btn:hover {
  border-color: var(--border-accent);
  color: var(--fg-1);
}

.onboarding-nav .btn.primary {
  background: var(--grad-brand);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--glow-teal-sm);
}









/* Pull-to-refresh / sync indicator */


/* ── Pull-to-Refresh Sync Indicator ── */
.ptr-indicator {
  position: fixed;
  top: 52px;
  left: 50%;
  transform: translateX(-50%) translateY(-40px);
  z-index: 250;
  background: var(--grad-card);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-pill);
  padding: 6px 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-2);
  display: none;
  align-items: center;
  gap: 6px;
  transition: transform var(--dur-normal) var(--ease-out);
  pointer-events: none;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-sm);
}
.ptr-indicator.visible {
  display: flex;
  transform: translateX(-50%) translateY(8px);
}



.ptr-indicator svg {
  animation: spin 1s linear infinite;
}

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

/* ============================================================
   TOPBAR THEME & COMMAND BUTTONS
   ============================================================ */

#btnTheme svg,
#btnCmd svg {
  width: 16px;
  height: 16px;
}

#btnCmd {
  position: relative;
  border-color: var(--border-accent);
  background: rgba(20,184,154,0.06);
}

/* Subtle "K" badge on the command button */
#btnCmd::after {
  content: 'K';
  position: absolute;
  bottom: -2px;
  right: -2px;
  font-family: var(--font-mono);
  font-size: 7px;
  font-weight: 700;
  color: var(--accent-2);
  background: rgba(7,14,26,0.85);
  border: 1px solid var(--border-accent);
  border-radius: 3px;
  padding: 0 2px;
  line-height: 1;
  pointer-events: none;
}

/* ============================================================
   LIGHT THEME OVERRIDES for hardcoded dark colors
   ============================================================ */

html[data-theme="light"] body {
  background:
    radial-gradient(ellipse 90% 60% at 15% 0%, rgba(20,184,154,0.06) 0%, transparent 55%),
    radial-gradient(ellipse 70% 50% at 100% 100%, rgba(62,240,226,0.04) 0%, transparent 55%),
    var(--bg-base);
}

html[data-theme="light"] .topbar {
  background: rgba(255, 255, 255, 0.82);
}

html[data-theme="light"] .status {
  background: rgba(255, 255, 255, 0.85);
}

html[data-theme="light"] .modal-body input[type=text] {
  background: rgba(240, 244, 248, 0.8);
  color: var(--fg-1);
}

html[data-theme="light"] .modal-body .commit-preview {
  background: rgba(240, 244, 248, 0.8);
}

html[data-theme="light"] .modal-foot {
  background: rgba(255, 255, 255, 0.5);
}

html[data-theme="light"] .cmd-item .kbd {
  background: rgba(240, 244, 248, 0.8);
}

html[data-theme="light"] .sc-grid kbd {
  background: rgba(240, 244, 248, 0.8);
}

html[data-theme="light"] .seg {
  background: rgba(240, 244, 248, 0.6);
}

html[data-theme="light"] .mode-btn {
  background: rgba(240, 244, 248, 0.6);
}

html[data-theme="light"] .right-pane-tabs {
  background: rgba(240, 244, 248, 0.6);
}

html[data-theme="light"] .sprint-section,
html[data-theme="light"] .sprint-card {
  background: rgba(240, 244, 248, 0.6);
}

html[data-theme="light"] .sprint-progress {
  background: rgba(203, 213, 225, 0.6);
}

html[data-theme="light"] .daily-target-bar {
  background: rgba(203, 213, 225, 0.6);
}

html[data-theme="light"] .stat-card {
  background: rgba(240, 244, 248, 0.8);
}

html[data-theme="light"] .stats-bar-track {
  background: rgba(203, 213, 225, 0.6);
}

html[data-theme="light"] .stats-branch-row {
  background: rgba(240, 244, 248, 0.5);
}

html[data-theme="light"] .analytics-card {
  background: rgba(240, 244, 248, 0.8);
}

html[data-theme="light"] .word-frequency-row .bar-wrap,
html[data-theme="light"] .sentiment-bar {
  background: rgba(203, 213, 225, 0.6);
}

html[data-theme="light"] .character-chip {
  background: rgba(240, 244, 248, 0.6);
}

html[data-theme="light"] .ai-panel {
  background: rgba(240, 244, 248, 0.6);
}

html[data-theme="light"] .ai-config-input {
  background: rgba(255, 255, 255, 0.8);
  color: var(--fg-1);
}

html[data-theme="light"] .search-input {
  background: rgba(240, 244, 248, 0.8);
  color: var(--fg-1);
}

html[data-theme="light"] .compare-select-row select {
  background: rgba(240, 244, 248, 0.8);
  color: var(--fg-1);
}

html[data-theme="light"] .compare-pane {
  background: rgba(240, 244, 248, 0.6);
}

html[data-theme="light"] .mobile-import-btn {
  background: rgba(240, 244, 248, 0.6);
}

html[data-theme="light"] .export-btn {
  background: var(--grad-card);
}

html[data-theme="light"] .onboarding-card {
  background: var(--grad-card);
}

html[data-theme="light"] .nudge {
  background: rgba(255, 255, 255, 0.92);
}

html[data-theme="light"] .focus-word-ring circle.track {
  stroke: rgba(203, 213, 225, 0.8);
}

/* Focus mode word count ring track fix */
.focus-word-ring circle.track {
  transition: stroke var(--dur-fast);
}

/* ═══════════════════════════════════════════════════════════════
   LIGHT THEME SCROLLBAR FIXES
   ═══════════════════════════════════════════════════════════════ */

html[data-theme="light"] .editor-wrap {
  scrollbar-color: var(--border-line) transparent;
}
html[data-theme="light"] .editor-wrap::-webkit-scrollbar-thumb {
  background: var(--border-line);
}

html[data-theme="light"] .pane {
  scrollbar-color: var(--border-line) transparent;
}
html[data-theme="light"] .pane::-webkit-scrollbar-thumb {
  background: var(--border-line);
}

html[data-theme="light"] .commit-list {
  scrollbar-color: var(--border-line) transparent;
}
html[data-theme="light"] .commit-list::-webkit-scrollbar-thumb {
  background: var(--border-line);
}

html[data-theme="light"] .cmd-results {
  scrollbar-color: var(--border-line) transparent;
}
html[data-theme="light"] .cmd-results::-webkit-scrollbar-thumb {
  background: var(--border-line);
}

html[data-theme="light"] .dashboard-body {
  scrollbar-color: var(--border-line) transparent;
}
html[data-theme="light"] .dashboard-body::-webkit-scrollbar-thumb {
  background: var(--border-line);
}

/* ============================================================
   LIGHT THEME OVERRIDES — Missing pieces for branch graph & UI
   ============================================================ */

/* -- Modal Scrim — needs lighter overlay in light mode -- */
html[data-theme="light"] .modal-scrim {
  background: rgba(15, 23, 42, 0.45);
}

/* -- Command Palette items — hover/selected states -- */
html[data-theme="light"] .cmd-item:hover,
html[data-theme="light"] .cmd-item.sel {
  background: rgba(20, 184, 154, 0.06);
}

html[data-theme="light"] .cmd-item .ic {
  background: rgba(20, 184, 154, 0.06);
}

html[data-theme="light"] .cmd-item .kbd {
  background: rgba(240, 244, 248, 0.8);
  border-color: var(--border-subtle);
  color: var(--fg-3);
}

/* -- Tags — hardcoded dark backgrounds need light equivalents -- */
html[data-theme="light"] .tag {
  background: rgba(240, 244, 248, 0.6);
  border-color: var(--border-subtle);
  color: var(--fg-2);
}

html[data-theme="light"] .tag.auto {
  color: var(--accent-1);
  border-color: rgba(20, 184, 154, 0.25);
  background: rgba(20, 184, 154, 0.06);
}

html[data-theme="light"] .tag.suggest {
  color: var(--fg-3);
  border-color: var(--border-subtle);
}

html[data-theme="light"] .tag.suggest:hover {
  color: var(--accent-1);
  background: rgba(20, 184, 154, 0.06);
}

/* -- Modal body inputs and commit preview -- */
html[data-theme="light"] .modal-body input[type=text] {
  background: rgba(255, 255, 255, 0.85);
  color: var(--fg-1);
  border-color: var(--border-line);
}

html[data-theme="light"] .modal-body .commit-preview {
  background: rgba(240, 244, 248, 0.7);
  color: var(--fg-2);
  border-color: var(--border-subtle);
}

/* -- Modal foot background -- */
html[data-theme="light"] .modal-foot {
  background: rgba(255, 255, 255, 0.5);
}

/* -- Shortcut sheet keyboard styles -- */
html[data-theme="light"] .sc-grid kbd {
  background: rgba(240, 244, 248, 0.8);
  border-color: var(--border-subtle);
  color: var(--accent-1);
}

/* -- Project switcher — hardcoded dark bg -- */
html[data-theme="light"] .project-switcher {
  background: var(--grad-card);
  border-color: var(--border-subtle);
}

/* -- Branch chip — subtle teal tint -- */
html[data-theme="light"] .branch-chip {
  background: rgba(20, 184, 154, 0.08);
  border-color: var(--border-accent);
}

/* -- Branch dropdown — glassmorphic panel -- */
html[data-theme="light"] .branch-dropdown {
  background: var(--grad-card);
  border-color: var(--border-line);
}

html[data-theme="light"] .branch-dropdown-item:hover {
  background: rgba(20, 184, 154, 0.06);
}

html[data-theme="light"] .branch-dropdown-item.active {
  background: rgba(20, 184, 154, 0.10);
}

/* -- Tree item hover — already uses rgba(20,184,154,0.06), stays fine -- */
html[data-theme="light"] .tree-item.active {
  background: rgba(20, 184, 154, 0.08);
  border-color: var(--border-accent);
}

/* -- Tree context menu — glass panel -- */
html[data-theme="light"] .tree-context-menu {
  background: var(--grad-card);
  border-color: var(--border-line);
}

html[data-theme="light"] .tree-context-item:hover {
  background: rgba(20, 184, 154, 0.06);
}

/* -- Tree add button — transparent border fix -- */
html[data-theme="light"] .tree-add-btn {
  border-color: var(--border-line);
  color: var(--fg-3);
}

html[data-theme="light"] .tree-add-btn:hover {
  background: rgba(20, 184, 154, 0.06);
  border-color: var(--border-accent);
  color: var(--accent-1);
}

/* -- Pane divider — hover glow -- */
html[data-theme="light"] .pane-divider:hover,
html[data-theme="light"] .pane-divider.dragging {
  background: rgba(20, 184, 154, 0.10);
}

/* -- Scene banner — card glass effect -- */
html[data-theme="light"] .scene-banner {
  background: var(--grad-card);
  border-color: var(--border-subtle);
}

/* -- Nudge — notification panel -- */
html[data-theme="light"] .nudge {
  background: rgba(255, 255, 255, 0.92);
  border-color: var(--border-accent);
}

/* -- Export buttons — card backgrounds -- */
html[data-theme="light"] .export-btn {
  background: var(--grad-card);
  border-color: var(--border-subtle);
}

html[data-theme="light"] .export-btn:hover {
  border-color: var(--border-accent);
}

/* -- Segmented controls — pill buttons container -- */
html[data-theme="light"] .seg {
  background: rgba(240, 244, 248, 0.6);
}

/* -- Mode buttons — Flow/Focus/Typewriter toggles -- */
html[data-theme="light"] .mode-btn {
  background: rgba(240, 244, 248, 0.6);
}

html[data-theme="light"] .mode-btn:hover {
  border-color: var(--border-accent);
}

/* -- Right pane tab bar -- */
html[data-theme="light"] .right-pane-tabs {
  background: rgba(240, 244, 248, 0.6);
}

/* -- Range / slider track -- */
html[data-theme="light"] input[type="range"] {
  background: rgba(203, 213, 225, 0.6);
}

/* -- Onboarding overlay — lighter backdrop -- */
html[data-theme="light"] .onboarding-overlay {
  background: rgba(15, 23, 42, 0.35);
}

html[data-theme="light"] .onboarding-card {
  background: var(--grad-card);
  border-color: var(--border-subtle);
}

/* -- File import drop zone -- */
html[data-theme="light"] #tree.file-drag-over {
  background: rgba(20, 184, 154, 0.04);
}

html[data-theme="light"] #tree.file-drag-over::after {
  background: rgba(255, 255, 255, 0.95);
  color: var(--accent-1);
  border-color: var(--border-accent);
}

/* -- Sprint timer — card surfaces -- */
html[data-theme="light"] .sprint-section,
html[data-theme="light"] .sprint-card {
  background: rgba(240, 244, 248, 0.5);
}

html[data-theme="light"] .sprint-time-display.running {
  text-shadow: 0 0 8px rgba(20, 184, 154, 0.2);
}

/* -- Stats — card surfaces -- */
html[data-theme="light"] .stat-card {
  background: rgba(240, 244, 248, 0.7);
}

/* -- Analytics — card and bar surfaces -- */
html[data-theme="light"] .analytics-card {
  background: rgba(240, 244, 248, 0.7);
}

html[data-theme="light"] .word-frequency-row .bar-wrap,
html[data-theme="light"] .sentiment-bar {
  background: rgba(203, 213, 225, 0.5);
}

/* -- AI Assistant — panel surfaces -- */
html[data-theme="light"] .ai-panel {
  background: rgba(240, 244, 248, 0.55);
  border-color: var(--border-accent);
}

html[data-theme="light"] .ai-config-input {
  background: rgba(255, 255, 255, 0.8);
  color: var(--fg-1);
}

/* -- Cross-branch search — input and results -- */
html[data-theme="light"] .search-input {
  background: rgba(255, 255, 255, 0.85);
  color: var(--fg-1);
}

html[data-theme="light"] .search-result:hover {
  background: rgba(20, 184, 154, 0.05);
}

html[data-theme="light"] .search-result mark {
  background: rgba(20, 184, 154, 0.15);
  color: var(--fg-1);
}

/* -- Branch comparison — select and pane surfaces -- */
html[data-theme="light"] .compare-select-row select {
  background: rgba(255, 255, 255, 0.85);
  color: var(--fg-1);
}

html[data-theme="light"] .compare-pane {
  background: rgba(240, 244, 248, 0.6);
}

html[data-theme="light"] .compare-diff-summary {
  background: rgba(20, 184, 154, 0.04);
}

/* -- Daily target — bar track -- */
html[data-theme="light"] .daily-target-bar {
  background: rgba(203, 213, 225, 0.5);
}

/* -- Character chips — tag-like items -- */
html[data-theme="light"] .character-chip {
  background: rgba(240, 244, 248, 0.6);
}

/* -- Stats bar track — weekly chart -- */
html[data-theme="light"] .stats-bar-track {
  background: rgba(203, 213, 225, 0.5);
}

/* -- Stats branch rows -- */
html[data-theme="light"] .stats-branch-row {
  background: rgba(240, 244, 248, 0.45);
}

/* -- Mobile import button -- */
html[data-theme="light"] .mobile-import-btn {
  background: rgba(240, 244, 248, 0.6);
  color: var(--fg-3);
}

html[data-theme="light"] .mobile-import-btn:hover {
  background: rgba(20, 184, 154, 0.06);
  color: var(--accent-1);
}

/* -- Drag ghost — touch D&D -- */
html[data-theme="light"] .drag-ghost {
  background: var(--bg-glass);
  border-color: var(--border-accent);
}

/* -- Commit list (backup: already styled in branch-graph.css) -- */
html[data-theme="light"] .commit-list {
  background: rgba(255, 255, 255, 0.55);
  border-color: var(--border-subtle);
}

html[data-theme="light"] .commit-item:hover {
  background: rgba(20, 184, 154, 0.06);
  border-left-color: var(--accent-1);
  color: var(--fg-1);
}

/* -- Branch graph SVG (backup: primary styles in branch-graph.css) -- */
html[data-theme="light"] .branch-graph-svg {
  background: rgba(255, 255, 255, 0.5);
  border-color: var(--border-subtle);
}

/* -- Graph tooltip (backup: primary styles in branch-graph.css) -- */
html[data-theme="light"] .graph-tooltip {
  background: rgba(255, 255, 255, 0.95);
  border-color: var(--border-subtle);
  color: var(--fg-2);
}

/* -- Graph control buttons (backup: primary styles in branch-graph.css) -- */
html[data-theme="light"] .graph-control-btn {
  background: rgba(240, 244, 248, 0.7);
  border-color: var(--border-subtle);
  color: var(--fg-3);
}

html[data-theme="light"] .graph-control-btn:hover {
  background: rgba(20, 184, 154, 0.06);
  border-color: var(--border-accent);
  color: var(--accent-1);
}




/* ═══════════════════════════════════════════════════════════════
   STORY TIMELINE
   ═══════════════════════════════════════════════════════════════ */

.timeline-bar {
  grid-area: timeline;
  height: 64px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
  overflow: hidden;
  transition: height var(--dur-slow) var(--ease-out);
}
.timeline-bar.collapsed { height: 0; border: none; }
.timeline-svg { width: 100%; height: 100%; cursor: grab; display: block; }
.timeline-svg:active { cursor: grabbing; }
.timeline-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px; height: 24px;
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  color: var(--fg-3);
  cursor: pointer;
  display: grid; place-items: center;
  font-size: 10px;
  z-index: 5;
  transition: all var(--dur-fast);
  padding: 0;
  line-height: 1;
}
.timeline-toggle:hover { color: var(--accent-2); border-color: var(--border-accent); }

/* Timeline nodes */
.timeline-node { cursor: pointer; }
.timeline-node:hover { filter: brightness(1.3); }
.timeline-node.chapter circle[fill] { filter: drop-shadow(0 0 3px currentColor); }
.timeline-node.scene circle[fill] { filter: drop-shadow(0 0 2px currentColor); }
.timeline-node.beat rect[fill] { filter: drop-shadow(0 0 2px currentColor); }
.timeline-node-label {
  font-family: var(--font-mono);
  font-size: 9px;
  fill: var(--fg-3);
  text-anchor: middle;
  pointer-events: none;
}
.timeline-connection {
  fill: none;
  stroke: var(--border-subtle);
  stroke-dasharray: 4 2;
  stroke-width: 1;
}
.timeline-main-line {
  stroke: var(--border-line);
  stroke-width: 2;
}

/* Timeline popup */
.timeline-popup {
  position: absolute;
  background: var(--grad-card);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-md), var(--glow-teal-sm);
  z-index: 100;
  display: none;
  min-width: 200px;
  pointer-events: none;
  left: 0;
  top: 0;
}
.timeline-popup.visible { display: block; animation: fade-in var(--dur-fast) var(--ease-out); }
.timeline-popup-title { font-family: var(--font-display); font-size: 13px; color: var(--fg-1); margin-bottom: 4px; }
.timeline-popup-chapter { font-family: var(--font-mono); font-size: 10px; color: var(--accent-2); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.08em; }
.timeline-popup-desc { font-size: 12px; color: var(--fg-2); line-height: 1.4; margin-bottom: 6px; }
.timeline-popup-status { font-family: var(--font-mono); font-size: 10px; display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: var(--radius-pill); background: rgba(20,184,154,0.1); color: var(--accent-2); }

/* Grid area update for timeline */
.app.has-timeline {
  grid-template-areas:
    "topbar topbar topbar"
    "timeline timeline timeline"
    "left   center right"
    "status status status";
  grid-template-rows: 52px 64px 1fr 36px;
}
.app.has-timeline.timeline-collapsed {
  grid-template-rows: 52px 0 1fr 36px;
}

/* Light theme overrides */
html[data-theme="light"] .timeline-bar { background: var(--bg-surface); }
html[data-theme="light"] .timeline-node-label { fill: var(--fg-3); }
html[data-theme="light"] .timeline-connection { stroke: var(--border-subtle); }
html[data-theme="light"] .timeline-main-line { stroke: var(--border-line); }

/* Status dots on nodes */
.timeline-node .status-dot { pointer-events: none; }

/* Chapter-specific node colors */
.timeline-node.chapter circle { fill: var(--accent-2); }
.timeline-node.scene circle { fill: var(--accent-1); }
.timeline-node.beat rect { fill: var(--fg-3); }

/* Hover state for node groups */
.timeline-node:hover circle,
.timeline-node:hover rect { filter: brightness(1.4); }

/* Responsive: hide labels when narrow */
@media (max-width: 900px) {
  .timeline-node-label { display: none; }
}

/* ============================================================
   INTERACTIVE MAPS
   ============================================================ */
.map-modal { width: min(900px, 95vw); height: min(700px, 85vh); }
.map-body { padding: 0; position: relative; overflow: hidden; flex: 1; display: flex; }
.interactive-map-canvas { width: 100%; height: 100%; cursor: grab; background: transparent; }
.interactive-map-canvas:active { cursor: grabbing; }
.map-toolbar { display: flex; gap: 4px; margin-left: auto; margin-right: 12px; }
.map-pin-popup { position: absolute; background: var(--grad-card); border: 1px solid var(--border-accent); border-radius: var(--radius-sm); padding: var(--space-3); box-shadow: var(--shadow-md); z-index: 10; display: none; min-width: 200px; }
.map-pin-popup.open { display: block; animation: fade-in var(--dur-fast) var(--ease-out); }
.map-pin-popup input { width: 100%; margin-bottom: var(--space-2); }
.map-pin-actions { display: flex; gap: var(--space-2); justify-content: flex-end; }
/* Light theme overrides */
html[data-theme="light"] .interactive-map-canvas { background: transparent; }

/* ============================================================
   UNIVERSE DASHBOARD
   ============================================================ */

/* ---------- Trigger Button ---------- */
.dashboard-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 8px 12px;
  margin-top: var(--space-3);
  margin-bottom: var(--space-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-accent);
  background: rgba(20, 184, 154, 0.08);
  color: var(--accent-2);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
  width: 100%;
}
.dashboard-trigger:hover {
  background: rgba(20, 184, 154, 0.16);
  box-shadow: var(--glow-teal-sm);
  transform: translateY(-1px);
}
.dashboard-trigger span {
  font-size: 12px;
}

/* ---------- Modal ---------- */
.dashboard-modal {
  width: min(960px, 95vw);
  max-height: min(720px, 90vh);
  display: flex;
  flex-direction: column;
}

/* ---------- Body: Two-Column Grid ---------- */
.dashboard-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5);
  padding: var(--space-4);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--navy-700) transparent;
}
.dashboard-body::-webkit-scrollbar { width: 6px; }
.dashboard-body::-webkit-scrollbar-thumb { background: var(--navy-700); border-radius: 3px; }
.dashboard-body::-webkit-scrollbar-track { background: transparent; }

/* ---------- Columns ---------- */
.dashboard-column {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.dashboard-col-title {
  font-family: var(--font-display);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent-2);
  margin: 0 0 var(--space-3) 0;
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* ---------- Card Grid ---------- */
.dashboard-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

/* ============================================================
   CHARACTER MINI-WINDOW
   ============================================================ */
.char-window {
  background: var(--grad-card);
  border: 1px solid var(--border-subtle);
  border-top: 3px solid var(--border-line);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: all var(--dur-normal) var(--ease-out);
  cursor: pointer;
  position: relative;
  box-shadow: var(--shadow-sm);
}
.char-window:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md), var(--glow-teal-sm);
  border-color: var(--border-accent);
}
.char-window.dragging {
  opacity: 0.5;
  transform: scale(0.98);
}
.char-window.drop-target {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 2px rgba(20, 184, 154, 0.25);
}

/* Type-colored top borders */
.char-window.protagonist { border-top-color: var(--accent-2); }
.char-window.antagonist  { border-top-color: var(--danger-red); }
.char-window.supporting  { border-top-color: var(--warn-amber); }

/* Window Chrome (Title Bar) */
.char-window-chrome {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 10px;
  background: rgba(7, 14, 26, 0.45);
  border-bottom: 1px solid var(--border-subtle);
  min-height: 32px;
}
.char-window-dots {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.wdot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: block;
}
.wdot.red    { background: #ff5f57; box-shadow: inset 0 0 0 0.5px rgba(0,0,0,0.15); }
.wdot.yellow { background: #febc2e; box-shadow: inset 0 0 0 0.5px rgba(0,0,0,0.15); }
.wdot.green  { background: #28c840; box-shadow: inset 0 0 0 0.5px rgba(0,0,0,0.15); }
.char-window-title {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-2);
  white-space: nowrap;
  overflow: hidden;
}
.char-type-icon {
  font-size: 10px;
  opacity: 0.8;
  flex-shrink: 0;
}
.char-name-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.char-window-controls {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.cwin-btn {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  background: transparent;
  border: none;
  color: var(--fg-4);
  font-size: 10px;
  cursor: pointer;
  border-radius: var(--radius-xs);
  transition: all var(--dur-fast) var(--ease-out);
  line-height: 1;
}
.cwin-btn:hover {
  color: var(--fg-1);
  background: rgba(124, 180, 200, 0.12);
}
.cwin-btn.close-btn:hover {
  color: var(--danger-red);
  background: rgba(255, 93, 115, 0.12);
}

/* Window Body */
.char-window-body {
  padding: var(--space-3);
}
.char-meta {
  margin-bottom: 6px;
}
.char-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid var(--border-subtle);
}
.char-type-badge.protagonist { color: var(--accent-2); background: rgba(20, 184, 154, 0.08); border-color: rgba(20, 184, 154, 0.2); }
.char-type-badge.antagonist  { color: var(--danger-red); background: rgba(255, 93, 115, 0.06); border-color: rgba(255, 93, 115, 0.18); }
.char-type-badge.supporting  { color: var(--warn-amber); background: rgba(244, 184, 64, 0.06); border-color: rgba(244, 184, 64, 0.18); }
.char-desc {
  font-size: 12px;
  color: var(--fg-3);
  line-height: 1.55;
  margin: 0 0 var(--space-2) 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: all var(--dur-normal) var(--ease-out);
}
.char-traits {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.char-trait {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: rgba(20, 41, 63, 0.5);
  border: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-3);
  transition: all var(--dur-fast) var(--ease-out);
}
.char-window:hover .char-trait {
  border-color: var(--border-line);
}

/* Expanded State */
.char-window.expanded {
  grid-column: 1 / -1;
  box-shadow: var(--shadow-lg), var(--glow-teal-sm);
}
.char-window.expanded .char-desc {
  -webkit-line-clamp: unset;
}
.char-expanded-extra {
  margin-top: var(--space-2);
}
.char-detail-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--space-2) 0;
}
.char-detail-stats {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-4);
}

/* ============================================================
   STORY BEAT CARD
   ============================================================ */
.beat-card {
  background: var(--grad-card);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--beat-act-color, var(--accent-2));
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: all var(--dur-normal) var(--ease-out);
  cursor: pointer;
  position: relative;
  box-shadow: var(--shadow-sm);
}
.beat-card:hover {
  transform: translateY(-2px) scale(1.01);
  box-shadow: var(--shadow-md);
  border-color: var(--border-accent);
}
.beat-card.dragging {
  opacity: 0.5;
  transform: scale(0.98);
}
.beat-card.drop-target {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 2px rgba(20, 184, 154, 0.25);
}

.beat-card-inner {
  padding: var(--space-3);
}

/* Beat Header */
.beat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.beat-act-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 10px;
  border: 1px solid;
  background: transparent;
}
.beat-act-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

/* Status Badges */
.beat-status {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 10px;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
  border: 1px solid var(--border-subtle);
}
.beat-status:hover {
  transform: scale(1.05);
}
.beat-status.status-planned  { color: var(--fg-4); background: rgba(124, 180, 200, 0.08); }
.beat-status.status-drafted  { color: var(--accent-2); background: rgba(20, 184, 154, 0.08); border-color: rgba(20, 184, 154, 0.2); }
.beat-status.status-revised  { color: var(--electric-violet); background: rgba(124, 77, 255, 0.06); border-color: rgba(124, 77, 255, 0.18); }
.beat-status.status-complete { color: var(--pulse-green); background: rgba(74, 222, 128, 0.08); border-color: rgba(74, 222, 128, 0.2); }

/* Beat Content */
.beat-title {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-1);
  margin: 0 0 4px 0;
  line-height: 1.35;
}
.beat-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-4);
}
.beat-chapter {
  color: var(--accent-2);
}
.beat-scene {
  color: var(--fg-4);
}
.beat-desc {
  font-size: 12px;
  color: var(--fg-3);
  line-height: 1.5;
  margin: 0 0 var(--space-2) 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: all var(--dur-normal) var(--ease-out);
}

/* Character chips within beat */
.beat-chars {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: var(--space-1);
}
.beat-char-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 10px;
  border: 1px solid var(--border-subtle);
  background: rgba(20, 41, 63, 0.4);
  color: var(--fg-3);
}
.beat-char-chip.protagonist { color: var(--accent-2); border-color: rgba(20, 184, 154, 0.15); }
.beat-char-chip.antagonist  { color: var(--danger-red); border-color: rgba(255, 93, 115, 0.12); }
.beat-char-chip.supporting  { color: var(--warn-amber); border-color: rgba(244, 184, 64, 0.12); }

/* Expanded State */
.beat-card.expanded {
  grid-column: 1 / -1;
  box-shadow: var(--shadow-lg);
}
.beat-card.expanded .beat-desc {
  -webkit-line-clamp: unset;
}
.beat-expanded-extra {
  margin-top: var(--space-2);
  animation: fade-in var(--dur-normal) var(--ease-out);
}
@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.beat-detail-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--space-2) 0;
}
.beat-detail-timeline {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.beat-timeline-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 6px currentColor;
}
.beat-timeline-line {
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}
.beat-full-desc {
  font-size: 12px;
  color: var(--fg-3);
  line-height: 1.6;
  margin-bottom: var(--space-2);
}
.beat-full-desc strong {
  color: var(--fg-2);
  font-size: 11px;
  font-family: var(--font-display);
}
.beat-associated {
  font-size: 11px;
}
.beat-associated strong {
  color: var(--fg-2);
  font-family: var(--font-display);
  font-size: 11px;
}
.beat-associated-chars {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .dashboard-body {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }
  .dashboard-modal {
    width: min(100vw, 100vw);
    max-height: 95vh;
    border-radius: var(--radius-md);
  }
  .char-window.expanded,
  .beat-card.expanded {
    grid-column: unset;
  }
}

/* ============================================================
   LIGHT THEME OVERRIDES — Universe Dashboard
   ============================================================ */
html[data-theme="light"] .dashboard-trigger {
  background: rgba(20, 184, 154, 0.06);
  border-color: var(--border-accent);
  color: var(--accent-2);
}
html[data-theme="light"] .dashboard-trigger:hover {
  background: rgba(20, 184, 154, 0.12);
}

html[data-theme="light"] .char-window {
  background: var(--grad-card);
}
html[data-theme="light"] .char-window-chrome {
  background: rgba(240, 244, 248, 0.6);
}
html[data-theme="light"] .wdot.red    { background: #ff6b63; }
html[data-theme="light"] .wdot.yellow { background: #ffc93d; }
html[data-theme="light"] .wdot.green  { background: #3dd656; }

html[data-theme="light"] .char-type-badge.protagonist { background: rgba(20, 184, 154, 0.06); }
html[data-theme="light"] .char-type-badge.antagonist  { background: rgba(255, 93, 115, 0.04); }
html[data-theme="light"] .char-type-badge.supporting  { background: rgba(244, 184, 64, 0.04); }

html[data-theme="light"] .char-trait {
  background: rgba(240, 244, 248, 0.8);
  border-color: var(--border-subtle);
}

html[data-theme="light"] .beat-card {
  background: var(--grad-card);
}
html[data-theme="light"] .beat-char-chip {
  background: rgba(240, 244, 248, 0.6);
}
html[data-theme="light"] .beat-status.status-planned {
  background: rgba(203, 213, 225, 0.2);
  color: var(--fg-3);
}
html[data-theme="light"] .beat-status.status-drafted {
  background: rgba(20, 184, 154, 0.06);
}
html[data-theme="light"] .beat-status.status-revised {
  background: rgba(124, 77, 255, 0.05);
}
html[data-theme="light"] .beat-status.status-complete {
  background: rgba(74, 222, 128, 0.06);
}
html[data-theme="light"] .char-window:hover,
html[data-theme="light"] .beat-card:hover {
  border-color: var(--border-accent);
}

/* ============================================================
   MOBILE ADAPTATIONS — Dashboard, Maps, Timeline, Touch
   ============================================================ */

/* ── Mobile Dashboard Modal (Bottom Sheet) ── */
@media (max-width: 768px) {
  .dashboard-modal {
    width: 100vw;
    max-width: 100vw;
    height: 92vh;
    max-height: none;
    border-radius: 16px 16px 0 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    animation: slide-up var(--dur-normal) var(--ease-out);
    margin: 0;
  }
  .dashboard-body {
    grid-template-columns: 1fr;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: var(--space-3);
  }
  .dashboard-column {
    min-width: 0;
  }
  .char-window {
    min-height: 120px;
  }
  .beat-card {
    padding: var(--space-3);
  }
}
@keyframes slide-up {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* ── Mobile Map Modal (Full Screen) ── */
@media (max-width: 768px) {
  .map-modal {
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
    border-radius: 0;
    margin: 0;
  }
  .map-modal .modal-head {
    padding: 8px 12px;
    min-height: 44px;
  }
  .map-modal .modal-head h3 {
    font-size: 13px;
  }
  .map-toolbar {
    margin-right: 8px;
  }
  .map-control-btn {
    width: 36px;
    height: 36px;
    font-size: 14px;
  }
  .map-pin-popup {
    left: 50% !important;
    transform: translateX(-50%);
    bottom: 80px;
    top: auto !important;
    min-width: 260px;
    max-width: 90vw;
  }
  .interactive-map-canvas {
    touch-action: none; /* Prevent browser scroll, handle pan in JS */
  }
}

/* ── Mobile Timeline ── */
@media (max-width: 768px) {
  .timeline-bar {
    height: 44px;
  }
  .timeline-bar.collapsed {
    height: 0;
  }
  .timeline-node {
    r: 5;
  }
  .timeline-node.chapter {
    r: 7;
  }
  .timeline-popup {
    min-width: 160px;
    padding: var(--space-2) var(--space-3);
    font-size: 11px;
  }
  .timeline-popup-title {
    font-size: 12px;
  }
  .timeline-toggle {
    width: 20px;
    height: 20px;
    font-size: 8px;
  }
}

/* ── Mobile Nav Dashboard Button ── */
#mobileNavDashboard {
  font-size: 16px;
  color: var(--fg-3);
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  transition: color var(--dur-fast);
}
#mobileNavDashboard:hover,
#mobileNavDashboard.active {
  color: var(--accent-2);
}

/* ── Touch Improvements ── */
@media (pointer: coarse) {
  .char-window,
  .beat-card {
    -webkit-tap-highlight-color: transparent;
  }
  .char-window:active,
  .beat-card:active {
    transform: scale(0.98);
  }
  .timeline-node {
    /* Larger touch targets on touch devices */
    stroke-width: 8px;
    stroke: transparent;
  }
  .interactive-map-canvas {
    touch-action: none;
  }
  .graph-control-btn,
  .map-control-btn {
    min-width: 44px;
    min-height: 44px;
  }
}

/* ── Bottom sheet scrim (mobile modals) ── */
@media (max-width: 768px) {
  .modal-scrim .dashboard-modal,
  .modal-scrim .map-modal {
    align-self: flex-end;
  }
  .modal-scrim.show .dashboard-modal {
    animation: slide-up var(--dur-normal) var(--ease-out);
  }
}

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
  .dashboard-modal,
  .map-modal {
    animation: none !important;
  }
}


/* ═══════════════════════════════════════════════════════════════
   SVG ICON SYSTEM
   ═══════════════════════════════════════════════════════════════ */

.icon-svg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1em;
  height: 1em;
  vertical-align: middle;
  flex-shrink: 0;
}
.icon-svg svg {
  width: 100%;
  height: 100%;
}

/* ═══════════════════════════════════════════════════════════════
   CUSTOM INLINE DIALOGS (replaces window.prompt/confirm/alert)
   ═══════════════════════════════════════════════════════════════ */

/* ── Inline Input Dialog ── */
.inline-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 950;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(7, 14, 26, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-fast) var(--ease-out);
}
.inline-dialog-overlay.open {
  opacity: 1;
  pointer-events: auto;
}
.inline-dialog-box {
  background: var(--grad-card);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-md);
  padding: var(--space-5) var(--space-6);
  min-width: 320px;
  max-width: 420px;
  box-shadow: var(--shadow-lg), var(--glow-teal-sm);
  transform: translateY(8px) scale(0.97);
  transition: transform var(--dur-normal) var(--ease-out);
}
.inline-dialog-overlay.open .inline-dialog-box {
  transform: translateY(0) scale(1);
}
.inline-dialog-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--fg-1);
  margin: 0 0 var(--space-3) 0;
  letter-spacing: 0.04em;
}
.inline-dialog-message {
  font-size: 12px;
  color: var(--fg-3);
  line-height: 1.5;
  margin: 0 0 var(--space-4) 0;
}
.inline-dialog-input {
  width: 100%;
  padding: 8px 12px;
  background: rgba(10, 20, 35, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--fg-1);
  font-family: var(--font-mono);
  font-size: 12px;
  margin-bottom: var(--space-4);
  outline: none;
  transition: border-color var(--dur-fast);
}
.inline-dialog-input:focus {
  border-color: var(--accent-2);
  box-shadow: var(--glow-teal-sm);
}
.inline-dialog-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
}
.inline-dialog-btn {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
  transition: all var(--dur-fast);
  border: 1px solid transparent;
}
.inline-dialog-btn.cancel {
  background: transparent;
  border-color: var(--border-subtle);
  color: var(--fg-3);
}
.inline-dialog-btn.cancel:hover {
  border-color: var(--border-accent);
  color: var(--fg-2);
}
.inline-dialog-btn.confirm {
  background: var(--grad-brand);
  color: var(--fg-inverse);
  border-color: transparent;
}
.inline-dialog-btn.confirm:hover {
  box-shadow: var(--glow-teal-md);
}
.inline-dialog-btn.danger {
  background: linear-gradient(135deg, var(--danger-red), #c0392b);
  color: #fff;
}
.inline-dialog-btn.danger:hover {
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.4);
}

/* ── Toast Notification ── */
.inline-toast {
  position: fixed;
  bottom: 48px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  z-index: 1000;
  background: var(--grad-card);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-md);
  padding: 10px 18px;
  box-shadow: var(--shadow-md), var(--glow-teal-sm);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-2);
  opacity: 0;
  pointer-events: none;
  transition: all var(--dur-fast) var(--ease-out);
  display: flex;
  align-items: center;
  gap: 8px;
}
.inline-toast.open {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.inline-toast-icon {
  color: var(--accent-2);
  font-size: 13px;
}

/* Light theme */
html[data-theme="light"] .inline-dialog-overlay {
  background: rgba(15, 23, 42, 0.25);
}
html[data-theme="light"] .inline-dialog-input {
  background: rgba(240, 244, 248, 0.8);
  color: var(--fg-1);
}
html[data-theme="light"] .inline-dialog-box {
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}
html[data-theme="light"] .inline-toast {
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}

/* ═══════════════════════════════════════════════════════════════
   TIMELINE CONTEXT MENU
   ═══════════════════════════════════════════════════════════════ */

.timeline-context-menu {
  position: fixed;
  z-index: 500;
  background: var(--grad-card);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg), var(--glow-teal-sm);
  padding: 6px 0;
  min-width: 180px;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.95);
  transition: all var(--dur-fast) var(--ease-out);
  font-family: var(--font-mono);
  font-size: 11px;
}
.timeline-context-menu.open {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}
.timeline-context-item {
  padding: 8px 16px;
  color: var(--fg-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all var(--dur-fast);
  white-space: nowrap;
}
.timeline-context-item:hover {
  background: rgba(20, 184, 154, 0.08);
  color: var(--fg-1);
}
.timeline-context-item.danger {
  color: var(--danger-red);
}
.timeline-context-item.danger:hover {
  background: rgba(239, 68, 68, 0.08);
}
.timeline-context-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 4px 12px;
}
.timeline-context-submenu {
  position: absolute;
  left: 100%;
  top: 0;
  background: var(--grad-card);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 6px 0;
  min-width: 140px;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-4px);
  transition: all var(--dur-fast) var(--ease-out);
}
.timeline-context-item:hover > .timeline-context-submenu,
.timeline-context-submenu.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

/* Light theme */
html[data-theme="light"] .timeline-context-menu {
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}

/* ============================================================
   WORLDBUILDING MEDIA ZONE
   ============================================================ */
.media-zone {
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6) var(--space-7);
  gap: var(--space-4);
}
.media-zone-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
}
.media-zone-title {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--fg-3);
  flex: 1;
}
.media-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  font-size: 12px;
  font-family: var(--font-ui);
  color: var(--accent-2);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-sm);
  background: rgba(20,184,154,.06);
  cursor: pointer;
  transition: background var(--dur-fast), box-shadow var(--dur-fast);
  user-select: none;
}
.media-add-btn:hover { background: rgba(20,184,154,.12); box-shadow: var(--glow-teal-sm); }
.media-drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 140px;
  border: 1.5px dashed var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--fg-4);
  font-size: 13px;
  cursor: pointer;
  transition: border-color var(--dur-fast), background var(--dur-fast);
  padding: var(--space-5);
  text-align: center;
}
.media-drop-zone:hover, .media-drop-zone.drag-over {
  border-color: var(--accent-2);
  background: rgba(20,184,154,.04);
  color: var(--fg-2);
}
.media-drop-hint { font-size: 11px; color: var(--fg-4); }
.media-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-3);
}
.media-thumb {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--navy-800);
  border: 1px solid var(--border-subtle);
  aspect-ratio: 4/3;
  cursor: pointer;
  transition: box-shadow var(--dur-fast), transform var(--dur-fast);
}
.media-thumb:hover { box-shadow: var(--glow-teal-sm); transform: translateY(-1px); }
.media-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-thumb .media-thumb-label {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 4px 8px;
  background: rgba(5,10,20,.75);
  font-size: 10px; color: var(--fg-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.media-thumb-del {
  position: absolute; top: 4px; right: 4px;
  width: 20px; height: 20px;
  background: rgba(5,10,20,.8);
  border: none; border-radius: 50%;
  color: var(--fg-3); font-size: 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity var(--dur-fast);
  line-height: 1;
}
.media-thumb:hover .media-thumb-del { opacity: 1; }
.media-pdf-thumb {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  width: 100%; height: 100%;
  color: var(--fg-3); gap: 6px; font-size: 11px;
}
/* Light theme */
html[data-theme="light"] .media-drop-zone { border-color: rgba(20,184,154,.3); }
html[data-theme="light"] .media-thumb { background: var(--navy-100); }
@media (max-width: 768px) {
  .media-preview-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .media-zone { padding: var(--space-4); }
}

/* ── MAP MODAL IMAGE STRIP ── */
.map-body { flex-direction: column; }
.map-media-strip {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  overflow-x: auto;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  flex-shrink: 0;
  scrollbar-width: thin;
  align-items: center;
  min-height: 64px;
}
.map-media-item {
  position: relative;
  flex-shrink: 0;
  width: 80px; height: 56px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  background: var(--navy-800);
  cursor: pointer;
}
.map-media-item img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.map-media-pdf {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; color: var(--fg-3);
}
.map-media-item .map-del {
  position: absolute; top: 2px; right: 2px;
  width: 16px; height: 16px; font-size: 10px;
  opacity: 0; transition: opacity var(--dur-fast);
}
.map-media-item:hover .map-del { opacity: 1; }
.map-set-bg {
  position: absolute; bottom: 2px; left: 2px;
  height: 16px; padding: 0 4px;
  font-size: 9px; font-family: var(--font-mono, monospace);
  background: rgba(4,8,16,0.75); color: var(--accent-2);
  border: 1px solid rgba(20,184,154,0.35); border-radius: 3px;
  cursor: pointer; opacity: 0; transition: opacity var(--dur-fast);
  white-space: nowrap;
}
.map-media-item:hover .map-set-bg { opacity: 1; }
.map-media-item.is-bg { border-color: var(--accent-2); box-shadow: 0 0 0 1px var(--accent-2); }
.map-media-item.is-bg .map-set-bg { opacity: 1; color: var(--warn-amber); border-color: rgba(251,191,36,0.4); }
