/* Ghost Biographer — Outline / Define Your Chapters page styles
   Page-specific layout and overrides only.
   Shared tokens and components live in design.css. */

/* ── Body / shell layout ─────────────────────────── */
body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

/* ── Two-column app layout ───────────────────────── */
.app {
  flex: 1;
  display: grid;
  grid-template-columns: 300px 1fr;
  overflow: hidden;
  min-height: 0;
}

/* ── Sidebar ─────────────────────────────────────── */
.sidebar {
  background: var(--paper-2);
  border-right: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--hairline);
  flex-shrink: 0;
}
.sidebar-header h2 {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 8px;
}

.chapter-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 6px 280px;
}
.chapter-item {
  background: var(--paper);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  border: 2px solid transparent;
  margin-bottom: 5px;
  transition: border-color 150ms, box-shadow 150ms;
  box-shadow: var(--shadow-sm);
}
.chapter-item:hover { border-color: var(--plum-3); }
.chapter-item.active {
  border-color: var(--plum);
  box-shadow: 0 0 0 1px var(--plum), var(--shadow-sm);
}
.chapter-item.done { opacity: .75; }
.chapter-num {
  font-size: 11px;
  color: var(--ink-4);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.chapter-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin-top: 2px;
}
.chapter-period {
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 2px;
}
.chapter-done-badge {
  font-size: 10px;
  background: var(--sage-bg);
  color: var(--sage);
  border-radius: 99px;
  padding: 1px 8px;
  display: inline-block;
  margin-top: 3px;
}

/* Sidebar phase navigation footer */
.sidebar-nav {
  padding: 10px 14px;
  border-top: 1px solid var(--hairline);
  flex-shrink: 0;
}
.sidebar-nav-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-4);
  margin-bottom: 5px;
}
.sidebar-nav a {
  display: block;
  font-size: 13px;
  color: var(--ink-3);
  text-decoration: none;
  padding: 4px 0;
  border-bottom: 1px solid var(--hairline);
  transition: color 120ms;
}
.sidebar-nav a:hover { color: var(--plum); }
.sidebar-nav a.primary {
  font-weight: 600;
  color: var(--plum);
  border-bottom: none;
  margin-top: 4px;
}

/* ── Main panel ──────────────────────────────────── */
.main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--paper);
}
.toolbar {
  padding: 10px 14px;
  border-bottom: 1px solid var(--hairline);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.toolbar h1 {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  flex: 1;
}
#status-bar {
  font-size: 12px;
  color: var(--ink-3);
  padding: 4px 14px;
  border-bottom: 1px solid var(--hairline);
  min-height: 26px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
#status-bar.error { color: var(--rose); }

/* ── Outline title banner ────────────────────────── */
#outline-title-banner {
  padding: 7px 14px;
  background: var(--paper-2);
  border-bottom: 1px solid var(--hairline);
  font-size: 13px;
  color: var(--ink-2);
  display: none;
  flex-shrink: 0;
}
#outline-title-banner strong { color: var(--plum); }

/* ── Content area ────────────────────────────────── */
.content {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* Chapter detail panel */
.chapter-detail {
  width: 260px;
  border-right: 1px solid var(--hairline);
  overflow-y: auto;
  padding: 14px;
  font-size: 13px;
  flex-shrink: 0;
  background: var(--paper-2);
}
.chapter-detail h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--plum);
  margin-bottom: 8px;
}
.detail-section { margin-bottom: 14px; }
.detail-section h4 {
  font-size: 10px;
  color: var(--ink-4);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 5px;
}
.detail-section ul { list-style: none; padding: 0; }
.detail-section li {
  padding: 3px 0;
  border-bottom: 1px solid var(--hairline);
  color: var(--ink-2);
}
.question-item {
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  padding: 5px 8px;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--ink-3);
}

/* ── People face chips ───────────────────────────── */
#chapter-faces {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.ch-face-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
}
.ch-face-img {
  width: 48px; height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--hairline);
  display: block;
  background: var(--paper-2);
  transition: border-color 120ms;
}
.ch-face-chip:hover .ch-face-img { border-color: var(--plum-3); }
.ch-face-chip-name {
  font-size: 10px;
  color: var(--ink-3);
  text-align: center;
  max-width: 56px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ch-face-text {
  font-size: 12px;
  color: var(--ink-2);
  padding: 3px 0;
  border-bottom: 1px solid var(--hairline);
  width: 100%;
}

/* ── Related photos gallery ──────────────────────── */
#chapter-photos { margin-top: 10px; }
#chapter-photo-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.ch-photo-thumb {
  width: 60px; height: 80px;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid var(--hairline);
  flex-shrink: 0;
  position: relative;
  transition: border-color 120ms;
}
.ch-photo-thumb:hover { border-color: var(--plum-3); }
.ch-photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ch-thumb-label {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,.6);
  font-size: 8px;
  color: #fff;
  text-align: center;
  padding: 1px 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

/* Floating photo preview */
#ch-photo-preview {
  position: fixed;
  z-index: 9999;
  display: none;
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 8px;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
}
#ch-photo-preview img {
  display: block;
  width: 240px; height: 240px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--paper-2);
}
#ch-photo-preview-label {
  font-size: 11px;
  color: var(--ink-3);
  text-align: center;
  margin-top: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}

/* ── Placeholder ─────────────────────────────────── */
.placeholder-msg {
  color: var(--ink-4);
  font-style: italic;
  font-size: 13px;
  margin: auto;
  text-align: center;
  padding: 24px;
}

/* ── Spinner ─────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--hairline);
  border-top-color: var(--plum);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  vertical-align: middle;
  margin-right: 5px;
}

/* ── Auth overlay ────────────────────────────────── */
#auth-overlay {
  position: fixed;
  inset: 0;
  background: oklch(0.98 0.01 270 / 0.95);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-box {
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 32px;
  width: 360px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.auth-box h2 { color: var(--ink); font-size: 17px; }
.auth-box .field-label {
  font-size: 13px;
  color: var(--ink-2);
  display: block;
  margin-bottom: 4px;
}
#login-error { font-size: 13px; color: var(--rose); min-height: 18px; }

/* Password toggle */
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 72px; }
.pw-eye-btn {
  position: absolute;
  right: 40px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none;
  cursor: pointer;
  color: var(--ink-3);
  font-size: 15px;
  padding: 0; line-height: 1;
}
.pw-eye-btn:hover { color: var(--ink); }

/* ── What's Next modal ───────────────────────────── */
#wn-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
#wn-overlay.open { display: flex; }
#wn-modal {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 540px; width: 100%;
  max-height: 85vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 16px;
  box-shadow: var(--shadow-lg);
  position: relative;
}
#wn-modal h2 { font-size: 18px; color: var(--ink); font-weight: 600; }
.wn-guidance {
  font-size: 14px;
  line-height: 1.65;
  color: var(--ink-2);
  background: var(--paper-2);
  border-radius: 8px;
  padding: 12px 16px;
}
.wn-arc-summary { display: flex; flex-wrap: wrap; gap: 6px; }
.wn-arc-chip {
  background: var(--paper-2);
  border: 1px solid var(--hairline);
  border-radius: 99px;
  padding: 3px 12px;
  font-size: 12px;
  color: var(--ink-3);
}
.wn-arc-chip span { color: var(--plum); font-weight: 600; }
.wn-tip {
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-3);
  border-left: 2px solid var(--hairline);
  padding: 5px 12px;
  font-style: italic;
}
.wn-phases { display: flex; flex-direction: column; gap: 6px; }
.wn-phase {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  padding: 6px 8px;
  border-radius: 6px;
}
.wn-phase .wn-icon { flex-shrink: 0; width: 18px; text-align: center; }
.wn-phase .wn-phase-name { font-weight: 600; min-width: 9rem; }
.wn-phase.complete { color: var(--sage); }
.wn-phase.in_progress { color: var(--terra); background: oklch(0.97 0.04 60 / 0.5); }
.wn-phase.not_started { color: var(--ink-4); }
.wn-phase.clickable { cursor: pointer; transition: background 120ms; }
.wn-phase.clickable:hover { background: oklch(0.95 0.04 295); }
.wn-steps { display: flex; flex-direction: column; gap: 6px; }
.wn-step {
  font-size: 13px;
  color: var(--ink);
  display: flex; gap: 8px;
  border-radius: 6px;
  padding: 5px 8px;
}
.wn-step::before { content: "→"; color: var(--plum); flex-shrink: 0; }
.wn-step.clickable { cursor: pointer; transition: background 120ms, color 120ms; }
.wn-step.clickable:hover { background: var(--paper-2); color: var(--plum); }
#wn-close {
  position: absolute;
  top: 12px; right: 12px;
  background: transparent; border: none;
  color: var(--ink-3); font-size: 20px; line-height: 1;
  cursor: pointer; padding: 2px 5px; border-radius: 4px;
}
#wn-close:hover { color: var(--ink); background: var(--paper-2); }
#wn-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px 0;
}
#wn-loading span { font-size: 13px; color: var(--ink-3); }
.wn-progress-track {
  width: 100%; height: 5px;
  background: var(--hairline);
  border-radius: 99px; overflow: hidden;
}
.wn-progress-bar {
  height: 100%; width: 30%;
  background: linear-gradient(90deg, var(--plum), oklch(0.6 0.17 295), var(--plum));
  background-size: 200% 100%;
  border-radius: 99px;
  animation: wn-sweep 1.6s ease-in-out infinite;
}

/* ── Regen warning modal ─────────────────────────── */
#regen-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 80;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
#regen-overlay.open { display: flex; }
#regen-modal {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 480px; width: 100%;
  display: flex; flex-direction: column; gap: 16px;
  box-shadow: var(--shadow-lg);
}
#regen-modal h3 { color: var(--terra); font-size: 15px; }
#regen-modal p { font-size: 13px; line-height: 1.6; color: var(--ink-2); }
.regen-reassurance {
  font-size: 13px;
  color: var(--sage);
  background: var(--sage-bg);
  border-radius: 8px;
  padding: 10px 14px;
  line-height: 1.55;
}
.regen-drafts {
  font-size: 12px;
  color: var(--ink-3);
  display: flex; flex-direction: column; gap: 4px;
  max-height: 150px; overflow-y: auto;
}
.regen-draft-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  border-bottom: 1px solid var(--hairline);
}
.regen-draft-row a {
  font-size: 12px;
  color: var(--plum);
  text-decoration: none;
}
.regen-draft-row a:hover { text-decoration: underline; }
.regen-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* ── Animations ──────────────────────────────────── */
@keyframes wn-sweep {
  0%,100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}
@keyframes spin { to { transform: rotate(360deg); } }
