@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Newsreader:ital,opsz,wght@0,6..72,400;0,6..72,600;1,6..72,400;1,6..72,600&display=swap");

/* Version 3: one editorial type system, night mode, TBR lists, and the reading calendar. */
:root {
  --font-body: "DM Sans", ui-sans-serif, system-ui, sans-serif;
  --font-display: "Newsreader", Georgia, serif;
  --muted: #746772;
  --soft-paper: #f2e8f0;
  --sage-paper: #e4eddf;
  --audio-paper: #e8d9bc;
  --audio-paper-alt: #dce5d8;
  --shadow: #29213d;
  color-scheme: light;
}

[data-theme="dark"] {
  --butter: #17131d;
  --paper: #241e2b;
  --ink: #f7edda;
  --plum: #d19abb;
  --coral: #f07964;
  --blue: #91a9df;
  --yellow: #e9bd55;
  --green: #86aa91;
  --line: #4a3f51;
  --muted: #c4b6c1;
  --soft-paper: #302637;
  --sage-paper: #26332d;
  --audio-paper: #31291f;
  --audio-paper-alt: #23312b;
  --shadow: #09070c;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --butter: #17131d;
    --paper: #241e2b;
    --ink: #f7edda;
    --plum: #d19abb;
    --coral: #f07964;
    --blue: #91a9df;
    --yellow: #e9bd55;
    --green: #86aa91;
    --line: #4a3f51;
    --muted: #c4b6c1;
    --soft-paper: #302637;
    --sage-paper: #26332d;
    --audio-paper: #31291f;
    --audio-paper-alt: #23312b;
    --shadow: #09070c;
    color-scheme: dark;
  }
}

html { background: var(--butter); }
body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  background: var(--butter);
  color: var(--ink);
  transition: background-color .22s ease, color .22s ease;
}
button, input, select, textarea { font-family: var(--font-body); }
h1, h2, h3, blockquote { text-wrap: balance; }

.brand,
.date-note,
.date-note b,
.hero h1,
.intro,
.hero-note,
.section-heading h2,
.section-heading>i,
.stamp,
.book-cover>span,
.book-no,
.reading-copy h3,
.page-stats b,
.goal-card strong,
.goal-card small,
.goal-card h2,
.goal-card>p:not(.kicker),
.shelf-book h3,
.audio-card h3,
.review-card blockquote,
.review-empty span,
.review-empty h3,
.review-empty p,
.empty-state,
.empty-shelf,
.loading-card,
.dialog-close,
.dialog h2,
.quick-tip,
.search-result h3,
.login-card h1,
.setup-card h1,
.profile-card h1,
.profile-preview span,
.back-link,
.setup-help {
  font-family: var(--font-display);
}

.topbar {
  background: color-mix(in srgb, var(--butter) 91%, transparent);
  border-color: var(--ink);
}
.brand { font-size: 23px; font-weight: 600; letter-spacing: -.025em; }
.topbar nav { gap: clamp(18px, 2.3vw, 34px); }
.topbar nav a {
  font-family: var(--font-body);
  font-size: 13px;
  font-style: normal;
  font-weight: 650;
  letter-spacing: .005em;
  padding: 10px 2px;
}
.header-actions { display: flex; align-items: center; gap: 10px; }
.import-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  text-decoration: none;
  font-size: 10px;
  font-weight: 750;
  border-bottom: 1px solid transparent;
}
.import-link:hover { border-color: currentColor; }
.import-link span { font-size: 17px; color: var(--coral); }
.theme-toggle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  background: var(--paper);
  box-shadow: 2px 2px 0 var(--ink);
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
}
.search-open { font-size: 12px; }
.profile-menu>div a { font-size: 11px; }
.paper-noise { opacity: .18; }
[data-theme="dark"] .paper-noise { opacity: .1; mix-blend-mode: screen; }

.kicker { font-size: 10px; letter-spacing: .16em; }
.hero h1 { font-size: clamp(58px, 6vw, 88px); line-height: .88; font-weight: 400; }
.hero h1 em { color: var(--plum); }
.intro { color: var(--muted); font-size: 17px; line-height: 1.5; }
.date-note { font-size: 13px; }
.hero-note { font-size: 17px; }
.round-add { font-size: 12px; }

.section-heading p { color: var(--muted); font-size: 9px; }
.section-heading h2 { font-size: 34px; line-height: 1; font-weight: 500; letter-spacing: -.02em; }
.section-heading>i { font-size: 15px; }
.stamp { font-size: 17px; }
.reading-card { background: var(--paper); box-shadow: 7px 8px 0 var(--shadow); }
.reading-card.tilt-1 { background: var(--soft-paper); }
.reading-card.tilt-2 { background: var(--sage-paper); }
.reading-copy h3 { font-size: 24px; }
.reading-copy>p,
.shelf-book>p,
.audio-card p,
.search-result p,
.search-result small { color: var(--muted); font-size: 11px; }
.book-no { color: var(--muted); }
.page-stats { font-size: 10px; }
.page-stats b { font-size: 21px; }
.book-actions button,
.shelf-book button,
.audio-card button { font-size: 10px; padding: 5px 0; }
.rating-chip { font-size: 11px; }
.rating-chip small { font-size: 8px; }
.rating-chip.unrated { background: color-mix(in srgb, var(--paper) 75%, var(--muted)); }

.goal-card { box-shadow: 8px 8px 0 var(--shadow); transform: none; min-height: 0; }
.middle-grid { grid-template-columns: minmax(340px,370px) 1fr; align-items: start; }
.goal-card strong { font-size: 78px; }
.goal-card h2 { font-size: 28px; }
.goal-card>p:not(.kicker) { font-size: 15px; }
.edit-goal {
  margin-top: 18px;
  padding: 7px 0;
  border: 0;
  border-bottom: 1.5px solid currentColor;
  background: transparent;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}
.goal-insights { display: grid; grid-template-columns: repeat(3,1fr); gap: 7px; margin-top: 17px; }
.goal-insights>div { min-width: 0; padding: 9px 5px; border-top: 1.5px solid var(--ink); }
.goal-insights b { display: block; font: 600 18px/1 var(--font-display); color: var(--paper); }
.goal-insights span { display: block; margin-top: 3px; font-size: 7px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }

.next-section { min-width: 0; }
.tbr-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: -4px 0 24px;
}
.tbr-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding: 3px 2px 6px;
  scrollbar-width: none;
}
.tbr-tabs::-webkit-scrollbar { display: none; }
.tbr-tabs button,
.tbr-toolbar>button {
  flex: 0 0 auto;
  border: 1.5px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  padding: 8px 11px;
  box-shadow: 2px 2px 0 var(--ink);
  font-size: 10px;
  font-weight: 750;
  cursor: pointer;
}
.tbr-tabs button:not(:first-child) { border-top: 4px solid var(--list-color, var(--blue)); }
.tbr-tabs button.active { background: var(--ink); color: var(--paper); transform: translateY(-2px); }
.tbr-tabs span { opacity: .65; margin-left: 4px; }
.tbr-toolbar>button { margin-left: auto; background: var(--yellow); }
.book-shelf { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.shelf-book .book-cover {
  width: 100%;
  height: auto !important;
  min-height: 0;
  aspect-ratio: 2 / 3;
  background: color-mix(in srgb, var(--plum) 72%, var(--paper));
}
.shelf-book .book-cover img { object-fit: cover; object-position: center; background: var(--paper); }
.shelf-book h3 { font-size: 19px; margin-top: 13px; }
.shelf-book>div:last-child { gap: 8px 12px; }
.book-shelf { border-color: var(--plum); }
.book-shelf:after { background: color-mix(in srgb, var(--plum) 70%, var(--shadow)); }
.library-search {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  padding: 0 12px;
  box-shadow: 2px 2px 0 var(--ink);
}
.library-search input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 12px; }
.next-section>.library-search { width: min(360px,100%); margin: 0 0 25px; }
.shelf-pagination { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-top: 28px; color: var(--muted); font-size: 10px; }
.shelf-pagination>div { display: flex; align-items: center; gap: 10px; }
.shelf-pagination button { border: 1.5px solid var(--ink); background: var(--paper); padding: 8px 11px; box-shadow: 2px 2px 0 var(--ink); font-size: 9px; font-weight: 750; cursor: pointer; }
.shelf-pagination button:disabled { opacity: .35; cursor: default; box-shadow: none; }
.shelf-pagination b { min-width: 48px; text-align: center; color: var(--ink); }

.cover-repair {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 13px;
  margin: 18px 0 3px;
  padding: 13px 15px;
  background: color-mix(in srgb,var(--blue) 18%,var(--paper));
  border: 1.5px solid var(--ink);
  box-shadow: 4px 4px 0 var(--blue);
}
.cover-repair[hidden] { display: none; }
.cover-repair>span { color: var(--coral); font-size: 22px; }
.cover-repair>div { display: grid; gap: 2px; }
.cover-repair b { font: 600 16px var(--font-display); }
.cover-repair small { color: var(--muted); font-size: 9px; }
.cover-repair button { border: 0; border-bottom: 1px solid var(--ink); background: transparent; padding: 5px 0; font-size: 9px; font-weight: 800; cursor: pointer; }

.calendar-section { border-top: 2px solid var(--ink); }
.calendar-card {
  background: var(--paper);
  border: 1.5px solid var(--ink);
  padding: 24px;
  box-shadow: 8px 8px 0 var(--blue);
}
.compact-calendar { margin-top: 20px; padding: 12px; background: var(--paper); color: var(--ink); box-shadow: 4px 4px 0 var(--ink); transform: rotate(.5deg); }
.compact-calendar .calendar-top { grid-template-columns: 28px 1fr 28px; gap: 5px; }
.compact-calendar .calendar-top h3 { font-size: 19px; }
.compact-calendar .calendar-top button { width: 27px; height: 27px; font-size: 10px; }
.compact-calendar .calendar-weekdays { margin-top: 9px; }
.compact-calendar .calendar-weekdays span { padding: 4px 1px; font-size: 6px; }
.compact-calendar .calendar-day { min-height: 37px; padding: 3px; }
.compact-calendar .calendar-day b { font-size: 7px; }
.compact-calendar .calendar-day>span { gap: 1px; margin-top: 3px; }
.compact-calendar .started-dot,
.compact-calendar .finished-dot,
.compact-calendar .target-dot { width: 12px; height: 12px; font-size: 6px; }
.compact-calendar .calendar-day.today b { width: 16px; height: 16px; }
.compact-calendar .calendar-legend { gap: 8px; margin: 9px 0 0; font-size: 7px; }
.compact-calendar .calendar-legend i { width: 13px; height: 13px; }
.calendar-top { display: grid; grid-template-columns: 42px 1fr 42px; align-items: center; gap: 12px; }
.calendar-top h3 { margin: 0; text-align: center; font: 500 29px/1 var(--font-display); }
.calendar-top button {
  width: 38px;
  height: 38px;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  background: var(--butter);
  cursor: pointer;
  font-weight: 800;
}
.calendar-legend { display: flex; justify-content: center; flex-wrap: wrap; gap: 18px; margin: 17px 0 22px; color: var(--muted); font-size: 10px; font-weight: 650; }
.calendar-legend span { display: flex; align-items: center; gap: 5px; }
.calendar-weekdays,
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.calendar-weekdays { border: 1px solid var(--line); border-bottom: 0; background: var(--butter); }
.calendar-weekdays span { padding: 8px; text-align: center; color: var(--muted); font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.calendar-grid { border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.calendar-day {
  min-height: 78px;
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  padding: 8px;
  text-align: left;
}
.calendar-day.empty { pointer-events: none; }
.calendar-day b { display: block; font-size: 11px; }
.calendar-day>span { display: flex; align-items: center; gap: 5px; margin-top: 11px; }
.calendar-day.today b { display: grid; place-items: center; width: 25px; height: 25px; margin: -3px 0 0 -3px; border-radius: 50%; background: var(--coral); color: #fff9ec; }
.calendar-day.pace-day { background: color-mix(in srgb, var(--yellow) 13%, transparent); }
.started-dot,
.finished-dot,
.target-dot { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; font-style: normal; font-size: 11px; font-weight: 900; }
.started-dot { background: var(--blue); color: #16111d; }
.finished-dot { background: var(--green); color: white; }
.target-dot { background: var(--yellow); color: #29213d; position: relative; }
.target-dot small { position: absolute; right: -5px; top: -6px; width: 14px; height: 14px; border-radius: 50%; background: var(--ink); color: var(--paper); display: grid; place-items: center; font: 700 7px var(--font-body); }

.archive-section,
.ratings-section { border-top: 2px solid var(--ink); }
.archive-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 28px; }
.archive-toolbar .library-search { width: min(420px,60%); }
.archive-toolbar>label:last-child { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 10px; font-weight: 700; }
.archive-toolbar select { border: 1.5px solid var(--ink); background: var(--paper); padding: 9px 28px 9px 10px; font-size: 10px; }
.archive-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 27px 20px; }
.archive-book { display: grid; grid-template-columns: minmax(95px,42%) 1fr; gap: 14px; min-width: 0; background: var(--paper); border: 1.5px solid var(--ink); padding: 12px; box-shadow: 5px 5px 0 var(--plum); }
.archive-book:nth-child(4n+2) { box-shadow: 5px 5px 0 var(--blue); transform: rotate(.3deg); }
.archive-book:nth-child(4n+3) { box-shadow: 5px 5px 0 var(--coral); transform: rotate(-.3deg); }
.archive-book .book-cover { height: auto; min-height: 0; aspect-ratio: 2/3; border: 1px solid var(--ink); }
.archive-book .book-cover.square { aspect-ratio: 1; align-self: start; }
.archive-book .book-cover img { object-fit: cover; }
.archive-book>div:last-child { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; }
.archive-date { color: var(--muted); font-size: 8px; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; }
.archive-book h3 { margin: 11px 0 3px; font: 500 18px/1.05 var(--font-display); }
.archive-book p { margin: 0; color: var(--muted); font-size: 9px; }
.personal-stars { margin-top: auto; padding: 12px 0 7px; color: var(--coral); font-size: 10px; letter-spacing: .04em; }
.archive-book button { border: 0; border-bottom: 1px solid var(--ink); background: transparent; padding: 4px 0; font-size: 8px; font-weight: 800; cursor: pointer; }
.archive-book>div:last-child>div { display: flex; flex-wrap: wrap; gap: 5px 9px; }
.archive-empty { grid-column: 1/-1; min-height: 140px; display: grid; place-items: center; border: 2px dashed var(--plum); background: color-mix(in srgb,var(--paper) 70%,transparent); font: italic 18px var(--font-display); }

.ratings-history { border-top: 1.5px solid var(--ink); }
.rating-entry { display: grid; grid-template-columns: 56px minmax(180px,1.2fr) 125px minmax(220px,1.6fr) auto; gap: 16px; align-items: center; padding: 13px 8px; border-bottom: 1px solid var(--line); }
.rating-entry:nth-child(even) { background: color-mix(in srgb,var(--paper) 55%,transparent); }
.rating-entry .book-cover { width: 50px; height: auto; min-height: 0; aspect-ratio: 2/3; border: 1px solid var(--ink); }
.rating-entry .book-cover.square { aspect-ratio: 1; }
.rating-entry .book-cover img { object-fit: cover; }
.rating-entry-main { min-width: 0; }
.rating-entry-main>span { color: var(--muted); font-size: 8px; text-transform: uppercase; letter-spacing: .06em; }
.rating-entry h3 { margin: 3px 0 1px; font: 500 18px/1.05 var(--font-display); }
.rating-entry p { margin: 0; color: var(--muted); font-size: 9px; }
.rating-entry>strong { color: var(--coral); font-size: 13px; letter-spacing: .04em; white-space: nowrap; }
.rating-entry blockquote { margin: 0; color: var(--muted); font: italic 13px/1.35 var(--font-display); }
.rating-entry blockquote.no-note { opacity: .55; }
.rating-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; }
.rating-actions button { border: 0; border-bottom: 1px solid var(--ink); background: transparent; padding: 4px 0; font-size: 8px; font-weight: 800; cursor: pointer; }
.ratings-featured { border-top: 0; border-bottom: 2px solid var(--ink); }

.reading-card.is-audio { background: var(--audio-paper); }
.reading-card.is-audio .cover-wrap { align-self: start; }
.reading-card.is-audio .book-cover { height: auto; min-height: 0; aspect-ratio: 1; }
.reading-card.is-audio .book-cover img { object-fit: cover; }
.format-badge { position: absolute; right: -7px; top: 14px; z-index: 3; padding: 5px 7px; background: var(--blue); border: 1.5px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); font-size: 7px; font-weight: 900; transform: rotate(4deg); }

.book-dialog { width: min(690px,calc(100% - 30px)); }
.book-dialog form { display: grid; gap: 18px; }
.book-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.book-dialog label { display: grid; gap: 6px; font-size: 10px; font-weight: 850; letter-spacing: .06em; }
.book-dialog input,
.book-dialog select { width: 100%; min-width: 0; border: 1.5px solid var(--ink); background: var(--paper); padding: 11px; }
.book-dialog .cover-upload { padding: 15px; border: 1.5px dashed var(--plum); background: color-mix(in srgb,var(--paper) 70%,transparent); }
.book-dialog .cover-upload small { color: var(--muted); font-size: 9px; font-weight: 500; letter-spacing: 0; }
.book-dialog form>button { border: 0; background: var(--ink); color: var(--paper); padding: 14px; font-size: 10px; font-weight: 900; cursor: pointer; }

.audio-card { background: var(--audio-paper); box-shadow: 6px 6px 0 var(--plum); }
.audio-card:nth-child(even) { background: var(--audio-paper-alt); }
.audio-card .book-cover { aspect-ratio: 1; }
.audio-card .book-cover img { object-fit: cover; }
.audio-card h3 { font-size: 26px; }
.audio-label { font-size: 8px; }
.audio-stats { font-size: 10px; }
.review-card { background: var(--paper); }
.review-meta { font-size: 11px; }
.review-card blockquote { font-size: 17px; }
.empty-state span { font: 500 11px var(--font-body); }

.dialog { background: var(--butter); box-shadow: 12px 12px 0 var(--coral); }
.dialog h2 { font-size: 40px; }
.small-dialog label,
.login-card label,
.setup-card label,
.profile-card form>label { font-size: 11px; }
.small-dialog input,
.small-dialog select,
.small-dialog textarea,
.search-form label,
.search-result,
.profile-card,
.profile-card input,
.login-card,
.setup-card { background: var(--paper); }
.small-dialog form>button,
.search-form>button { font-size: 11px; }
.quick-tip { font-size: 12px; color: var(--muted); }
.search-result h3 { font-size: 19px; }
.result-actions button { font-size: 10px; }
.profile-card h1 { font-size: 47px; }
.profile-menu>div a,
.back-link { color: var(--ink); }
.login-tagline,
.setup-help { color: var(--muted); }

[data-theme="dark"] .brand span,
[data-theme="dark"] .profile-avatar img { filter: saturate(.9); }
[data-theme="dark"] .tape { background: rgba(227, 193, 112, .7); }
[data-theme="dark"] .form-error,
[data-theme="dark"] .danger-box { background: #4a282c; }
[data-theme="dark"] .setup-success { background: #243a2c; }

.import-page { min-height: 100vh; padding: 44px 22px; }
.import-shell { position: relative; z-index: 1; width: min(930px, 100%); margin: auto; }
.import-card {
  position: relative;
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 22px 42px;
  background: var(--paper);
  border: 2px solid var(--ink);
  padding: clamp(28px, 5vw, 58px);
  box-shadow: 12px 12px 0 var(--coral);
}
.import-mark {
  align-self: start;
  width: 124px;
  padding: 17px;
  background: var(--yellow);
  border: 2px solid var(--ink);
  box-shadow: 5px 5px 0 var(--ink);
  text-align: center;
  font: 700 22px/1 var(--font-display);
  transform: rotate(-4deg);
}
.import-mark span { color: var(--coral); font: 28px/1 var(--font-body); }
.import-copy h1 { margin: 0; font: 400 clamp(48px, 7vw, 74px)/.85 var(--font-display); letter-spacing: -.045em; }
.import-copy h1 em { color: var(--plum); font-weight: 400; }
.import-copy>p:last-child { max-width: 560px; color: var(--muted); font-size: 15px; }
.import-message,
.import-steps,
.import-form,
.import-results,
.import-privacy { grid-column: 2; }
.import-steps { display: grid; gap: 10px; margin-top: 10px; }
.import-steps>div { display: grid; grid-template-columns: 31px 1fr; align-items: center; gap: 11px; }
.import-steps span { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 50%; background: var(--blue); border: 1.5px solid var(--ink); font: italic 15px var(--font-display); }
.import-steps p { margin: 0; font-size: 12px; }
.import-steps a { color: var(--coral); font-weight: 800; }
.import-form { display: grid; grid-template-columns: 1fr auto; gap: 12px; margin-top: 10px; }
.file-drop {
  min-height: 112px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--butter) 66%, var(--paper));
  border: 2px dashed var(--plum);
  padding: 18px;
  text-align: center;
  cursor: pointer;
}
.file-drop>span { color: var(--coral); font-size: 26px; }
.file-drop>b { font-size: 13px; }
.file-drop>small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.file-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.import-form button,
.import-done { border: 0; background: var(--ink); color: var(--paper); padding: 16px 22px; font-size: 11px; font-weight: 850; cursor: pointer; text-decoration: none; display: grid; place-items: center; }
.import-privacy { margin: -7px 0 0; color: var(--muted); font-size: 9px; text-align: center; }
.import-results { position: relative; background: var(--butter); border: 1.5px solid var(--ink); padding: 28px; box-shadow: 6px 6px 0 var(--blue); }
.import-results h2 { margin: 0 0 20px; font: 500 31px/1 var(--font-display); }
.import-confetti { position: absolute; right: 24px; top: 18px; color: var(--coral); font-size: 28px; transform: rotate(9deg); }
.result-totals { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.result-totals>div { border-top: 3px solid var(--coral); padding-top: 8px; }
.result-totals>div:nth-child(2) { border-color: var(--blue); }
.result-totals>div:nth-child(3) { border-color: var(--yellow); }
.result-totals>div:nth-child(4) { border-color: var(--green); }
.result-totals b { display: block; font: 600 29px/1 var(--font-display); }
.result-totals span { color: var(--muted); font-size: 9px; }
.import-results>p,
.import-results details { color: var(--muted); font-size: 10px; }
.import-results details { margin-bottom: 18px; }
.import-results summary { cursor: pointer; font-weight: 750; }
.import-done { display: inline-grid; margin-top: 8px; }

@media (max-width: 1080px) {
  .middle-grid { grid-template-columns: 320px 1fr; gap: 32px; }
}

@media (max-width: 700px) {
  body { font-size: 16px; padding-bottom: 78px; }
  .topbar { height: 66px; grid-template-columns: 1fr auto auto; gap: 11px; padding: 0 16px; }
  .brand { font-size: 20px; }
  .header-actions { display: flex; gap: 9px; }
  .import-link b { display: none; }
  .import-link { width: 35px; height: 35px; justify-content: center; border: 1.5px solid var(--ink); border-radius: 50%; background: var(--paper); }
  .import-link span { font-size: 18px; }
  .theme-toggle { width: 35px; height: 35px; box-shadow: none; }
  .profile-avatar { width: 35px; height: 35px; box-shadow: none; }
  .shell { padding: 0 18px 60px; }
  .hero { min-height: 365px; padding-top: 58px; }
  .hero h1 { font-size: 56px; }
  .intro { max-width: 275px; font-size: 15px; }
  .hero-note { top: 186px; }
  .hero-star { top: 190px; }
  .section-block { padding: 43px 0; }
  .section-heading { margin-bottom: 24px; }
  .section-heading h2 { font-size: 30px; }
  .section-heading p { font-size: 8px; }
  .stamp { width: 39px; height: 39px; font-size: 15px; }
  .reading-card { min-width: min(88vw, 345px); grid-template-columns: 125px 1fr; }
  .reading-copy h3 { font-size: 21px; }
  .book-actions { gap: 9px 12px; }
  .book-actions button,
  .shelf-book button,
  .audio-card button { font-size: 11px; min-height: 30px; }
  .middle-grid { gap: 56px; }
  .goal-card { min-height: 360px; padding: 34px 28px; }
  .goal-card strong { font-size: 82px; }
  .tbr-toolbar { align-items: stretch; flex-direction: column; margin-bottom: 20px; }
  .tbr-toolbar>button { align-self: flex-start; margin-left: 0; }
  .book-shelf { gap: 20px; }
  .shelf-book { min-width: 154px; width: 154px; }
  .shelf-book .book-cover { height: auto !important; aspect-ratio: 2 / 3; }
  .shelf-book h3 { font-size: 18px; }
  .shelf-pagination { align-items: flex-start; flex-direction: column; }
  .shelf-pagination>div { width: 100%; justify-content: space-between; }
  .shelf-pagination button { min-height: 38px; }
  .cover-repair { grid-template-columns: auto 1fr; }
  .cover-repair button { grid-column: 2; justify-self: start; }
  .calendar-card { margin: 0 -10px; padding: 16px 10px; box-shadow: 5px 5px 0 var(--blue); }
  .calendar-top h3 { font-size: 25px; }
  .calendar-legend { gap: 10px 15px; margin: 14px 0 17px; }
  .calendar-weekdays span { padding: 7px 2px; font-size: 7px; letter-spacing: .03em; }
  .calendar-day { min-height: 55px; padding: 5px; }
  .calendar-day b { font-size: 9px; }
  .calendar-day>span { gap: 2px; margin-top: 6px; flex-wrap: wrap; }
  .started-dot,
  .finished-dot,
  .target-dot { width: 17px; height: 17px; font-size: 8px; }
  .calendar-day.today b { width: 21px; height: 21px; }
  .archive-toolbar { align-items: stretch; flex-direction: column; }
  .archive-toolbar .library-search { width: 100%; }
  .archive-toolbar>label:last-child { justify-content: space-between; }
  .archive-grid { display: flex; overflow-x: auto; margin: 0 -18px; padding: 0 18px 15px; gap: 14px; scrollbar-width: none; }
  .archive-book { min-width: 292px; grid-template-columns: 116px 1fr; scroll-snap-align: start; }
  .archive-book h3 { font-size: 20px; }
  .rating-entry { grid-template-columns: 48px 1fr auto; gap: 11px; padding: 14px 4px; }
  .rating-entry .book-cover { width: 44px; }
  .rating-entry>strong { grid-column: 2; }
  .rating-entry blockquote { grid-column: 2/4; font-size: 15px; }
  .rating-actions { grid-column: 3; grid-row: 1; align-self: end; }
  .book-form-grid { grid-template-columns: 1fr; }
  .book-dialog { padding: 34px 20px 24px; }
  .audio-card h3 { font-size: 20px; }
  .review-card blockquote { font-size: 16px; }
  .mobile-nav { height: 74px; grid-template-columns: repeat(4, 1fr); background: var(--paper); }
  .mobile-nav a { font-size: 9px; font-weight: 650; gap: 2px; }
  .mobile-nav a span { font-size: 19px; }
  .mobile-nav button { top: 9px; width: 52px; height: 52px; }
  .dialog { background: var(--butter); }
  .dialog h2 { font-size: 34px; }
  .search-result { grid-template-columns: 78px 1fr; }
  .result-actions { flex-wrap: wrap; }
  .result-actions button { min-height: 34px; }
  .toast { max-width: calc(100vw - 28px); white-space: normal; text-align: center; }
  .import-page { padding: 22px 14px 44px; }
  .import-card { display: block; padding: 30px 22px; box-shadow: 7px 7px 0 var(--coral); }
  .import-mark { width: 82px; padding: 11px; margin-bottom: 32px; font-size: 16px; }
  .import-mark span { font-size: 20px; }
  .import-copy h1 { font-size: 52px; }
  .import-copy>p:last-child { font-size: 14px; }
  .import-steps { margin: 27px 0 20px; }
  .import-steps p { font-size: 12px; }
  .import-form { grid-template-columns: 1fr; }
  .import-form button { min-height: 52px; }
  .import-privacy { margin-top: 10px; }
  .import-results { margin-top: 28px; padding: 23px 18px; }
  .result-totals { grid-template-columns: 1fr 1fr; gap: 17px 10px; }
}

@media (max-width: 390px) {
  .brand span { display: none; }
  .hero h1 { font-size: 50px; }
  .date-note { opacity: .9; }
  .reading-card { min-width: 305px; grid-template-columns: 116px 1fr; }
  .calendar-day { min-height: 51px; }
  .calendar-day>span { gap: 1px; }
  .started-dot,
  .finished-dot,
  .target-dot { width: 15px; height: 15px; }
}

.book-actions .read-today {
  color: var(--green);
  border-bottom-color: var(--green);
}

.book-actions .read-today.is-done,
.book-actions .read-today:disabled {
  color: var(--green);
  cursor: default;
  opacity: .78;
}

.reading-card.is-audio .page-stats b {
  color: var(--green);
}

/* v8: one nightstand, one personal history */
.reading-card .cover-wrap,
.reading-card.is-audio .cover-wrap { align-self: start; }
.reading-card .book-cover,
.reading-card.is-audio .book-cover { width: 100%; height: auto; min-height: 0; aspect-ratio: 2 / 3; background: color-mix(in srgb, var(--paper) 86%, var(--plum)); }
.reading-card .book-cover img,
.reading-card.is-audio .book-cover img { object-fit: contain; }
.reading-card.is-audio .page-stats { justify-content: flex-start; }
.format-note { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.format-note i { display: grid; place-items: center; width: 30px; height: 30px; border: 1.5px solid var(--ink); border-radius: 50%; background: var(--blue); color: var(--ink); font: normal 15px/1 var(--font-display); }
.format-note b { color: var(--ink) !important; font-size: 17px; }
.book-actions.icon-actions { align-items: flex-end; gap: 8px; margin-top: 8px; }
.book-actions.icon-actions .icon-action { display: grid; place-items: center; align-content: center; gap: 2px; width: 45px; height: 47px; padding: 3px; border: 1.5px solid var(--ink); border-radius: 50% 50% 46% 54%; background: var(--paper); box-shadow: 2px 2px 0 var(--ink); color: var(--ink); transition: transform .15s ease, box-shadow .15s ease; }
.book-actions.icon-actions .icon-action:hover:not(:disabled) { transform: translate(-1px,-1px) rotate(-2deg); box-shadow: 3px 3px 0 var(--ink); }
.book-actions.icon-actions .icon-action span { font: 700 17px/1 var(--font-display); }
.book-actions.icon-actions .icon-action small { font-size: 6px; font-weight: 850; letter-spacing: .04em; text-transform: uppercase; }
.book-actions.icon-actions .read-today { color: var(--ink); border-bottom: 1.5px solid var(--ink); background: var(--yellow); }
.book-actions.icon-actions .read-today.is-done,
.book-actions.icon-actions .read-today:disabled { background: var(--green); color: white; opacity: 1; }
.book-actions.icon-actions .finish-action { background: var(--ink); color: var(--paper); }
.library-history-layout { display: grid; grid-template-columns: minmax(0,1fr) 320px; gap: 38px; align-items: start; }
.library-history-layout .archive-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
.ratings-column { position: sticky; top: 96px; min-width: 0; padding: 24px 20px 18px; border: 1.5px solid var(--ink); background: var(--paper); box-shadow: 6px 6px 0 var(--yellow); }
.ratings-column h3 { margin: -4px 0 20px; font: 500 28px/1 var(--font-display); }
.ratings-column .ratings-history { border-top: 1.5px solid var(--ink); }
.ratings-column .rating-entry { display: grid; grid-template-columns: 44px minmax(0,1fr); gap: 11px; align-items: start; padding: 13px 0; }
.ratings-column .rating-entry .book-cover { width: 42px; }
.ratings-column .rating-entry-main>strong { display: block; margin-top: 7px; color: var(--coral); font-size: 11px; letter-spacing: .03em; }
.ratings-column .rating-entry h3 { margin: 3px 0 1px; font-size: 17px; }
.ratings-column .rating-entry blockquote { margin: 7px 0; font-size: 12px; }
.ratings-column .rating-actions { margin-top: 5px; }
.ratings-column .shelf-pagination { align-items: flex-start; flex-direction: column; gap: 9px; margin-top: 15px; }
.ratings-column .shelf-pagination>div { width: 100%; justify-content: space-between; }
@media (max-width: 1120px) {
  .library-history-layout { grid-template-columns: minmax(0,1fr) 280px; gap: 26px; }
  .library-history-layout .archive-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 800px) {
  .library-history-layout { grid-template-columns: 1fr; }
  .ratings-column { position: static; }
  .library-history-layout .archive-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 700px) {
  .book-actions.icon-actions { gap: 7px; }
  .book-actions.icon-actions .icon-action { width: 43px; height: 45px; min-height: 45px; }
  .library-history-layout .archive-grid { display: flex; }
  .ratings-column { margin: 0 -4px; }
}

/* v9: touch-first phone library and complete TBR controls */
.tbr-toolbar-actions { display: flex; gap: 8px; margin-left: auto; flex: 0 0 auto; }
.tbr-toolbar-actions button { min-height: 38px; border: 1.5px solid var(--ink); background: var(--paper); color: var(--ink); padding: 8px 11px; box-shadow: 2px 2px 0 var(--ink); font-size: 10px; font-weight: 800; cursor: pointer; }
.tbr-toolbar-actions button:first-child { background: var(--yellow); }
.tbr-actions { display: grid !important; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px !important; margin-top: 10px; }
.tbr-actions .tbr-action { display: flex; align-items: center; justify-content: center; gap: 5px; min-height: 34px; padding: 6px !important; border: 1px solid var(--ink) !important; background: var(--paper) !important; font-size: 8px !important; line-height: 1; text-align: center; }
.tbr-actions .tbr-action span { font-size: 13px; }
.tbr-actions .tbr-action.primary { background: var(--ink) !important; color: var(--paper); }
.tbr-actions .tbr-action.danger { color: var(--coral); border-color: var(--coral) !important; }

@media (max-width: 700px) {
  html { scroll-padding-top: 72px; }
  body { padding-bottom: calc(82px + env(safe-area-inset-bottom)); overflow-x: hidden; }
  .topbar { height: 62px; grid-template-columns: minmax(0,1fr) auto auto; gap: 8px; padding: 0 12px; }
  .topbar nav { display: none; }
  .brand { min-width: 0; font-size: 19px; white-space: nowrap; }
  .brand span { width: 29px; height: 29px; }
  .header-actions { gap: 7px; }
  .header-actions .search-open { display: none; }
  .profile-menu { gap: 0; }
  .profile-menu>div { display: none; }
  .shell { padding: 0 14px 48px; }
  .hero { min-height: 255px; padding: 38px 0 28px; }
  .hero h1 { font-size: clamp(48px,15vw,62px); }
  .intro { max-width: 250px; margin-top: 16px; font-size: 14px; }
  .date-note { right: 3px; top: 34px; width: 58px; height: 82px; }
  .date-note b { font-size: 31px; }
  .hero-note { top: auto; right: 7px; bottom: 31px; font-size: 13px; }
  .hero-star { top: auto; right: 12px; bottom: 61px; }
  .section-block { padding: 34px 0; }
  .section-heading { gap: 10px; margin-bottom: 18px; }
  .section-heading h2 { font-size: 29px; }
  .stamp { width: 36px; height: 36px; }

  .reading-grid { display: grid; grid-template-columns: 1fr; overflow: visible; margin: 0; padding: 0; gap: 16px; }
  .reading-card { width: 100%; min-width: 0; min-height: 0; grid-template-columns: 108px minmax(0,1fr); gap: 14px; padding: 13px; transform: none !important; box-shadow: 5px 5px 0 var(--shadow); }
  .reading-copy h3 { margin-top: 24px; font-size: 22px; }
  .reading-card .rating-chip { left: -5px; max-width: 112px; }
  .book-actions.icon-actions { gap: 6px; margin-top: 11px; }
  .book-actions.icon-actions .icon-action { width: 41px; height: 43px; min-height: 43px; box-shadow: 1.5px 1.5px 0 var(--ink); }
  .book-actions.icon-actions .icon-action span { font-size: 15px; }

  .middle-grid { display: grid; grid-template-columns: 1fr; gap: 38px; padding: 38px 0; }
  .goal-card { width: 100%; min-height: 0; margin: 0; padding: 28px 22px; box-shadow: 5px 5px 0 var(--shadow); }
  .goal-card strong { font-size: 72px; }
  .goal-card h2 { font-size: 25px; }
  .goal-insights { gap: 4px; }
  .calendar-card { margin: 0; padding: 14px 8px; }
  .calendar-top h3 { font-size: 22px; }
  .calendar-day { min-height: 43px; padding: 4px; }
  .calendar-legend { margin-bottom: 0; }

  .tbr-toolbar { display: block; margin-bottom: 15px; }
  .tbr-tabs { margin: 0 -14px 10px; padding: 4px 14px 8px; scroll-snap-type: x proximity; }
  .tbr-tabs button { min-height: 40px; scroll-snap-align: start; }
  .tbr-toolbar-actions { width: 100%; margin: 0; }
  .tbr-toolbar-actions button { flex: 1; min-height: 43px; }
  .next-section>.library-search { width: 100%; margin-bottom: 16px; }
  .book-shelf { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); overflow: visible; margin: 0; padding: 0; gap: 14px 11px; border: 0; }
  .book-shelf:after { display: none; }
  .shelf-book { display: flex; flex-direction: column; width: auto; min-width: 0; padding: 9px; border: 1.5px solid var(--ink); background: var(--paper); box-shadow: 3px 3px 0 var(--plum); transform: none; }
  .shelf-book:nth-child(even) { box-shadow: 3px 3px 0 var(--blue); }
  .shelf-book .book-cover { width: 100%; }
  .shelf-book h3 { margin: 9px 0 2px; font-size: 17px; }
  .shelf-book>p { min-height: 29px; font-size: 9px; }
  .shelf-book>.rating-chip { align-self: flex-start; margin: 7px 0 3px; font-size: 9px; }
  .tbr-actions { margin-top: auto; padding-top: 8px; gap: 6px !important; }
  .tbr-actions .tbr-action { min-height: 38px; font-size: 8px !important; touch-action: manipulation; }
  .shelf-pagination { margin-top: 18px; }

  .library-history-layout { display: flex; flex-direction: column; gap: 28px; }
  .archive-main { width: 100%; }
  .archive-grid,
  .library-history-layout .archive-grid { display: grid; grid-template-columns: 1fr; overflow: visible; margin: 0; padding: 0; gap: 13px; }
  .archive-book { width: 100%; min-width: 0; grid-template-columns: 92px minmax(0,1fr); transform: none !important; }
  .archive-book .book-cover { width: 92px; }
  .ratings-column { width: 100%; margin: 0; padding: 22px 17px; }

  .mobile-nav { height: calc(68px + env(safe-area-inset-bottom)); padding: 0 64px env(safe-area-inset-bottom) 0; grid-template-columns: repeat(4,1fr); }
  .mobile-nav a { min-width: 0; font-size: 8px; }
  .mobile-nav button { top: 8px; right: 8px; width: 50px; height: 50px; }
  .dialog { width: 100%; max-height: 92dvh; margin: auto 0 0; border-radius: 20px 20px 0 0; padding: 34px 18px calc(24px + env(safe-area-inset-bottom)); box-shadow: 0 -6px 0 var(--coral); }
  .book-dialog { width: 100%; }
  .small-dialog form>button { min-height: 48px; }
}

@media (max-width: 360px) {
  .brand { font-size: 17px; }
  .book-shelf { grid-template-columns: 1fr; }
  .shelf-book { display: grid; grid-template-columns: 105px minmax(0,1fr); column-gap: 12px; }
  .shelf-book .book-cover { grid-row: 1 / span 4; }
  .shelf-book h3 { margin-top: 0; }
  .shelf-book>.rating-chip { position: static; grid-column: 2; }
  .tbr-actions { grid-column: 1 / -1; margin-top: 9px; }
}

/* v10: unambiguous date and destructive TBR controls */
.date-note { height: 128px; padding: 10px 5px; }
.date-note .date-weekday { line-height: 1; }
.date-note .date-month { margin-top: 1px; font-size: 11px; line-height: 1; }
.date-note .date-year { margin-top: 3px; font: 700 8px/1 var(--font-body); letter-spacing: .14em; }
.tbr-toolbar-actions { flex-wrap: wrap; justify-content: flex-end; }
.tbr-toolbar-actions .delete-list-button { color: var(--coral); border-color: var(--coral); background: transparent; box-shadow: 2px 2px 0 var(--coral); }
.tbr-actions .remove-membership,
.tbr-actions .danger { grid-column: 1 / -1; }
.tbr-actions .remove-membership { border-style: dashed !important; }

@media (max-width: 700px) {
  .date-note { width: 64px; height: 103px; padding: 8px 3px; }
  .date-note b { font-size: 32px; }
  .date-note .date-weekday { font-size: 10px; }
  .date-note .date-month { font-size: 10px; }
  .date-note .date-year { font-size: 7px; }
  .tbr-toolbar-actions .delete-list-button { flex-basis: 100%; }
}

/* v11: reader-first sign in and emergency recovery */
.account-login { width: min(620px,100%); }
.account-login h1,
.emergency-reset-card h1 { font-size: clamp(40px,7vw,58px); }
.account-picker { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 11px; min-width: 0; margin: 2px 0 8px; padding: 0; border: 0; }
.account-picker legend { grid-column: 1 / -1; margin-bottom: 7px; font-size: 9px; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; }
.account-option { position: relative; display: grid !important; place-items: center; align-content: center; gap: 6px !important; min-width: 0; min-height: 144px; padding: 13px 8px; border: 1.5px solid var(--ink); background: var(--butter); box-shadow: 3px 3px 0 var(--ink); cursor: pointer; text-align: center; transition: transform .15s ease,background .15s ease; }
.account-option:hover { transform: translate(-1px,-1px) rotate(-.5deg); }
.account-option:has(input:checked) { background: color-mix(in srgb,var(--yellow) 40%,var(--paper)); box-shadow: 5px 5px 0 var(--coral); transform: translate(-2px,-2px); }
.account-option:has(input:focus-visible) { outline: 3px solid var(--blue); outline-offset: 3px; }
.account-option input { position: absolute; width: 1px !important; height: 1px; opacity: 0; pointer-events: none; }
.account-avatar { display: grid; place-items: center; width: 66px; height: 66px; overflow: hidden; border: 2px solid var(--ink); border-radius: 50%; background: var(--account-color,var(--blue)); color: white; box-shadow: 2px 2px 0 var(--ink); }
.account-avatar img { width: 100%; height: 100%; object-fit: cover; }
.account-avatar b { font: 600 27px/1 var(--font-display); }
.account-option input:checked + .account-avatar { outline: 3px solid var(--coral); outline-offset: 3px; }
.account-option strong { max-width: 100%; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.account-option small { color: var(--muted); font-size: 7px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.account-option:has(input:checked) small { color: var(--coral); }
.password-entry { margin-top: 5px; }
.emergency-reset-card { width: min(660px,100%); }
.emergency-reset-card .danger-box b { display: block; margin-bottom: 5px; }
.emergency-reset-card .account-picker { margin-bottom: 12px; }

@media (max-width: 700px) {
  .login-page,.setup-page { align-items: start; padding: 22px 14px calc(30px + env(safe-area-inset-bottom)); }
  .account-login,.emergency-reset-card { margin-top: 10px; padding: 28px 18px; }
  .account-login h1,.emergency-reset-card h1 { font-size: 42px; }
  .account-picker { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
  .account-option { min-height: 126px; padding: 11px 6px; }
  .account-avatar { width: 58px; height: 58px; }
  .account-login form>button,.emergency-reset-card form>button { min-height: 50px; }
}

@media (max-width: 360px) {
  .account-picker { grid-template-columns: 1fr; }
  .account-option { grid-template-columns: 58px minmax(0,1fr) auto; justify-items: start; min-height: 82px; padding: 10px 12px; text-align: left; }
  .account-avatar { grid-row: 1 / span 2; }
  .account-option small { grid-column: 3; grid-row: 1 / span 2; align-self: center; }
}
