:root {
  --paper: #f3eee5;
  --paper-2: #ebe4d7;
  --ink: #1f1b16;
  --ink-2: #5b5349;
  --ink-3: #8f8577;
  --line: #d9d0c1;
  --accent: #d4542a;
  --accent-ink: #fff7f0;
  --card: #fbf8f2;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: ui-sans-serif, -apple-system, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
#dither { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; opacity: .55; image-rendering: pixelated; }
button { font: inherit; cursor: pointer; }
[hidden] { display: none !important; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 18px; padding: 12px 20px; background: color-mix(in srgb, var(--paper) 86%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 140px; }
.brand canvas { width: 32px; height: 32px; image-rendering: pixelated; border-radius: 50%; }
.brand b { font-family: var(--serif); font-size: 20px; letter-spacing: -.01em; }
.brand span { display: block; font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .08em; line-height: 1; }
.rail { display: flex; gap: 4px; list-style: none; margin: 0 auto; padding: 0; counter-reset: s; }
.rail li { counter-increment: s; font-size: 12.5px; color: var(--ink-3); padding: 5px 10px; border-radius: 999px; white-space: nowrap; transition: all .3s; }
.rail li::before { content: counter(s) "  "; font-family: var(--mono); font-size: 11px; opacity: .7; }
.rail li.done { color: var(--ink-2); }
.rail li.on { background: var(--ink); color: var(--paper); }
.top-actions { display: flex; gap: 6px; min-width: 140px; justify-content: flex-end; }
.ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); padding: 6px 12px; border-radius: 999px; font-size: 13px; }
.ghost:hover { border-color: var(--ink-2); }
.ghost.tiny { padding: 6px 10px; }
#skillsBtn span { font-family: var(--mono); font-size: 11px; color: var(--accent); }

main { position: relative; z-index: 1; max-width: 720px; margin: 0 auto; padding: 32px 20px 220px; }
.gate { padding-top: 14vh; }
.gate h1, .intro h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(34px, 6vw, 52px); line-height: 1.05; letter-spacing: -.02em; margin: 0 0 14px; }
.intro h1 em { color: var(--accent); }
.intro p, .gate p { color: var(--ink-2); max-width: 520px; font-size: 17px; }
.intro { margin: 6vh 0 36px; animation: rise .6s ease both; }
.gate form { display: flex; gap: 8px; margin-top: 18px; max-width: 420px; }
.gate input { flex: 1; font: inherit; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.gate button, .primary { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 600; }
.primary:hover, .gate button:hover { filter: brightness(1.05); }
.err { color: var(--accent); font-size: 14px; }

.log { display: flex; flex-direction: column; gap: 18px; }
.msg { animation: rise .35s ease both; max-width: 100%; }
.msg.bean { font-size: 17px; }
.msg.bean .who { font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: 4px; }
.msg.user { align-self: flex-end; background: var(--ink); color: var(--paper); padding: 10px 14px; border-radius: 16px 16px 4px 16px; max-width: 80%; white-space: pre-wrap; }
.msg.note { align-self: center; font-size: 13px; color: var(--ink-3); }
.md p { margin: 0 0 .6em; } .md p:last-child { margin-bottom: 0; }
.md ul, .md ol { margin: .3em 0 .7em; padding-left: 1.2em; } .md li { margin: .15em 0; }
.md h1, .md h2, .md h3 { font-family: var(--serif); font-weight: 500; line-height: 1.2; margin: 1em 0 .4em; }
.md h1 { font-size: 26px; } .md h2 { font-size: 21px; } .md h3 { font-size: 18px; }
.md code { font-family: var(--mono); font-size: .88em; background: var(--paper-2); padding: 1px 5px; border-radius: 5px; }
.md pre { background: var(--paper-2); padding: 12px; border-radius: 10px; overflow: auto; } .md pre code { background: none; padding: 0; }
.md blockquote { margin: .5em 0; padding-left: 12px; border-left: 3px solid var(--line); color: var(--ink-2); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 1em 0; }
.md strong { font-weight: 650; }
.md .tbl { overflow-x: auto; margin: .4em 0 .8em; }
.md table { border-collapse: collapse; font-size: 14px; width: 100%; }
.md th, .md td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.md th { font-weight: 600; color: var(--ink-2); font-size: 12.5px; }
.typing { display: inline-flex; gap: 4px; padding: 6px 0; }
.typing i { width: 6px; height: 6px; background: var(--ink-3); border-radius: 50%; animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }

.cta { margin-top: 22px; display: flex; flex-wrap: wrap; gap: 10px; animation: rise .4s ease both; }
.inline-skills { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-top: 12px; }

.composer { position: fixed; z-index: 4; left: 0; right: 0; bottom: 0; padding: 10px 20px calc(10px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--paper) 28%); }
.composer > * { max-width: 720px; margin-left: auto; margin-right: auto; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; min-height: 0; }
.chip { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 14px; color: var(--ink); animation: rise .3s ease both; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
#form { display: flex; gap: 8px; align-items: flex-end; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 8px 8px 8px 16px; box-shadow: 0 8px 30px -18px rgba(40,30,20,.35); }
#form:focus-within { border-color: var(--ink-3); }
#input { flex: 1; border: 0; outline: 0; resize: none; font: inherit; font-size: 16px; background: transparent; max-height: 180px; padding: 6px 0; color: var(--ink); }
#sendBtn { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--ink); color: var(--paper); font-size: 17px; flex: none; }
#sendBtn:disabled { opacity: .35; }
.fine { font-size: 11.5px; color: var(--ink-3); text-align: center; margin-top: 6px; }

.sheet { position: fixed; inset: 0; z-index: 10; background: rgba(31,27,22,.28); backdrop-filter: blur(3px); display: flex; justify-content: flex-end; animation: fade .2s ease both; }
.sheet-inner { width: min(760px, 100%); height: 100%; overflow: auto; background: var(--paper); border-left: 1px solid var(--line); padding: 22px 24px 60px; animation: slide .3s ease both; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; position: sticky; top: -22px; background: var(--paper); padding: 6px 0 12px; z-index: 2; }
.sheet-head h2 { font-family: var(--serif); font-weight: 400; font-size: 28px; margin: 0; }
.cat { font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); margin: 22px 0 8px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 6px; position: relative; transition: border-color .2s, transform .2s; }
.card:hover { border-color: var(--ink-3); transform: translateY(-1px); }
.card.rec { border-color: var(--accent); }
.card h3 { font-family: var(--serif); font-weight: 500; font-size: 18px; margin: 0; }
.card p { margin: 0; font-size: 14px; color: var(--ink-2); }
.card .why { color: var(--accent); font-size: 13.5px; }
.card .row { display: flex; gap: 6px; margin-top: auto; padding-top: 8px; }
.card .row button { font-size: 13px; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--line); background: transparent; }
.card .row .try { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.card .row .add.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.badge { position: absolute; top: 12px; right: 12px; font-family: var(--mono); font-size: 10px; color: var(--accent); letter-spacing: .06em; text-transform: uppercase; }

.demo textarea { width: 100%; min-height: 140px; font: inherit; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); resize: vertical; }
.demo .hint { color: var(--ink-2); }
.demo .out { margin-top: 18px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.demo .actions { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.muted { color: var(--ink-3); font-size: 13px; }

.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 14px; }
.tabs button { font-family: var(--mono); font-size: 12px; padding: 5px 10px; border-radius: 8px; border: 1px solid var(--line); background: transparent; color: var(--ink-2); }
.tabs button.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.filebox { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; }
.packbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.progress { height: 3px; background: var(--line); border-radius: 3px; overflow: hidden; margin: 18px 0; }
.progress i { display: block; height: 100%; width: 30%; background: var(--accent); animation: slidebar 1.4s ease-in-out infinite; }

@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide { from { transform: translateX(30px); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@keyframes slidebar { 0% { transform: translateX(-100%); } 100% { transform: translateX(340%); } }

@media (max-width: 860px) {
  .rail li { font-size: 0; padding: 5px 8px; } .rail li::before { font-size: 11px; }
  .rail li.on { font-size: 12px; }
  .brand, .top-actions { min-width: 0; }
  .top { gap: 8px; padding: 10px 12px; }
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-left: -20px; margin-right: -20px; padding: 0 20px; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }

body.gated .rail, body.gated .top-actions { visibility: hidden; }
