/* ---- Fonts (vendored, no external requests) ------------------------------- */
@font-face{font-family:'Inter';font-style:normal;font-weight:400;font-display:swap;
  src:url('fonts/inter-latin-400-normal.woff2') format('woff2')}
@font-face{font-family:'Inter';font-style:normal;font-weight:500;font-display:swap;
  src:url('fonts/inter-latin-500-normal.woff2') format('woff2')}
@font-face{font-family:'Inter';font-style:normal;font-weight:600;font-display:swap;
  src:url('fonts/inter-latin-600-normal.woff2') format('woff2')}
@font-face{font-family:'Poppins';font-style:normal;font-weight:600;font-display:swap;
  src:url('fonts/poppins-latin-600-normal.woff2') format('woff2')}
@font-face{font-family:'Poppins';font-style:normal;font-weight:700;font-display:swap;
  src:url('fonts/poppins-latin-700-normal.woff2') format('woff2')}

/* ---- Palette (sampled from the book cover) -------------------------------- */
:root{
  --bg:#ffffff;
  --panel:#f7f5f5;        /* assistant card */
  --line:#ece7e7;
  --line-strong:#ddd6d6;
  --ink:#312e2e;          /* charcoal title/body */
  --ink-soft:#574f4f;
  --muted:#938b8b;
  --red:#e60000;
  --red-dark:#c20000;
  --red-tint:#fdecec;
  --ui:'Inter',system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
  --display:'Poppins','Inter',system-ui,sans-serif;
  --shadow:0 1px 2px rgba(49,46,46,.04),0 8px 24px rgba(49,46,46,.06);
}
*{box-sizing:border-box}
html,body{height:100%}
body{margin:0;background:var(--bg);color:var(--ink);font-family:var(--ui);
  font-size:16px;line-height:1.6;display:flex;flex-direction:column;
  -webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}

/* ---- Header --------------------------------------------------------------- */
header{background:var(--bg);border-bottom:1px solid var(--line);position:sticky;top:0;z-index:5}
.header-inner{max-width:860px;margin:0 auto;padding:16px 24px;
  display:flex;align-items:center;gap:16px}
.logo{height:34px;width:auto;flex:none}
.header-cover{margin-left:auto;flex:none;height:46px;width:auto;border-radius:5px;
  border:1px solid var(--line);box-shadow:var(--shadow)}
.brand h1{font-family:var(--display);font-weight:700;font-size:21px;margin:0;
  letter-spacing:.2px;color:var(--ink)}
.brand h1 .amp{color:var(--red)}
.brand .sub{display:block;color:var(--muted);font-size:12.5px;font-weight:500;margin-top:2px}
.tag{margin-left:auto;font-size:12px;font-weight:600;color:var(--red);
  border:1px solid var(--red);border-radius:999px;padding:5px 13px;white-space:nowrap}

[hidden]{display:none !important}

/* ---- Landing (welcome) view ----------------------------------------------- */
#welcome{flex:1;display:flex;align-items:center;justify-content:center;
  width:100%;overflow-y:auto;padding:24px}
.welcome-inner{display:flex;flex-direction:column;align-items:center;
  width:100%;max-width:560px;gap:20px;padding:20px 0}
.author{width:96px;height:96px;border-radius:50%;object-fit:cover;object-position:center top;
  border:3px solid #fff;box-shadow:var(--shadow);margin-bottom:-4px}
.cover{width:auto;height:auto;max-width:200px;max-height:280px;border-radius:10px;
  border:1px solid var(--line);box-shadow:var(--shadow)}
@media (min-width:700px){
  .author{width:116px;height:116px}
  .cover{max-width:300px;max-height:420px}
}
.welcome-tag{margin:0;color:var(--ink-soft);font-size:16px;text-align:center}
#welcome .suggest{justify-content:center;margin:0}
#composer-slot{width:100%}

/* ---- Chat scroll area (full width; content centered) ---------------------- */
#chat{flex:1;overflow-y:auto;width:100%}
#chat-inner{max-width:860px;margin:0 auto;padding:22px 24px 8px}

.msg{display:flex;margin:20px 0}
.msg .body{font-size:16px}
/* Assistant: avatar + plain text on the canvas, left-aligned, no bubble */
.msg.bot{justify-content:flex-start;gap:12px}
.msg.bot .body{flex:1;min-width:0;padding:0;padding-top:4px}
.msg .avatar{flex:none;width:34px;height:34px;border-radius:50%;object-fit:cover;
  object-position:center top;border:1px solid var(--line)}
/* User: right-aligned bubble */
.msg.user{justify-content:flex-end}
.msg.user .body{max-width:80%;background:var(--ink);color:#fff;white-space:pre-wrap;
  border-radius:16px;padding:12px 16px}
.msg .body.typing{color:var(--muted);font-style:italic}

/* ---- Markdown inside assistant bubbles ------------------------------------ */
.msg .body{overflow-wrap:anywhere}
.msg .body > :first-child{margin-top:0}
.msg .body > :last-child{margin-bottom:0}
.msg .body p{margin:0 0 10px}
.msg .body ul,.msg .body ol{margin:0 0 10px;padding-left:22px}
.msg .body li{margin:4px 0}
.msg .body li > ul,.msg .body li > ol{margin:4px 0}
.msg .body h1,.msg .body h2,.msg .body h3,.msg .body h4{
  font-family:var(--display);font-weight:600;line-height:1.3;margin:16px 0 8px;color:var(--ink)}
.msg .body h1{font-size:20px}
.msg .body h2{font-size:18px}
.msg .body h3{font-size:16px}
.msg .body strong{font-weight:600;color:var(--ink)}
.msg .body a{color:var(--red);text-decoration:none;border-bottom:1px solid var(--red-tint)}
.msg .body a:hover{border-bottom-color:var(--red)}
.msg .body blockquote{margin:0 0 10px;padding:4px 16px;border-left:3px solid var(--red);
  color:var(--ink-soft)}
.msg .body code{background:#fff;border:1px solid var(--line-strong);border-radius:5px;
  padding:1px 6px;font-size:14px;font-family:ui-monospace,Consolas,monospace}
.msg .body pre{background:#fbfafa;border:1px solid var(--line-strong);border-radius:10px;
  padding:14px;overflow-x:auto;margin:0 0 10px}
.msg .body pre code{background:none;border:0;padding:0}
.msg .body hr{border:0;border-top:1px solid var(--line);margin:14px 0}
.msg .body table{border-collapse:collapse;margin:0 0 10px;font-size:14px}
.msg .body th,.msg .body td{border:1px solid var(--line-strong);padding:7px 11px;text-align:left}
.msg .body th{background:#fbfafa}

/* ---- Inline figures (diagrams from the book) ------------------------------ */
.msg .body figure.bookfig{margin:14px 0;padding:0}
.msg .body figure.bookfig img{display:block;max-width:100%;height:auto;background:#fff;
  border:1px solid var(--line-strong);border-radius:12px;padding:8px;box-shadow:var(--shadow)}
.msg .body figure.bookfig figcaption{margin-top:7px;font-size:12px;font-weight:500;
  color:var(--muted);text-align:center}

/* ---- Bottom dock (full width; content centered) --------------------------- */
.dock{background:var(--bg);border-top:1px solid var(--line);position:sticky;bottom:0}
.dock-inner{max-width:860px;margin:0 auto;padding:14px 24px 18px}
.suggest{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:12px}
.suggest button{background:#fff;color:var(--ink);border:1px solid var(--line-strong);
  border-radius:999px;padding:8px 15px;font-family:var(--ui);font-size:13px;font-weight:500;
  cursor:pointer;transition:border-color .15s,color .15s}
.suggest button:hover{border-color:var(--red);color:var(--red)}
.composer{display:flex;gap:10px;align-items:flex-end}
textarea{flex:1;resize:none;overflow-y:hidden;background:#fff;border:1px solid var(--line-strong);
  color:var(--ink);border-radius:14px;padding:13px 15px;font-size:16px;font-family:var(--ui);
  max-height:200px;line-height:1.5;transition:border-color .15s,box-shadow .15s}
textarea:focus{outline:none;border-color:var(--red);box-shadow:0 0 0 3px var(--red-tint)}
.composer button{background:var(--red);color:#fff;border:0;border-radius:14px;
  padding:0 24px;height:48px;font-family:var(--ui);font-weight:600;font-size:15px;cursor:pointer;
  transition:background .15s}
.composer button:hover{background:var(--red-dark)}
.composer button:disabled{opacity:.45;cursor:not-allowed}
.hint{color:var(--muted);font-size:12px;text-align:center;margin:10px 0 0}

/* ---- Subtle scrollbar ----------------------------------------------------- */
#chat{scrollbar-width:thin;scrollbar-color:var(--line-strong) transparent}
#chat::-webkit-scrollbar{width:10px}
#chat::-webkit-scrollbar-thumb{background:var(--line-strong);border-radius:999px;
  border:3px solid var(--bg)}
#chat::-webkit-scrollbar-thumb:hover{background:var(--muted)}
