:root {
  color-scheme: light;
  --ink: #17191a;
  --night: #111516;
  --paper: #eef0ed;
  --white: #fff;
  --red: #d94b3d;
  --cyan: #69c4c3;
  --line: #cfd3cf;
  --muted: #616865;
  --soft: #e3e7e3;
  --focus: #2b7b7c;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
  line-height: 1.7;
}
a { color: inherit; }
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible { outline: 3px solid var(--cyan); outline-offset: 3px; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.site-header {
  position: absolute;
  z-index: 2;
  top: 0;
  left: 50%;
  width: min(1120px, calc(100% - 40px));
  min-height: 72px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--white);
  border-bottom: 1px solid rgb(255 255 255 / 24%);
}
.site-header.light { position: relative; color: var(--ink); border-bottom-color: var(--line); }
.brand { font-family: Georgia, serif; font-size: 22px; font-weight: 700; text-decoration: none; }
.site-nav { display: flex; gap: 24px; flex-wrap: wrap; justify-content: flex-end; }
.site-nav a { font-size: 14px; text-decoration: none; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--cyan); }

.hero { position: relative; min-height: min(760px, 88vh); overflow: hidden; display: grid; align-items: center; background: var(--night); color: var(--white); }
#math-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero-content { position: relative; z-index: 1; width: min(1120px, calc(100% - 40px)); margin: 0 auto; padding: 112px 0 72px; }
.kicker, .section-heading > p, .hero-index, .equation, .eyebrow, .status { font-family: "Courier New", monospace; }
.kicker { margin: 0 0 12px; color: var(--cyan); font-size: 14px; }
h1 { margin: 0; font-family: Georgia, serif; font-size: clamp(64px, 12vw, 156px); line-height: .9; letter-spacing: 0; }
.intro { width: min(600px, 100%); margin: 30px 0; color: #e4e7e3; font-size: 18px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 22px; align-items: center; }
.hero .hero-ideas { border-color: var(--cyan); background: var(--cyan); color: var(--night); text-decoration: none; }
.command { display: inline-flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 2px solid var(--red); text-decoration: none; font-weight: 700; }
.hero-index { position: absolute; right: 28px; bottom: 22px; margin: 0; color: rgb(255 255 255 / 38%); font-size: 12px; writing-mode: vertical-rl; }

.page-main { width: min(1120px, calc(100% - 40px)); margin: 0 auto; padding: 58px 0 100px; }
.page-main.narrow { width: min(820px, calc(100% - 40px)); }
.page-title { margin: 0 0 14px; font-family: Georgia, serif; font-size: clamp(42px, 7vw, 76px); line-height: 1; }
.page-lede { max-width: 680px; margin: 0 0 46px; color: var(--muted); font-size: 18px; }
.section-heading { display: grid; grid-template-columns: 180px 1fr; align-items: end; margin-bottom: 36px; }
.section-heading > p { margin: 0; color: var(--red); text-transform: uppercase; }
h2 { margin: 0; font-family: Georgia, serif; font-size: 42px; line-height: 1.15; letter-spacing: 0; }
h3 { margin: 0 0 8px; font-size: 25px; line-height: 1.3; }
.posts, .mail, .about { width: min(1120px, calc(100% - 40px)); margin: 0 auto; padding: 96px 0; }
.post-row { display: grid; grid-template-columns: 180px 1fr; padding: 34px 0; border-top: 1px solid var(--line); }
.post-row:last-child { border-bottom: 1px solid var(--line); }
.post-meta { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13px; }
.post-body > p { margin: 0; color: var(--muted); }
details { margin-top: 20px; }
summary { cursor: pointer; color: var(--red); font-weight: 700; }
.article-content { max-width: 720px; padding-top: 14px; }
blockquote { margin: 24px 0 0; padding-left: 18px; border-left: 3px solid var(--cyan); font-family: Georgia, serif; font-size: 22px; }
.mail { display: grid; grid-template-columns: 180px 1fr; column-gap: 0; color: var(--white); background: var(--night); box-shadow: 0 0 0 100vmax var(--night); clip-path: inset(0 -100vmax); }
.mail .section-heading { grid-column: 1 / -1; }
.mail-copy p { max-width: 600px; margin: 0 0 22px; color: #b9c1bd; }
.mail-address { color: var(--cyan); font-family: Georgia, serif; font-size: clamp(28px, 5vw, 54px); text-decoration-thickness: 2px; text-underline-offset: 8px; overflow-wrap: anywhere; }
.alias-list { margin: 0; border-top: 1px solid rgb(255 255 255 / 20%); }
.alias-list div { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; padding: 13px 0; border-bottom: 1px solid rgb(255 255 255 / 20%); }
.alias-list dt { color: var(--cyan); font-family: "Courier New", monospace; }
.alias-list dd { margin: 0; color: #b9c1bd; }
.about { display: grid; grid-template-columns: 1fr 1fr; gap: 48px; }
.about .section-heading { grid-column: 1 / -1; }
.about > p { margin: 0; color: var(--muted); }
.equation { align-self: end; justify-self: end; color: var(--red); }
footer { display: flex; justify-content: space-between; gap: 20px; padding: 28px max(20px, calc((100% - 1120px) / 2)); background: var(--ink); color: #c7c9c6; font-size: 13px; }

.panel { padding: 28px; border: 1px solid var(--line); background: rgb(255 255 255 / 60%); }
.panel + .panel { margin-top: 22px; }
.ideas-layout { display: grid; grid-template-columns: minmax(280px, 420px) minmax(0, 1fr); gap: 48px; align-items: start; }
.drawing-board { width: 100%; max-width: 360px; aspect-ratio: 1; touch-action: none; display: block; border: 1px solid var(--ink); background: var(--white); image-rendering: pixelated; }
.tool-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.tool-row label { display: inline-flex; align-items: center; gap: 7px; padding: 7px 9px; border: 1px solid var(--line); background: var(--white); font-size: 14px; }
.tool-row input[type="color"] { width: 28px; height: 28px; padding: 0; border: 0; }
.tool-row input[type="range"] { width: 100px; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 8px 14px; border: 1px solid var(--ink); background: var(--ink); color: var(--white); }
.button.secondary { background: transparent; color: var(--ink); }
.button.danger { border-color: var(--red); background: var(--red); }
.button:disabled { cursor: not-allowed; opacity: .55; }
.field { display: grid; gap: 8px; margin: 18px 0; }
.field textarea, .field input, .field select { width: 100%; padding: 10px 12px; border: 1px solid var(--line); background: var(--white); color: var(--ink); }
.field textarea { min-height: 130px; resize: vertical; }
.field small, .muted { color: var(--muted); }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.notice { min-height: 28px; margin: 12px 0 0; color: var(--muted); }
.notice.error { color: var(--red); }
.notice.success { color: var(--focus); }
.comment-list { display: grid; gap: 14px; }
.comment-item { display: grid; grid-template-columns: 64px 1fr; gap: 16px; padding: 16px 0; border-top: 1px solid var(--line); }
.comment-avatar { width: 64px; height: 64px; border: 1px solid var(--line); background: var(--white); image-rendering: pixelated; }
.comment-body { min-width: 0; }
.comment-body p { margin: 0 0 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-time { color: var(--muted); font-size: 12px; }
.empty { padding: 24px 0; color: var(--muted); }
.admin-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 20px; }
.admin-list { display: grid; gap: 14px; }
.admin-card { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 16px; align-items: start; padding: 16px; border: 1px solid var(--line); background: var(--white); }
.admin-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.login-box { max-width: 480px; margin: 24px auto 0; }
.hidden { display: none !important; }

@media (max-width: 760px) {
  .site-header { min-height: 62px; }
  .site-nav { gap: 13px; }
  .hero { min-height: 620px; }
  .hero-index { display: none; }
  .section-heading, .post-row, .mail, .about, .ideas-layout, .admin-card { grid-template-columns: 1fr; }
  .section-heading { gap: 6px; }
  .post-row { gap: 14px; }
  .posts, .mail, .about { padding: 68px 0; }
  .mail-copy { margin-bottom: 44px; }
  .about .section-heading, .mail .section-heading { grid-column: auto; }
  .equation { justify-self: start; }
  footer { flex-direction: column; }
  .admin-actions { justify-content: flex-start; }
}

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