:root {
  --bg: #F2EBDD;
  --bg-2: #ECE2CF;
  --paper: #FCF8F0;
  --ink: #16130E;
  --ink-soft: #574F41;
  --muted: #8B8273;
  --line: #E1D6C1;
  --accent: #FF5A2C;
  --accent-ink: #C23C15;
  --accent-soft: #FFE3D6;
  --cobalt: #1E2A66;
  --cobalt-soft: #3C4AA6;
  --mint: #1F8F6B;
  --disp: "Bricolage Grotesque", Georgia, "Times New Roman", serif;
  --sans: "Space Grotesk", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  --maxw: 1080px;
  --shadow: 6px 7px 0 var(--ink);
  --shadow-cobalt: 6px 7px 0 var(--cobalt);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans);
  line-height: 1.6; overflow-x: hidden; -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--disp); font-weight: 800; margin: 0; letter-spacing: -0.02em; line-height: 1.02; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

.grain { position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: 0.05; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }

/* floating 3D letters */
.floaters { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.floaters span { position: absolute; left: var(--x); top: var(--y); font-family: var(--disp); font-weight: 800;
  font-size: clamp(70px, 12vw, 160px); color: var(--ink); opacity: 0.05; transform: rotate(var(--r));
  animation: float 9s ease-in-out infinite; animation-delay: var(--d); }
@keyframes float { 0%, 100% { translate: 0 0; } 50% { translate: 0 -26px; } }

/* ---------- nav ---------- */
.nav { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; justify-content: space-between;
  gap: 16px; max-width: var(--maxw); margin: 0 auto; padding: 18px clamp(18px, 4vw, 30px);
  background: rgba(242, 235, 221, 0.82); backdrop-filter: blur(6px); }
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; background: var(--accent); color: #fff;
  border: 2px solid var(--ink); border-radius: 11px; box-shadow: 3px 3px 0 var(--ink); font-family: var(--disp); font-weight: 800; }
.brand-mark b { font-size: 20px; line-height: 1; }
.brand-word { font-family: var(--disp); font-weight: 800; font-size: 22px; letter-spacing: -0.03em; }
.brand-word em { font-style: normal; color: var(--accent); }
.nav-links { display: flex; align-items: center; gap: clamp(12px, 2.5vw, 26px); }
.nav-links a { font-weight: 500; font-size: 15px; position: relative; }
.nav-links a:not(.btn)::after { content: ""; position: absolute; left: 0; bottom: -4px; height: 2px; width: 0; background: var(--accent); transition: width .25s ease; }
.nav-links a:not(.btn):hover::after { width: 100%; }
#keyDot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
#keyBtn.on #keyDot { background: var(--mint); box-shadow: 0 0 8px var(--mint); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; font-size: 15px;
  padding: 13px 20px; border: 2px solid var(--ink); border-radius: 12px; background: var(--paper); color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink); transition: transform .12s ease, box-shadow .12s ease, background .2s ease; }
.btn:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.tonal { background: var(--cobalt); color: #fff; }
.btn.ghost { background: transparent; box-shadow: none; border-color: var(--line); }
.btn.ghost:hover { border-color: var(--ink); box-shadow: 3px 3px 0 var(--ink); }
.btn.sm { padding: 8px 13px; font-size: 13.5px; border-radius: 10px; }
.btn:disabled { opacity: .55; pointer-events: none; }

.wrap { position: relative; z-index: 1; max-width: var(--maxw); margin: 0 auto; padding: 0 clamp(18px, 4vw, 30px) 60px; }
.eyebrow { display: inline-block; font-weight: 700; font-size: 12.5px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--accent-ink); background: var(--accent-soft); border: 1.5px solid var(--accent); padding: 5px 11px; border-radius: 999px; }

/* ---------- hero ---------- */
.hero { padding: clamp(30px, 6vw, 60px) 0 20px; }
.hero-head { max-width: 760px; }
.display { font-size: clamp(40px, 8vw, 82px); margin: 20px 0 0; letter-spacing: -0.035em; }
.rotator { display: inline-block; height: 1em; overflow: hidden; vertical-align: bottom; }
.rot-track { display: flex; flex-direction: column; animation: roll 9s cubic-bezier(.7,0,.2,1) infinite; }
.rot-track i { height: 1em; font-style: normal; color: var(--accent); }
@keyframes roll {
  0%, 18% { transform: translateY(0); } 22%, 40% { transform: translateY(-1em); }
  44%, 62% { transform: translateY(-2em); } 66%, 84% { transform: translateY(-3em); }
  88%, 100% { transform: translateY(-4em); } }
.lede { font-size: clamp(16px, 2.1vw, 20px); color: var(--ink-soft); margin-top: 22px; max-width: 52ch; }

/* console */
.console { margin-top: 34px; background: var(--paper); border: 2px solid var(--ink); border-radius: 20px;
  box-shadow: var(--shadow); padding: clamp(20px, 3vw, 30px); display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-weight: 700; font-size: 14px; }
.field label .opt { font-weight: 400; color: var(--muted); font-size: 12.5px; margin-left: 6px; }
.field input, .select-wrap select {
  width: 100%; padding: 13px 15px; font-family: var(--sans); font-size: 16px; color: var(--ink);
  background: var(--bg); border: 2px solid var(--ink); border-radius: 12px; }
.field input::placeholder { color: var(--muted); }
.field input:focus, .select-wrap select:focus { outline: none; box-shadow: 0 0 0 4px var(--accent-soft); border-color: var(--accent); }
.field-row { display: grid; grid-template-columns: 1fr 1.2fr; gap: 18px; }
.select-wrap { position: relative; }
.select-wrap select { appearance: none; -webkit-appearance: none; cursor: pointer; }
.select-wrap::after { content: "▾"; position: absolute; right: 14px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 9px; }
.chip { font-weight: 600; font-size: 14px; padding: 9px 14px; border: 2px solid var(--ink); border-radius: 999px;
  background: var(--paper); transition: transform .1s ease, background .2s ease, color .2s ease; }
.chip:hover { transform: translateY(-2px); }
.chip.is-active { background: var(--ink); color: var(--paper); }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 4px; }
.actions .btn.primary { flex: 1 1 auto; }
.ai-status { min-height: 18px; font-size: 13.5px; color: var(--ink-soft); font-weight: 500; }
.ai-status.think { color: var(--accent-ink); }

/* ---------- results ---------- */
.results-wrap { margin-top: 44px; }
.results-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 18px; }
.results-head h2 { font-size: clamp(22px, 3vw, 30px); }
.count { color: var(--muted); font-size: 14px; font-weight: 600; }
.results { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.placeholder { grid-column: 1 / -1; border: 2px dashed var(--line); border-radius: 16px; padding: 46px 20px;
  text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.placeholder .ph-mark { font-size: 30px; color: var(--accent); }

.name { background: var(--paper); border: 2px solid var(--ink); border-radius: 15px; box-shadow: 4px 5px 0 var(--ink);
  padding: 16px 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  transform-style: preserve-3d; animation: tumbleIn .6s cubic-bezier(.3,.9,.3,1.1) both; will-change: transform; }
.name .n-main { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.name strong { font-family: var(--disp); font-weight: 700; font-size: clamp(19px, 2.4vw, 25px); letter-spacing: -0.02em; line-height: 1.05; word-break: break-word; }
.name .n-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; }
.tag.cat { background: var(--cobalt); color: #fff; }
.tag.sty { background: var(--accent-soft); color: var(--accent-ink); }
.n-actions { display: flex; gap: 7px; flex: none; }
.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; border: 2px solid var(--ink); border-radius: 10px;
  background: var(--bg); font-size: 15px; transition: transform .1s ease, background .2s ease; }
.icon-btn:hover { transform: translateY(-2px); }
.icon-btn.saved { background: var(--accent); color: #fff; }
@keyframes tumbleIn { from { opacity: 0; transform: perspective(800px) rotateX(-58deg) translateY(26px); } to { opacity: 1; transform: perspective(800px) rotateX(0) translateY(0); } }

/* ---------- favorites ---------- */
.card { background: var(--paper); border: 2px solid var(--ink); border-radius: 20px; box-shadow: var(--shadow-cobalt); padding: clamp(22px, 3vw, 30px); }
.favs { margin-top: 44px; }
.favs-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.favs-head h2 { font-size: 22px; }
.favs-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.fav-list { display: flex; flex-wrap: wrap; gap: 10px; }
.fav-chip { display: inline-flex; align-items: center; gap: 8px; background: var(--bg); border: 2px solid var(--ink);
  border-radius: 999px; padding: 8px 8px 8px 15px; font-weight: 600; }
.fav-chip button { border: none; background: none; font-size: 16px; color: var(--muted); width: 22px; height: 22px; border-radius: 50%; }
.fav-chip button:hover { color: var(--accent); }

/* ---------- how ---------- */
.how { margin-top: 64px; }
.how-head { text-align: center; margin-bottom: 30px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.how-head h2 { font-size: clamp(26px, 4vw, 40px); }
.how-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.how-card { background: var(--paper); border: 2px solid var(--ink); border-radius: 16px; box-shadow: 4px 5px 0 var(--ink);
  padding: 24px; display: flex; flex-direction: column; gap: 8px; transition: box-shadow .2s ease; will-change: transform; }
.how-num { font-family: var(--disp); font-weight: 800; font-size: 30px; color: var(--accent); }
.how-card h3 { font-size: 20px; }
.how-card p { color: var(--ink-soft); font-size: 14.5px; }

/* ---------- blog ---------- */
.blog { margin-top: 44px; }
.blog-controls { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between; margin: 6px 0 22px; }
#blogSearch { flex: 1 1 220px; max-width: 320px; padding: 11px 14px; border: 2px solid var(--ink); border-radius: 11px; background: var(--bg); font-family: var(--sans); font-size: 15px; }
#blogSearch:focus { outline: none; box-shadow: 0 0 0 4px var(--accent-soft); border-color: var(--accent); }
.blog-filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filter { font-weight: 600; font-size: 13.5px; padding: 7px 13px; border: 2px solid var(--ink); border-radius: 999px; background: var(--paper); }
.filter.is-active { background: var(--ink); color: var(--paper); }
.blog-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.blog-card { background: var(--bg); border: 2px solid var(--ink); border-radius: 14px; padding: 18px; display: flex; flex-direction: column; gap: 8px; transition: transform .18s ease, box-shadow .18s ease; }
.blog-card:hover { transform: translateY(-3px); box-shadow: 4px 5px 0 var(--ink); }
.blog-card h3 { font-size: 18px; }
.blog-card .meta { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.blog-card p { font-size: 14px; color: var(--ink-soft); }
.blog-card .btn { align-self: flex-start; margin-top: 4px; }

.foot { margin-top: 56px; padding-top: 24px; border-top: 2px solid var(--line); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; color: var(--ink-soft); font-size: 14px; font-weight: 500; }

/* ---------- modal + toast ---------- */
.modal { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 20px; background: rgba(22,19,14,.5); backdrop-filter: blur(3px); }
.modal[hidden] { display: none; }
.modal-card { position: relative; width: min(460px, 100%); background: var(--paper); border: 2px solid var(--ink); border-radius: 20px; box-shadow: 8px 9px 0 var(--cobalt); padding: 30px; }
.modal-close { position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; border: 2px solid var(--ink); border-radius: 9px; background: var(--bg); font-size: 15px; }
.modal-card h3 { font-size: 26px; }
.modal-sub { color: var(--ink-soft); font-size: 14.5px; margin: 10px 0 18px; }
.modal-card label { font-weight: 700; font-size: 13px; }
.modal-card input { width: 100%; margin-top: 7px; padding: 12px 14px; border: 2px solid var(--ink); border-radius: 11px; background: var(--bg); font-family: var(--sans); font-size: 15px; }
.modal-card input:focus { outline: none; box-shadow: 0 0 0 4px var(--accent-soft); border-color: var(--accent); }
.modal-actions { display: flex; align-items: center; gap: 10px; margin-top: 18px; }
.modal-actions .spacer { flex: 1; }
.modal-note { min-height: 16px; margin-top: 12px; font-size: 13px; font-weight: 600; }
.modal-note.ok { color: var(--mint); } .modal-note.err { color: var(--accent-ink); }

.toast { position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px); z-index: 95; background: var(--ink); color: var(--paper);
  padding: 12px 20px; border-radius: 999px; font-weight: 600; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .3s ease, transform .3s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .nav-links a:not(.btn) { display: none; }
  .floaters { display: none; }
  .field-row { grid-template-columns: 1fr; }
  .results, .how-grid, .blog-grid { grid-template-columns: 1fr; }
  .actions .btn { flex: 1 1 100%; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .floaters span, .rot-track { animation: none; }
  .name { animation: none; }
  * { transition-duration: 0.001ms !important; }
}
