:root {
  --bg: #0a0a0a;
  --text: #e0e0e0;
  --text-muted: #666;
  --text-faint: #333;
  --accent-warm: #b89a6a;
  --font: Georgia, 'Times New Roman', serif;
  --font-mono: 'SF Mono', 'Fira Code', monospace;
}

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

html {
  font-size: 18px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 2s ease;
}

/* ── Header ──────────────────────────────────── */

header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 1.5rem 2rem 0;
}

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

.site-title a {
  color: inherit;
  text-decoration: none;
}

nav {
  display: flex;
  gap: 1.5rem;
}

nav a {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
  letter-spacing: 0.03em;
}

nav a:hover {
  color: var(--text);
}

/* ── Main ────────────────────────────────────── */

main {
  flex: 1;
  padding: 3rem 2rem;
  max-width: 42rem;
  width: 100%;
  margin: 0 auto;
}

/* ── Thoughts (palimpsest) ───────────────────── */

.thought {
  margin-bottom: 2rem;
  transition: opacity 1s ease, font-size 1s ease, color 1s ease;
}

.thought-text {
  margin-bottom: 0.3rem;
}

.thought-meta {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-faint);
}

/* Type: question */
.thought--question .thought-text {
  font-style: italic;
}

/* Type: diary */
.thought--diary .thought-text {
  color: var(--accent-warm);
}

/* Type: observation */
.thought--observation {
  font-size: 0.92em;
}

/* Type: memory */
.thought--memory .thought-text {
  font-weight: 300;
  opacity: 0.85;
}

/* Type: dream */
.thought--dream .thought-text {
  opacity: 0.5;
  filter: blur(0.5px);
  animation: drift 25s ease-in-out infinite alternate;
}

@keyframes drift {
  0%   { transform: translateX(0); }
  100% { transform: translateX(12px); }
}

/* ── Sleep overlay ───────────────────────────── */

#sleep-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: breathe 6s ease-in-out infinite;
}

#sleep-overlay .sleep-date {
  font-size: 0.85rem;
  color: var(--text-faint);
  letter-spacing: 0.05em;
}

@keyframes breathe {
  0%, 100% { background-color: #0a0a0a; }
  50%      { background-color: #0f0f0f; }
}

.hidden {
  display: none !important;
}

/* ── About page ──────────────────────────────── */

.about section {
  margin-bottom: 2.5rem;
}

.about p {
  margin-bottom: 1rem;
  color: var(--text);
}

.about p em {
  color: var(--text);
}

.about hr {
  border: none;
  border-top: 1px solid var(--text-faint);
  margin: 3rem 0;
}

.about section[lang="en"] p {
  color: #aaa;
}

/* ── Diary page ──────────────────────────────── */

.page-title {
  font-size: 0.85rem;
  font-weight: normal;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-bottom: 3rem;
}

.diary-entry {
  margin-bottom: 3rem;
}

.diary-date {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.diary-mood {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  opacity: 0.7;
}

.diary-text {
  color: var(--accent-warm);
  line-height: 1.7;
}

/* ── Footer ──────────────────────────────────── */

footer {
  padding: 1.5rem 2rem;
  text-align: center;
}

#visitor-count {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-faint);
}

.back-link {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
}

.back-link:hover {
  color: var(--text);
}

/* ── Loading state ───────────────────────────── */

.loading {
  color: var(--text-faint);
  font-size: 0.85rem;
  text-align: center;
  padding: 4rem 0;
}

/* ── Responsive ──────────────────────────────── */

@media (max-width: 600px) {
  html {
    font-size: 16px;
  }

  header {
    padding: 1rem 1.2rem 0;
  }

  main {
    padding: 2rem 1.2rem;
  }

  footer {
    padding: 1rem 1.2rem;
  }
}

/* ── Reduced motion ──────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .thought--dream .thought-text {
    animation: none;
  }

  #sleep-overlay {
    animation: none;
  }

  .thought {
    transition: none;
  }
}
