/* === Journal Vault — Warm Library Aesthetic === */

:root {
  /* Paper & background */
  --bg: #FAF6F0;
  --bg-warm: #F5F0E8;
  --bg-card: #FFFFFF;
  --bg-nav: #3D3229;

  /* Text */
  --text: #2C2419;
  --text-muted: #7A6E5E;
  --text-light: #A69882;
  --text-nav: #F5F0E8;

  /* Accent */
  --gold: #C9A84C;
  --gold-light: #E8D9A0;
  --gold-dark: #9A7B2F;
  --navy: #4A6FA5;
  --sage: #6B8E6B;
  --rose: #C08497;
  --amber: #D4883A;

  /* Borders & shadows */
  --border: #E0D6C8;
  --shadow: rgba(44, 36, 25, 0.08);
  --shadow-md: rgba(44, 36, 25, 0.12);

  /* Emotion colors */
  --emotion-joy: #E8B84B;
  --emotion-love: #D4788C;
  --emotion-gratitude: #D4A843;
  --emotion-hope: #7DB87D;
  --emotion-peace: #89B4C8;
  --emotion-contentment: #C8B89A;
  --emotion-wonder: #9B89B4;
  --emotion-determination: #D48B4B;
  --emotion-nostalgia: #B89AAC;
  --emotion-confusion: #9E9E9E;
  --emotion-anxiety: #D4A088;
  --emotion-loneliness: #8A9BAA;
  --emotion-grief: #5B7B9A;
  --emotion-anger: #B85A5A;
  --emotion-fear: #6B7B8B;
  --emotion-guilt: #8B8B6B;
  --emotion-resentment: #A07040;
  --emotion-shame: #8B7060;

  /* Graph node colors */
  --node-entry: #E8DCC8;
  --node-theme: #C9A84C;
  --node-person: #4A6FA5;
  --node-symbol: #6B8E6B;
  --node-emotion: #C08497;
  --node-life-event: #D4883A;

  /* Sizing */
  --radius: 8px;
  --radius-lg: 12px;
  --max-width: 900px;
  --tap-target: 48px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html {
  font-size: 18px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* === Typography === */

.font-serif {
  font-family: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
}

h1 { font-size: 2rem; font-weight: 600; color: var(--text); font-family: 'Cinzel', Georgia, serif; }
h2 { font-size: 1.5rem; font-weight: 600; color: var(--text); font-family: 'Cinzel', Georgia, serif; }
h3 { font-size: 1.15rem; font-weight: 600; color: var(--text); font-family: 'Cinzel', Georgia, serif; }

/* === Login Screen === */

.screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
  background: var(--bg);
  background-image: url('/img/assets/parchment.png');
  background-size: cover;
  background-position: center;
  position: relative;
}

.screen::before,
.screen::after {
  content: '';
  position: absolute;
  width: 120px;
  height: 120px;
  background: url('/img/assets/corner-flourish.png') no-repeat center/contain;
  opacity: 0.5;
  pointer-events: none;
}

.screen::before {
  top: 1rem;
  left: 1rem;
}

.screen::after {
  bottom: 1rem;
  right: 1rem;
  transform: rotate(180deg);
}

.login-container {
  text-align: center;
  max-width: 380px;
  width: 100%;
  position: relative;
  z-index: 1;
}

.login-icon {
  width: 75vw;
  max-width: 500px;
  margin: 0 auto 1rem;
  display: block;
  /* Break out of login-container max-width so the image can fill 75vw */
  position: relative;
  left: 50%;
  transform: translateX(-50%);
}

.login-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.login-container h1 {
  font-family: 'Cinzel', Georgia, serif;
  color: var(--gold-dark);
  font-size: 2rem;
  letter-spacing: 0.06em;
}

.login-subtitle { color: var(--text-muted); margin: 0.5rem 0 1.5rem; font-size: 1rem; font-family: 'Cormorant Garamond', Georgia, serif; font-style: italic; }

.login-container input[type="password"] {
  width: 100%;
  padding: 0.85rem 1rem;
  font-size: 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  margin-bottom: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.login-container input:focus {
  border-color: var(--gold);
}

.error-text { color: #B85A5A; font-size: 0.9rem; margin-top: 0.75rem; }

/* === Buttons === */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1.25rem;
  font-size: 1rem;
  font-weight: 500;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
  min-height: var(--tap-target);
  min-width: var(--tap-target);
  text-decoration: none;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--gold-dark); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--gold); }

.btn-secondary { background: var(--bg-warm); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--border); }

.btn-danger { background: #B85A5A; color: #fff; }
.btn-danger:hover:not(:disabled) { background: #9A4444; }

.btn-large { width: 100%; padding: 0.85rem; font-size: 1.1rem; }

.btn-small { padding: 0.4rem 0.8rem; font-size: 0.85rem; min-height: 36px; }

/* === Navigation === */

.top-nav {
  background: var(--bg-nav);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px var(--shadow-md);
}

.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  flex-wrap: wrap;
}

.nav-brand {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--gold-light);
  text-decoration: none;
  letter-spacing: 0.06em;
}

.nav-links {
  display: flex;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
}

.nav-links::-webkit-scrollbar { display: none; }

.nav-links a {
  color: var(--text-nav);
  text-decoration: none;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: 'Cinzel', Georgia, serif;
  letter-spacing: 0.03em;
  min-height: var(--tap-target);
  display: flex;
  align-items: center;
  transition: background 0.2s;
  white-space: nowrap;
}

.nav-links a:hover { background: rgba(255,255,255,0.1); }
.nav-links a.active { background: var(--gold-dark); color: #fff; }

/* === Content Area === */

.content-area {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

/* === Cards === */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 4px var(--shadow);
  transition: box-shadow 0.2s, transform 0.2s;
  position: relative;
}

.card:hover { box-shadow: 0 4px 16px var(--shadow-md); }
.card-clickable { cursor: pointer; }
.card-clickable:hover { transform: translateY(-2px); }

/* === Upload View === */

.dropzone {
  border: none;
  border-radius: 0;
  padding: 0;
  text-align: center;
  cursor: pointer;
  transition: transform 0.2s;
  background: transparent;
  position: relative;
  overflow: visible;
}

.dropzone:hover, .dropzone.dragover {
  transform: scale(1.01);
}

/* The frame image defines the overall size */
.dropzone-frame {
  width: 100%;
  height: auto;
  display: block;
  pointer-events: none;
}

/* Inner content area positioned over the parchment region of the frame */
.dropzone-inner {
  position: absolute;
  /* These percentages map to the inner parchment area of the frame */
  top: 34%;
  left: 18%;
  right: 18%;
  bottom: 18%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  pointer-events: none;
}

.dropzone-hint {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-family: Georgia, serif;
  text-align: center;
  padding: 0.5rem;
}

/* Thumbnails inside the frame */
.dropzone-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  gap: 4px;
  width: 100%;
  max-height: 100%;
  overflow-y: auto;
  padding: 4px;
}

.dropzone-thumbs .thumbnail {
  aspect-ratio: 1;
  min-height: 60px;
}

.dropzone-thumbs .thumbnail img {
  border-radius: 4px;
}

.thumbnail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.75rem;
  margin: 1.25rem 0;
}

.thumbnail {
  position: relative;
  aspect-ratio: 3/4;
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px solid var(--border);
  background: var(--bg-warm);
}

.thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumbnail-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.thumbnail-number {
  position: absolute;
  bottom: 4px;
  left: 4px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
}

.upload-fields {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 1.25rem 0;
}

.field-label {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  display: block;
}

.field-input {
  width: 100%;
  padding: 0.7rem 0.9rem;
  font-size: 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}

.field-input:focus { border-color: var(--gold); }

/* Section header with banner */
.section-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  padding: 0.75rem 1.5rem;
  background: linear-gradient(135deg, rgba(201,168,76,0.08) 0%, rgba(201,168,76,0.15) 50%, rgba(201,168,76,0.08) 100%);
  border-top: 1px solid rgba(201,168,76,0.25);
  border-bottom: 1px solid rgba(201,168,76,0.25);
}

.banner-flourish {
  width: 60px;
  height: 40px;
  flex-shrink: 0;
}

.section-banner h2 {
  font-family: 'Cinzel', Georgia, serif;
  color: var(--gold-dark);
  font-size: 1.5rem;
  text-align: center;
  white-space: nowrap;
  letter-spacing: 0.08em;
  margin: 0;
}

/* Analysis header — CSS+SVG banner */
.analysis-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 0.6rem 1.5rem;
  background: linear-gradient(135deg, rgba(44,36,25,0.06) 0%, rgba(201,168,76,0.12) 50%, rgba(44,36,25,0.06) 100%);
  border-top: 1px solid rgba(201,168,76,0.2);
  border-bottom: 1px solid rgba(201,168,76,0.2);
}

.analysis-eye {
  width: 50px;
  height: 28px;
  flex-shrink: 0;
}

.analysis-header h3 {
  color: var(--gold-dark, #8B6914);
  font-family: 'Cinzel', Georgia, serif;
  font-size: 1.4rem;
  letter-spacing: 0.08em;
  margin: 0;
  white-space: nowrap;
}

/* Transcribing status image */
.transcribing-img {
  max-width: 240px;
  height: auto;
  margin: 0 auto;
  display: block;
}

/* Empty state with paper stack */
.empty-state-asset {
  max-width: 180px;
  height: auto;
  margin: 0 auto 1rem;
  display: block;
  opacity: 0.8;
}

/* Symbols circle for login & analysis */
.symbols-img {
  max-width: 140px;
  height: auto;
  display: block;
  margin: 0 auto 0.75rem;
}

/* Corner flourish decorations on content area */
.content-area {
  position: relative;
}

/* Progress display */
.progress-list { list-style: none; margin: 1rem 0; }

.progress-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  font-size: 1rem;
}

.progress-icon { font-size: 1.2rem; width: 1.5rem; text-align: center; }
.progress-status { color: var(--text-muted); font-size: 0.9rem; font-family: Georgia, serif; }

.spinner {
  display: inline-block;
  width: 1.2rem;
  height: 1.2rem;
  border: 2px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* === Entry List === */

.entry-card { text-decoration: none; color: inherit; display: block; }

.entry-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.entry-date {
  font-weight: 600;
  color: var(--text);
}

.entry-date-unknown { color: var(--text-light); font-style: italic; }

.entry-title {
  font-family: Georgia, serif;
  font-size: 1.1rem;
  margin-bottom: 0.35rem;
}

.entry-summary {
  color: var(--text-muted);
  font-size: 0.95rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tone-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.theme-pills {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.theme-pill {
  background: var(--bg-warm);
  color: var(--text-muted);
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.8rem;
  border: 1px solid var(--border);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.8rem;
  background: var(--gold-light);
  color: var(--gold-dark);
}

.status-badge.error { background: #F5D5D5; color: #B85A5A; }

/* Search & filters */
.filters-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.filters-bar .field-input {
  flex: 1;
  min-width: 150px;
}

.filters-bar select {
  padding: 0.6rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.9rem;
  min-width: 120px;
}

.load-more-container { text-align: center; margin-top: 1rem; }

/* === Entry Detail === */

.detail-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 768px) {
  .detail-layout { grid-template-columns: 1fr; }
}

.detail-header {
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Parchment card — CSS gradients, no images */
.parchment-card {
  position: relative;
  background:
    radial-gradient(ellipse at 20% 10%, rgba(180, 160, 120, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 90%, rgba(160, 140, 100, 0.2) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, var(--bg-warm) 0%, #dcd0b2 100%);
  border-radius: 4px;
  padding: 48px 32px 40px;
  margin-bottom: 20px;
  box-shadow:
    0 2px 8px var(--shadow),
    0 8px 32px rgba(44, 36, 22, 0.15),
    inset 0 0 60px rgba(180, 160, 120, 0.15);
  transform: rotate(-0.3deg);
  overflow: hidden;
}

/* Paper grain texture via SVG noise */
.parchment-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='256' height='256' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  background-size: 256px 256px;
  pointer-events: none;
  border-radius: 4px;
}

/* Aged edge vignette */
.parchment-card::after {
  content: '';
  position: absolute;
  inset: 0;
  box-shadow:
    inset 0 0 30px rgba(140, 120, 80, 0.2),
    inset 0 0 80px rgba(100, 80, 50, 0.08);
  border-radius: 4px;
  pointer-events: none;
}

/* Decorative double border */
.ornate-border {
  position: absolute;
  inset: 12px;
  border: 1.5px solid rgba(74, 98, 117, 0.5);
  border-radius: 6px;
  pointer-events: none;
}

.ornate-border::after {
  content: '';
  position: absolute;
  inset: 4px;
  border: 0.75px solid rgba(74, 98, 117, 0.3);
  border-radius: 4px;
}

/* SVG corner flourishes */
.corner-flourish {
  position: absolute;
  width: 60px;
  height: 60px;
  opacity: 0.45;
  pointer-events: none;
  z-index: 2;
}

.corner-flourish.top-left { top: 4px; left: 4px; }
.corner-flourish.top-right { top: 4px; right: 4px; transform: scaleX(-1); }
.corner-flourish.bottom-left { bottom: 4px; left: 4px; transform: scaleY(-1); }
.corner-flourish.bottom-right { bottom: 4px; right: 4px; transform: scale(-1, -1); }

/* Journal text inside parchment */
.journal-text {
  position: relative;
  z-index: 1;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.05rem;
  line-height: 1.75;
  color: var(--text);
  max-width: 520px;
  margin: 0 auto;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Original scan display (when viewing photos) */
.scan-container {
  position: relative;
  z-index: 1;
}

.scan-container img {
  width: 100%;
  height: auto;
  border-radius: 4px;
  display: block;
}

/* Scan page navigation */
.scan-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  margin: 16px 0;
}

.scan-nav button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px solid rgba(58, 50, 38, 0.2);
  background: rgba(255,255,255,0.5);
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scan-nav button:hover {
  background: rgba(255,255,255,0.8);
  border-color: var(--text-muted);
}

.scan-nav button:disabled {
  opacity: 0.3;
  cursor: default;
}

.scan-indicator {
  font-size: 0.85rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

/* Analysis panel */
.analysis-panel { }

.analysis-tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1rem;
  overflow-x: auto;
}

.analysis-tab {
  padding: 0.5rem 0.9rem;
  font-size: 0.9rem;
  font-family: 'Cinzel', Georgia, serif;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  min-height: var(--tap-target);
}

.analysis-tab.active {
  color: var(--gold-dark);
  border-bottom-color: var(--gold-dark);
  font-weight: 600;
}

.analysis-content { min-height: 200px; }

.emotion-bar-container { margin: 0.5rem 0; }

.emotion-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

.emotion-bar-track {
  height: 8px;
  background: var(--bg-warm);
  border-radius: 4px;
  overflow: hidden;
}

.emotion-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.symbol-card, .dream-card {
  background: var(--bg-warm);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.dream-card {
  background: #F0EBF5;
  border: 1px solid #D5CCE0;
}

.clickable-entity {
  color: var(--navy);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
}

.clickable-entity:hover { text-decoration-style: solid; }

/* === Graph View === */

.graph-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
}

.graph-container svg {
  width: 100%;
  height: 600px;
  display: block;
}

.graph-controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  align-items: center;
}

.graph-controls label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.graph-tooltip {
  position: absolute;
  background: var(--bg-nav);
  color: var(--text-nav);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  pointer-events: none;
  z-index: 20;
  max-width: 250px;
  box-shadow: 0 2px 8px var(--shadow-md);
}

.graph-legend {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* === Timeline View === */

.timeline {
  position: relative;
  padding-left: 2rem;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 0.5rem;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--border);
  border-radius: 2px;
}

.timeline-year {
  position: relative;
  margin-bottom: 0.5rem;
}

.timeline-year-label {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--gold-dark);
  margin-bottom: 0.75rem;
  position: relative;
}

.timeline-year-label::before {
  content: '';
  position: absolute;
  left: calc(-2rem + 0.5rem + 1.5px - 7px);
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  background: var(--gold);
  border-radius: 50%;
  border: 3px solid var(--bg);
  z-index: 1;
}

.timeline-entry {
  position: relative;
  margin-bottom: 0.75rem;
}

.timeline-entry::before {
  content: '';
  position: absolute;
  left: calc(-2rem + 0.5rem + 1.5px - 4px);
  top: 0.75rem;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg);
  z-index: 1;
}

.timeline-entry .card {
  margin-left: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
}

.timeline-entry .card:hover {
  box-shadow: none;
  background: rgba(201,168,76,0.05);
}

/* Year jump nav */
.year-jump {
  position: fixed;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  z-index: 50;
}

.year-jump a {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  transition: background 0.2s;
}

.year-jump a:hover { background: var(--bg-warm); color: var(--text); }

/* === People & Themes Management === */

.entity-list { }

.entity-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.entity-row:last-child { border-bottom: none; }

.entity-name { font-weight: 500; flex: 1; }
.entity-count { color: var(--text-muted); font-size: 0.9rem; }
.entity-meta { color: var(--text-light); font-size: 0.85rem; }

.merge-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: var(--bg-warm);
  border-radius: var(--radius);
}

/* === Utility === */

.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.gap-1 { gap: 0.5rem; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state-icon { font-size: 3rem; margin-bottom: 0.5rem; display: block; }

.confirm-dialog {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}

.confirm-box {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 8px 32px var(--shadow-md);
}

.confirm-box p { margin-bottom: 1rem; font-size: 1rem; }

.confirm-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* === Chat View === */

.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 56px - 3rem);
  min-height: 400px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  scroll-behavior: smooth;
}

.chat-welcome {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.chat-welcome h3 {
  font-family: 'Cinzel', Georgia, serif;
  color: var(--gold-dark);
  margin-bottom: 0.5rem;
}

.chat-welcome p {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.05rem;
  max-width: 400px;
  margin: 0 auto;
  line-height: 1.5;
}

.chat-bubble {
  max-width: 85%;
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius-lg);
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.05rem;
  line-height: 1.55;
  word-wrap: break-word;
}

.chat-bubble.user {
  align-self: flex-end;
  background: var(--gold-light);
  color: var(--text);
  border-bottom-right-radius: 4px;
}

.chat-bubble.assistant {
  align-self: flex-start;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px var(--shadow);
}

.chat-quote {
  display: inline;
  background: var(--bg-warm);
  color: var(--gold-dark);
  font-style: italic;
  padding: 0.1em 0.3em;
  border-left: 3px solid var(--gold);
  border-radius: 2px;
}

.chat-input-bar {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 0;
  position: sticky;
  bottom: 0;
  background: var(--bg);
  border-top: 1px solid var(--border);
}

.chat-input {
  flex: 1;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-family: 'Cormorant Garamond', Georgia, serif;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
  min-height: var(--tap-target);
}

.chat-input:focus {
  border-color: var(--gold);
}

.chat-input:disabled {
  opacity: 0.6;
}

.chat-send-btn {
  flex-shrink: 0;
  padding: 0.75rem 1.25rem;
  font-family: 'Cinzel', Georgia, serif;
  letter-spacing: 0.03em;
}

/* Typing indicator */
.chat-bubble.chat-typing {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  padding: 1rem 1.25rem;
}

.chat-bubble.chat-typing span {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: chatTyping 1.4s infinite ease-in-out both;
}

.chat-bubble.chat-typing span:nth-child(1) { animation-delay: 0s; }
.chat-bubble.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-bubble.chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatTyping {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* === Responsive === */

@media (max-width: 600px) {
  html { font-size: 16px; }
  .nav-inner { padding: 0 0.5rem; }
  .nav-links a { padding: 0.4rem 0.5rem; font-size: 0.8rem; }
  .content-area { padding: 1rem 0.75rem 2rem; }
  .parchment-card { padding: 36px 20px 32px; }
  .year-jump { display: none; }
  .graph-container svg { height: 400px; }
  .screen::before,
  .screen::after { width: 80px; height: 80px; }
  .section-banner img { max-width: 100%; }
  .dropzone-hint { font-size: 0.85rem; }
  .dropzone-thumbs { grid-template-columns: repeat(auto-fill, minmax(50px, 1fr)); }
  .login-icon { width: 75vw; max-width: 400px; }
  .transcribing-img { max-width: 180px; }
  .chat-container { height: calc(100vh - 56px - 2rem); }
  .chat-bubble { max-width: 90%; font-size: 1rem; }
  .chat-input { font-size: 16px; } /* prevents iOS zoom */
}
