/* ============================================================
   DJC FLOW WRITER — Visual Enhancement Layer v1
   Deep neural aesthetic polish on top of app.css.
   No HTML structure changes · No behavior changes.
   ============================================================ */

/* ── Topbar: teal accent stripe + depth ── */
.topbar {
  border-bottom-color: transparent;
  box-shadow:
    0 1px 0 var(--border-subtle),
    0 2px 16px rgba(0,0,0,0.25),
    0 1px 0 rgba(20,184,154,0.06);
  position: relative;
}
.topbar::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--teal-700) 15%,
    var(--teal-500) 40%,
    var(--electric-cyan) 50%,
    var(--teal-500) 60%,
    var(--teal-700) 85%,
    transparent 100%
  );
  opacity: 0.55;
  pointer-events: none;
  z-index: 1;
}

/* ── Brand tile: elevated presence ── */
.brand-tile {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  box-shadow: var(--glow-teal-md), var(--shadow-inset),
              inset 0 1px 0 rgba(255,255,255,0.12);
  font-size: 9px;
  letter-spacing: 0.08em;
}
.brand-title {
  letter-spacing: 0.1em;
}

/* ── Back link: more refined ── */
.back-link {
  opacity: 0.7;
  font-size: 10px;
}
.back-link:hover { opacity: 1; }

/* ── Panes: atmospheric depth layers ── */
.pane.left {
  background:
    radial-gradient(ellipse 160% 45% at -5% 0%,  rgba(20,184,154,0.08) 0%, transparent 55%),
    radial-gradient(ellipse 80%  25% at 110% 95%, rgba(62,240,226,0.04) 0%, transparent 50%);
}
.pane.right {
  background:
    radial-gradient(ellipse 130% 40% at 110% 0%, rgba(20,184,154,0.06) 0%, transparent 55%);
}

/* ── Section eyebrow: left accent bar ── */
.section-eyebrow {
  position: relative;
  padding-left: 9px;
}
.section-eyebrow::before {
  content: '';
  position: absolute;
  left: 0; top: 1px; bottom: 1px;
  width: 2px;
  background: linear-gradient(180deg, var(--electric-cyan) 0%, var(--teal-500) 100%);
  border-radius: 2px;
  box-shadow: 0 0 6px rgba(20,184,154,0.6);
  opacity: 0.85;
}

/* ── Project switcher ── */
.project-switcher {
  box-shadow: var(--shadow-xs), inset 0 1px 0 rgba(255,255,255,0.03);
}

/* ── Branch chip: glowing pill ── */
.branch-chip {
  box-shadow: var(--glow-teal-sm), inset 0 0 10px rgba(20,184,154,0.05);
}
.branch-chip:hover {
  box-shadow: var(--glow-teal-md), inset 0 0 14px rgba(20,184,154,0.10);
}

/* ── Tree active item: prominent glow ── */
.tree-item.active::before {
  width: 3px;
  box-shadow: 0 0 8px var(--accent-2), 0 0 18px rgba(20,184,154,0.35);
}

/* ── Center: subtle ambient glow from bottom ── */
.center {
  background:
    radial-gradient(ellipse 55% 35% at 50% 105%, rgba(20,184,154,0.05) 0%, transparent 65%);
}

/* ── Scene banner: glass morphism ── */
.scene-banner {
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(20,184,154,0.18);
  border-bottom: 1px solid rgba(0,0,0,0.15);
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(62,240,226,0.06);
}

/* ── Editor: teal caret glow ── */
.editor:focus {
  caret-color: var(--electric-cyan);
}

/* ── Sprint time: Orbitron + atmospheric glow ── */
.sprint-time-display {
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 700;
  letter-spacing: 0.12em;
  line-height: 1;
  padding: var(--space-2) 0;
}
.sprint-time-display.running {
  color: var(--accent-2);
  animation: sprint-glow-pulse 2s ease-in-out infinite;
}
@keyframes sprint-glow-pulse {
  0%, 100% {
    text-shadow: 0 0 14px rgba(20,184,154,0.45), 0 0 28px rgba(20,184,154,0.2);
  }
  50% {
    text-shadow: 0 0 22px rgba(20,184,154,0.7), 0 0 44px rgba(62,240,226,0.3);
  }
}

/* ── Sprint/daily progress bars: taller, more refined ── */
.sprint-progress { height: 8px; border-radius: var(--radius-pill); }
.sprint-progress-fill { border-radius: var(--radius-pill); }
.daily-target-bar { height: 8px; }

/* ── Sprint duration buttons: active indicator ── */
.sprint-dur-btn.on {
  box-shadow: var(--glow-teal-sm);
}

/* ── Right pane tab: active glow ── */
.right-pane-tab.active {
  box-shadow: var(--glow-teal-sm), inset 0 1px 0 rgba(255,255,255,0.10);
  letter-spacing: 0.08em;
}

/* ── Export buttons: more refined hover ── */
.export-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--glow-teal-md);
}
.export-btn .ext {
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 0.08em;
}

/* ── Status bar: gradient + shadow ── */
.status {
  background: linear-gradient(
    90deg,
    rgba(5, 10, 20, 0.94) 0%,
    rgba(9, 17, 30, 0.9)  35%,
    rgba(9, 17, 30, 0.9)  65%,
    rgba(5, 10, 20, 0.94) 100%
  );
  border-top-color: transparent;
  box-shadow: 0 -1px 0 var(--border-subtle), 0 -1px 16px rgba(0,0,0,0.3);
}

/* ── Timeline bar: accent lines ── */
.timeline-bar {
  position: relative;
}
.timeline-bar::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--teal-500) 40%, var(--electric-cyan) 50%, var(--teal-500) 60%, transparent);
  opacity: 0.4;
  pointer-events: none;
  z-index: 5;
}

/* ── Modals: teal top border + richer glass ── */
.modal {
  border-top: 1px solid rgba(20,184,154,0.35) !important;
  box-shadow: var(--shadow-lg), var(--glow-teal-md),
              inset 0 1px 0 rgba(62,240,226,0.07) !important;
}
.modal-head {
  background: rgba(7,14,26,0.3);
}
.modal-head h3 {
  letter-spacing: 0.12em;
}

/* ── Command palette: item icon border ── */
.cmd-item .ic {
  border: 1px solid var(--border-subtle);
}

/* ── Nudge: stronger glass ── */
.nudge {
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--glow-teal-md), 0 8px 32px rgba(0,0,0,0.5);
}
.nudge .icon {
  box-shadow: inset 0 0 12px rgba(20,184,154,0.15);
}

/* ── Focus word ring: atmospheric ── */
.focus-word-ring {
  filter:
    drop-shadow(0 0 10px rgba(20,184,154,0.35))
    drop-shadow(0 0 22px rgba(62,240,226,0.15));
}

/* ── Onboarding overlay ── */
.onboarding-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 8, 16, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  /* Override app.css animation — that one uses translateX(-50%) which shifts
     a full-screen overlay 50vw off-screen */
  animation: fw-tutorial-fade 0.35s ease-out 0.3s both;
  transform: none;
}
@keyframes fw-tutorial-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.onboarding-card {
  background: var(--grad-card);
  border: 1px solid var(--border-accent);
  border-top: 1px solid rgba(62,240,226,0.25);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg), var(--glow-teal-sm),
              inset 0 1px 0 rgba(62,240,226,0.07);
  padding: var(--space-5) var(--space-6);
  position: relative;
  max-width: 300px;
  width: 90vw;
}
.onboarding-card h4 {
  font-size: var(--fs-lg);
  margin-bottom: var(--space-2);
}
.onboarding-card p {
  font-size: 13px;
  line-height: var(--lh-body);
  color: var(--fg-3);
  margin-bottom: var(--space-4);
}
.onboarding-progress {
  display: flex;
  gap: 6px;
  justify-content: center;
}
.tutorial-dismiss {
  position: absolute;
  top: 10px; right: 14px;
  background: transparent;
  border: none;
  color: var(--fg-4);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  padding: 2px;
  transition: color var(--dur-fast);
}
.tutorial-dismiss:hover { color: var(--accent-2); }

/* ── Mobile nav: elevated DJC bar ── */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 52px;
  background: rgba(5, 10, 20, 0.92);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid var(--border-subtle);
  box-shadow:
    0 -1px 0 rgba(20,184,154,0.12),
    0 -4px 24px rgba(0,0,0,0.5);
  z-index: 50;
  align-items: center;
  justify-content: space-around;
  padding: 0 var(--space-3);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.mobile-nav button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  background: transparent;
  border: none;
  color: var(--fg-4);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
.mobile-nav button:hover,
.mobile-nav button.active {
  color: var(--accent-2);
  background: rgba(20,184,154,0.10);
  box-shadow: var(--glow-teal-sm);
}
@media (max-width: 768px) {
  .mobile-nav { display: flex; }
}

/* ── Left pane overlay (mobile) ── */
.left-pane-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 16, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-out);
}
.left-pane-overlay.open,
.left-pane-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

/* ── Hamburger button (mobile) ── */
.hamburger {
  display: none;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--fg-3);
  cursor: pointer;
  width: 32px; height: 32px;
  align-items: center;
  justify-content: center;
  transition: all var(--dur-fast) var(--ease-out);
  flex-shrink: 0;
}
.hamburger:hover {
  color: var(--accent-2);
  border-color: var(--border-accent);
  background: rgba(20,184,154,0.06);
}
@media (max-width: 920px) {
  .hamburger { display: flex; }
}

/* ── Inline ghost text (AI suggestions) ── */
.ai-ghost-text {
  color: var(--fg-4);
  text-shadow: 0 0 8px rgba(20,184,154,0.3);
}

/* ── Timeline popup: must be fixed to escape overflow:hidden on .timeline-bar ── */
.timeline-popup {
  position: fixed !important;
  z-index: 300;
}

/* ── Timeline context menu: max z-index, ensure nothing occludes it ── */
.timeline-context-menu {
  z-index: 9999 !important;
  background: var(--navy-800) !important;
  border: 1px solid var(--border-accent) !important;
}

/* ── Branch graph maximize modal ── */
.branch-graph-max-modal {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(4, 8, 16, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-out);
}
.branch-graph-max-modal.open {
  opacity: 1;
  pointer-events: auto;
}
.branch-graph-max-inner {
  width: min(1080px, 96vw);
  height: min(720px, 90vh);
  background: var(--bg-raised);
  border: 1px solid var(--border-accent);
  border-top: 1px solid rgba(62,240,226,0.3);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg), var(--glow-teal-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.96) translateY(8px);
  transition: transform var(--dur-base) var(--ease-out);
}
.branch-graph-max-modal.open .branch-graph-max-inner {
  transform: scale(1) translateY(0);
}
.branch-graph-max-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(7,14,26,0.4);
  flex-shrink: 0;
}
.branch-graph-max-title {
  font-family: var(--font-display);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--accent-2);
  flex: 1;
}
.branch-graph-max-controls { display: flex; gap: 4px; }
.branch-graph-max-close {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--fg-4);
  cursor: pointer;
  transition: all var(--dur-fast);
}
.branch-graph-max-close:hover { color: var(--danger-red); border-color: rgba(255,93,115,0.4); }

/* Two-column layout */
.branch-graph-max-layout {
  display: grid;
  grid-template-columns: 1fr 260px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.branch-graph-max-body {
  overflow: auto;
  padding: var(--space-3);
  scrollbar-width: thin;
  scrollbar-color: var(--navy-700) transparent;
  border-right: 1px solid var(--border-subtle);
}
.branch-graph-max-svg { width: 100%; min-height: 400px; }

/* Detail panel */
.branch-graph-max-detail {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--navy-700) transparent;
}

.bgm-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  text-align: center;
  color: var(--fg-4);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;
}

.bgm-detail-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
}
.bgm-detail-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}
.bgm-detail-branch {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--accent-2);
  background: rgba(20,184,154,0.10);
  border: 1px solid var(--border-accent);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  letter-spacing: 0.04em;
}
.bgm-detail-time {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-4);
}
.bgm-detail-message {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-1);
  line-height: 1.35;
  letter-spacing: -0.01em;
}
.bgm-detail-wc {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-3);
}
.bgm-delta { font-weight: 600; }
.bgm-delta.positive { color: var(--pulse-green); }
.bgm-delta.negative { color: var(--danger-red); }

.bgm-section-title {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-display);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent-2);
  margin-top: var(--space-2);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
}
.bgm-chars {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.bgm-char-chip {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  background: rgba(20,184,154,0.08);
  border: 1px solid rgba(20,184,154,0.2);
  color: var(--accent-2);
}
.bgm-note-input {
  width: 100%;
  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-sans);
  font-size: 12px;
  line-height: 1.5;
  padding: 8px 10px;
  resize: vertical;
  outline: none;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
  min-height: 80px;
}
.bgm-note-input:focus {
  border-color: var(--border-accent);
  box-shadow: var(--glow-teal-sm);
}
.bgm-note-input::placeholder { color: var(--fg-4); font-style: italic; }
.bgm-hop-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 9px 14px;
  background: var(--grad-brand-deep);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: var(--font-display);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
  box-shadow: var(--glow-teal-sm);
  margin-top: var(--space-2);
}
.bgm-hop-btn:hover {
  box-shadow: var(--glow-teal-md);
  transform: translateY(-1px);
}

/* ── PTR Indicator ── */
.ptr-indicator {
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sm), var(--glow-teal-sm);
}

/* ── Universe Dashboard trigger: enhanced ── */
.dashboard-trigger {
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 0.12em;
  box-shadow: inset 0 0 10px rgba(20,184,154,0.05);
}
.dashboard-trigger:hover {
  box-shadow: var(--glow-teal-sm), inset 0 0 14px rgba(20,184,154,0.08);
}

/* ── Toast notifications: elevated glass ── */
.inline-toast {
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow-md), var(--glow-teal-sm);
}

/* ── Inline dialog: glass ── */
.inline-dialog-box {
  box-shadow: var(--shadow-lg), var(--glow-teal-md),
              inset 0 1px 0 rgba(62,240,226,0.06);
}

/* ── Map modal: teal toolbar ── */
.map-toolbar .graph-control-btn:hover {
  box-shadow: var(--glow-teal-sm);
}

/* ── Beat cards: left border glow ── */
.beat-card:hover {
  box-shadow: var(--shadow-md), var(--glow-teal-sm);
}

/* ── Character windows: hover elevation ── */
.char-window:hover {
  box-shadow: var(--shadow-lg), var(--glow-teal-sm);
}

/* ── Kbd hints: refined ── */
.status .kbd-hint kbd {
  background: rgba(5, 10, 20, 0.7);
  box-shadow: 0 1px 0 rgba(255,255,255,0.04), inset 0 -1px 0 rgba(0,0,0,0.3);
}

/* ─────────────────────────────────────────────
   LIGHT THEME OVERRIDES
   ───────────────────────────────────────────── */
html[data-theme="light"] .topbar::after { opacity: 0.3; }
html[data-theme="light"] .timeline-bar::before { opacity: 0.25; }

html[data-theme="light"] .pane.left {
  background:
    radial-gradient(ellipse 160% 45% at -5% 0%,  rgba(20,184,154,0.04) 0%, transparent 55%);
}
html[data-theme="light"] .pane.right {
  background:
    radial-gradient(ellipse 130% 40% at 110% 0%, rgba(20,184,154,0.03) 0%, transparent 55%);
}
html[data-theme="light"] .center {
  background:
    radial-gradient(ellipse 55% 35% at 50% 105%, rgba(20,184,154,0.025) 0%, transparent 65%);
}

html[data-theme="light"] .status {
  background: linear-gradient(
    90deg,
    rgba(255,255,255,0.96) 0%,
    rgba(248,251,253,0.94) 35%,
    rgba(248,251,253,0.94) 65%,
    rgba(255,255,255,0.96) 100%
  );
  box-shadow: 0 -1px 0 var(--border-subtle), 0 -1px 8px rgba(0,0,0,0.05);
}

html[data-theme="light"] .scene-banner {
  border-top: 1px solid rgba(20,184,154,0.12);
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(20,184,154,0.04);
}

html[data-theme="light"] .nudge {
  background: rgba(255,255,255,0.94);
  box-shadow: var(--shadow-lg), 0 0 20px rgba(0,0,0,0.08);
}

html[data-theme="light"] .mobile-nav {
  background: rgba(255,255,255,0.94);
  box-shadow: 0 -1px 0 var(--border-subtle), 0 -4px 20px rgba(0,0,0,0.06);
}

html[data-theme="light"] .section-eyebrow::before {
  opacity: 0.7;
}

html[data-theme="light"] .modal {
  border-top: 1px solid rgba(20,184,154,0.2) !important;
}

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

html[data-theme="light"] .inline-toast {
  box-shadow: var(--shadow-md);
}

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