:root {
  --bg: #0d0f1c;
  --bg-raised: rgba(19, 22, 40, 0.86);
  --ink: #e8e4da;
  --muted: #8b8798;
  --faint: #565367;
  --accent: #e8a75c;
  --accent-soft: rgba(232, 167, 92, 0.16);
  --line: rgba(232, 228, 218, 0.09);
  --radius: 14px;
  font-size: 16px;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- hero ---------- */

.hero {
  position: relative;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

#pilgrimage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: pan-y;
  cursor: grab;
}
#pilgrimage.dragging { cursor: grabbing; }

.topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 1.25rem 1.5rem;
  pointer-events: none;
}

.wordmark {
  font-weight: 700;
  letter-spacing: 0.35em;
  font-size: 0.8rem;
  color: var(--ink);
  opacity: 0.9;
}

.count {
  font-size: 0.8rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.empty-hint {
  position: absolute;
  top: 34%;
  left: 0; right: 0;
  text-align: center;
  color: var(--muted);
  font-style: italic;
  font-size: 0.95rem;
  pointer-events: none;
}

/* ---------- today card ---------- */

.today-card {
  position: absolute;
  left: 50%;
  bottom: max(1.5rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(30rem, calc(100vw - 2rem));
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.today-label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--muted);
  margin-bottom: 0.45rem;
}

#note-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink);
  padding: 0.65rem 0.8rem;
  font-size: 1rem;
  outline: none;
}
#note-input:focus { border-color: rgba(232, 167, 92, 0.45); }
#note-input::placeholder { color: var(--faint); }

.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.7rem;
  flex-wrap: wrap;
}

.btn { border-radius: 9px; }

.btn.primary {
  background: var(--accent);
  color: #1a1206;
  font-weight: 600;
  padding: 0.6rem 1.1rem;
}
.btn.primary:hover { filter: brightness(1.08); }

.btn.ghost {
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0.35rem 0.2rem;
}
.btn.ghost:hover { color: var(--ink); }

.chip {
  align-self: flex-start;
  font-size: 0.8rem;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(232, 167, 92, 0.25);
  border-radius: 999px;
  padding: 0.3rem 0.85rem;
}
.chip:hover { background: rgba(232, 167, 92, 0.26); }

.marked-line { font-size: 0.95rem; }
.marked-line .wordless { color: var(--muted); font-style: italic; }

/* ---------- beats ---------- */

.beat {
  min-height: 88vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 4rem 1.5rem;
  max-width: 44rem;
  margin: 0 auto;
}

.beat h2 {
  font-size: clamp(1.7rem, 4.5vw, 2.6rem);
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 1.4rem;
  letter-spacing: -0.01em;
}

.beat p {
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 34rem;
}

.beat .law {
  margin-top: 1.6rem;
  color: var(--ink);
  font-weight: 600;
  font-size: 1.05rem;
}

.failures {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1rem;
  margin: 1rem 0;
  width: 100%;
  max-width: 36rem;
}

.failure {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.3rem 1.4rem;
  text-align: left;
}
.failure h3 { font-size: 1rem; margin-bottom: 0.4rem; color: var(--accent); }
.failure p { font-size: 0.92rem; }

.creed .motto {
  margin-top: 2.2rem;
  color: var(--ink);
  letter-spacing: 0.04em;
  font-size: 1.1rem;
}
.creed .motto em { color: var(--accent); font-style: normal; font-weight: 700; }

/* ---------- appendix + footer ---------- */

.appendix {
  max-width: 44rem;
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
  text-align: center;
}
.appendix h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 1.4rem;
}
.triptych { list-style: none; display: flex; justify-content: center; gap: 2.2rem; flex-wrap: wrap; }
.triptych .essay { color: var(--ink); font-weight: 500; }
.triptych .soon {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--faint);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  margin-left: 0.35rem;
  vertical-align: middle;
}

footer {
  border-top: 1px solid var(--line);
  padding: 2.2rem 1.5rem 3rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.log-tools { display: flex; justify-content: center; align-items: center; gap: 0.6rem; }
.dot-sep { color: var(--faint); }
.epoch-line { color: var(--faint); font-size: 0.75rem; }

/* ---------- popover + toast ---------- */

.mark-popover {
  position: fixed;
  z-index: 30;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.6rem 0.9rem;
  max-width: 17rem;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: none;
}
.pop-date { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.14em; color: var(--muted); }
.pop-note { font-size: 0.9rem; margin-top: 0.15rem; }
.pop-note.wordless { color: var(--muted); font-style: italic; }
.pop-note.monument { color: var(--accent); font-weight: 600; }

.toast {
  position: fixed;
  z-index: 40;
  left: 50%;
  bottom: 7.5rem;
  transform: translateX(-50%);
  background: var(--bg-raised);
  border: 1px solid rgba(232, 167, 92, 0.35);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.45rem 1.1rem;
  font-size: 0.85rem;
  white-space: nowrap;
}

@media (max-width: 480px) {
  .form-row { flex-direction: column; align-items: stretch; }
  .btn.primary { width: 100%; }
}
