:root {
  --bg: #f6f1e9;
  --surface: #fffdf8;
  --surface-2: #f0e9dd;
  --ink: #2a2420;
  --muted: #7a6e63;
  --line: #e4dacb;
  --accent: #2f5d50;
  --accent-ink: #ffffff;
  --accent-soft: #dfebe5;
  --mine: #b5562b;
  --mine-soft: #f8e6da;
  --easy: #3d7a4f;
  --difficult: #8a3b5a;
  --shadow: 0 1px 2px rgb(60 40 20 / 6%), 0 4px 16px rgb(60 40 20 / 6%);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171412;
    --surface: #221e1a;
    --surface-2: #2c2722;
    --ink: #efe7dc;
    --muted: #a69a8d;
    --line: #3a332c;
    --accent: #84bfa9;
    --accent-ink: #0f1f19;
    --accent-soft: #23362f;
    --mine: #eb9a6c;
    --mine-soft: #3a2619;
    --easy: #86c79a;
    --difficult: #e09ab6;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
}
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; margin: 0; }
p { margin: 0 0 .75em; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.loading { text-align: center; padding: 4rem 1rem; color: var(--muted); }

#app { max-width: 1080px; margin: 0 auto; padding: 0 16px 4rem; }
main.center { min-height: 80vh; display: grid; place-items: center; }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.1rem 0 1.5rem; }
.brand { display: flex; align-items: center; gap: .6rem; font: 600 1.35rem var(--serif); color: var(--ink); text-decoration: none; }
.brand img { width: 30px; height: 30px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .25rem;
  font: 600 .95rem var(--sans); padding: .6rem 1.1rem; border-radius: 999px;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: filter .15s, background .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn.secondary { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.btn.ghost { background: transparent; color: var(--accent); border-color: var(--line); }
.btn.small { padding: .35rem .8rem; font-size: .85rem; }
.btn.wide { width: 100%; }
.link { background: none; border: 0; padding: .25rem; color: var(--muted); font: inherit; cursor: pointer; }
.link:hover { color: var(--ink); }
.icon {
  width: 2.2rem; height: 2.2rem; border-radius: 50%; border: 1px solid var(--line);
  background: var(--surface); color: var(--muted); font-size: 1.2rem; cursor: pointer; align-self: end;
}
.icon:disabled { opacity: .3; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.tag {
  display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .8rem;
  background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.tag.ok { background: var(--accent-soft); color: var(--accent); }
.pill { font-size: .75rem; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; padding: .1rem .5rem; border-radius: 6px; border: 1px solid currentColor; }
.pill.easy { color: var(--easy); }
.pill.difficult { color: var(--difficult); }

/* sections & cards */
section { margin-bottom: 2.5rem; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.section-head h2 { margin: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 1rem; }
.empty { padding: 2.5rem 1rem; text-align: center; color: var(--muted); border: 2px dashed var(--line); border-radius: var(--radius); }

.card {
  display: flex; gap: 1rem; padding: 1rem; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); cursor: pointer; transition: transform .15s, border-color .15s;
}
.card:hover { transform: translateY(-2px); border-color: var(--muted); }
.card.mine { border-color: var(--mine); box-shadow: 0 0 0 1px var(--mine), var(--shadow); }
.card-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: .3rem; }
.card-body p { margin: 0; }
.card h3 a { color: inherit; text-decoration: none; }
.card-actions { margin-top: auto; padding-top: .4rem; }
.author { color: var(--muted); font-style: italic; font-family: var(--serif); }
.author.big { font-size: 1.15rem; }
.meta { display: flex; align-items: center; gap: .6rem; font-size: .85rem; margin: .2rem 0; }
.status { font-size: .9rem; font-weight: 500; }
.status.mine { color: var(--mine); font-weight: 600; }

.cover {
  flex: none; width: 84px; aspect-ratio: 2 / 3; border-radius: 4px 8px 8px 4px; object-fit: cover;
  background: var(--surface-2); box-shadow: inset 4px 0 6px -3px rgb(0 0 0 / 25%), 0 2px 6px rgb(0 0 0 / 15%);
}
.cover.large { width: 160px; }
.cover.placeholder {
  display: flex; flex-direction: column; justify-content: space-between; padding: .5rem .45rem;
  background: linear-gradient(160deg, hsl(var(--h) 38% 42%), hsl(calc(var(--h) + 30) 42% 28%));
  color: #fff; overflow: hidden;
}
.ph-title { font: 600 .78rem/1.15 var(--serif); display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.ph-author { font-size: .62rem; opacity: .85; }
.cover.large .ph-title { font-size: 1.15rem; }
.cover.large .ph-author { font-size: .85rem; }
.cover.large.placeholder { padding: 1rem .9rem; }

.progress { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: .3rem 0 .1rem; }
.progress span { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .3s; }

details.finished { margin-bottom: 2rem; }
details.finished summary { cursor: pointer; font: 600 1.35rem var(--serif); margin-bottom: 1rem; }
.footnote { text-align: center; margin-top: 2rem; }

/* panels & forms */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); }
.panel.narrow { max-width: 420px; width: 100%; }
main > form.panel { max-width: 620px; margin: 0 auto; display: flex; flex-direction: column; gap: 1.1rem; }
label, .label { display: flex; flex-direction: column; gap: .35rem; font-size: .9rem; font-weight: 600; }
input:not([type=radio]):not([type=file]) {
  font: 400 1rem var(--sans); color: var(--ink); background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: .6rem .75rem; width: 100%; min-width: 0;
}
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.row .grow { flex: 1 1 220px; }
label.pages { flex: 0 1 140px; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-size: .9rem; font-weight: 600; margin-bottom: .35rem; padding: 0; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .6rem; }
.choice {
  flex-direction: row; align-items: flex-start; gap: .6rem; font-weight: 400; padding: .8rem; cursor: pointer;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
}
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input { margin-top: .25rem; accent-color: var(--accent); }
.choice > span { display: flex; flex-direction: column; }
.upload { display: flex; align-items: center; gap: 1rem; margin-top: .35rem; }
.upload-preview {
  width: 72px; aspect-ratio: 2 / 3; border-radius: 6px; border: 1px dashed var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; font-size: .7rem; gap: .2rem;
}
.upload-preview img { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; }
.upload-preview:has(img) { border: 0; height: auto; }
.upload-preview:has(img) img { height: auto; aspect-ratio: 2 / 3; }
.form-actions { display: flex; justify-content: flex-end; gap: .6rem; flex-wrap: wrap; align-items: center; }
.form-actions.left { justify-content: flex-start; }

/* book page */
.back { display: inline-block; margin-bottom: 1rem; text-decoration: none; }
.book-head { display: flex; gap: 1.5rem; align-items: flex-start; margin-bottom: 1.5rem; }
.book-head h1 { margin-bottom: .2rem; }
.book-grid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 1.5rem; align-items: start; }
.book-main > * + * { margin-top: 1rem; }
.book-main > p { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }
.callout { border-radius: var(--radius); padding: 1.1rem 1.25rem; background: var(--mine-soft); border: 1px solid var(--mine); }
.callout.go { background: var(--accent-soft); border-color: var(--accent); }
.callout p { margin-bottom: .75rem; }

.stepper { display: flex; list-style: none; padding: 0; margin: 0 0 1.75rem; gap: .25rem; counter-reset: step; overflow-x: auto; }
.stepper li {
  flex: 1; min-width: 92px; position: relative; padding-top: 1.9rem; text-align: center;
  font-size: .8rem; color: var(--muted); counter-increment: step;
}
.stepper li::before {
  content: counter(step); position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 1.5rem; height: 1.5rem; border-radius: 50%; display: grid; place-items: center; font-size: .75rem; font-weight: 600;
  background: var(--surface-2); color: var(--muted); z-index: 1;
}
.stepper li + li::after {
  content: ""; position: absolute; top: .72rem; right: 50%; width: 100%; height: 2px; background: var(--line);
}
.stepper li.done::before { content: "✓"; background: var(--accent); color: var(--accent-ink); }
.stepper li.done, .stepper li.current { color: var(--ink); }
.stepper li.done::after, .stepper li.current::after { background: var(--accent); }
.stepper li.current::before { background: var(--mine); color: #fff; }
.stepper li.current { font-weight: 600; }

.schedule { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .5rem; }
.schedule li {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .8rem 1rem;
  display: grid; grid-template-columns: 11rem 1fr; gap: .1rem 1rem;
}
.schedule li > :nth-child(3) { grid-column: 2; }
.schedule .when { font-weight: 600; font-variant-numeric: tabular-nums; }
.schedule li.past { opacity: .55; }
.schedule li.next { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.schedule li.next .when::after { content: " · next"; color: var(--accent); }

.people { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .55rem; }
.people li { display: flex; align-items: center; gap: .6rem; }
.people li > span:nth-child(2) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.avatar {
  width: 1.9rem; height: 1.9rem; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-weight: 700; font-size: .85rem; color: #fff; background: hsl(var(--h) 35% 45%);
}

.editor { display: flex; flex-direction: column; gap: 1rem; align-items: flex-start; }
.editor > * { max-width: 100%; }
.editor .form-actions { align-self: stretch; }
.hint { margin: 0; color: var(--muted); font-size: .9rem; }
.hint.warn { color: var(--mine); }
.meeting-rows { display: flex; flex-direction: column; gap: .75rem; align-self: stretch; }
.meeting-row {
  display: grid; grid-template-columns: 1.6rem 13rem 1fr 1fr 2.2rem; gap: .6rem; align-items: end;
  padding: .75rem; background: var(--bg); border-radius: 10px;
}
.meeting-row .num {
  align-self: center; width: 1.6rem; height: 1.6rem; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font-size: .8rem; font-weight: 700;
}
.meeting-row label { font-weight: 500; font-size: .8rem; }
.meeting-row input:not([type=radio]) { background: var(--surface); }

#toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translate(-50%, 150%); opacity: 0;
  background: var(--ink); color: var(--bg); padding: .7rem 1.2rem; border-radius: 999px; font-size: .9rem;
  transition: transform .25s, opacity .25s; max-width: calc(100vw - 32px); z-index: 10; pointer-events: none;
}
#toast.show { transform: translate(-50%, 0); opacity: 1; }
#toast.error { background: var(--mine); color: #fff; }

@media (max-width: 760px) {
  h1 { font-size: 1.6rem; }
  .book-grid { grid-template-columns: 1fr; }
  .cover.large { width: 110px; }
  .book-head { gap: 1rem; }
  .meeting-row { grid-template-columns: 1.6rem 1fr 2.2rem; }
  .meeting-row label { grid-column: 2; }
  .meeting-row .icon { grid-column: 3; grid-row: 1; align-self: start; }
  .schedule li { grid-template-columns: 1fr; }
  .schedule li > :nth-child(3) { grid-column: 1; }
  .panel { padding: 1.1rem; }
}

/* fixes */
.editor label.pages { flex: none; width: 160px; }
span.label { display: block; }
.schedule li { grid-template-columns: 13rem 1fr; }
@media (max-width: 760px) {
  .schedule li { grid-template-columns: 1fr; }
  .stepper li { min-width: 0; font-size: .7rem; }
}

/* description & people needed */
textarea {
  font: 400 1rem/1.5 var(--sans); color: var(--ink); background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: .6rem .75rem; width: 100%; resize: vertical; min-height: 5.5rem;
}
textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.needed-row { display: flex; align-items: center; gap: .75rem; font-weight: 400; }
.needed-row input { flex: none; width: 5.5rem !important; }
.excerpt {
  font-size: .88rem; color: var(--ink); opacity: .85; white-space: pre-line;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
blockquote.description {
  margin: .25rem 0 .9rem; padding: .7rem 1rem; border-left: 3px solid var(--accent);
  background: var(--surface); border-radius: 0 10px 10px 0; max-width: 60ch;
}
blockquote.description p { white-space: pre-line; margin: 0 0 .35rem; font-family: var(--serif); font-size: 1.05rem; }
blockquote.description footer { font-size: .85rem; color: var(--muted); }

/* import from link */
.import { display: flex; flex-direction: column; gap: .35rem; padding: 1rem; background: var(--surface-2); border-radius: 12px; }
.import-row { display: flex; gap: .5rem; }
.import-row input { flex: 1; background: var(--surface) !important; }
