/* ============================================================
   Living Book — Heirloom Design System
   Warm paper & ink. Serif headings. Quiet, personal, not corporate.
   ============================================================ */

:root {
  /* Paper & ink palette */
  --paper:        #f4ece0;   /* aged paper */
  --paper-warm:   # efe4d4;
  --paper-card:   #fbf6ec;   /* lighter card surface */
  --ink:          #2b2118;   /* dark brown ink */
  --ink-soft:     #5b4d3e;   /* faded ink */
  --ink-faint:    #8a7a66;   /* very faded */
  --line:         #d8c9b2;   /* hairline rule */
  --line-soft:    #e6dac6;

  /* Accents */
  --sage:         #6f7a5a;   /* muted botanical green */
  --sage-dark:    #57603f;
  --rust:         #a4541f;   /* sealing-wax / leather */
  --rust-dark:    #8a4014;
  --gold:         #b08642;   /* aged brass */
  --burgundy:     #6e2f2a;

  --shadow:       0 1px 2px rgba(43,33,24,.08), 0 8px 24px rgba(43,33,24,.06);
  --shadow-lg:    0 4px 12px rgba(43,33,24,.12), 0 20px 48px rgba(43,33,24,.10);

  --serif: "Spectral", "Georgia", "Times New Roman", serif;
  --sans:  "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --hand:  "Caveat", cursive;

  --radius: 10px;
  --maxw: 920px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background-color: var(--paper);
  background-image:
    radial-gradient(circle at 20% 10%, rgba(176,134,66,.05), transparent 40%),
    radial-gradient(circle at 80% 90%, rgba(111,122,90,.05), transparent 40%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; line-height: 1.25; color: var(--ink); }
h1 { font-size: 2.2rem; margin: 0 0 .3em; }
h2 { font-size: 1.5rem; margin: 1.4em 0 .5em; }
h3 { font-size: 1.15rem; margin: 1.2em 0 .4em; }
p { margin: 0 0 1em; }
a { color: var(--rust); text-decoration: none; }
a:hover { text-decoration: underline; }
small { color: var(--ink-faint); }

/* ---------- Layout shell ---------- */
.app { min-height: 100vh; display: flex; flex-direction: column; }

.site-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--line);
  background: rgba(251,246,236,.7);
  backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 50;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .mark {
  width: 38px; height: 38px; border-radius: 8px;
  background: linear-gradient(135deg, var(--burgundy), var(--rust));
  color: #f4ece0; display: grid; place-items: center;
  font-family: var(--serif); font-size: 1.3rem; font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.15);
}
.brand .title { font-size: 1.3rem; font-weight: 600; letter-spacing: .2px; }
.brand .sub { display: block; font-family: var(--sans); font-size: .68rem; letter-spacing: .18em;
  text-transform: uppercase; color: var(--ink-faint); margin-top: -4px; }

.nav { display: flex; gap: 4px; font-family: var(--sans); font-size: .9rem; }
.nav a {
  color: var(--ink-soft); padding: 8px 14px; border-radius: 8px; text-decoration: none;
  transition: background .15s, color .15s;
}
.nav a:hover { background: var(--line-soft); color: var(--ink); }
.nav a.active { background: var(--ink); color: var(--paper-card); }

.main { flex: 1; width: 100%; max-width: var(--maxw); margin: 0 auto; padding: clamp(24px, 5vw, 56px) clamp(16px, 4vw, 32px); }

.site-footer {
  font-family: var(--sans); font-size: .8rem; color: var(--ink-faint);
  text-align: center; padding: 28px 16px; border-top: 1px solid var(--line);
}

/* ---------- Cards ---------- */
.card {
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(18px, 3vw, 28px);
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 18px; }

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--sans); font-size: .95rem; font-weight: 500;
  border: 1px solid transparent; border-radius: 9px;
  padding: 11px 20px; cursor: pointer; display: inline-flex; align-items: center; gap: 9px;
  transition: transform .08s ease, box-shadow .15s, background .15s; text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--rust); color: #fbf6ec; box-shadow: var(--shadow); }
.btn-primary:hover { background: var(--rust-dark); text-decoration: none; }
.btn-secondary { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { background: var(--line-soft); text-decoration: none; }
.btn-sage { background: var(--sage); color: #fbf6ec; }
.btn-sage:hover { background: var(--sage-dark); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--ink-soft); padding: 8px 12px; }
.btn-ghost:hover { color: var(--ink); }
.btn-lg { padding: 15px 30px; font-size: 1.05rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Forms ---------- */
input[type=text], textarea, select {
  width: 100%; font-family: var(--serif); font-size: 1.05rem; color: var(--ink);
  background: #fffdf8; border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 14px; line-height: 1.6;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(176,134,66,.18); }
textarea { resize: vertical; min-height: 120px; }
label { font-family: var(--sans); font-size: .82rem; font-weight: 600; color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: .06em; display: block; margin-bottom: 6px; }

/* ---------- Pills / tags ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px; font-family: var(--sans);
  font-size: .76rem; font-weight: 500; padding: 4px 11px; border-radius: 999px;
  background: var(--line-soft); color: var(--ink-soft); border: 1px solid var(--line);
}
.pill.person { background: #eef0e6; color: var(--sage-dark); border-color: #d6dcc4; }
.pill.place  { background: #f3e7da; color: var(--rust-dark); border-color: #e3cdb6; }
.pill.theme  { background: #ece6f0; color: #5a4a6a; border-color: #d8cfe2; }
.pill.org    { background: #e6ecf0; color: #3f5566; border-color: #c9d6e0; }

/* ---------- Hero / intro ---------- */
.hero { text-align: center; padding: clamp(20px, 5vw, 40px) 0; }
.hero .kicker { font-family: var(--sans); font-size: .78rem; letter-spacing: .22em;
  text-transform: uppercase; color: var(--gold); margin-bottom: 10px; }
.hero h1 { font-size: clamp(2.2rem, 6vw, 3.4rem); }
.hero .lede { font-size: 1.25rem; color: var(--ink-soft); max-width: 620px; margin: 0 auto 1.6em; font-style: italic; }
.hero-actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

/* ---------- Tile grid (modules / themes) ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.tile {
  background: var(--paper-card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; text-decoration: none; color: var(--ink); display: block;
  transition: transform .12s, box-shadow .15s, border-color .15s;
}
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--gold); text-decoration: none; }
.tile .ti { font-size: 1.6rem; color: var(--rust); margin-bottom: 10px; }
.tile h3 { margin: 0 0 6px; }
.tile p { font-family: var(--sans); font-size: .88rem; color: var(--ink-faint); margin: 0; }
.tile .count { font-family: var(--sans); font-size: .8rem; color: var(--sage-dark); margin-top: 10px; display: block; }

/* ---------- Section heading with rule ---------- */
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  border-bottom: 1px solid var(--line); padding-bottom: 10px; margin: 0 0 22px; }
.section-head h2 { margin: 0; }
.section-head .meta { font-family: var(--sans); font-size: .85rem; color: var(--ink-faint); }

/* ---------- Divider with motif ---------- */
.rule { text-align: center; color: var(--gold); margin: 32px 0; font-size: 1.1rem; }
.rule::before, .rule::after { content: "—————"; color: var(--line); margin: 0 12px; letter-spacing: -2px; }

/* ---------- Memory cards (library) ---------- */
.memory-list { display: grid; gap: 16px; }
.memory-card { background: var(--paper-card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px; box-shadow: var(--shadow); transition: box-shadow .15s; }
.memory-card:hover { box-shadow: var(--shadow-lg); }
.memory-card .mc-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.memory-card h3 { margin: 0; }
.memory-card .mc-date { font-family: var(--sans); font-size: .8rem; color: var(--ink-faint); white-space: nowrap; }
.memory-card .mc-body { color: var(--ink-soft); margin: 8px 0 12px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.memory-card .mc-tags { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Empty states ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--ink-faint); }
.empty .ei { font-size: 2.6rem; color: var(--line); margin-bottom: 14px; }
.empty p { font-family: var(--sans); }

/* ---------- Chat / conversation ---------- */
.convo { display: flex; flex-direction: column; gap: 16px; margin-bottom: 24px; }
.bubble { max-width: 88%; padding: 14px 18px; border-radius: 14px; line-height: 1.6; }
.bubble.interviewer, .bubble.twin { align-self: flex-start; background: var(--paper-card);
  border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble.narrator, .bubble.user { align-self: flex-end; background: var(--sage); color: #f7f3ea;
  border-bottom-right-radius: 4px; }
.bubble .who { font-family: var(--sans); font-size: .72rem; text-transform: uppercase; letter-spacing: .1em;
  opacity: .7; margin-bottom: 5px; display: block; }
.bubble .sources { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line-soft); }
.bubble .sources .who { color: var(--gold); }
.source-link { display: block; font-family: var(--sans); font-size: .84rem; color: var(--rust);
  padding: 4px 0; }

/* ---------- Recorder ---------- */
.recorder { text-align: center; padding: 20px; }
.rec-btn {
  width: 110px; height: 110px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--rust); color: #fbf6ec; font-size: 2.4rem; box-shadow: var(--shadow-lg);
  display: grid; place-items: center; margin: 0 auto; transition: transform .12s, background .2s;
}
.rec-btn:hover { transform: scale(1.04); }
.rec-btn.recording { background: var(--burgundy); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(110,47,42,.5); } 50% { box-shadow: 0 0 0 18px rgba(110,47,42,0); } }
.rec-status { font-family: var(--sans); font-size: .9rem; color: var(--ink-soft); margin-top: 16px; }
.rec-timer { font-family: var(--sans); font-variant-numeric: tabular-nums; font-size: 2rem; color: var(--ink); }

/* ---------- Banner / notices ---------- */
.banner { font-family: var(--sans); font-size: .9rem; border-radius: 9px; padding: 12px 16px;
  display: flex; gap: 10px; align-items: flex-start; margin-bottom: 20px; }
.banner.info { background: #f0ece2; border: 1px solid var(--line); color: var(--ink-soft); }
.banner.warn { background: #f6ecd8; border: 1px solid #e3cf9f; color: #7a5a14; }
.banner i { margin-top: 2px; }

/* ---------- Timeline ---------- */
.timeline { position: relative; padding-left: 30px; }
.timeline::before { content: ""; position: absolute; left: 8px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl-item { position: relative; margin-bottom: 26px; }
.tl-item::before { content: ""; position: absolute; left: -26px; top: 6px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--rust); border: 2px solid var(--paper); }
.tl-date { font-family: var(--sans); font-size: .8rem; font-weight: 600; color: var(--gold);
  text-transform: uppercase; letter-spacing: .06em; }

/* ---------- Authenticity slider ---------- */
.slider-row { display: flex; gap: 10px; flex-wrap: wrap; }
.slider-opt { flex: 1; min-width: 150px; border: 1px solid var(--line); border-radius: 9px; padding: 14px;
  cursor: pointer; background: var(--paper-card); transition: border-color .15s, background .15s; }
.slider-opt:hover { border-color: var(--gold); }
.slider-opt.active { border-color: var(--rust); background: #f7ede2; }
.slider-opt strong { font-family: var(--serif); display: block; margin-bottom: 4px; }
.slider-opt span { font-family: var(--sans); font-size: .82rem; color: var(--ink-faint); }

/* ---------- Utilities ---------- */
.muted { color: var(--ink-faint); }
.center { text-align: center; }
.stack > * + * { margin-top: 14px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.hidden { display: none !important; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--line);
  border-top-color: var(--rust); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Coming soon badge ---------- */
.soon { font-family: var(--sans); font-size: .68rem; text-transform: uppercase; letter-spacing: .1em;
  background: var(--gold); color: #fff; padding: 2px 8px; border-radius: 999px; vertical-align: middle; }

@media (max-width: 640px) {
  body { font-size: 17px; }
  .brand .title { font-size: 1.1rem; }
  .nav a { padding: 7px 10px; }
  .main { padding: 22px 16px 40px; }
}
