/* ==========================================================================
   reader.css — the reading view: full-width page, and the assistant that is
   summoned over it rather than parked beside it.
   ========================================================================== */

.reader { padding: var(--s6) 0 var(--s9); }

.reader-top {
  display: flex; align-items: center; gap: var(--s4);
  margin-bottom: var(--s5); flex-wrap: wrap;
}
.reader-title h2 { font-size: var(--t-xl); }
.reader-title p { font-size: var(--t-sm); color: var(--ink-faint); margin-top: 2px; }
.reader-top .right { margin-left: auto; display: flex; gap: var(--s2); }

.sheet-wrap { max-width: 940px; margin: 0 auto; }

.sheet-bar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s4);
  background: var(--paper); border: 1.5px solid var(--line); border-bottom: none;
  border-radius: var(--r-md) var(--r-md) 0 0; padding: var(--s3) var(--s4);
}
.sheet-bar .grp { display: flex; align-items: center; gap: var(--s3); }
.sheet-bar .folio { font-size: var(--t-sm); color: var(--ink-soft); font-variant-numeric: tabular-nums; font-weight: 600; }
.sheet-tool {
  width: 38px; height: 38px; border-radius: var(--r-sm); border: none; background: none;
  color: var(--ink-soft); display: grid; place-items: center; transition: all .15s;
}
.sheet-tool:hover:not(:disabled) { background: var(--page-2); color: var(--ink); }
.sheet-tool:disabled { opacity: .3; cursor: not-allowed; }
.sheet-tool.is-on { background: var(--teal); color: #fff; }

.sheet {
  background: var(--paper); border: 1.5px solid var(--line); border-radius: 0 0 var(--r-md) var(--r-md);
  padding: var(--s8) var(--s8) var(--s7); box-shadow: var(--shadow-md); min-height: 420px;
}
.sheet h3 { font-size: var(--t-2xl); margin-bottom: var(--s5); max-width: 24ch; }
.sheet p { font-size: var(--t-md); line-height: 1.9; color: var(--ink-soft); margin-bottom: var(--s4); max-width: 66ch; }
.sheet ul { margin: 0 0 var(--s4); padding-left: var(--s5); color: var(--ink-soft); font-size: var(--t-base); line-height: 1.8; max-width: 66ch; }
.sheet li { margin-bottom: var(--s2); }
.sheet mark {
  background: var(--marigold-lo); color: inherit; padding: 2px 4px; border-radius: 4px;
  box-decoration-break: clone; -webkit-box-decoration-break: clone;
  transition: background .35s, color .35s;
}
.sheet mark.is-lit { background: var(--marigold); color: #2B1B02; }
.sheet-foot {
  margin-top: var(--s6); padding-top: var(--s4); border-top: 1px solid var(--line-soft);
  font-size: var(--t-xs); color: var(--ink-faint);
}
.sheet-foot em { display: block; margin-top: var(--s1); }

/* --------------------------------------------------------------------------
   Summon button + assistant panel
   -------------------------------------------------------------------------- */
.ask-fab {
  position: fixed; right: var(--s5); bottom: var(--s5); z-index: 70;
  height: 58px; padding: 0 24px 0 18px; border: none; border-radius: var(--r-pill);
  background: var(--night); color: #fff; display: inline-flex; align-items: center; gap: var(--s3);
  font-family: var(--display); font-weight: 700; font-size: var(--t-sm);
  box-shadow: var(--shadow-night); transition: transform .16s var(--ease), background .16s;
}
.ask-fab:hover { background: var(--night-2); transform: translateY(-3px); }
.ask-fab .spark { width: 26px; height: 26px; border-radius: 8px; background: var(--marigold); color: #2B1B02; display: grid; place-items: center; flex: none; }

.assistant {
  position: fixed; right: var(--s5); bottom: calc(58px + var(--s5) + var(--s3)); z-index: 69;
  width: 412px; height: min(600px, calc(100vh - 160px));
  background: var(--paper); border: 1.5px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); display: none; flex-direction: column; overflow: hidden;
}
.assistant.is-open { display: flex; animation: assistant .24s var(--ease); }
@keyframes assistant { from { transform: translateY(16px) scale(.98); opacity: 0; } }

.assistant-top {
  display: flex; align-items: center; gap: var(--s3); padding: var(--s4);
  background: var(--night); color: #fff;
}
.assistant-top .mark {
  width: 36px; height: 36px; border-radius: 10px; background: var(--marigold); color: #2B1B02;
  display: grid; place-items: center; flex: none;
}
.assistant-top b { font-family: var(--display); font-size: var(--t-sm); display: block; }
.assistant-top span { font-size: var(--t-xs); color: var(--night-soft); }
.assistant-x {
  margin-left: auto; width: 32px; height: 32px; border-radius: var(--r-sm); border: none;
  background: rgba(255,255,255,.1); color: #fff; display: grid; place-items: center;
}
.assistant-x:hover { background: rgba(255,255,255,.22); }

.thread { flex: 1; overflow-y: auto; padding: var(--s4); display: flex; flex-direction: column; gap: var(--s4); }
.turn { display: flex; gap: var(--s3); max-width: 94%; }
.turn.me { align-self: flex-end; flex-direction: row-reverse; }
.turn .who {
  width: 30px; height: 30px; border-radius: 9px; flex: none; display: grid; place-items: center;
  font-family: var(--display); font-weight: 800; font-size: 11px;
}
.turn.ai .who { background: var(--marigold); color: #2B1B02; }
.turn.me .who { background: var(--page-2); color: var(--ink-soft); }
.bubble {
  background: var(--page-2); border-radius: var(--r-md); padding: var(--s3) var(--s4);
  font-size: var(--t-sm); line-height: 1.6;
}
.turn.me .bubble { background: var(--night); color: var(--night-ink); }
.bubble strong { color: var(--ink); }
.turn.me .bubble strong { color: #fff; }
.bubble .dots { display: flex; gap: 5px; padding: 4px 0; }
.bubble .dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-faint); animation: blink 1.2s infinite; }
.bubble .dots i:nth-child(2) { animation-delay: .15s; }
.bubble .dots i:nth-child(3) { animation-delay: .3s; }

.cite {
  display: inline-flex; align-items: center; gap: 6px; margin-top: var(--s3);
  background: var(--teal-lo); border: 1.5px solid var(--teal); color: var(--teal);
  border-radius: var(--r-pill); padding: 6px 13px; font-size: var(--t-xs); font-weight: 700;
}
.cite:hover { background: var(--teal); color: #fff; }

.quick { display: flex; gap: var(--s2); padding: 0 var(--s4) var(--s3); flex-wrap: wrap; }
.quick button {
  border: 1.5px solid var(--line); background: none; color: var(--ink-soft);
  border-radius: var(--r-pill); padding: 7px 13px; font-size: var(--t-xs); font-weight: 600;
}
.quick button:hover { border-color: var(--marigold); color: var(--ink); background: var(--marigold-lo); }

.compose { display: flex; gap: var(--s2); padding: var(--s3) var(--s4) var(--s4); border-top: 1px solid var(--line-soft); }
.compose input {
  flex: 1; min-width: 0; border: 1.5px solid var(--line); border-radius: var(--r-pill);
  padding: 11px 16px; font-size: var(--t-sm); background: var(--page); color: var(--ink); outline: none;
}
.compose input:focus { border-color: var(--marigold); }
.compose button {
  flex: none; width: 44px; height: 44px; border-radius: 50%; border: none;
  background: var(--marigold); color: #2B1B02; display: grid; place-items: center;
}
.compose button:hover { background: #FFB53C; }

/* --------------------------------------------------------------------------
   Peek sheet — pulled book preview
   -------------------------------------------------------------------------- */
.veil {
  position: fixed; inset: 0; z-index: 80; background: rgba(12,17,40,.62);
  backdrop-filter: blur(3px); display: none; place-items: center; padding: var(--s5);
}
.veil.is-on { display: grid; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; } }
.peek {
  position: relative; width: 100%; max-width: 560px; background: var(--paper);
  border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-lg);
  display: grid; grid-template-columns: 200px 1fr; animation: peek .24s var(--pop);
}
@keyframes peek { from { transform: translateY(16px) scale(.96); opacity: 0; } }
.peek-art { position: relative; background: var(--c); min-height: 240px; }
.peek-art svg.art { position: absolute; inset: 0; width: 100%; height: 100%; }
.peek-body { padding: var(--s5); display: flex; flex-direction: column; gap: var(--s3); }
.peek-body h3 { font-size: var(--t-lg); }
.peek-body .sub { font-size: var(--t-xs); color: var(--ink-faint); }
.peek-body p { font-size: var(--t-sm); color: var(--ink-soft); }
.peek-facts { display: flex; gap: var(--s4); font-size: var(--t-xs); color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.peek-facts span { display: inline-flex; align-items: center; gap: 5px; }
.peek-act { display: flex; gap: var(--s2); margin-top: auto; padding-top: var(--s2); }
.peek-x {
  position: absolute; top: var(--s3); right: var(--s3); z-index: 3; width: 34px; height: 34px;
  border-radius: 50%; border: none; background: var(--paper); color: var(--ink-soft);
  display: grid; place-items: center; box-shadow: var(--shadow-sm);
}
.peek-x:hover { color: var(--ink); }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .sheet { padding: var(--s6) var(--s5); }
  .sheet h3 { font-size: var(--t-xl); }
}
@media (max-width: 620px) {
  .peek { grid-template-columns: 1fr; }
  .peek-art { min-height: 150px; }
  .assistant {
    right: var(--s3); left: var(--s3); width: auto;
    bottom: calc(52px + var(--s3) + var(--s2)); height: min(520px, calc(100vh - 130px));
  }
  .ask-fab { right: var(--s3); bottom: var(--s3); height: 52px; padding: 0 18px 0 14px; }
  .sheet { padding: var(--s5) var(--s4); }
  .sheet p { font-size: var(--t-base); line-height: 1.8; }
}
