/* 1000 Nights — lamplight-first design */
:root, [data-theme="lamplight"] {
  --bg: #171310;
  --bg-soft: #201a15;
  --bg-card: #221c17;
  --ink: #ede1c9;
  --ink-dim: #a99a80;
  --ink-faint: #6f6350;
  --accent: #e2a34e;
  --accent-soft: rgba(226, 163, 78, 0.14);
  --line: #332a21;
  --check: #8fce6e;
  --serif: Georgia, "Iowan Old Style", "Source Serif Pro", "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Helvetica, Arial, sans-serif;
}
[data-theme="paper"] {
  --bg: #faf5ea;
  --bg-soft: #f3ecdd;
  --bg-card: #fffdf7;
  --ink: #2c2417;
  --ink-dim: #6d6046;
  --ink-faint: #a2977d;
  --accent: #9a6a1f;
  --accent-soft: rgba(154, 106, 31, 0.10);
  --line: #e2d7bd;
  --check: #3f7a2e;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 112.5%;
  line-height: 1.7;
  transition: background 0.25s, color 0.25s;
}
main { max-width: 42rem; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
a { color: var(--accent); }
::selection { background: var(--accent-soft); }

/* header */
.site-header {
  display: flex; justify-content: space-between; align-items: center;
  max-width: 46rem; margin: 0 auto; padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
}
.brand { font-family: var(--sans); font-weight: 700; text-decoration: none; color: var(--ink); font-size: 1.05rem; }
.brand-mark { color: var(--accent); margin-right: 0.3rem; }
.site-nav a {
  font-family: var(--sans); font-size: 0.85rem; text-decoration: none;
  color: var(--ink-dim); margin-left: 1.1rem;
}
.site-nav a:hover, .site-nav a.active { color: var(--accent); }

/* hero */
.hero { text-align: center; padding: 3.5rem 0 2.5rem; }
.notice {
  display: inline-block; font-family: var(--sans); font-size: 0.8rem;
  color: var(--ink-dim); background: var(--bg-card); border: 1px dashed var(--line);
  border-radius: 999px; padding: 0.4rem 1.1rem; margin: 0 0 1.75rem;
}
.kicker {
  font-family: var(--sans); font-size: 0.75rem; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--ink-faint); margin: 0 0 1rem;
}
.hero h1 { font-size: clamp(2rem, 6vw, 3rem); line-height: 1.2; margin: 0 0 1.25rem; font-weight: 600; }
.hero h1 em { color: var(--accent); font-style: italic; }
.lede { font-size: 1.1rem; color: var(--ink-dim); max-width: 34rem; margin: 0 auto 1.5rem; }

/* buttons */
.big-btn, .ghost-btn {
  font-family: var(--sans); cursor: pointer; border-radius: 999px;
  text-decoration: none; display: inline-block;
}
.big-btn {
  background: var(--accent); color: #1a1208; border: none;
  font-size: 1.05rem; font-weight: 700; padding: 0.85rem 2.2rem;
}
.big-btn:hover { filter: brightness(1.08); }
.ghost-btn {
  background: transparent; color: var(--ink-dim); border: 1px solid var(--line);
  font-size: 0.85rem; padding: 0.45rem 1.1rem;
}
.ghost-btn:hover { color: var(--accent); border-color: var(--accent); }

/* tonight card */
.tonight { margin: 2rem 0; }
.tonight h2, .how h2, .progress-snapshot h2, section h2 { font-size: 1.4rem; margin: 2.5rem 0 1rem; }
.tonight-item {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  background: var(--bg-card); border: 1px solid var(--line); border-radius: 0.75rem;
  padding: 1rem 1.25rem; margin-bottom: 0.75rem;
}
.tonight-item .kind { font-family: var(--sans); font-size: 0.7rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--ink-faint); margin: 0; }
.tonight-item h3 { margin: 0.15rem 0; font-size: 1.1rem; font-weight: 600; }
.tonight-item h3 a { color: var(--ink); text-decoration: none; }
.tonight-item h3 a:hover { color: var(--accent); }
.tonight-item .author { margin: 0; font-size: 0.9rem; color: var(--ink-dim); font-style: italic; }

/* check-off button */
.check {
  display: inline-flex; align-items: center; gap: 0.55rem; flex-shrink: 0;
  font-family: var(--sans); font-size: 0.82rem; color: var(--ink-dim);
  background: transparent; border: 1px solid var(--line); border-radius: 999px;
  padding: 0.45rem 1rem; cursor: pointer;
}
.check:hover { border-color: var(--accent); color: var(--accent); }
.check-box {
  width: 1rem; height: 1rem; border: 1.5px solid var(--ink-faint); border-radius: 50%;
  display: inline-block; transition: all 0.2s;
}
.check[aria-pressed="true"] { color: var(--check); border-color: var(--check); }
.check[aria-pressed="true"] .check-box { background: var(--check); border-color: var(--check); }
.check[aria-pressed="true"] .check-label::after { content: " ✓"; }

/* day page */
.day h1 { font-size: 2.2rem; margin: 0.25rem 0 1rem; }
.day-tools { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.dots { display: flex; gap: 0.5rem; }
.dots span {
  width: 0.9rem; height: 0.9rem; border-radius: 50%;
  border: 1.5px solid var(--ink-faint); display: inline-block;
}
.dots span.on { background: var(--check); border-color: var(--check); }
.day-nav {
  display: flex; justify-content: space-between; font-family: var(--sans);
  font-size: 0.9rem; padding: 0.75rem 0; border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line); margin-bottom: 2rem;
}
.day-nav a { text-decoration: none; }
.dim { color: var(--ink-faint); }

/* readings */
.reading { margin-bottom: 3rem; }
.reading-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.25rem; }
.reading .kind {
  font-family: var(--sans); font-size: 0.72rem; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--accent); margin: 0 0 0.25rem;
}
.reading h2 { font-size: 1.55rem; margin: 0 0 0.2rem; line-height: 1.3; }
.reading .author { font-style: italic; color: var(--ink-dim); margin: 0; }
.reading-body { font-size: 1.06rem; }
.reading-body p { margin: 0 0 1.1em; }
.reading-body p.verse { margin: 0 0 1.4em 1.25rem; line-height: 1.65; }
.reading-body blockquote {
  border-left: 2px solid var(--accent); margin: 1.25em 0; padding-left: 1.1em;
  color: var(--ink-dim); font-style: italic;
}
.reading-body p.src {
  font-size: 0.82rem; color: var(--ink-faint); border-top: 1px solid var(--line);
  padding-top: 0.8em; margin-top: 1.6em;
}
.reading-meta { font-family: var(--sans); font-size: 0.78rem; color: var(--ink-faint); }
.sec-nav { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  margin-top: 1.4rem; padding-top: 1rem; border-top: 1px solid var(--line);
  font-family: var(--sans); font-size: 0.82rem; }
.sec-nav a { color: var(--accent); text-decoration: none; max-width: 48%; }
.sec-nav a:hover { text-decoration: underline; }
.sec-next { margin-left: auto; text-align: right; }

/* reading mode */
body.focus .site-header, body.focus .site-footer, body.focus .day-nav,
body.focus .day-tools .ghost-btn { display: none; }
body.focus main { max-width: 38rem; }
body.focus .reading-head .check { position: fixed; bottom: 1.25rem; right: 1.25rem;
  background: var(--bg-card); box-shadow: 0 4px 18px rgba(0,0,0,0.35); z-index: 10; }

/* how it works */
.how ol { padding-left: 1.4rem; }
.how li { margin-bottom: 0.9rem; color: var(--ink-dim); }
.how li strong { color: var(--ink); }

/* library */
.filters { margin: 1.5rem 0; }
.filters input[type="search"] {
  width: 100%; font-family: var(--serif); font-size: 1.05rem;
  background: var(--bg-card); color: var(--ink); border: 1px solid var(--line);
  border-radius: 0.6rem; padding: 0.7rem 1rem; margin-bottom: 0.75rem;
}
.filter-row { display: flex; gap: 0.75rem; }
.filter-row select {
  font-family: var(--sans); font-size: 0.85rem; background: var(--bg-card);
  color: var(--ink); border: 1px solid var(--line); border-radius: 0.6rem;
  padding: 0.5rem 0.8rem;
}
.lib-results { display: grid; gap: 0.6rem; }
.lib-item {
  display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
  padding: 0.7rem 0; border-bottom: 1px solid var(--line);
}
.lib-item a { color: var(--ink); text-decoration: none; }
.lib-item a:hover { color: var(--accent); }
.lib-item .t { font-weight: 600; }
.lib-item .a { color: var(--ink-dim); font-style: italic; font-size: 0.92rem; }
.lib-item .m { font-family: var(--sans); font-size: 0.75rem; color: var(--ink-faint); white-space: nowrap; }
.lib-item .m .rd { color: var(--check); }

/* stats */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0.75rem; margin: 1.5rem 0 2rem; }
.stat {
  background: var(--bg-card); border: 1px solid var(--line); border-radius: 0.75rem;
  padding: 1rem 1.1rem;
}
.stat .v { font-size: 1.7rem; font-weight: 700; color: var(--accent); margin: 0; font-family: var(--sans); }
.stat .l { font-family: var(--sans); font-size: 0.75rem; color: var(--ink-dim); margin: 0.2rem 0 0; }
.heatmap { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr);
  gap: 3px; overflow-x: auto; padding-bottom: 0.5rem; }
.heatmap i { width: 12px; height: 12px; border-radius: 2px; background: var(--line); display: block; }
.heatmap i.l1 { background: #4a3a22; }
.heatmap i.l2 { background: #8a6428; }
.heatmap i.l3 { background: var(--accent); }
[data-theme="paper"] .heatmap i.l1 { background: #e3d3ac; }
[data-theme="paper"] .heatmap i.l2 { background: #c8a254; }

/* prose (about) */
.prose h2 { font-size: 1.35rem; margin: 2rem 0 0.75rem; }
.prose p { color: var(--ink-dim); }
.prose p strong, .prose strong { color: var(--ink); }

/* settings bar */
.settings-bar {
  position: fixed; bottom: 1rem; left: 1rem; display: flex; gap: 0.5rem; z-index: 20;
}
.settings-bar button {
  font-family: var(--sans); font-size: 0.75rem; background: var(--bg-card);
  color: var(--ink-dim); border: 1px solid var(--line); border-radius: 999px;
  padding: 0.35rem 0.8rem; cursor: pointer;
}
.settings-bar button:hover { color: var(--accent); border-color: var(--accent); }

/* footer */
.site-footer {
  max-width: 46rem; margin: 0 auto; padding: 2rem 1.25rem 3rem;
  border-top: 1px solid var(--line); font-family: var(--sans);
  font-size: 0.8rem; color: var(--ink-faint); text-align: center;
}
.site-footer p { margin: 0.4rem 0; }

@media (max-width: 560px) {
  body { font-size: 106%; }
  .reading-head { flex-direction: column; }
  .check { align-self: flex-start; }
  .site-header { padding: 0.8rem 1rem; }
  .brand { font-size: 0.95rem; white-space: nowrap; }
  .site-nav { display: flex; gap: 0.9rem; }
  .site-nav a { margin-left: 0; font-size: 0.8rem; }
  .hero { padding: 2.25rem 0 1.5rem; }
}

/* data page */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
@media (max-width: 700px) { .two-col { grid-template-columns: 1fr; } }
.hist { font-family: var(--sans); font-size: 0.82rem; }
.hrow { display: flex; align-items: center; gap: 0.6rem; margin: 0.32rem 0; }
.hlabel { flex: 0 0 5.2rem; text-align: right; color: var(--ink-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hlabel.wide { flex-basis: 9rem; }
.hbar { flex: 1; height: 0.85rem; background: var(--bg-card); border-radius: 3px; overflow: hidden; }
.hbar > span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.hcount { flex: 0 0 3.2rem; color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.hist-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1.5rem; }
.dtable { width: 100%; border-collapse: collapse; font-family: var(--sans); font-size: 0.82rem; }
.dtable td { padding: 0.28rem 0.4rem 0.28rem 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.dtable .num { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-dim); white-space: nowrap; padding-right: 0.7rem; }
.dtable a { color: var(--accent); text-decoration: none; }
.dtable a:hover { text-decoration: underline; }
.chart-wrap { background: var(--bg-card); border: 1px solid var(--line); border-radius: 8px; padding: 0.75rem; margin: 0.75rem 0 1.25rem; }
.chart-wrap canvas { display: block; width: 100%; }
.extreme-block { margin-bottom: 2rem; }
.extreme-block h4 { font-size: 0.9rem; color: var(--ink-dim); margin: 0.6rem 0 0.4rem; }
section h3 { margin-top: 1.6rem; }
