:root {
  --paper: #f4ecdc;
  --paper-2: #efe4d0;
  --ink: #241c16;
  --ink-soft: #5c4e40;
  --rule: #d7c7ae;
  --wax: #7a2e2a;
  --wax-hover: #5e201d;
  --locked: #b7a894;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1200px 600px at 10% -10%, #fbf6ea 0%, transparent 50%),
    var(--paper);
  color: var(--ink);
  font-family: "Source Sans 3", system-ui, sans-serif;
  line-height: 1.5;
}

.frame {
  max-width: 42rem;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 4rem;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 2rem;
}

.mark {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: inherit;
  font-family: Fraunces, Georgia, serif;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.mark img { width: 28px; height: 28px; }

nav { display: flex; gap: 1rem; }
nav a {
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.95rem;
}
nav a[aria-current="page"], nav a:hover { color: var(--ink); }

.kicker {
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--wax);
  margin: 0 0 0.75rem;
}

h1 {
  font-family: Fraunces, Georgia, serif;
  font-weight: 600;
  font-size: clamp(1.8rem, 4vw, 2.55rem);
  line-height: 1.15;
  margin: 0 0 0.8rem;
}

.lede, .meta {
  color: var(--ink-soft);
  font-size: 1.05rem;
  margin: 0 0 1.4rem;
}
.lede em { font-family: "Source Serif 4", Georgia, serif; }

.actions { display: flex; flex-wrap: wrap; gap: 0.7rem; margin: 1.4rem 0 2rem; }

.btn {
  appearance: none;
  border: 0;
  background: var(--wax);
  color: #fbf6ea;
  font: inherit;
  font-weight: 600;
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.btn:hover { background: var(--wax-hover); }
.btn.ghost {
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--rule);
}
.btn.small { padding: 0.4rem 0.9rem; font-size: 0.9rem; }
.btn.file { cursor: pointer; }
.btn.file input { display: none; }

.chapter { padding-bottom: 2rem; }
.prose {
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 1.18rem;
  line-height: 1.7;
}
.prose p { margin: 0 0 1.1rem; }
.tomorrow {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  color: var(--ink-soft);
  font-style: italic;
}

.note {
  margin-top: 2rem;
  display: grid;
  gap: 0.5rem;
}
.note label { font-size: 0.85rem; color: var(--ink-soft); }
textarea, input[type="text"], input[type="time"], input[type="password"] {
  width: 100%;
  font: inherit;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--rule);
  background: #fbf6ea;
  color: inherit;
  border-radius: 0.4rem;
}
.notes { list-style: none; padding: 0; margin: 1rem 0 0; }
.notes li {
  border-left: 2px solid var(--wax);
  padding: 0.2rem 0 0.2rem 0.8rem;
  color: var(--ink-soft);
  margin-bottom: 0.6rem;
}

.shelf { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.8rem; }
.shelf a, .toc a, .toc li > div {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  gap: 0.15rem 0.9rem;
  text-decoration: none;
  color: inherit;
  padding: 0.95rem 1rem;
  background: var(--paper-2);
  border-radius: 0.6rem;
}
.shelf strong { font-family: Fraunces, Georgia, serif; font-size: 1.2rem; }
.shelf em { grid-column: 2; color: var(--ink-soft); font-style: normal; }
.days, .n {
  font-variant-numeric: tabular-nums;
  color: var(--wax);
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  align-self: center;
}
.now { grid-column: 2; font-size: 0.8rem; color: var(--wax); }

.drop {
  margin: 1.2rem 0 2rem;
  border: 1px dashed var(--rule);
  border-radius: 0.8rem;
  padding: 1.4rem;
  background: rgba(255,255,255,0.25);
}
.drop label { display: grid; gap: 0.5rem; cursor: pointer; color: var(--ink-soft); }
.flash { color: var(--wax); }
.flash.ok { color: #3f5c3a; }

.toc { list-style: none; padding: 0; margin: 1.5rem 0 0; display: grid; gap: 0.45rem; }
.toc .t { font-family: Fraunces, Georgia, serif; }
.toc .p, .toc .w { grid-column: 2; color: var(--ink-soft); font-size: 0.85rem; }
.toc .p { display: inline; margin-right: 0.6rem; }
.toc li.locked .t, .toc li.locked .n { color: var(--locked); }

.pager {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font-size: 0.95rem;
}
.pager a { color: var(--wax); text-decoration: none; }
.book-head .lede { margin-bottom: 0.4rem; }

.settings { display: grid; gap: 1rem; margin: 1.5rem 0; }
.settings label { display: grid; gap: 0.35rem; }
.hint { color: var(--ink-soft); font-weight: 400; }
code { font-size: 0.92em; }

.colophon {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  color: var(--locked);
  font-size: 0.85rem;
}

@media (max-width: 640px) {
  .frame { padding: 1rem 1rem 3rem; }
  .top { flex-direction: column; align-items: flex-start; }
  .prose { font-size: 1.12rem; }
  .shelf a { grid-template-columns: 1fr; }
  .days { margin-bottom: 0.2rem; }
}
