:root {
  --ink: #1c1814;
  --muted: #6b645c;
  --line: #e6dfd4;
  --soft: #f4efe6;
  --paper: #faf6f0;
  --card: #fffcf7;
  --accent: #c45c26;
  --accent-hover: #a64b1c;
  --focus: rgb(196 92 38 / 28%);
  font-family: Figtree, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1000px 520px at 12% -18%, rgb(196 92 38 / 18%), transparent 58%),
    radial-gradient(720px 400px at 92% 4%, rgb(196 92 38 / 8%), transparent 52%),
    radial-gradient(700px 380px at 100% 8%, rgb(28 24 20 / 5%), transparent 50%),
    var(--paper);
}

.site-header {
  position: sticky; top: 0; z-index: 8;
  height: 76px; padding: 0 clamp(20px, 4vw, 48px);
  display: flex; align-items: center; gap: 12px;
  background: rgb(250 246 240 / 88%);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.site-header .button { margin-left: auto; }
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--ink); text-decoration: none;
  font-family: Fraunces, Georgia, serif;
  font-size: 22px; font-weight: 640; letter-spacing: -.04em;
}
.brand-mark {
  width: 11px; height: 11px; border-radius: 99px;
  background: var(--accent); box-shadow: 0 0 0 4px rgb(196 92 38 / 16%);
}
.catalog-spark {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 36px; padding: 0 12px 0 10px;
  border: 1px solid rgb(196 92 38 / 22%);
  border-radius: 999px;
  background: linear-gradient(180deg, #fff8f1, #f8eadc);
  color: var(--ink); text-decoration: none;
  box-shadow: 0 0 0 3px rgb(196 92 38 / 6%), 0 8px 18px rgb(196 92 38 / 8%);
}
.catalog-spark:hover { border-color: rgb(196 92 38 / 40%); }
.catalog-spark-num {
  font-family: Fraunces, Georgia, serif;
  font-size: 18px; font-weight: 640; letter-spacing: -.04em;
  color: var(--accent);
}
.catalog-spark-label { font-size: 13px; font-weight: 650; color: #7a4a2e; }
.spark {
  position: relative; width: 18px; height: 18px; flex: none;
}
.spark-star {
  position: absolute; background: var(--accent);
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
}
.spark-star-main { inset: 1px; }
.spark-star-a, .spark-star-b { width: 7px; height: 7px; opacity: .55; }
.spark-star-a { top: -3px; right: -4px; }
.spark-star-b { bottom: -2px; left: -3px; }
.button {
  border: 0; border-radius: 999px; min-height: 44px; padding: 0 18px;
  font-weight: 650; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
}
.button-primary { color: #fff; background: var(--accent); }
.button-primary:hover { background: var(--accent-hover); }
.button-lg { min-height: 52px; padding: 0 22px; font-size: 16px; }
.button-quiet {
  color: var(--ink); background: transparent;
  border: 1px solid var(--line);
}
.button-quiet:hover { background: #fff; }
.button:focus-visible, .text-button:focus-visible, .icon-button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--focus); outline-offset: 2px;
}

main { width: min(1080px, calc(100% - 40px)); margin: 0 auto; padding: 56px 0 72px; flex: 1; }

.kicker {
  margin: 0 0 18px; color: var(--accent);
  font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
}
.intro-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 260px);
  gap: 28px 40px;
  align-items: center;
}
.intro h1 {
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  font-size: clamp(48px, 7vw, 88px); line-height: .92; letter-spacing: -.055em; font-weight: 640;
}
.intro h1 em {
  display: block;
  font-style: italic;
  font-weight: 500;
  color: var(--accent);
}
.lede { margin: 18px 0 0; max-width: 560px; color: var(--ink); font-size: 19px; line-height: 1.5; font-weight: 500; }
.intro-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.intro-stat {
  display: grid; justify-items: center; text-align: center; gap: 6px;
  padding: 28px 22px 24px;
  border-radius: 28px;
  color: inherit; text-decoration: none;
  background: linear-gradient(165deg, #fffdf8, #f6e1d0);
  border: 1px solid rgb(196 92 38 / 24%);
  box-shadow: 0 24px 50px rgb(196 92 38 / 16%), 0 0 0 6px rgb(196 92 38 / 6%);
}
.intro-stat:hover { border-color: rgb(196 92 38 / 40%); }
.intro-stat-num {
  font-family: Fraunces, Georgia, serif;
  font-size: clamp(72px, 10vw, 108px);
  line-height: .8; letter-spacing: -.07em; font-weight: 640;
  color: var(--accent);
}
.intro-stat-label { font-size: 14px; font-weight: 750; letter-spacing: -.02em; }
.intro-stat-sub { font-size: 13px; font-weight: 600; color: var(--muted); }
.intro-steps {
  list-style: none; margin: 36px 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px;
  counter-reset: step;
}
.intro-steps li {
  margin: 0; padding: 16px 18px 16px 48px;
  position: relative;
  border: 1px solid var(--line); border-radius: 16px; background: var(--card);
  color: var(--muted); font-weight: 600; font-size: 15px; line-height: 1.4;
}
.intro-steps strong { color: var(--ink); }
.intro-steps li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute; left: 16px; top: 16px;
  width: 22px; height: 22px; border-radius: 99px;
  display: grid; place-items: center;
  background: var(--ink); color: #fff;
  font-size: 12px; font-weight: 750;
}
.intro-note { margin: 16px 0 0; color: var(--muted); font-size: 14px; font-weight: 600; }

.directory { margin-top: 56px; }
.directory-toolbar {
  padding: 22px; border: 1px solid var(--line); border-radius: 22px;
  background: var(--card); box-shadow: 0 18px 50px rgb(28 24 20 / 5%);
}
.search {
  width: 100%; min-height: 54px; display: flex; align-items: center; gap: 12px;
  padding: 0 16px; border: 1px solid var(--line); border-radius: 14px; background: #fff;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.search svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; flex: none; }
.search input { border: 0; outline: 0; width: 100%; font-size: 16px; background: transparent; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.filter {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 8px 14px; color: #4c463f; cursor: pointer; font-weight: 600; font-size: 14px;
}
.filter:hover { border-color: #cfc6b8; }
.filter[aria-pressed="true"] { color: #fff; background: var(--ink); border-color: var(--ink); }

.result-count { margin: 22px 0 16px; color: var(--muted); font-size: 13px; font-weight: 600; }
.template-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.template-row {
  position: relative;
  display: grid; gap: 16px; padding: 22px;
  border: 1px solid var(--line); border-radius: 20px; background: var(--card);
  min-height: 0;
}
.template-row:hover { border-color: #d3c9bb; box-shadow: 0 12px 30px rgb(28 24 20 / 6%); }
.card-hit { position: absolute; inset: 0; z-index: 1; border-radius: 20px; cursor: pointer; }
.card-link, .use-link { position: relative; z-index: 2; }
.card-top, .card-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-top-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.opens { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: -.01em; }
.bot-mark {
  width: 44px; height: 44px; display: grid; place-items: center;
  border-radius: 12px; flex: none;
}
.bot-mark svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.template-copy h2 { margin: 0 0 8px; font-size: 22px; letter-spacing: -.03em; font-family: Fraunces, Georgia, serif; font-weight: 640; }
.template-copy p { margin: 0; color: var(--muted); line-height: 1.45; }
.category {
  font-size: 12px; font-weight: 700; color: var(--ink);
  padding: 5px 10px; border-radius: 999px; background: var(--soft);
}
.creator { font-size: 14px; color: var(--muted); font-weight: 600; }
.card-link { color: inherit; text-decoration: none; }
.card-link:hover { text-decoration: underline; }
.use-link {
  display: inline-flex; flex-direction: row-reverse; gap: 8px; align-items: center;
  color: var(--accent); text-decoration: none; font-weight: 700; font-size: 14px;
}
.use-link:hover { text-decoration: underline; }
.use-link svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; }

.empty-state {
  padding: 56px 20px; text-align: center;
  border: 1px dashed var(--line); border-radius: 20px; background: rgb(255 252 247 / 60%);
}
.empty-state h2 { margin: 0 0 8px; font-family: Fraunces, Georgia, serif; }
.empty-state p { color: var(--muted); }
.text-button { padding: 0; border: 0; color: var(--accent); background: none; font-weight: 700; cursor: pointer; }

.site-footer {
  width: min(1080px, calc(100% - 40px)); margin: 0 auto;
  padding: 28px 0 48px; border-top: 1px solid var(--line);
}
.footer-brand {
  margin: 0 0 10px; font-family: Fraunces, Georgia, serif;
  font-size: 18px; font-weight: 640;
}
.footer-contact { margin: 0 0 12px; }
.footer-contact a { color: var(--ink); font-weight: 700; }
.site-footer p { margin: 0; max-width: 760px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.site-footer .footer-contact { margin-bottom: 12px; }

dialog {
  width: min(440px, calc(100% - 30px)); max-height: calc(100vh - 30px);
  padding: 0; border: 1px solid var(--line); border-radius: 20px;
  background: var(--card); box-shadow: 0 24px 70px rgb(28 24 20 / 22%);
}
dialog::backdrop { background: rgb(28 24 20 / 46%); }
.submit-form { padding: 28px; display: grid; gap: 16px; }
.dialog-header { display: flex; align-items: center; justify-content: space-between; }
.dialog-header h2 { margin: 0; font-family: Fraunces, Georgia, serif; font-size: 28px; letter-spacing: -.04em; font-weight: 640; }
.icon-button { width: 40px; height: 40px; border: 0; background: transparent; cursor: pointer; }
.icon-button svg { width: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.submit-form label { display: grid; gap: 8px; font-weight: 650; font-size: 14px; }
.submit-form input, .submit-form select, .submit-form textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: #fff; font-weight: 400;
}
.submit-form textarea { resize: vertical; }
.form-note { margin: -4px 0 0; color: var(--muted); font-size: 13px; }
#submit-error, #login-error { color: #b42318; }
.button-full { width: 100%; }
.hidden-field, .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.admin-main { width: min(760px, 100%); margin: 0 auto; padding: 56px 0 72px; flex: 1; }
.admin-login { max-width: 400px; padding: 0; }
.admin-list { display: grid; gap: 18px; margin-top: 8px; }
.admin-card {
  display: grid; gap: 16px; padding: 22px; border: 1px solid var(--line); border-radius: 16px; background: var(--card);
}
.admin-card dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0; }
.admin-card dt { color: var(--muted); font-size: 12px; font-weight: 650; }
.admin-card dd { margin: 4px 0 0; font-size: 14px; }
.admin-card .use-link { justify-self: start; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.status-pill {
  font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: 999px;
}
.status-pill.is-wait { background: #f3d9c8; color: #a64b1c; }
.status-pill.is-live { background: #dce8d8; color: #3f6b3a; }
.edit-form { display: grid; gap: 12px; padding-top: 8px; border-top: 1px solid var(--line); }
.edit-form[hidden] { display: none; }
.edit-form label { display: grid; gap: 6px; font-weight: 650; font-size: 14px; }
.edit-form input, .edit-form textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: #fff; font-weight: 400;
}
.button-ghost { color: var(--ink); background: var(--soft); }
.button-ghost:hover { background: #ece6db; }

@media (max-width: 820px) {
  .template-list { grid-template-columns: 1fr; }
  .intro-hero { grid-template-columns: 1fr; }
  .intro-stat { max-width: 280px; }
  .intro-steps { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .site-header { height: 68px; padding: 0 16px; }
  .brand { font-size: 18px; }
  .catalog-spark { padding: 0 10px 0 8px; gap: 6px; }
  .catalog-spark-label { display: none; }
  .site-header .button { min-height: 40px; padding: 0 14px; font-size: 14px; }
  main { width: calc(100% - 32px); padding-top: 36px; }
  .intro h1 { font-size: clamp(40px, 12vw, 56px); }
  .lede { font-size: 17px; }
  .intro-stat { justify-self: start; }
  .directory-toolbar { padding: 14px; }
  .submit-form { padding: 22px; }
  .admin-main { width: calc(100% - 36px); }
  .admin-card dl { grid-template-columns: 1fr; }
  .site-footer { width: calc(100% - 32px); }
}

@media (prefers-reduced-motion: no-preference) {
  dialog[open] { animation: appear 160ms ease-out; }
  @keyframes appear { from { opacity: 0; transform: translateY(8px) scale(.99); } }
  .spark-star-main { animation: spark-core 1.8s ease-in-out infinite; }
  .spark-star-a { animation: spark-flicker 1.1s ease-in-out infinite; }
  .spark-star-b { animation: spark-flicker 1.4s ease-in-out .25s infinite; }
  .catalog-spark.is-sparking .catalog-spark-num { animation: count-pop .45s ease-out; }
  .catalog-spark.is-sparking { animation: pill-glow .7s ease-out; }
  @keyframes spark-core {
    0%, 100% { transform: rotate(0deg) scale(1); filter: drop-shadow(0 0 0 rgb(196 92 38 / 0%)); }
    45% { transform: rotate(18deg) scale(1.12); filter: drop-shadow(0 0 6px rgb(196 92 38 / 70%)); }
  }
  @keyframes spark-flicker {
    0%, 100% { opacity: .15; transform: scale(.6); }
    50% { opacity: .9; transform: scale(1.15); }
  }
  @keyframes count-pop {
    0% { transform: scale(1); }
    40% { transform: scale(1.18); }
    100% { transform: scale(1); }
  }
  @keyframes pill-glow {
    0% { box-shadow: 0 0 0 3px rgb(196 92 38 / 6%), 0 8px 18px rgb(196 92 38 / 8%); }
    35% { box-shadow: 0 0 0 5px rgb(196 92 38 / 18%), 0 10px 24px rgb(196 92 38 / 22%); }
    100% { box-shadow: 0 0 0 3px rgb(196 92 38 / 6%), 0 8px 18px rgb(196 92 38 / 8%); }
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
