/* Calm, single-accent, dark-mode aware. One decision on screen at a time. */
:root {
  --bg: #faf9f7; --card: #ffffff; --ink: #1a1a1a; --muted: #6b6b6b;
  --accent: #e8590c; --accent-ink: #fff; --line: #e5e2dd;
  --ok: #2f9e44;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161513; --card: #211f1c; --ink: #ece9e4; --muted: #9b968e;
    --accent: #ff7a2f; --accent-ink: #1a1208; --line: #35322d;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
#app { max-width: 720px; margin: 0 auto; padding: 24px 20px 80px; }

/* shelf switcher */
.shelf-switch { display: flex; gap: 4px; border: 1px solid var(--line);
  border-radius: 12px; padding: 3px; margin-bottom: 18px; }
.shelf-btn { flex: 1; border: none; background: none; color: var(--muted);
  padding: 8px 10px; border-radius: 9px; font: inherit; font-size: 14px;
  font-weight: 600; cursor: pointer; }
.shelf-btn.active { background: var(--accent); color: var(--accent-ink); }

.home-head { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.streak { font-size: 15px; white-space: nowrap; }
.progress { flex: 1; height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--accent); border-radius: 4px; transition: width .3s; }
.progress-label { font-size: 13px; color: var(--muted); white-space: nowrap; }

.next-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 28px; margin-bottom: 20px; box-shadow: 0 1px 4px rgb(0 0 0 / 5%);
}
.kicker { text-transform: uppercase; letter-spacing: .08em; font-size: 12px;
  color: var(--accent); margin: 0 0 6px; font-weight: 600; }
.next-card h2 { margin: 0 0 6px; font-size: 24px; line-height: 1.25; }
.detail { color: var(--muted); margin: 0 0 20px; }
.big-btn {
  display: block; text-align: center; background: var(--accent); color: var(--accent-ink);
  padding: 14px; border-radius: 12px; font-size: 18px; font-weight: 650;
  text-decoration: none;
}
.big-btn:active { transform: scale(.99); }

details { border-top: 1px solid var(--line); padding: 14px 0; }
summary { cursor: pointer; color: var(--muted); font-weight: 550; }
.banner { background: #fff3cd; color: #664d03; border-radius: 10px;
  padding: 10px 14px; margin-bottom: 16px; font-size: 14px; }

/* gate */
.gate { background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 28px; }
.gate .meta { color: var(--muted); font-size: 14px; margin: 0 0 14px; }
.relevance-strip { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px;
  margin: 0 0 14px; }
.relevance-strip .block-name { color: var(--muted); font-size: 12px;
  text-transform: uppercase; letter-spacing: .05em; }
.relevance-strip .why-text { flex-basis: 100%; color: var(--muted); font-size: 13px; }
.gate h1 { font-size: 26px; margin: 0 0 4px; line-height: 1.25; }
.gate h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); margin: 18px 0 6px; }
.gate ul { margin: 0; padding-left: 20px; }
.gate li { margin-bottom: 6px; }
.gate .actions { margin-top: 24px; display: grid; gap: 10px; }
.ghost-btn { display: block; text-align: center; background: none;
  border: 1px solid var(--line); color: var(--muted); padding: 10px;
  border-radius: 12px; text-decoration: none; font-size: 15px; cursor: pointer; }
.back { color: var(--muted); text-decoration: none; font-size: 15px;
  display: inline-block; margin-bottom: 14px; }

/* reader */
.reader-bar { position: sticky; top: 0; z-index: 10; display: flex;
  align-items: center; gap: 12px; background: var(--bg); padding: 10px 0;
  border-bottom: 1px solid var(--line); }
.reader-bar .back { margin: 0; }
.page-progress { flex: 1; height: 6px; background: var(--line);
  border-radius: 3px; overflow: hidden; }
.page-progress .bar { height: 100%; background: var(--accent); transition: width .2s; }
#pageLabel { font-size: 13px; color: var(--muted); white-space: nowrap; }
.done-btn { background: var(--ok); color: #fff; border: 0; border-radius: 10px;
  padding: 8px 14px; font-size: 14px; font-weight: 600; cursor: pointer; }
.pdf-scroll { margin-top: 12px; }
.pdf-page { min-height: 60vh; margin: 0 auto 16px; max-width: 100%;
  background: var(--card); border: 1px solid var(--line); border-radius: 4px; }
.pdf-page canvas { width: 100%; height: auto; display: block; border-radius: 4px; }
.pdf-error { text-align: center; padding: 40px 20px; color: var(--muted); }

/* browse */
.block-group { margin-top: 6px; }
.block-head { margin: 18px 0 6px; font-size: 14px; font-weight: 650; }
.block-progress { color: var(--muted); font-size: 12px; font-weight: 400; }
.paper-row { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px;
  padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.paper-row .title { flex: 1; }
.paper-row a { color: var(--ink); }
.paper-row .status { color: var(--muted); font-size: 12px; }
.promote-btn { border: 1px solid var(--line); background: none; color: var(--muted);
  border-radius: 8px; font-size: 12px; cursor: pointer; padding: 2px 8px; }
.paper-row .why-line { display: none; flex-basis: 100%; color: var(--muted);
  font-size: 12px; padding: 2px 0 4px 30px; }
.paper-row .why-line.show { display: block; }

/* chips */
.score-chip { flex-shrink: 0; border: none; border-radius: 6px; width: 22px;
  height: 22px; line-height: 22px; text-align: center; padding: 0;
  font-size: 12px; font-weight: 700; cursor: pointer; font-family: inherit; }
.score-5 { background: var(--accent); color: var(--accent-ink); }
.score-4 { background: var(--ok); color: #fff; }
.score-3 { background: var(--line); color: var(--ink); }
.score-2, .score-1 { background: none; border: 1px solid var(--line); color: var(--muted); }
.type-chip { flex-shrink: 0; border: 1px solid var(--line); color: var(--muted);
  border-radius: 8px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .04em; padding: 2px 7px; }

/* recap */
.recap-item { padding: 10px 0; border-bottom: 1px dashed var(--line); }
.recap-item .quote { font-style: italic; }
.recap-item .src { color: var(--muted); font-size: 13px; }

/* takeaway modal */
.modal-wrap { position: fixed; inset: 0; background: rgb(0 0 0 / 45%);
  display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: var(--card); border-radius: 16px; padding: 24px;
  width: min(480px, 90vw); }
.modal h3 { margin: 0 0 10px; }
.modal textarea { width: 100%; min-height: 80px; font: inherit; padding: 10px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--bg);
  color: var(--ink); resize: vertical; }
.modal .row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 12px; }
.toast { position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%);
  background: var(--ok); color: #fff; padding: 12px 22px; border-radius: 12px;
  font-weight: 600; animation: toast 1.6s ease forwards; z-index: 60; }
@keyframes toast {
  0% { opacity: 0; transform: translateX(-50%) translateY(10px); }
  15%, 80% { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; }
}

/* deep dive */
.deepdive { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; }
.deepdive summary { cursor: pointer; color: var(--muted); font-weight: 550; }
.deepdive blockquote { margin: 10px 0; padding: 8px 14px; border-left: 3px solid var(--accent);
  background: var(--bg); border-radius: 6px; font-style: italic; }
.deepdive .q-where { display: block; font-style: normal; font-size: 12px;
  color: var(--muted); margin-top: 4px; }

/* reading guide */
.rguide { list-style: none; padding-left: 0; }
.rguide li { margin-bottom: 8px; padding-left: 0; }
.rg-badge { display: inline-block; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; border-radius: 6px;
  padding: 1px 7px; margin-right: 6px; }
.rg-must .rg-badge { background: var(--accent); color: var(--accent-ink); }
.rg-skim .rg-badge { background: var(--line); color: var(--ink); }
.rg-skip .rg-badge { background: none; border: 1px solid var(--line); color: var(--muted); }
.rg-skip { color: var(--muted); }

/* companion rail — margin notes (wide) that scroll with the document,
   a drawer panel (narrow) that doesn't. */
#app.wide { max-width: 1140px; }
.reader-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px;
  align-items: start; }
.reader-layout.companion-off { grid-template-columns: minmax(0,1fr); }
.reader-layout.companion-off .companion { display: none; }
.comp-toggle { flex-shrink: 0; padding: 6px 12px; font-size: 13px; }

.companion { position: relative; align-self: stretch; font-size: 14px; }
.comp-empty { color: var(--muted); font-style: italic; }

/* card shell — shared by every note type except quote cards, which are a
   bare blockquote so they don't double-box. */
.comp-lead, .comp-guide, .comp-quotes, .comp-limits-final, .comp-findings-final {
  background: var(--card); border: 1px solid var(--line); border-left: 3px solid transparent;
  border-radius: 10px; padding: 12px 14px; margin-bottom: 12px;
}
.comp-current { border-left-color: var(--accent); }

.comp-label { text-transform: uppercase; letter-spacing: .05em; font-size: 11px;
  color: var(--muted); margin: 0 0 8px; }
.comp-section-name { font-weight: 650; margin-top: 6px; }
.comp-why { color: var(--muted); margin: 4px 0 0; }

.comp-lead .comp-tldr { margin: 6px 0 0; }
.comp-lead details { border-top: none; padding: 8px 0 0; margin-top: 6px; }
.comp-lead summary { font-size: 13px; }

.comp-findings { margin: 10px 0 0; padding-left: 18px; font-size: 13.5px; line-height: 1.45; }
.comp-findings li { margin-bottom: 6px; }
.comp-limits { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--line); }
.comp-limits ul, .comp-limits-final ul, .comp-findings-final ul {
  margin: 0; padding-left: 18px; font-size: 13.5px; line-height: 1.45; }
.comp-limits li, .comp-limits-final li, .comp-findings-final li { margin-bottom: 6px; }
.comp-limits li { color: var(--muted); }

.comp-quotes blockquote, .comp-quote-card blockquote {
  margin: 0 0 10px; padding: 8px 12px; border-left: 3px solid var(--accent);
  background: var(--bg); border-radius: 6px; font-style: italic; }
.comp-quotes blockquote:last-child { margin-bottom: 0; }
.comp-quote-card blockquote { margin-bottom: 0; }
.q-where { display: block; font-style: normal; font-size: 12px;
  color: var(--muted); margin-top: 4px; }

@media (min-width: 1100px) {
  /* margin notes: absolutely positioned, translateY'd to their anchor page. */
  /* Positioned via inline `top` — NOT transform: repositioning fires on every
     page render, and Safari drops a transform that is re-set while its
     transition is still pending, leaving every card stacked at the top. */
  .comp-card { position: absolute; left: 0; right: 0; }
}

@media (max-width: 1099px) {
  #app.wide { max-width: 720px; }
  .reader-layout { grid-template-columns: minmax(0,1fr); }
  .companion { position: fixed; right: 0; top: 52px; bottom: 0;
    width: min(320px, 85vw); background: var(--card); overflow-y: auto;
    border-left: 1px solid var(--line); box-shadow: -6px 0 24px rgb(0 0 0 / 18%);
    padding: 16px; z-index: 40; }
}

/* Accounts, sign-in and the shared dashboard.
   Motif: the library circulation card. Two people sharing a shelf of papers
   is precisely what that artifact was for -- a ruled card, a name, and a
   column of stamped dates recording who had the book and when. The week
   strip below is that stamp row, so it carries the real date rather than an
   abstract on/off dot. Everything else stays quiet around it. */
:root { --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace; }

/* --- sign in ---------------------------------------------------------- */
.login-wrap { min-height: 100svh; display: grid; place-items: center; padding: 24px 20px; }
.login {
  width: 100%; max-width: 22rem;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 28px;
  box-shadow: 0 1px 4px rgb(0 0 0 / 5%);
}
.login-mark {
  font: 600 12px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent); margin: 0 0 14px;
}
.login h1 { font-size: 22px; line-height: 1.25; margin: 0 0 4px; }
.login .detail { margin: 0 0 22px; font-size: 14px; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label {
  font: 600 11px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted);
}
.field input {
  font: inherit; padding: 11px 12px; color: inherit;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
}
.field input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.login .big-btn { margin-top: 20px; width: 100%; border: 0; cursor: pointer; font-family: inherit; }
.login-error {
  margin: 14px 0 0; padding: 10px 12px; border-radius: 10px;
  background: color-mix(in srgb, #c0392b 12%, transparent);
  color: #c0392b; font-size: 14px;
}
@media (prefers-color-scheme: dark) { .login-error { color: #ff8f80; } }

/* --- home nav --------------------------------------------------------- */
.home-nav { display: flex; align-items: center; gap: 8px; margin: 0 0 18px; }
.home-nav .nav-link, .linklike {
  font: inherit; font-size: 13px; font-weight: 600;
  padding: 7px 12px; border-radius: 9px;
  border: 1px solid var(--line); background: none; color: var(--muted);
  text-decoration: none; cursor: pointer;
}
.home-nav .nav-link:hover, .linklike:hover { color: var(--ink); border-color: var(--muted); }
.home-nav .linklike { margin-left: auto; border-color: transparent; }

/* --- dashboard -------------------------------------------------------- */
.dash-head-block { margin-bottom: 22px; }
.dash-title { font-size: 26px; line-height: 1.2; margin: 0 0 4px; }
.dash-sub { color: var(--muted); margin: 0; font-size: 15px; }
.dash-cols { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 46rem) { .dash-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.dash-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 22px; box-shadow: 0 1px 4px rgb(0 0 0 / 5%);
  display: flex; flex-direction: column;
}
.dash-card.is-you { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }

.card-head { display: flex; align-items: baseline; gap: 8px; }
.card-head h2 { font-size: 18px; margin: 0; }
.you-tag {
  font: 600 10px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent-ink); background: var(--accent);
  padding: 3px 6px; border-radius: 5px;
}
.card-count { margin-left: auto; font: 13px/1 var(--mono); color: var(--muted); }

/* the stamp row -- one slot per day, Monday first */
.week {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
  margin: 18px 0 4px; padding-top: 16px; border-top: 1px solid var(--line);
}
.week .day { display: grid; gap: 4px; justify-items: center; }
.week .dow { font: 600 9px/1 var(--mono); letter-spacing: .06em; color: var(--muted); }
.week .slot {
  width: 100%; aspect-ratio: 1; max-height: 34px;
  display: grid; place-items: center; border-radius: 7px;
  font: 600 11px/1 var(--mono);
  border: 1px dashed var(--line); color: transparent;
}
.week .day.on .slot {
  border: 1.5px solid var(--accent); border-style: solid;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  transform: rotate(-2deg);
}
.week .day.today .slot { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent); }
.week-note { font: 11px/1.4 var(--mono); color: var(--muted); margin: 8px 0 0; }

.dash-feed { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.dash-feed .recap-item { margin-bottom: 16px; }
.dash-feed .recap-item:last-child { margin-bottom: 0; }
.dash-feed .quote { line-height: 1.5; }
.dash-feed .src { font-size: 13px; color: var(--muted); margin-top: 5px; }
/* The takeaway is the point; the paper it came from is the footnote. Dropping
   the underline is what quiets it -- line-clamping the anchor is not, because
   a -webkit-box anchor stops flowing inline and strands the em-dash on its
   own line. */
.dash-feed .src a { color: var(--muted); text-decoration: none; }
.dash-feed .src a:hover { color: var(--ink); text-decoration: underline; }
.when { font-family: var(--mono); font-size: 11px; }
.dash-empty { color: var(--muted); font-size: 14px; margin: 0; }

@media (prefers-reduced-motion: reduce) {
  .week .day.on .slot { transform: none; }
}
