:root {
  --ink: #0d0d0d;
  --muted: #6b6b6b;
  --faint: #a0a0a0;
  --line: rgba(0, 0, 0, 0.09);
  --line-strong: rgba(0, 0, 0, 0.16);
  --accent: #4a90e2;
  --accent-deep: #3186ff;
  --accent-press: #3a7bc8;
  --accent-soft: rgba(74, 144, 226, 0.10);
  --bg: #ffffff;
  --panel: rgba(255, 255, 255, 0.92);
  --dot: rgba(0, 0, 0, 0.12);
  --danger: #c4372f;
  --ff-sans: 'Google Sans Flex', 'Google Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --ff-mono: 'Google Sans Code', ui-monospace, 'SF Mono', Menlo, monospace;
  --r: 4px;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh; display: flex; flex-direction: column;
  font-family: var(--ff-sans); color: var(--ink); background-color: var(--bg);
  background-image: radial-gradient(var(--dot) 1px, transparent 1px); background-size: 20px 20px;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--ff-mono); }

/* ── nav ── */
.nav { width: 100%; max-width: 1080px; margin: 0 auto; padding: 18px 16px; display: flex; align-items: center; justify-content: space-between; }
.nav-brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; letter-spacing: 0.14em; font-size: 15px; }
.nav-brand img { width: 26px; height: 26px; display: block; }
.nav-links { display: flex; gap: 22px; }
.nav-links a { font-family: var(--ff-mono); font-size: 12px; letter-spacing: 0.16em; text-decoration: none; color: var(--muted); }
.nav-links a:hover, .nav-links a[aria-current="page"] { color: var(--ink); }

.page { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 40px 16px 56px; display: flex; flex-direction: column; gap: 40px; }
footer { padding: 24px 16px 32px; text-align: center; font-family: var(--ff-mono); font-size: 12px; color: var(--faint); letter-spacing: 0.06em; }

/* ── hero + search ── */
.hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; }
.hero-title { margin: 0; font-size: clamp(40px, 8vw, 64px); font-weight: 700; letter-spacing: 0.12em; line-height: 1; padding-left: 0.12em; }
.hero-subtitle { margin: 0 0 18px; font-family: var(--ff-mono); font-size: 13px; letter-spacing: 0.32em; color: var(--muted); padding-left: 0.32em; }
.search {
  width: 100%; max-width: 560px; display: flex; align-items: center; gap: 6px; padding: 5px;
  background: #fff; border: 1px solid var(--line-strong); border-radius: var(--r);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  transition: border-color .2s ease, box-shadow .2s ease;
}
.search:focus-within { border-color: rgba(74, 144, 226, 0.6); box-shadow: 0 6px 24px rgba(74, 144, 226, 0.14); }
.search-input { flex: 1; min-width: 0; border: none; outline: none; background: transparent; font: inherit; font-size: 15px; color: var(--ink); padding: 8px 6px; }
.search-input::placeholder { color: var(--faint); }
.btn-sq {
  flex: none; width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: var(--r); cursor: pointer; transition: background-color .15s ease, transform .1s ease;
}
.btn-sq svg { width: 18px; height: 18px; }
.btn-sq:active { transform: scale(0.94); }
.btn-sq:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }
.search-create.locked textarea { opacity: 0.55; cursor: not-allowed; }
.btn-sq:focus-visible, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-add { background: #f0f0f0; color: var(--ink); }
.btn-add:hover { background: #e4e4e4; }
.btn-go { background: var(--accent); color: #fff; }
.btn-go:hover { background: var(--accent-press); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 0 14px;
  border-radius: var(--r); border: 1px solid var(--line-strong); background: #fff; color: var(--ink);
  font: inherit; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-press); border-color: var(--accent-press); }
.btn-small { min-height: 30px; padding: 0 10px; font-size: 12px; font-family: var(--ff-mono); letter-spacing: 0.08em; }
.btn[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }

.status { max-width: 560px; line-height: 1.5; text-align: center; min-height: 20px; margin: 4px 0 0; font-family: var(--ff-mono); font-size: 12px; color: var(--muted); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: center; }
.linkbtn { border: none; background: none; padding: 0; font: inherit; color: var(--accent-deep); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* ── modes + create form ── */
.modes { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r); background: #fff; padding: 3px; gap: 3px; margin: 0 0 14px; }
.modes button { border: none; background: none; padding: 8px 14px; border-radius: 3px; font-family: var(--ff-mono); font-size: 12px; letter-spacing: 0.12em; color: var(--muted); cursor: pointer; }
.modes button[aria-selected="true"] { background: var(--ink); color: #fff; }
.modes button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.panel-search, .panel-create { width: 100%; display: flex; flex-direction: column; align-items: center; }
.search-create { position: relative; align-items: flex-end; }
.search-create textarea.search-input { resize: none; overflow-y: auto; line-height: 1.5; min-height: 40px; max-height: 220px; padding-top: 9px; font-family: inherit; }
.status .err { color: var(--danger); }
.panel-create .job { max-width: 560px; }
.draft { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: start; }
.draft-body { min-width: 0; }
.draft .btn-gen { margin-top: 26px; }
.draft-text { display: block; width: 100%; margin: 8px 0 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r); background: #fff; font: inherit; font-size: 14px; line-height: 1.65; color: var(--ink); resize: none; overflow: hidden; }
.draft-text:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.draft-wait { margin: 10px 0 0; font-size: 14px; color: var(--muted); }
.job-head label { cursor: text; }
.draft-err { margin: 8px 0 0; font-size: 13px; color: var(--danger); }
.btn-gen { width: 64px; height: 64px; border: none; border-radius: var(--r); background: var(--accent); color: #fff; font-family: var(--ff-mono); font-size: 14px; font-weight: 500; letter-spacing: 0.12em; cursor: pointer; }
.btn-gen:hover { background: var(--accent-press); }
.btn-gen:disabled { opacity: .6; cursor: default; }
.btn-gen:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pulse { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }

/* ── job panel ── */
.job { width: 100%; max-width: 560px; margin: 6px auto 0; padding: 16px; border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--panel); text-align: left; }
.job[hidden] { display: none; }
.job-head { display: flex; justify-content: space-between; gap: 12px; font-family: var(--ff-mono); font-size: 12px; color: var(--muted); letter-spacing: 0.08em; }
.steps { list-style: none; margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.steps li { font-family: var(--ff-mono); font-size: 11px; letter-spacing: 0.08em; color: var(--faint); padding-top: 8px; border-top: 2px solid var(--line-strong); }
.steps li.on { color: var(--accent-deep); border-top-color: var(--accent); }
.steps li.now { color: var(--ink); border-top-color: var(--ink); }
.steps li.now::after { content: ' …'; }
.job-msg { margin: 12px 0 0; font-size: 14px; line-height: 1.5; }
.job-msg.err { color: var(--danger); }
.confirm { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.confirm input { flex: 1; min-width: 160px; min-height: 38px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--r); font: inherit; font-size: 14px; }

/* ── gallery ── */
.section-label { font-family: var(--ff-mono); font-size: 12px; letter-spacing: 0.2em; color: var(--muted); margin: 0 0 -20px; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
@media (max-width: 860px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .grid { grid-template-columns: 1fr; } .page { padding-top: 24px; } }
.card { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 16px 12px 20px; border-radius: var(--r); text-decoration: none; transition: background-color .2s ease, transform .2s ease; }
.card:hover { background: rgba(255, 255, 255, 0.9); transform: translateY(-2px); }
.card-id { font-family: var(--ff-mono); font-size: 12px; letter-spacing: 0.1em; color: var(--faint); }
.card-view { width: 100%; height: 190px; margin: 8px 0; position: relative; }
.card-name { margin: 0 0 4px; font-size: 16px; font-weight: 700; }
.card-desc { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.5; }
.card-desc i { font-style: italic; }
.view-msg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--ff-mono); font-size: 12px; color: var(--faint); }
canvas.three { display: block; width: 100% !important; height: 100% !important; }
.empty { text-align: center; color: var(--muted); font-size: 14px; }
.more { display: flex; justify-content: center; }

/* ── specimen page ── */
.spec-wrap { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 32px; align-items: start; }
@media (max-width: 860px) { .spec-wrap { grid-template-columns: 1fr; } }
.stage { position: relative; height: 520px; border: 1px solid var(--line); border-radius: var(--r); background: rgba(255, 255, 255, 0.6); }
@media (max-width: 560px) { .stage { height: 360px; } }
.stage-bar { position: absolute; left: 12px; right: 12px; bottom: 12px; display: flex; gap: 6px; flex-wrap: wrap; }
.prompt-text { margin: 8px 0 0; font-size: 12px; color: var(--muted); font-family: var(--ff-mono); }
.desc-text { margin: 0; font-size: 15px; line-height: 1.65; white-space: pre-wrap; }
.clip-note { align-self: center; font-family: var(--ff-mono); font-size: 11px; color: var(--faint); }
.stage-hint { position: absolute; top: 12px; right: 12px; font-family: var(--ff-mono); font-size: 11px; color: var(--faint); }
.info h1 { margin: 4px 0 2px; font-size: 30px; line-height: 1.15; }
.info .sci { margin: 0; color: var(--muted); font-style: italic; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 0; padding: 0; list-style: none; }
.chips li { font-family: var(--ff-mono); font-size: 11px; letter-spacing: 0.08em; padding: 4px 8px; border: 1px solid var(--line-strong); border-radius: var(--r); background: #fff; }
.block { margin-top: 26px; }
.block h2 { margin: 0 0 10px; font-family: var(--ff-mono); font-size: 12px; font-weight: 500; letter-spacing: 0.2em; color: var(--muted); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.slider { display: grid; grid-template-columns: 90px 1fr 64px; align-items: center; gap: 10px; margin: 8px 0; font-size: 14px; }
.slider input { width: 100%; accent-color: var(--accent); }
.slider output { font-family: var(--ff-mono); font-size: 12px; text-align: right; }
.prov { font-family: var(--ff-mono); font-size: 11px; line-height: 1.7; color: var(--muted); word-break: break-word; }
.prov b { color: var(--ink); font-weight: 500; }
.tag-stub { color: #b06a00; }
.lineage a { color: var(--accent-deep); }
.lineage ul { margin: 6px 0 0; padding-left: 18px; font-size: 14px; }

/* ── text pages ── */
.prose { width: 100%; min-width: 0; max-width: 680px; margin: 0 auto; line-height: 1.7; font-size: 16px; }
.prose h1 { font-size: 34px; letter-spacing: 0.04em; margin: 0 0 8px; }
.prose h2 { font-family: var(--ff-mono); font-size: 12px; font-weight: 500; letter-spacing: 0.2em; color: var(--muted); margin: 36px 0 8px; }
.prose ol { padding-left: 20px; }
.prose .lead { font-size: 18px; color: var(--muted); }
.prose a { color: inherit; text-underline-offset: 3px; }
.prose a.btn { text-decoration: none; }
.prose a.btn-primary { color: #fff; }
.prose ul { padding-left: 20px; }
.prose code { font-family: var(--ff-mono); font-size: 0.88em; background: #f4f4f4; padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere; }
.prose pre { font-family: var(--ff-mono); font-size: 13px; line-height: 1.6; background: #f6f6f6; border: 1px solid var(--line, #e6e6e6); border-radius: 8px; padding: 14px 16px; overflow-x: auto; }
.prose pre code { background: none; padding: 0; font-size: inherit; }
.prose table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 8px 0; }
.prose th, .prose td { text-align: left; vertical-align: top; padding: 7px 10px 7px 0; border-bottom: 1px solid var(--line, #e6e6e6); }
.prose th { font-family: var(--ff-mono); font-size: 11px; font-weight: 500; letter-spacing: 0.14em; color: var(--muted); }
.prose .table-wrap { overflow-x: auto; }

/* back link on text pages */
.prose .back { display: inline-block; font-family: var(--ff-mono); font-size: 14px; text-decoration: none; color: var(--muted); border: 1px solid var(--line, #e6e6e6); border-radius: 6px; padding: 2px 10px; margin-bottom: 16px; }
.prose .back:hover { color: var(--ink); border-color: var(--ink); }
/* Ko-fi embedded donation panel */
.prose .kofi { display: block; width: 100%; border: none; border-radius: 8px; background: #f9f9f9; }
.prose .kofi-alt { font-size: 13px; color: var(--muted); }
