:root {
  --bg: #f7f7fa;
  --surface: #ffffff;
  --fg: #14161c;
  --muted: #5d6370;
  --line: #e3e4ea;
  --accent: #6b4dff;
  --accent-fg: #ffffff;
  --pink: #ff5f8f;
  --violet: #7c5cff;
  --teal: #2fd3c6;
  --warn-bg: #fff6e5; --warn-line: #f2c46b;
  --err-bg: #ffecef;  --err-line: #f08a9c;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(20 22 28 / .05), 0 8px 24px rgb(20 22 28 / .06);
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0f14; --surface: #161922; --fg: #eef0f4; --muted: #9aa0ab; --line: #272b36;
    --accent: #8b74ff; --warn-bg: #2a2212; --warn-line: #8a6a23; --err-bg: #2d151b; --err-line: #9b3e51;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 80px; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 17px/1.6 var(--font); }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.015em; margin: 0 0 .5em; }
h1 { font-size: clamp(2rem, 5vw, 3rem); letter-spacing: -0.03em; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
code { font-family: var(--mono); font-size: .9em; background: var(--line); padding: .1em .35em; border-radius: 5px; }
pre { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; overflow-x: auto; font-size: .88rem; line-height: 1.5; }
pre code { background: none; padding: 0; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.wrap { width: min(1120px, 100% - 32px); margin-inline: auto; }
.narrow { width: min(720px, 100% - 32px); }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 12px; z-index: 10; background: var(--surface); padding: 8px 12px; }

/* Header */
.site-header { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; gap: 16px; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--fg); text-decoration: none; font-weight: 800; font-size: 1.15rem; letter-spacing: -0.02em; }
.brand b { background: linear-gradient(90deg, var(--pink), var(--violet), var(--teal)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-ecg { width: 44px; }
.site-nav { margin-left: auto; display: flex; gap: 4px; flex-wrap: wrap; }
.site-nav a { color: var(--muted); text-decoration: none; padding: 8px 12px; border-radius: 999px; font-size: .95rem; }
.site-nav a:hover, .site-nav a[aria-current] { color: var(--fg); background: var(--surface); }
.nav-toggle { display: none; margin-left: auto; font: inherit; background: var(--surface); color: var(--fg); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; }
@media (max-width: 820px) {
  .nav-toggle { display: block; }
  .site-nav { display: none; position: absolute; top: 64px; left: 0; right: 0; flex-direction: column; background: var(--bg); border-bottom: 1px solid var(--line); padding: 8px 16px 16px; }
  .site-nav.open { display: flex; }
}

/* ECG trace */
.ecg { display: block; overflow: visible; }
.ecg path { fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.brand-ecg path { stroke-width: 6; }
.ecg--animated path { stroke-dasharray: 100; stroke-dashoffset: 100; animation: trace 2.4s cubic-bezier(.45, 0, .55, 1) infinite; }
@keyframes trace {
  0% { stroke-dashoffset: 100; opacity: 1; }
  65% { stroke-dashoffset: 0; opacity: 1; }
  90% { stroke-dashoffset: 0; opacity: 1; }
  100% { stroke-dashoffset: 0; opacity: 0; }
}
.hero-ecg { width: min(240px, 70vw); margin: 0 auto 24px; }

/* Hero */
.hero { position: relative; overflow: hidden; padding: clamp(56px, 10vw, 112px) 0 clamp(40px, 8vw, 80px); text-align: center; }
.hero::before { content: ""; position: absolute; inset: -30% -10% auto; height: 140%; z-index: -1; filter: blur(50px); opacity: .55;
  background: radial-gradient(30% 40% at 20% 30%, color-mix(in srgb, var(--pink) 45%, transparent), transparent 70%),
              radial-gradient(35% 45% at 80% 60%, color-mix(in srgb, var(--violet) 45%, transparent), transparent 70%),
              radial-gradient(25% 35% at 55% 15%, color-mix(in srgb, var(--teal) 35%, transparent), transparent 70%); }
.hero-inner { max-width: 760px; }
.grad { background: linear-gradient(90deg, var(--pink), var(--violet), var(--teal)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { font-size: 1.15rem; color: var(--muted); }
.actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 28px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--fg); font: inherit; font-weight: 600; font-size: .95rem; text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--muted); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn--primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.btn--danger { color: #c0274a; }
.btn--block { display: flex; width: 100%; margin-bottom: 10px; }

/* Sections */
.section { padding: 32px 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head { padding: 48px 0 16px; }
.pillars { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; padding: 8px 0 24px; }
.pillar, .notice, .empty, .admin-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.pillar h2 { font-size: 1.15rem; }
.pillar p { color: var(--muted); }
.notice { border-left: 4px solid var(--teal); }
.notice h2 { font-size: 1.2rem; }
.notice p:last-child { margin-bottom: 0; }
.empty { text-align: center; padding: 40px 22px; }

/* Cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); transition: transform .15s ease; }
.card:hover { transform: translateY(-2px); }
.card-link { color: inherit; text-decoration: none; display: block; height: 100%; }
.card-img { aspect-ratio: 16 / 10; object-fit: cover; width: 100%; background: var(--line); border-bottom: 1px solid var(--line); }
.card-body { padding: 16px 18px 18px; }
.card-body h3 { margin-bottom: .3em; }
.card-body p { color: var(--muted); margin: 0; font-size: .95rem; }
.card-body .tag { margin-bottom: 6px; }
.tag { display: inline-block; font-size: .78rem; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.filters a { text-decoration: none; color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: .9rem; }
.filters a span { color: var(--muted); }
.filters a[aria-current] { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.filters a[aria-current] span { color: inherit; }

/* Project page */
.project { padding: 40px 0 64px; }
.crumbs { color: var(--muted); font-size: .9rem; }
.crumbs a { color: inherit; }
.shot { margin: 24px 0 32px; }
.shot img { border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow); width: 100%; }
.project-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 40px; align-items: start; }
@media (max-width: 820px) { .project-grid { grid-template-columns: 1fr; } }
.meta { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; position: sticky; top: 84px; }
.meta dl { margin: 0 0 16px; }
.meta dt { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-top: 12px; }
.meta dt:first-child { margin-top: 0; }
.meta dd { margin: 2px 0 0; }
.admin-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--line); }

/* Prose & guides */
.prose { max-width: 72ch; }
.prose h2 { margin-top: 1.8em; }
.prose h3 { margin-top: 1.4em; }
.prose li { margin-bottom: .4em; }
.prose ul, .prose ol { padding-left: 1.3em; }
.guide { padding-bottom: 64px; }
.guide-grid { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 48px; align-items: start; }
.toc { position: sticky; top: 84px; font-size: .92rem; }
.toc p { font-weight: 700; margin-bottom: 8px; }
.toc ol { margin: 0; padding-left: 1.2em; color: var(--muted); }
.toc li { margin-bottom: 6px; }
.toc a { color: var(--muted); text-decoration: none; }
.toc a:hover { color: var(--fg); }
@media (max-width: 900px) { .guide-grid { grid-template-columns: 1fr; gap: 8px; } .toc { position: static; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; } }
.checklist { list-style: none; padding-left: 0 !important; }
.checklist li { padding-left: 30px; position: relative; }
.checklist li::before { content: ""; position: absolute; left: 0; top: .3em; width: 18px; height: 18px; border: 2px solid var(--accent); border-radius: 5px; }

/* Forms */
.form { display: grid; gap: 8px; padding-bottom: 64px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px 8px; margin: 0 0 16px; background: var(--surface); }
legend { font-weight: 700; padding: 0 6px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; margin-bottom: 4px; }
.opt { font-weight: 400; color: var(--muted); }
.hint { font-size: .88rem; color: var(--muted); margin: 0 0 6px; }
input[type=text], input[type=email], input[type=url], input[type=password], select, textarea {
  width: 100%; font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
input[type=file] { font: inherit; font-size: .95rem; max-width: 100%; }
.check { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 14px; }
.check input { width: 20px; height: 20px; margin-top: 3px; flex: none; accent-color: var(--accent); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.cf-turnstile { margin: 8px 0 16px; min-height: 65px; }
.role-note { color: #c0274a; }

.alert { border-radius: var(--radius); padding: 14px 18px; margin-bottom: 20px; border: 1px solid; }
.alert p:last-child, .alert ul:last-child { margin-bottom: 0; }
.alert--warn { background: var(--warn-bg); border-color: var(--warn-line); }
.alert--error { background: var(--err-bg); border-color: var(--err-line); }

/* Admin */
.admin { padding-bottom: 64px; }
.admin-item { margin-top: 16px; }
.admin-item form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.admin-project { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 18px; }
.admin-project img { border-radius: 8px; border: 1px solid var(--line); }
@media (max-width: 600px) { .admin-project { grid-template-columns: 1fr; } }

/* Footer */
.site-footer { border-top: 1px solid var(--line); padding: 32px 0 40px; color: var(--muted); font-size: .92rem; }
.footer-inner p { max-width: 70ch; }
.footer-links { display: flex; gap: 18px; flex-wrap: wrap; }
.footer-links a { color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .ecg--animated path { stroke-dashoffset: 0; }
}
