@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,600;0,700;1,400;1,600&family=Inter:wght@300;400;500;600&display=swap');

:root {
  --bg: #0a0a0f;
  --bg-card: #12121a;
  --bg-hover: #1a1a2e;
  --bg-modal: #0d0d14;
  --text: #e8e6e3;
  --text-dim: #8a8694;
  --text-muted: #5a5666;
  --accent: #c4956a;
  --accent-dim: #8a6a4a;
  --accent-glow: rgba(196, 149, 106, 0.15);
  --border: #1e1e2a;
  --border-light: #2a2a3a;
  --entry-dot: #c4956a;
  --shadow: rgba(0, 0, 0, 0.4);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

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

#app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

header {
  text-align: center;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

header h1 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 2.8rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.02em;
  margin-bottom: 0.3rem;
}

.subtitle {
  font-size: 0.9rem;
  color: var(--text-dim);
  font-style: italic;
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.1rem;
}

/* Navigation */
#timeline-nav {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.nav-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 0.5rem 1.5rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: 'Inter', sans-serif;
  transition: all 0.2s;
}

.nav-btn:hover { border-color: var(--accent-dim); color: var(--text); }
.nav-btn.active { background: var(--accent-glow); border-color: var(--accent); color: var(--accent); }

/* Views */
.view { display: none; }
.view.active { display: block; }

/* Calendar */
.calendar-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 0.5rem;
}

.calendar-header h2 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--text);
  min-width: 220px;
  text-align: center;
}

.year-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

#year-label {
  color: var(--text-dim);
  font-size: 0.9rem;
}

.arrow-btn, .year-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.arrow-btn:hover, .year-btn:hover {
  border-color: var(--accent-dim);
  color: var(--accent);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 1.5rem;
}

.day-header {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.day-cell {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--text-dim);
  position: relative;
  cursor: default;
  transition: all 0.15s;
  min-height: 50px;
}

.day-cell.other-month { color: var(--text-muted); opacity: 0.3; }

.day-cell.has-entries {
  cursor: pointer;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.day-cell.has-entries:hover {
  background: var(--bg-hover);
  border-color: var(--accent-dim);
  transform: scale(1.05);
}

.day-cell.has-entries .entry-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  margin-top: 3px;
}

.day-cell .entry-count {
  font-size: 0.6rem;
  color: var(--accent);
  margin-top: 2px;
}

.day-cell.today {
  border: 1px solid var(--accent) !important;
}

/* Day entries panel */
.day-entries {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
  margin-top: 1rem;
  position: relative;
}

.day-entries.hidden { display: none; }

.day-entries h3 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.4rem;
  color: var(--accent);
  margin-bottom: 1rem;
}

.entry-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.2rem;
  margin-bottom: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.entry-card:hover {
  border-color: var(--accent-dim);
  background: var(--bg-hover);
}

.entry-card .entry-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.3rem;
}

.entry-card .entry-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.entry-card .entry-preview {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-top: 0.5rem;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.entry-card .mood-bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  border-radius: 8px 0 0 8px;
}

.close-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.close-btn:hover { color: var(--accent); }

/* Reader Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.modal.hidden { display: none; }

.modal-content {
  background: var(--bg-modal);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 90%;
  max-width: 750px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2.5rem;
  position: relative;
  box-shadow: 0 20px 60px var(--shadow);
}

#reader-nav {
  display: flex;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.nav-arrow {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 0.4rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s;
}

.nav-arrow:hover { border-color: var(--accent-dim); color: var(--accent); }
.nav-arrow:disabled { opacity: 0.3; cursor: default; }

#reader-body .entry-date {
  font-size: 0.85rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.5rem;
}

#reader-body .entry-full-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 0.5rem;
}

#reader-body .entry-trajectory {
  font-size: 0.85rem;
  color: var(--text-dim);
  font-style: italic;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

#reader-body .entry-narrative {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.2rem;
  line-height: 1.85;
  color: var(--text);
  white-space: pre-wrap;
}

#reader-body .entry-narrative p {
  margin-bottom: 1.2rem;
  text-indent: 0;
}

#reader-body .entry-arc-types {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.arc-tag {
  font-size: 0.7rem;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  background: var(--bg-hover);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

#reader-body .entry-moments {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

#reader-body .entry-moments h4 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1rem;
  color: var(--accent-dim);
  margin-bottom: 0.5rem;
}

#reader-body .entry-moments ul {
  list-style: none;
  padding: 0;
}

#reader-body .entry-moments li {
  font-size: 0.85rem;
  color: var(--text-dim);
  padding: 0.3rem 0;
  padding-left: 1rem;
  position: relative;
}

#reader-body .entry-moments li::before {
  content: '~';
  position: absolute;
  left: 0;
  color: var(--accent-dim);
}

#reader-body .entry-twist {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--accent-glow);
  border-radius: 8px;
  border-left: 3px solid var(--accent);
}

#reader-body .entry-twist h4 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 0.9rem;
  color: var(--accent);
  margin-bottom: 0.3rem;
}

#reader-body .entry-twist p {
  font-size: 0.9rem;
  color: var(--text-dim);
  font-style: italic;
}

/* Timeline View */
#timeline-filters {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

#timeline-filters select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-family: 'Inter', sans-serif;
}

#timeline-list .timeline-entry {
  display: flex;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
}

#timeline-list .timeline-entry:hover { background: var(--bg-card); padding-left: 0.5rem; }

.timeline-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  min-width: 90px;
  padding-top: 0.15rem;
}

.timeline-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.05rem;
  color: var(--text);
}

.timeline-source {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* Search */
#search-input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.8rem 1.2rem;
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: 'Inter', sans-serif;
  margin-bottom: 1.5rem;
  outline: none;
  transition: border-color 0.2s;
}

#search-input:focus { border-color: var(--accent-dim); }
#search-input::placeholder { color: var(--text-muted); }

#search-results .search-hit {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
}

#search-results .search-hit:hover { background: var(--bg-card); }

.search-hit-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.05rem;
  color: var(--text);
}

.search-hit-date {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.search-hit-excerpt {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 0.3rem;
  line-height: 1.4;
}

.search-hit-excerpt mark {
  background: var(--accent-glow);
  color: var(--accent);
  padding: 0 2px;
  border-radius: 2px;
}

/* Footer */
footer {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

#stats {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-dim); }

/* Responsive */
@media (max-width: 600px) {
  #app { padding: 1rem; }
  header h1 { font-size: 2rem; }
  .calendar-header h2 { font-size: 1.3rem; min-width: 160px; }
  .modal-content { padding: 1.5rem; width: 95%; }
  #reader-body .entry-full-title { font-size: 1.5rem; }
  #reader-body .entry-narrative { font-size: 1.05rem; }
  .day-cell { min-height: 40px; font-size: 0.75rem; }
}
