:root {
  color-scheme: light;
  --bg: #f7f7fa;
  --surface: #ffffff;
  --text: #17171a;
  --muted: #6d6d76;
  --quiet: #92929c;
  --line: rgba(23, 23, 26, 0.12);
  --line-strong: rgba(23, 23, 26, 0.22);
  --accent: #655cff;
  --accent-2: #9874ff;
  --accent-soft: #eceaff;
  --shadow: 0 24px 80px rgba(46, 40, 92, 0.1);
  --page: 1080px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0d10;
  --surface: #17171c;
  --text: #f4f4f7;
  --muted: #aaaab3;
  --quiet: #81818b;
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.22);
  --accent: #9e98ff;
  --accent-2: #c2a5ff;
  --accent-soft: #282441;
  --shadow: 0 28px 90px rgba(0, 0, 0, 0.36);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background-color 180ms ease, color 180ms ease;
}
a { color: inherit; text-decoration: none; }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
img, svg { display: block; }
::selection { background: color-mix(in srgb, var(--accent) 25%, transparent); }
.skip-link { position: fixed; top: 12px; left: 12px; z-index: 100; padding: 10px 14px; border-radius: 10px; background: var(--text); color: var(--bg); transform: translateY(-160%); }
.skip-link:focus { transform: translateY(0); }
.page-width { width: min(calc(100% - 40px), var(--page)); margin-inline: auto; }
.site-header { position: sticky; top: 0; z-index: 50; height: 66px; border-bottom: 1px solid transparent; background: color-mix(in srgb, var(--bg) 84%, transparent); backdrop-filter: blur(18px) saturate(150%); transition: border-color 160ms ease; }
.site-header[data-scrolled="true"] { border-color: var(--line); }
.nav-shell { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; width: min(calc(100% - 32px), var(--page)); height: 100%; margin-inline: auto; }
.brand { display: inline-flex; align-items: center; justify-self: start; gap: 10px; min-height: 44px; font-size: 0.96rem; font-weight: 650; letter-spacing: -0.02em; }
.brand-avatar { width: 38px; height: 38px; object-fit: cover; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-links a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 13px; color: var(--muted); font-size: 0.88rem; }
.nav-links a:hover, .nav-links a:focus-visible, .nav-links a[aria-current="page"] { color: var(--text); outline: none; }
.nav-actions { display: flex; justify-self: end; gap: 2px; }
.icon-button { display: inline-grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; color: var(--text); cursor: pointer; }
.icon-button:hover, .icon-button:focus-visible { background: color-mix(in srgb, var(--text) 7%, transparent); outline: none; }
.icon-button svg { width: 20px; height: 20px; fill: currentColor; }
.theme-toggle svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sun-icon { display: none; }
html[data-theme="dark"] .moon-icon { display: none; }
html[data-theme="dark"] .sun-icon { display: block; }
.hero { display: flex; min-height: calc(100svh - 66px); flex-direction: column; justify-content: center; padding: 110px 0 68px; }
.hero-copy { max-width: 850px; }
.hero-name, .section-label { margin: 0 0 14px; color: var(--accent); font-size: 0.88rem; font-weight: 650; }
.hero h1 { margin: 0; max-width: 900px; font-size: clamp(3.4rem, 8vw, 7.5rem); font-weight: 700; letter-spacing: -0.075em; line-height: 0.98; }
.hero-intro { max-width: 720px; margin: 34px 0 0; color: var(--muted); font-size: clamp(1.03rem, 1.6vw, 1.22rem); line-height: 1.78; }
.hero-links { display: flex; flex-wrap: wrap; gap: 24px; margin-top: 34px; }
.hero-links a, .quiet-link, .project-source-link, .back-link, .project-ending a { display: inline-flex; align-items: center; gap: 7px; color: var(--accent); font-weight: 600; }
.hero-links a:hover, .quiet-link:hover, .project-source-link:hover, .back-link:hover, .project-ending a:hover { opacity: 0.72; }
.day-flow { margin-top: auto; padding-top: 90px; --day-progress: 50%; }
.day-flow-meta, .day-flow-scale { display: flex; align-items: center; justify-content: space-between; }
.day-flow-meta { margin-bottom: 13px; color: var(--muted); font-size: 0.86rem; }
.day-flow-meta time { color: var(--text); font-variant-numeric: tabular-nums; font-weight: 650; }
.day-flow-track { position: relative; height: 2px; background: var(--line); }
.day-flow-fill { position: absolute; inset: 0 auto 0 0; width: var(--day-progress); background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 700ms ease; }
.day-flow-marker { position: absolute; top: 50%; left: var(--day-progress); width: 12px; height: 12px; border: 3px solid var(--bg); border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 14%, transparent); transform: translate(-50%, -50%); animation: marker-pulse 2.8s ease-in-out infinite; }
.day-flow-scale { margin-top: 12px; color: var(--quiet); font-size: 0.68rem; font-variant-numeric: tabular-nums; }
.section { padding: 124px 0; border-top: 1px solid var(--line); }
.section-heading { max-width: 760px; margin-bottom: 56px; }
.section-heading h2, .about-copy h2, .writing-page-head h1, .project-hero h1 { margin: 0; font-size: clamp(2.5rem, 5.6vw, 5rem); font-weight: 690; letter-spacing: -0.065em; line-height: 1.04; }
.section-heading > p:last-child, .writing-page-head > p:last-child, .project-hero > p:last-of-type, .about-copy > p { max-width: 680px; margin: 23px 0 0; color: var(--muted); font-size: 1.04rem; line-height: 1.76; }
.section-heading-split { display: flex; align-items: end; justify-content: space-between; max-width: none; gap: 32px; }
.section-heading-split > div { max-width: 760px; }
.keke-entry { display: grid; grid-template-columns: minmax(0, 0.92fr) minmax(360px, 1.08fr); min-height: 620px; overflow: hidden; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.keke-entry-copy { display: flex; flex-direction: column; align-items: flex-start; padding: 64px 64px 64px 0; }
.keke-title-row { display: flex; align-items: center; gap: 18px; }
.keke-title-row img, .project-hero-icon { object-fit: cover; border-radius: 24%; box-shadow: 0 14px 38px rgba(60, 52, 132, 0.18); }
.keke-title-row img { width: 80px; height: 80px; }
.keke-title-row span { color: var(--muted); font-size: 0.8rem; }
.keke-title-row h3 { margin: 4px 0 0; font-size: 2.8rem; letter-spacing: -0.055em; line-height: 1; }
.keke-thesis { max-width: 540px; margin: 58px 0 0; font-size: clamp(1.7rem, 3.2vw, 2.8rem); font-weight: 650; letter-spacing: -0.05em; line-height: 1.28; }
.keke-summary { max-width: 560px; margin: 24px 0 0; color: var(--muted); }
.read-more { display: inline-flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 48px; color: var(--accent); font-weight: 600; }
.keke-motion { position: relative; display: flex; min-height: 620px; flex-direction: column; justify-content: center; overflow: hidden; padding: 58px; background: radial-gradient(circle at 74% 24%, rgba(255, 255, 255, 0.78), transparent 21rem), linear-gradient(145deg, #e8edff, #d8ddff 48%, #ece4ff); }
html[data-theme="dark"] .keke-motion { background: radial-gradient(circle at 74% 24%, rgba(255, 255, 255, 0.08), transparent 21rem), linear-gradient(145deg, #172039, #222448 48%, #392b4b); }
.keke-motion-date { color: #575268; font-size: 0.8rem; font-weight: 650; }
html[data-theme="dark"] .keke-motion-date { color: #d2cde0; }
.keke-motion-line { position: relative; height: 2px; margin: 34px 0 20px; background: rgba(91, 83, 160, 0.18); }
.keke-motion-line span { position: absolute; inset: 0 42% 0 0; background: #6f65ff; }
.keke-motion-line i { position: absolute; top: 50%; left: 58%; width: 12px; height: 12px; border: 3px solid rgba(245, 247, 255, 0.9); border-radius: 50%; background: #6f65ff; transform: translate(-50%, -50%); animation: marker-pulse 2.8s ease-in-out infinite; }
.keke-motion-course { display: grid; grid-template-columns: 70px 1fr; gap: 18px; padding: 24px 0; border-bottom: 1px solid rgba(77, 72, 116, 0.14); color: #3a3746; }
html[data-theme="dark"] .keke-motion-course { color: #f2eff9; border-color: rgba(255, 255, 255, 0.12); }
.keke-motion-course time { color: #77718a; font-size: 0.78rem; font-variant-numeric: tabular-nums; }
.keke-motion-course div { display: grid; gap: 5px; }
.keke-motion-course strong { font-size: 1.12rem; }
.keke-motion-course small { color: #77718a; }
.keke-motion-course.current strong, .keke-motion-course.current small { color: #655cff; }
.writing-list, .archive-list { border-top: 1px solid var(--line); }
.writing-row, .archive-row { display: grid; align-items: baseline; border-bottom: 1px solid var(--line); transition: padding-left 160ms ease; }
.writing-row { grid-template-columns: 120px 1fr auto; gap: 28px; padding: 25px 0; }
.archive-row { grid-template-columns: 140px 1fr auto; gap: 34px; padding: 30px 0; }
.writing-row:hover, .archive-row:hover { padding-left: 8px; }
.writing-row time, .archive-row time { color: var(--quiet); font-size: 0.78rem; font-variant-numeric: tabular-nums; }
.writing-row h3, .archive-row h2 { margin: 0; font-size: 1.08rem; font-weight: 610; letter-spacing: -0.02em; }
.archive-row h2 { font-size: clamp(1.25rem, 2.1vw, 1.75rem); }
.writing-row span, .archive-row span { color: var(--accent); }
.archive-row-copy p { max-width: 700px; margin: 9px 0 0; color: var(--muted); font-size: 0.9rem; }
.about-section { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 0.42fr); gap: 90px; }
.about-copy { max-width: 720px; }
.about-contact { align-self: end; display: grid; gap: 12px; padding-bottom: 6px; }
.about-contact span { margin-bottom: 5px; color: var(--quiet); font-size: 0.78rem; }
.about-contact a { width: fit-content; border-bottom: 1px solid var(--line-strong); font-weight: 600; }
.site-footer { display: flex; align-items: center; justify-content: space-between; min-height: 150px; border-top: 1px solid var(--line); color: var(--quiet); font-size: 0.82rem; }
.site-footer a:hover { color: var(--text); }
.writing-page, .article-main { min-height: calc(100svh - 66px); }
.writing-page { padding: 112px 0 150px; }
.writing-page-head { max-width: 840px; padding-bottom: 80px; }
.article-main { max-width: 760px; padding: 72px 0 150px; }
.back-link { margin-bottom: 72px; }
.note-article header { margin-bottom: 60px; }
.note-article .article-category { margin: 0 0 14px; color: var(--accent); font-size: 0.85rem; font-weight: 650; }
.note-article h1 { margin: 0; font-size: clamp(2.6rem, 6vw, 4.8rem); font-weight: 700; letter-spacing: -0.065em; line-height: 1.08; }
.note-article .article-meta { margin: 22px 0 0; color: var(--quiet); font-size: 0.82rem; }
.note-article .article-source { margin-top: 10px; color: var(--quiet); font-size: 0.8rem; }
.article-body { font-family: "Songti SC", "STSong", "Noto Serif CJK SC", serif; font-size: clamp(1.08rem, 1.6vw, 1.22rem); line-height: 2; }
.article-body p { margin: 0 0 1.35em; }
.note-navigation { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 90px; padding-top: 28px; border-top: 1px solid var(--line); }
.note-navigation a { display: grid; gap: 5px; }
.note-navigation a:last-child { text-align: right; }
.note-navigation span { color: var(--quiet); font-size: 0.75rem; }
.note-navigation strong { font-size: 0.92rem; }
.loading-copy { color: var(--muted); }
.project-page { padding-bottom: 120px; }
.project-hero { padding: 112px 0 130px; }
.project-hero-icon { width: 112px; height: 112px; margin-bottom: 42px; }
.project-hero h1 { max-width: 900px; }
.project-hero > p:last-of-type { max-width: 720px; }
.project-source-link { margin-top: 28px; }
.project-story { border-top: 1px solid var(--line); }
.story-block { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 40px; padding: 86px 0; border-bottom: 1px solid var(--line); }
.story-number { color: var(--quiet); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.story-block > div { max-width: 780px; }
.story-block h2 { margin: 0 0 26px; font-size: clamp(2rem, 4vw, 3.6rem); font-weight: 680; letter-spacing: -0.055em; line-height: 1.08; }
.story-block p { margin: 0 0 1.1em; color: var(--muted); font-size: 1.04rem; line-height: 1.84; }
.story-block blockquote { margin: 0 0 28px; font-size: clamp(1.7rem, 3.4vw, 2.8rem); font-weight: 650; letter-spacing: -0.045em; line-height: 1.34; }
.tech-list { margin: 0; border-top: 1px solid var(--line); }
.tech-list div { display: grid; grid-template-columns: 150px 1fr; padding: 17px 0; border-bottom: 1px solid var(--line); }
.tech-list dt { color: var(--quiet); }
.tech-list dd { margin: 0; font-weight: 600; }
.project-ending { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 80px 0 0; color: var(--muted); }
.reveal { opacity: 1; }
.js .reveal { opacity: 0; transform: translateY(14px); transition: opacity 600ms ease, transform 600ms ease; }
.js .reveal.is-visible { opacity: 1; transform: translateY(0); }
@keyframes marker-pulse { 0%, 100% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 14%, transparent); } 50% { box-shadow: 0 0 0 10px color-mix(in srgb, var(--accent) 5%, transparent); } }
@media (max-width: 820px) {
  .nav-shell { grid-template-columns: 1fr auto; }
  .nav-links { display: none; }
  .hero { min-height: auto; padding-top: 92px; }
  .hero h1 { font-size: clamp(3rem, 13vw, 5.6rem); }
  .day-flow { padding-top: 110px; }
  .section { padding: 92px 0; }
  .section-heading-split { display: block; }
  .section-heading-split .quiet-link { margin-top: 22px; }
  .keke-entry { grid-template-columns: 1fr; }
  .keke-entry-copy { min-height: 560px; padding: 44px 0 54px; }
  .keke-motion { min-height: 500px; margin-inline: -20px; padding: 44px 28px; }
  .writing-row, .archive-row { grid-template-columns: 90px 1fr auto; gap: 18px; }
  .about-section { grid-template-columns: 1fr; gap: 52px; }
  .story-block { grid-template-columns: 60px 1fr; gap: 22px; }
}
@media (max-width: 560px) {
  .page-width { width: min(calc(100% - 28px), var(--page)); }
  .brand span { display: none; }
  .hero { padding-top: 74px; }
  .hero-intro { margin-top: 26px; }
  .hero-links { display: grid; gap: 14px; }
  .day-flow-scale span:nth-child(2), .day-flow-scale span:nth-child(4) { display: none; }
  .section-heading { margin-bottom: 40px; }
  .keke-title-row img { width: 66px; height: 66px; }
  .keke-title-row h3 { font-size: 2.3rem; }
  .writing-row, .archive-row { grid-template-columns: 1fr auto; gap: 10px 18px; padding: 22px 0; }
  .writing-row time, .archive-row time { grid-column: 1 / -1; }
  .archive-row-copy p { display: none; }
  .about-contact a { overflow-wrap: anywhere; }
  .site-footer { align-items: flex-start; flex-direction: column; justify-content: center; gap: 4px; }
  .writing-page { padding-top: 80px; }
  .writing-page-head { padding-bottom: 52px; }
  .article-main { padding-top: 48px; }
  .back-link { margin-bottom: 52px; }
  .note-navigation { grid-template-columns: 1fr; }
  .note-navigation a:last-child { text-align: left; }
  .project-hero { padding: 82px 0 94px; }
  .project-hero-icon { width: 88px; height: 88px; }
  .story-block { grid-template-columns: 1fr; gap: 18px; padding: 64px 0; }
  .project-ending { align-items: flex-start; flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .js .reveal { opacity: 1; transform: none; }
}

/* UI/UX audit pass: improve professional baselines without changing the visual concept. */
:root {
  --quiet: #70707a;
  --accent: #5f56ef;
  --focus-ring: #5f56ef;
  --focus-ring-soft: color-mix(in srgb, var(--focus-ring) 22%, transparent);
}

html[data-theme="dark"] {
  --focus-ring: #b8b4ff;
  --focus-ring-soft: color-mix(in srgb, var(--focus-ring) 24%, transparent);
}

:where(a, button, [role="tab"]):focus-visible {
  outline: 2px solid var(--focus-ring) !important;
  outline-offset: 3px;
}

.skip-link:focus-visible {
  outline-color: currentColor !important;
}

.nav-links a[aria-current="page"] {
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 7%, transparent);
}

/* The cosmos keeps its own focus language: a small orbital halo, not a box. */
body[data-page="home"] .note-star::after {
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(var(--note-star-size, 12px) + 12px);
  height: calc(var(--note-star-size, 12px) + 12px);
  border: 2px solid transparent;
  border-radius: 50%;
  content: "";
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(.82);
  transition: opacity 160ms ease, transform 180ms cubic-bezier(.22, 1, .36, 1), border-color 160ms ease, box-shadow 160ms ease;
}

body[data-page="home"] .note-star:focus-visible,
body[data-page="home"] .orbit-project:focus-visible {
  outline: none !important;
}

body[data-page="home"] .note-star:focus-visible::after {
  border-color: var(--cosmos-star, var(--focus-ring));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--cosmos-star, var(--focus-ring)) 16%, transparent), 0 0 18px color-mix(in srgb, var(--cosmos-glow, var(--focus-ring)) 45%, transparent);
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

body[data-page="home"] .orbit-project:focus-visible .orbit-icon-shell {
  box-shadow: 0 0 0 3px var(--cosmos-bg, var(--bg)), 0 0 0 5px var(--cosmos-star, var(--focus-ring)), 0 0 24px color-mix(in srgb, var(--cosmos-glow, var(--focus-ring)) 55%, transparent) !important;
  transform: scale(1.04);
}

/* Article kinds use both color and geometry: work = diamond, essay = round star. */
.note-kind-marker {
  display: inline-grid !important;
  width: 10px !important;
  height: 10px !important;
  place-items: center;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

.note-kind-marker::before {
  display: block;
  width: 7px;
  height: 7px;
  background: var(--note-kind-color);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--note-kind-color) 10%, transparent);
  content: "";
}

.note-kind-work .note-kind-marker::before {
  border-radius: 1px;
  transform: rotate(45deg) scale(.9);
}

.note-kind-essay .note-kind-marker::before {
  border-radius: 50%;
}

@media (max-width: 820px) {
  .nav-shell {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 4px;
    width: min(calc(100% - 24px), var(--page));
  }

  .brand span {
    display: none;
  }

  .nav-links {
    display: flex;
    justify-self: center;
    gap: 0;
  }

  .nav-links a {
    min-width: 44px;
    justify-content: center;
    padding-inline: 9px;
    border-radius: 999px;
    font-size: .82rem;
  }

  .nav-actions {
    gap: 0;
  }
}

@media (max-width: 380px) {
  .nav-shell {
    gap: 0;
    width: min(calc(100% - 16px), var(--page));
  }

  .nav-links a {
    padding-inline: 7px;
    font-size: .78rem;
  }

  .brand-avatar {
    width: 36px;
    height: 36px;
  }
}
