/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #faf8f5;
  --bg-card: #ffffff;
  --bg-sidebar: #f3f0ea;
  --text: #2c2825;
  --text-secondary: #6b6560;
  --text-muted: #9e9890;
  --accent: #c47a5a;
  --accent-hover: #a86548;
  --accent-light: #f5ebe4;
  --border: #e8e2d8;
  --border-light: #f0ebe4;
  --success: #5a9e6f;
  --success-light: #e8f2ec;
  --danger: #c45a5a;
  --danger-hover: #a84848;
  --danger-light: #f5e4e4;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.08);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', SFMono-Regular, ui-monospace, monospace;
  --max-width: 1200px;
  --sidebar-width: 360px;
}
html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ===== Header ===== */
.site-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1rem;
}
.logo-icon { color: var(--accent); flex-shrink: 0; }
.main-nav {
  display: flex;
  gap: 24px;
}
.main-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.15s;
}
.main-nav a:hover { color: var(--accent); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  border: none;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  text-decoration: none;
  line-height: 1.4;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-sidebar); color: var(--text); }
.btn-small { padding: 6px 14px; font-size: 0.82rem; }
.btn-danger { color: var(--danger); border-color: var(--danger-light); }
.btn-danger:hover { background: var(--danger-light); }

/* ===== Intro Section ===== */
.intro {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 64px 24px 48px;
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 48px;
  align-items: start;
}
.intro-content h1 {
  font-size: 2.4rem;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 16px;
}
.intro-lede {
  font-size: 1.1rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 28px;
  max-width: 520px;
}
.intro-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.intro-card {
  background: var(--accent-light);
  border-radius: var(--radius-lg);
  padding: 28px;
}
.intro-card-inner { display: flex; flex-direction: column; gap: 16px; }
.intro-stat strong {
  display: block;
  font-size: 1.6rem;
  color: var(--accent);
  font-weight: 800;
}
.intro-stat span {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ===== Journal Section ===== */
.journal-section {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px 64px;
}
.journal-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  gap: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

/* Sidebar */
.journal-sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  max-height: 75vh;
  overflow: hidden;
}
.sidebar-header {
  padding: 20px 20px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-header h2 { font-size: 1.05rem; font-weight: 700; }
.filter-bar {
  padding: 0 20px 12px;
  display: flex;
  gap: 6px;
}
.filter-btn {
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  font-size: 0.78rem;
  font-family: var(--font);
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s;
}
.filter-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.filter-btn:hover:not(.active) { background: var(--accent-light); }
.weight-legend {
  padding: 0 20px 16px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.dot-light { background: #a8c5a0; }
.dot-moderate { background: #d4a853; }
.dot-heavy { background: #c47a5a; }
.dot-overwhelming { background: #b05a5a; }

.entries-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: 0 12px;
}
.entry-item {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s;
  margin-bottom: 2px;
  border-left: 3px solid transparent;
}
.entry-item:hover { background: var(--accent-light); }
.entry-item.active { background: var(--accent-light); border-left-color: var(--accent); }
.entry-item-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.entry-item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.entry-item-weight {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.entry-item.resolved .entry-item-title {
  text-decoration: line-through;
  color: var(--text-muted);
}
.empty-entries {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.6;
}
.sidebar-actions {
  padding: 12px 20px 16px;
  display: flex;
  gap: 8px;
  border-top: 1px solid var(--border);
}

/* Main Panel */
.journal-main {
  padding: 28px 32px;
  min-height: 400px;
  max-height: 75vh;
  overflow-y: auto;
}
.entry-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  text-align: center;
  gap: 16px;
  padding: 40px;
}
.empty-icon { color: var(--border); }

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}
.detail-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.weight-badge {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}
.weight-badge.light { background: #e4efe0; color: #4a7a3f; }
.weight-badge.moderate { background: #f5edd4; color: #8a6d2b; }
.weight-badge.heavy { background: var(--accent-light); color: var(--accent); }
.weight-badge.overwhelming { background: var(--danger-light); color: var(--danger); }
.status-badge {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}
.status-badge.resolved { background: var(--success-light); color: var(--success); }
.status-badge.unresolved { background: #f0ebe4; color: var(--text-muted); }
.detail-actions { display: flex; gap: 8px; }
.detail-description {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-light);
}

/* Reflection Panel */
.reflection-panel {
  background: var(--bg-sidebar);
  border-radius: var(--radius-md);
  padding: 24px;
}
.reflection-panel h4 {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
}
.prompt-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}
.prompt-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 0.88rem;
  color: var(--text-secondary);
  padding: 10px 14px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}
.prompt-icon { flex-shrink: 0; margin-top: 2px; color: var(--accent); }
.reflection-input-group textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.88rem;
  line-height: 1.6;
  resize: vertical;
  background: var(--bg-card);
  color: var(--text);
  margin-bottom: 10px;
  transition: border-color 0.15s;
}
.reflection-input-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(196,122,90,0.1);
}

/* Entry Form */
.entry-form h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 20px; }
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg);
  transition: border-color 0.15s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(196,122,90,0.1);
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}

/* Patterns Section */
.patterns-section {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px 64px;
}
.patterns-section h2 {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 8px;
}
.patterns-sub {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 32px;
}
.patterns-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}
.pattern-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.pattern-card h3 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.pattern-stats { display: flex; gap: 32px; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-number { font-size: 2rem; font-weight: 800; color: var(--accent); line-height: 1; }
.stat-label { font-size: 0.78rem; color: var(--text-muted); }
.weight-chart { display: flex; flex-direction: column; gap: 10px; }
.chart-row { display: flex; align-items: center; gap: 12px; }
.chart-label { font-size: 0.8rem; color: var(--text-secondary); width: 110px; flex-shrink: 0; }
.chart-bar-bg { flex: 1; height: 20px; background: var(--bg-sidebar); border-radius: 10px; overflow: hidden; }
.chart-bar-fill { height: 100%; border-radius: 10px; transition: width 0.4s ease; }
.chart-count { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); width: 24px; text-align: right; }
.people-list, .oldest-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.people-list li, .oldest-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
  padding: 8px 12px;
  background: var(--bg-sidebar);
  border-radius: var(--radius-sm);
}
.people-count {
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
}
.oldest-list li { color: var(--text-secondary); }
.oldest-date { font-size: 0.78rem; color: var(--text-muted); }
.empty-list-item { font-size: 0.85rem; color: var(--text-muted); font-style: italic; background: var(--bg-sidebar); padding: 12px; border-radius: var(--radius-sm); }

/* About Section */
.about-section {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 64px 24px;
}
.about-grid { max-width: var(--max-width); margin: 0 auto; }
.about-content { max-width: 720px; }
.about-content h2 { font-size: 1.6rem; font-weight: 800; margin-bottom: 20px; }
.about-content h3 { font-size: 1.05rem; font-weight: 700; margin: 32px 0 12px; }
.about-content p { color: var(--text-secondary); font-size: 0.95rem; line-height: 1.75; margin-bottom: 14px; }
.mistakes-list { list-style: none; display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.mistakes-list li {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.65;
  padding: 14px 18px;
  background: var(--bg-sidebar);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent);
}
.mistakes-list strong { color: var(--text); }
.scenario-list { display: flex; flex-direction: column; gap: 16px; margin-top: 8px; }
.scenario-list dt {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--text);
  padding: 10px 16px;
  background: var(--accent-light);
  border-radius: var(--radius-sm);
}
.scenario-list dd {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.65;
  padding: 10px 16px 0;
}
.version-note {
  margin-top: 32px;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.version-note a { color: var(--accent); }
.version-note a:hover { color: var(--accent-hover); }

/* Footer */
.site-footer {
  background: var(--bg-sidebar);
  border-top: 1px solid var(--border);
  padding: 32px 24px;
}
.footer-inner { max-width: var(--max-width); margin: 0 auto; text-align: center; }
.footer-nav { display: flex; justify-content: center; gap: 24px; margin-bottom: 12px; flex-wrap: wrap; }
.footer-nav a { color: var(--text-secondary); text-decoration: none; font-size: 0.85rem; }
.footer-nav a:hover { color: var(--accent); }
.footer-copy { font-size: 0.78rem; color: var(--text-muted); }

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .intro { grid-template-columns: 1fr; padding: 40px 20px 32px; }
  .intro-card { display: none; }
  .intro-content h1 { font-size: 1.8rem; }
  .journal-layout { grid-template-columns: 1fr; }
  .journal-sidebar { max-height: none; border-right: none; border-bottom: 1px solid var(--border); }
  .entries-list { max-height: 300px; }
  .journal-main { max-height: none; padding: 24px 20px; }
  .patterns-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .header-inner { padding: 0 16px; }
  .main-nav { gap: 16px; }
  .main-nav a { font-size: 0.82rem; }
  .logo-text { font-size: 0.88rem; }
}
@media (max-width: 480px) {
  .intro-content h1 { font-size: 1.5rem; }
  .intro-actions { flex-direction: column; }
  .intro-actions .btn { width: 100%; }
  .detail-header { flex-direction: column; }
  .pattern-stats { gap: 20px; }
}

/* Scrollbar styling */
.entries-list::-webkit-scrollbar,
.journal-main::-webkit-scrollbar { width: 6px; }
.entries-list::-webkit-scrollbar-track,
.journal-main::-webkit-scrollbar-track { background: transparent; }
.entries-list::-webkit-scrollbar-thumb,
.journal-main::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.entries-list::-webkit-scrollbar-thumb:hover,
.journal-main::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Focus styles for accessibility */
*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Animation for new items */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.entry-item { animation: fadeIn 0.2s ease-out; }

/* Chart bar colors */
.bar-light { background: #a8c5a0; }
.bar-moderate { background: #d4a853; }
.bar-heavy { background: var(--accent); }
.bar-overwhelming { background: var(--danger); }


/* Factory-injected deployment helpers. The AI owns the site design above this block. */
.ad-unit {
  width: min(100%, 720px);
  min-height: 120px;
  margin: 24px auto;
  display: block;
}

.legal-page {
  width: min(900px, calc(100% - 32px));
  margin: 40px auto;
}

.factory-fallback-nav {
  width: min(900px, calc(100% - 32px));
  margin: 24px auto 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  font-size: 0.95rem;
}

.factory-fallback-nav a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}
