/* ═══════════════════════════════════════════════
   BookAI — Your cozy reading nook
   A quiet place where books feel like home.
   ═══════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=Inter:wght@400;500;600;700&display=swap');

/* ── Tokens ─────────────────────────────── */
:root {
  --page:        #f8f3ea;
  --surface:     #fffdf7;
  --ink:         #1c1828;
  --ink-soft:    #6e6760;
  --ink-muted:   #a0998e;
  --line:        #e4ddd2;
  --line-soft:   #f0eae0;

  --rose:        #c4726a;
  --rose-glow:   #f0cfc6;
  --gold:        #c4954c;
  --gold-glow:   #f3dfb0;
  --lavender:    #8b7aa8;
  --lavender-glow:#e0d8f0;

  --shadow:      0 2px 20px rgba(28,24,40,.06), 0 1px 3px rgba(28,24,40,.04);
  --shadow-lg:   0 8px 40px rgba(28,24,40,.09), 0 2px 8px rgba(28,24,40,.04);
  --radius:      16px;
  --radius-sm:   10px;

  --serif:       'Instrument Serif', 'Georgia', serif;
  --sans:        'Inter', system-ui, -apple-system, sans-serif;
}

/* ── Reset ──────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { min-height: 100%; -webkit-font-smoothing: antialiased; }
body {
  background: var(--page);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select {
  font: inherit;
  color: inherit;
  border: none;
  background: none;
  outline: none;
}
button { cursor: pointer; }

/* ── Atmosphere ──────────────────────────── */
/* The signature: an imperceptibly shifting warm glow
   that makes the reading nook feel physically alive. */
.app-body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 60% 50% at 20% 30%, rgba(196,114,106,.07) 0%, transparent 70%),
    radial-gradient(ellipse 50% 60% at 80% 70%, rgba(196,149,76,.06) 0%, transparent 70%),
    radial-gradient(ellipse 40% 40% at 50% 50%, rgba(139,122,168,.04) 0%, transparent 70%);
  animation: hearth 90s ease-in-out infinite alternate;
}
@keyframes hearth {
  0%   { opacity: .6; transform: scale(1) translate(0,0); }
  33%  { opacity: 1; transform: scale(1.05) translate(-1%, .5%); }
  66%  { opacity: .7; transform: scale(.97) translate(1%, -.5%); }
  100% { opacity: .85; transform: scale(1.02) translate(.5%, .3%); }
}

/* ── Typography ──────────────────────────── */
h1, h2, h3, h4 { font-weight: 400; }
.eyebrow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--rose);
  margin-bottom: 10px;
}

/* ── Buttons ────────────────────────────── */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -.01em;
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
  box-shadow: 0 4px 14px rgba(28,24,40,.12);
  position: relative;
  overflow: hidden;
}
.button:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(28,24,40,.18);
}
.button:active { transform: translateY(0); }
.button-small { padding: 8px 16px; font-size: 13px; }
.button-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
  box-shadow: none;
}
.button-ghost:hover { background: var(--surface); box-shadow: var(--shadow); }
.button-rose { background: var(--rose); }

.icon-button {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 19px;
  transition: background .15s, transform .15s;
  color: var(--ink-soft);
}
.icon-button:hover { background: var(--rose-glow); color: var(--ink); transform: scale(1.05); }
.icon-button:active { transform: scale(.95); }

/* ── Toast ───────────────────────────────── */
.toast {
  position: fixed; z-index: 200;
  left: 50%; bottom: 90px;
  transform: translate(-50%, 12px);
  background: var(--ink);
  color: #fff;
  border-radius: 999px;
  padding: 11px 20px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s cubic-bezier(.16,1,.3,1);
  box-shadow: 0 4px 20px rgba(28,24,40,.2);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ── Access Gate ─────────────────────────── */
.gate {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 70% 50% at 50% 30%, rgba(196,149,76,.08) 0%, transparent 70%),
    var(--page);
}
.gate-card {
  width: min(400px, 100%);
  text-align: center;
}
.gate-card .brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.02em;
  margin-bottom: 32px;
}
.gate-card .brand-mark {
  display: grid; place-items: center;
  width: 32px; height: 32px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--gold-glow);
  font-size: 16px;
}
.gate-card h1 {
  font-family: var(--serif);
  font-size: 34px;
  font-style: italic;
  line-height: 1.15;
  margin-bottom: 10px;
  color: var(--ink);
}
.gate-card p {
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 28px;
}
.gate-card label {
  display: block;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  letter-spacing: .02em;
}
.gate-card input {
  display: block;
  width: 100%;
  margin: 8px 0 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 16px;
  transition: border-color .2s, box-shadow .2s;
}
.gate-card input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-glow);
}
.gate-card .button { width: 100%; }
.gate-card small { display: block; color: var(--rose); margin-top: 10px; font-size: 12px; }

.hidden { display: none !important; }

/* ── App Shell ───────────────────────────── */
.app-shell {
  min-height: 100vh;
  padding-bottom: 76px;
  position: relative;
  z-index: 1;
}

/* ── Header ──────────────────────────────── */
.app-header {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(20px, calc((100% - 1100px) / 2));
  border-bottom: 1px solid var(--line-soft);
  background: rgba(248,243,234,.85);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  position: sticky; top: 0; z-index: 10;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -.02em;
}
.brand-mark {
  display: grid; place-items: center;
  width: 30px; height: 30px;
  border-radius: 9px;
  background: var(--ink);
  color: var(--gold-glow);
  font-size: 15px;
}
.header-actions { display: flex; align-items: center; gap: 4px; }
.version-label { font-size: 10px; color: var(--ink-muted); margin-right: 8px; }

/* ── Main Content ────────────────────────── */
.app-main {
  width: min(1100px, calc(100% - 36px));
  margin: 0 auto;
}
.view { display: none; padding: 36px 0 60px; animation: viewIn .35s ease; }
.view.active { display: block; }
@keyframes viewIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.view-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}
.view-heading h1, .view h1 {
  font-family: var(--serif);
  font-size: clamp(28px, 5vw, 40px);
  font-style: italic;
  line-height: 1.12;
  letter-spacing: -.03em;
}

/* ── Shelf ───────────────────────────────── */
.shelf-section { margin: 28px 0 44px; }
.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.section-heading h2 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--ink-soft);
}
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 14px;
}
.book-card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s;
}
.book-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--line);
}
.book-card:active { transform: translateY(-1px); }
.cover {
  height: 160px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, #3d4a6e, #c47a72);
  color: #fff;
  position: relative;
  overflow: hidden;
}
.cover::after {
  content: '✦';
  position: absolute;
  top: 10px; right: 14px;
  opacity: .5;
  color: var(--gold-glow);
  font-size: 14px;
}
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover-fallback {
  font-family: var(--serif);
  text-align: center;
  font-size: 16px;
  line-height: 1.25;
  padding: 18px;
  text-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.book-info { padding: 14px; }
.book-title {
  font-family: var(--serif);
  font-size: 15px;
  font-style: italic;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.book-author {
  color: var(--ink-soft);
  font-size: 12px;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.progress-track {
  height: 4px;
  background: var(--rose-glow);
  border-radius: 4px;
  margin-top: 12px;
  overflow: hidden;
}
.progress-value {
  height: 100%;
  background: var(--rose);
  border-radius: 4px;
  transition: width .4s ease;
}
.progress-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
  color: var(--ink-muted);
  font-size: 10px;
}

/* Nudge card — gentle invitation to read */
.nudge-card {
  background: linear-gradient(135deg, var(--lavender-glow), var(--rose-glow));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin-bottom: 28px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nudge-card span {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--rose);
}
.nudge-card strong {
  font-family: var(--serif);
  font-size: 19px;
  font-style: italic;
  font-weight: 400;
  line-height: 1.3;
}
.nudge-card small { color: var(--ink-soft); font-size: 12px; }

/* Empty state */
.empty-state {
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  text-align: center;
  padding: 56px 24px;
  color: var(--ink-soft);
}
.empty-state .empty-mark { font-size: 36px; color: var(--gold); margin-bottom: 12px; }
.empty-state strong { display: block; color: var(--ink); font-family: var(--serif); font-size: 20px; font-style: italic; font-weight: 400; margin-bottom: 6px; }
.empty-state p { margin: 0 auto 18px; max-width: 360px; font-size: 14px; line-height: 1.6; }

/* ── Bottom Nav ──────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 10;
  height: 70px;
  background: rgba(255,253,247,.92);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  border-top: 1px solid var(--line-soft);
  display: flex;
  justify-content: center;
  gap: min(8vw, 80px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  font-size: 10px;
  font-weight: 500;
  color: var(--ink-muted);
  min-width: 52px;
  padding: 0 4px;
  transition: color .2s;
}
.nav-item span { font-size: 18px; line-height: 1; }
.nav-item.active { color: var(--rose); }

/* ── Book Detail ─────────────────────────── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 20px;
  transition: color .15s;
}
.back-link:hover { color: var(--ink); }
.book-hero {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 24px;
}
.book-hero .cover {
  width: 150px; height: 210px;
  border-radius: 10px;
  flex-shrink: 0;
  box-shadow: var(--shadow-lg);
}
.book-hero-copy { padding-top: 4px; min-width: 0; }
.book-hero-copy h1 { font-size: clamp(26px, 4vw, 36px); margin-bottom: 4px; }
.book-hero-copy .author { color: var(--ink-soft); font-size: 15px; }
.badge {
  display: inline-block;
  margin-top: 12px;
  background: var(--rose-glow);
  color: var(--rose);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 18px 0; }
.upload-label { cursor: pointer; }
.upload-label input[type="file"] { display: none; }

.detail-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 16px; margin-bottom: 16px; }
.panel {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 22px;
}
.panel h2 {
  font-family: var(--serif);
  font-size: 18px;
  font-style: italic;
  margin: 0 0 12px;
}
.panel p { color: var(--ink-soft); font-size: 14px; line-height: 1.6; }
.panel .muted { font-size: 12px; }

.detail-note-list { display: grid; gap: 8px; }
.mini-entry {
  border-left: 2px solid var(--gold-glow);
  padding-left: 12px;
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.5;
}
.mini-entry small { display: block; color: var(--ink-muted); margin-top: 3px; font-size: 11px; }

.inline-form { display: flex; gap: 8px; margin-top: 14px; }
.inline-form input, .inline-form select {
  flex: 1; min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--surface);
  font-size: 13px;
}
.inline-form input:focus, .inline-form select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-glow);
}
.progress-editor { display: flex; gap: 6px; align-items: center; }
.progress-editor input {
  width: 70px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  background: var(--surface);
  font-size: 13px;
}
.progress-panel { margin-bottom: 18px; }

/* ── Search / Discover ───────────────────── */
.search-row { display: flex; gap: 8px; margin-bottom: 20px; }
.search-row input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  background: var(--surface);
  font-size: 15px;
  transition: border-color .2s, box-shadow .2s;
}
.search-row input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-glow); }
.result-list { display: grid; gap: 8px; }
.result-card {
  display: flex; gap: 14px; align-items: center;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
}
.result-card:hover { border-color: var(--line); box-shadow: var(--shadow); }
.result-thumb {
  width: 44px; height: 62px;
  background: #3d4a6e;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
}
.result-copy { flex: 1; min-width: 0; }
.result-actions { display: flex; gap: 6px; flex-shrink: 0; }
.button-gold { background: var(--gold); color: #fff; border-color: var(--gold); }
.button-gold:hover { background: #c9a036; border-color: #c9a036; }
.button-gold:disabled { opacity: 0.6; }
.result-copy strong {
  display: block;
  font-family: var(--serif);
  font-size: 14px;
  font-style: italic;
}
.result-copy span { display: block; color: var(--ink-soft); font-size: 12px; }

/* ── Modals ──────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(28,24,40,.35);
  backdrop-filter: blur(4px);
  display: grid; place-items: center;
  padding: 18px;
  animation: fadeIn .2s ease;
}
.modal-card {
  position: relative;
  width: min(500px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--page);
  border-radius: 20px;
  padding: 30px;
  box-shadow: 0 20px 60px rgba(28,24,40,.15);
  animation: modalIn .3s cubic-bezier(.16,1,.3,1);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn {
  from { opacity: 0; transform: translateY(16px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-close {
  position: absolute;
  right: 14px; top: 10px;
  font-size: 26px;
  color: var(--ink-soft);
  padding: 4px 10px;
  border-radius: 8px;
  transition: background .15s, color .15s;
}
.modal-close:hover { background: var(--rose-glow); color: var(--rose); }
.modal-card h2 {
  font-family: var(--serif);
  font-size: 26px;
  font-style: italic;
  font-weight: 400;
  margin: 0 0 20px;
}
.modal-card label, .source-form label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  letter-spacing: .02em;
  margin: 12px 0;
}
.modal-card label input,
.modal-card label textarea,
.source-form label input,
.source-form label select {
  display: block; width: 100%; margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  background: var(--surface);
  font-size: 14px;
}
.modal-card label input:focus,
.modal-card label textarea:focus,
.source-form label input:focus,
.source-form label select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-glow);
}
.modal-card textarea { min-height: 70px; resize: vertical; }
.muted { font-weight: 400; color: var(--ink-muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.modal-card hr { border: 0; border-top: 1px solid var(--line); margin: 22px 0 14px; }
.upload-book { display: flex; flex-direction: column; gap: 4px; color: var(--ink-soft); font-size: 13px; }
.upload-book b { color: var(--ink); }

/* ── Reader ──────────────────────────────── */
.reader-modal, .chat-modal {
  position: fixed; inset: 0; z-index: 50;
  background: var(--page);
  display: flex; flex-direction: column;
  animation: fadeIn .2s ease;
}
.reader-header, .chat-header {
  flex-shrink: 0;
  min-height: 60px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line-soft);
  padding: 8px max(16px, calc((100% - 820px) / 2));
  background: rgba(255,253,247,.9);
  backdrop-filter: blur(12px);
}
.reader-header div, .chat-header div { flex: 1; min-width: 0; }
.reader-header strong, .chat-header strong { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reader-header small, .chat-header small { display: block; color: var(--ink-soft); font-size: 11px; }
.reader-selection {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--gold-glow);
  font-size: 11px;
  color: var(--ink-soft);
}
.reader-selection.active { display: flex; }
.reader-selection span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reader-selection button {
  border: 1px solid #d4ba85;
  border-radius: 999px;
  background: var(--surface);
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 500;
  transition: background .15s;
}
.reader-selection button:hover { background: var(--page); }
.reader-area {
  flex: 1;
  width: min(780px, 100%);
  margin: auto;
  overflow: auto;
  background: #fffdf7;
  box-shadow: 0 0 40px rgba(28,24,40,.04);
}
.reader-area iframe { width: 100%; height: 100%; border: 0; }
.reader-empty {
  display: grid; place-items: center;
  height: 100%; padding: 40px;
  text-align: center;
  color: var(--ink-soft);
}
.reader-footer {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px max(20px, calc((100% - 780px) / 2));
  border-top: 1px solid var(--line-soft);
  background: var(--surface);
}
.reader-footer button {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--gold-glow);
  color: var(--ink);
  font-size: 16px;
  transition: background .15s, transform .15s;
}
.reader-footer button:hover { background: var(--gold); color: #fff; }
.reader-footer button:active { transform: scale(.93); }
.reader-footer span { font-size: 12px; color: var(--ink-soft); font-weight: 500; }

/* ── Chat Panel ──────────────────────────── */
.chat-modal {
  left: auto; right: 0;
  width: min(460px, 100%);
  box-shadow: -8px 0 40px rgba(28,24,40,.1);
}
.chat-header { padding: 8px 16px; }
.chat-header select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  background: var(--surface);
  font-size: 11px;
}
.chat-messages {
  flex: 1; overflow-y: auto;
  padding: 20px 16px;
  display: flex; flex-direction: column; gap: 8px;
}
.chat-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  animation: bubbleIn .25s ease;
}
@keyframes bubbleIn {
  from { opacity: 0; transform: translateY(6px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.chat-bubble.user {
  align-self: flex-end;
  background: var(--ink);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-bubble.assistant {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-bottom-left-radius: 4px;
}
.chat-bubble small {
  display: block;
  color: #aaa;
  font-size: 10px;
  margin-top: 4px;
}
.chat-context {
  display: none;
  padding: 8px 14px;
  background: var(--lavender-glow);
  font-size: 11px;
  color: var(--ink-soft);
  align-items: center;
  gap: 6px;
  border-top: 1px solid var(--line-soft);
}
.chat-context.active { display: flex; }
.chat-context span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-context button {
  font-size: 16px;
  color: var(--ink-soft);
  padding: 2px 6px;
  border-radius: 4px;
}
.chat-context button:hover { background: rgba(0,0,0,.05); }
.chat-input {
  display: flex; gap: 8px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line-soft);
  background: var(--surface);
}
.chat-input textarea {
  flex: 1; resize: none; max-height: 100px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  background: var(--page);
  font-size: 14px;
}
.chat-input textarea:focus { border-color: var(--lavender); box-shadow: 0 0 0 3px var(--lavender-glow); }
.send-button {
  width: 40px; height: 40px;
  align-self: flex-end; flex-shrink: 0;
  border-radius: 50%;
  background: var(--rose);
  color: #fff;
  font-size: 18px;
  transition: background .15s, transform .15s;
}
.send-button:hover { background: #b0625b; }
.send-button:active { transform: scale(.9); }

/* ── Settings ────────────────────────────── */
.source-card {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
}
.source-card:last-child { border: 0; }
.source-card div { flex: 1; }
.source-card strong { display: block; font-size: 14px; }
.source-card span { display: block; color: var(--ink-soft); font-size: 12px; }
.source-form {
  background: var(--gold-glow);
  padding: 16px;
  border-radius: var(--radius-sm);
  margin-top: 14px;
}
.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--line-soft);
  gap: 14px;
}
.setting-row:last-child { border: 0; }
.setting-row label { font-weight: 600; font-size: 14px; }
.setting-row small { display: block; color: var(--ink-soft); font-weight: 400; font-size: 12px; margin-top: 2px; }
.setting-row select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  background: var(--surface);
  font-size: 13px;
}

/* ── Landing Page ────────────────────────── */
.landing-body { background: var(--page); }
.site-header {
  width: min(1100px, calc(100% - 36px));
  margin: auto;
  padding: 22px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.hero {
  width: min(1100px, calc(100% - 36px));
  margin: auto;
  padding: 60px 0 50px;
  position: relative;
}
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--lavender-glow);
  color: var(--lavender);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 24px;
}
.hero-badge span { font-size: 16px; }
.hero h1 {
  font-family: var(--serif);
  font-size: clamp(38px, 7vw, 66px);
  font-style: italic;
  line-height: 1.06;
  letter-spacing: -.04em;
  max-width: 680px;
  margin: 0;
}
.hero h1 em { color: var(--rose); font-style: italic; }
.hero-copy {
  color: var(--ink-soft);
  font-size: 17px;
  max-width: 480px;
  margin: 20px 0 28px;
  line-height: 1.6;
}
.hero-actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.text-link { color: var(--ink-soft); font-size: 13px; border-bottom: 1px solid var(--gold); padding-bottom: 2px; transition: color .15s; }
.text-link:hover { color: var(--ink); }
.hero-card {
  width: min(100%, 680px);
  height: 190px;
  margin: 56px auto 0;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #2d3758, #3d3a5c);
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  padding: 24px;
  gap: 10px;
}
.hero-card::before {
  content: '';
  position: absolute; inset: -50%;
  background: radial-gradient(circle, rgba(224,200,160,.12) 0 1px, transparent 1.5px) 0 0 / 30px 30px;
  transform: rotate(12deg);
}
.book-spine {
  height: 110px; width: 36px;
  border-radius: 4px 6px 3px 3px;
  box-shadow: inset -4px 0 0 rgba(0,0,0,.08);
  z-index: 1;
}
.spine-1 { background: #c47a72; transform: rotate(-4deg); }
.spine-2 { background: #c4954c; height: 130px; transform: rotate(2deg); }
.spine-3 { background: #8b7aa8; transform: rotate(7deg); }
.hero-note {
  z-index: 1;
  background: #fffdf7;
  color: var(--ink);
  padding: 16px 20px;
  margin-left: auto;
  width: 240px;
  box-shadow: 0 6px 16px rgba(0,0,0,.12);
  transform: rotate(-1.5deg);
  border-radius: 2px;
}
.hero-note span {
  color: var(--rose);
  text-transform: uppercase;
  font-size: 9px;
  letter-spacing: .1em;
  font-weight: 700;
}
.hero-note strong {
  display: block;
  font-family: var(--serif);
  font-style: italic;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.4;
  margin-top: 4px;
}
.hero-sparkle {
  position: absolute;
  top: 22px; right: 36px;
  color: var(--gold-glow);
  font-size: 22px;
  z-index: 1;
}

/* Feature grid */
.feature-grid {
  width: min(1100px, calc(100% - 36px));
  margin: auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  padding-bottom: 60px;
}
.feature {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 24px;
  transition: border-color .2s, box-shadow .2s;
}
.feature:hover { border-color: var(--line); box-shadow: var(--shadow); }
.feature-icon { color: var(--rose); font-size: 22px; margin-bottom: 16px; }
.feature h2 {
  font-family: var(--serif);
  font-size: 18px;
  font-style: italic;
  margin: 0 0 8px;
}
.feature p { color: var(--ink-soft); font-size: 13px; line-height: 1.6; }

/* How it works */
.how-section {
  width: min(1100px, calc(100% - 36px));
  margin: auto;
  background: var(--gold-glow);
  border-radius: var(--radius);
  padding: 44px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 44px;
  align-items: center;
  margin-bottom: 40px;
}
.how-section h2 {
  font-family: var(--serif);
  font-style: italic;
  font-size: 28px;
  line-height: 1.2;
  margin: 0 0 12px;
}
.how-steps { display: grid; gap: 14px; }
.how-steps > div {
  display: flex; flex-direction: column; gap: 3px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(196,149,76,.2);
}
.how-steps > div:last-child { border: 0; padding: 0; }
.how-steps b { font-size: 14px; }
.how-steps span { font-size: 12px; color: var(--ink-soft); }

.privacy-strip {
  width: min(1100px, calc(100% - 36px));
  margin: auto;
  padding: 18px 22px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  margin-bottom: 40px;
}
.privacy-strip span { font-weight: 700; white-space: nowrap; }
.privacy-strip p { margin: 0; color: var(--ink-soft); }
.privacy-strip a { margin-left: auto; color: var(--rose); white-space: nowrap; font-weight: 500; }

.site-footer {
  width: min(1100px, calc(100% - 36px));
  margin: auto;
  color: var(--ink-muted);
  font-size: 12px;
  padding: 40px 0 30px;
  display: flex;
  justify-content: space-between;
}

/* ── Journal ─────────────────────────────── */
#journal-content .detail-grid { grid-template-columns: 1fr 1fr; }
#journal-content .mini-entry b { color: var(--ink); font-size: 14px; }

/* ── Responsive ──────────────────────────── */
@media (max-width: 700px) {
  .site-header, .hero, .feature-grid, .how-section, .privacy-strip, .site-footer,
  .app-main { width: calc(100% - 28px); }
  .hero { padding: 40px 0 36px; }
  .hero-card { margin-top: 36px; height: 160px; padding: 14px; }
  .hero-note { width: 190px; padding: 12px; }
  .hero-note strong { font-size: 13px; }
  .book-spine { width: 24px; height: 80px; }
  .book-spine.spine-2 { height: 105px; }
  .feature-grid, .how-section, .detail-grid, #journal-content .detail-grid {
    grid-template-columns: 1fr;
  }
  .feature-grid { padding-bottom: 36px; }
  .how-section { padding: 24px; gap: 24px; }
  .privacy-strip { align-items: flex-start; flex-wrap: wrap; gap: 8px; }
  .privacy-strip a { margin-left: 0; }
  .site-footer { flex-direction: column; gap: 8px; padding-top: 30px; }
  .view { padding: 28px 0 50px; }
  .view-heading { align-items: flex-start; flex-direction: column; gap: 10px; }
  .book-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .cover { height: 140px; }
  .book-hero { gap: 14px; }
  .book-hero .cover { width: 105px; height: 148px; }
  .result-card { flex-wrap: wrap; align-items: flex-start; }
  .result-card .button { margin-left: 58px; }
  .chat-modal { width: 100%; }
  .version-label { display: none; } { width: 100%; justify-content: center; }
}

/* ── Upload Hub (shortcuts replacement) ──── */
.upload-hub {
  width: min(500px, calc(100% - 32px));
  margin: 40px auto;
  text-align: center;
}
.upload-hub .brand { margin-bottom: 28px; }
.upload-hub h1 {
  font-family: var(--serif);
  font-size: 30px;
  font-style: italic;
  margin-bottom: 6px;
}
.upload-hub p { color: var(--ink-soft); font-size: 14px; margin-bottom: 28px; line-height: 1.6; }
.upload-drop {
  background: var(--surface);
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 40px 24px;
  transition: border-color .2s, background .2s;
  cursor: pointer;
}
.upload-drop:hover, .upload-drop.drag-over {
  border-color: var(--gold);
  background: var(--gold-glow);
}
.upload-drop .upload-icon { font-size: 40px; margin-bottom: 12px; }
.upload-drop strong { display: block; font-family: var(--serif); font-size: 18px; font-style: italic; font-weight: 400; margin-bottom: 4px; }
.upload-drop span { color: var(--ink-soft); font-size: 13px; }
.upload-drop input[type="file"] { display: none; }
.upload-result {
  margin-top: 16px;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  display: none;
}
.upload-result.success {
  display: block;
  background: #e8f5e9;
  color: #2e7d32;
  border: 1px solid #c8e6c9;
}
.upload-result.error {
  display: block;
  background: #fce4ec;
  color: #c62828;
  border: 1px solid #f8bbd0;
}