:root {
  --paper: #f2efe7;
  --paper-2: #faf8f2;
  --ink: #171714;
  --ink-2: #3f3d37;
  --muted: #746f63;
  --line: #d8d1c3;
  --line-dark: #2b2e27;
  --accent: #a33a2b;
  --green: #2f6b53;
  --rail: #171915;
  --rail-text: #e9e3d6;
  --mono: "SFMono-Regular", "DejaVu Sans Mono", Consolas, "Liberation Mono", monospace;
  --sans: "Inter", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", "Songti SC", "Noto Serif SC", Georgia, serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--accent); color: #fff; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
p, h1, h2, h3, ul { margin: 0; }
ul { padding: 0; list-style: none; }
svg.icon { width: 18px; height: 18px; display: block; flex: 0 0 auto; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.page {
  width: 100%;
  margin: 0;
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  min-height: 100vh;
}

/* ---------- left rail ---------- */
.rail {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  min-height: 100vh;
  max-height: 100vh;
  background: var(--rail);
  color: var(--rail-text);
  padding: 34px 32px 28px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--rail);
}
.rail-top { display: flex; align-items: center; justify-content: space-between; }
.monogram {
  width: 46px; height: 46px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid rgba(233,227,214,.62);
  font-family: var(--mono);
  font-size: 15px;
  letter-spacing: .06em;
  color: #f4efe3;
  transition: background .2s, color .2s, border-color .2s;
}
.monogram:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.rail-kicker {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .16em;
  color: #8d9287;
}
.rail-intro { margin-top: 58px; }
.rail-eyebrow {
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: .14em;
  line-height: 1.8;
  color: #9ca297;
  max-width: 220px;
}
.rail h1 {
  margin-top: 14px;
  font-family: var(--serif);
  font-size: 40px;
  line-height: 1.1;
  font-weight: 500;
  letter-spacing: -.04em;
  color: #f6f1e6;
}
.handle {
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  letter-spacing: .08em;
}
.rail-bio {
  margin-top: 20px;
  font-size: 12px;
  line-height: 1.85;
  color: #b8b9ae;
  max-width: 240px;
}
.rail-nav {
  margin-top: 44px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rail-nav a {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 9px 0;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .06em;
  color: #9b9f94;
  border-bottom: 1px solid rgba(233,227,214,.09);
  transition: color .18s, padding-left .18s;
}
.rail-nav a span { color: #666b61; font-size: 8px; width: 16px; }
.rail-nav a:hover, .rail-nav a.is-active { color: #f5efe2; padding-left: 4px; }
.rail-nav a:hover span, .rail-nav a.is-active span { color: var(--accent); }
.rail-bottom { margin-top: auto; }
.status {
  display: flex; align-items: center; gap: 7px;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: .08em;
  color: #9ca297;
  margin-bottom: 13px;
}
.status i { width: 5px; height: 5px; background: #63b58f; border-radius: 50%; box-shadow: 0 0 0 3px rgba(99,181,143,.12); }
.rail-icons { display: flex; gap: 6px; }
.rail-icons a {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid rgba(233,227,214,.18);
  color: #c9cbbf;
  transition: border-color .2s, color .2s, background .2s;
}
.rail-icons a:hover { border-color: var(--accent); background: var(--accent); color: #fff; }
.print-btn {
  margin-top: 16px;
  width: 100%;
  height: 34px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid rgba(233,227,214,.18);
  background: transparent;
  color: #aeb2a6;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: .08em;
  cursor: pointer;
  transition: color .2s, border-color .2s;
}
.print-btn:hover { color: #fff; border-color: rgba(233,227,214,.55); }
.print-btn .icon { width: 14px; height: 14px; }

/* ---------- main ---------- */
main { padding: 58px 64px 38px; min-width: 0; }
.hero { padding: 26px 0 56px; border-bottom: 1px solid var(--line); }
.eyebrow {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .16em;
  color: var(--muted);
}
.eyebrow .accent { color: var(--accent); }
.hero h2 {
  margin-top: 20px;
  font-family: var(--serif);
  font-size: clamp(48px, 6.2vw, 78px);
  line-height: .99;
  letter-spacing: -.055em;
  font-weight: 500;
  max-width: 720px;
}
.hero-lead {
  margin-top: 24px;
  max-width: 600px;
  font-size: 14px;
  line-height: 1.9;
  color: var(--ink-2);
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 26px; }
.btn {
  height: 40px;
  padding: 0 15px;
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .04em;
  border: 1px solid var(--ink);
  transition: background .2s, color .2s, border-color .2s;
}
.btn .icon { width: 14px; height: 14px; }
.btn-dark { background: var(--ink); color: #f7f2e7; }
.btn-dark:hover { background: var(--accent); border-color: var(--accent); }
.btn-line { color: var(--ink); }
.btn-line:hover { background: var(--ink); color: #f7f2e7; }
.hero-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 42px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.hero-meta > div { display: flex; flex-direction: column; gap: 4px; }
.meta-key { font-family: var(--mono); font-size: 8px; letter-spacing: .12em; color: var(--muted); }
.hero-meta > div > span:last-child { font-size: 11px; color: var(--ink-2); }

.section { padding: 62px 0; border-bottom: 1px solid var(--line); }
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}
.section-head > div { display: flex; align-items: baseline; gap: 12px; }
.section-num { font-family: var(--mono); font-size: 9px; color: var(--accent); }
.section-head h2 {
  font-family: var(--serif);
  font-size: 32px;
  line-height: 1;
  letter-spacing: -.035em;
  font-weight: 500;
}
.section-head > p { font-size: 10px; color: var(--muted); text-align: right; max-width: 260px; }

/* ---------- projects ---------- */
.project-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.project {
  min-height: 264px;
  padding: 20px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  transition: transform .2s ease, border-color .2s, background .2s, box-shadow .2s;
}
.project:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  background: #fffdf8;
  box-shadow: 0 12px 26px rgba(23,23,20,.06);
}
.project-featured { border-color: #b9b0a0; }
.project-top { display: flex; align-items: flex-start; justify-content: space-between; }
.project-icon {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  background: var(--ink);
  color: #f5efe3;
}
.project-icon .icon { width: 18px; height: 18px; }
.project-arrow { color: #9b9588; transition: color .2s, transform .2s; }
.project:hover .project-arrow { color: var(--accent); transform: translate(2px,-2px); }
.project-kicker {
  margin-top: 22px;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: .1em;
  color: var(--muted);
}
.project h3 {
  margin-top: 7px;
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -.03em;
}
.project h3 span { font-family: var(--sans); font-size: 11px; color: var(--muted); letter-spacing: 0; margin-left: 5px; }
.project-desc { margin-top: 9px; font-size: 11px; line-height: 1.8; color: var(--ink-2); }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 15px; }
.tags span {
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: .04em;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 3px 5px;
  background: var(--paper);
}
.project-repo {
  margin-top: auto;
  padding-top: 16px;
  display: flex; align-items: center; gap: 6px;
  font-family: var(--mono);
  font-size: 8px;
  color: #8b8579;
}
.project-repo .icon { width: 12px; height: 12px; }

/* ---------- education ---------- */
.split-section { display: grid; grid-template-columns: 220px minmax(0,1fr); gap: 34px; }
.split-section .section-head { display: block; margin-bottom: 0; }
.split-section .section-head > div { display: block; }
.split-section .section-num { display: block; margin-bottom: 8px; }
.timeline { border-top: 1px solid var(--line); }
.timeline-item { display: grid; grid-template-columns: 64px 1fr; gap: 16px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.timeline-date { font-family: var(--mono); font-size: 8px; letter-spacing: .08em; color: var(--accent); padding-top: 3px; }
.timeline-item h3 { font-size: 14px; font-weight: 600; letter-spacing: -.01em; }
.timeline-item p { margin-top: 5px; font-size: 11px; line-height: 1.8; color: var(--ink-2); }

/* ---------- toolkit ---------- */
.toolkit { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tool-group {
  padding: 15px;
  background: var(--paper-2);
  border: 1px solid var(--line);
}
.tool-head { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; }
.tool-head h3 { font-family: var(--mono); font-size: 8px; letter-spacing: .1em; color: var(--accent); }
.tool-head span { font-family: var(--mono); font-size: 8px; color: #a39c8f; }
.tool-line { margin-top: 9px; font-size: 11px; line-height: 1.7; color: var(--ink); font-weight: 500; }
.tool-notes { margin-top: 9px; padding-top: 9px; border-top: 1px solid var(--line); }
.tool-notes li {
  position: relative;
  padding-left: 11px;
  margin-top: 5px;
  font-size: 10px;
  line-height: 1.7;
  color: var(--ink-2);
}
.tool-notes li::before { content: ""; position: absolute; left: 0; top: .72em; width: 4px; height: 1px; background: var(--accent); }
.tool-current {
  grid-column: 1 / -1;
  display: flex; align-items: baseline; gap: 18px;
  padding: 12px 15px;
  border: 1px solid var(--line);
  background: transparent;
}
.tool-current > span { font-family: var(--mono); font-size: 7px; letter-spacing: .1em; color: var(--accent); flex: 0 0 auto; }
.tool-current p { font-size: 10px; color: var(--muted); }

/* first screen: in landscape the daily frame ends at the viewport bottom */
.first-screen { display: block; }
@media (orientation: landscape) and (min-width: 900px) {
  .first-screen { min-height: calc(100vh - 58px); display: flex; flex-direction: column; }
  .first-screen .hero { flex: 0 0 auto; }
  .first-screen .daily { margin-top: auto; }
}

/* ---------- contact ---------- */
.contact-section { padding: 64px 0 56px; }
.contact-section h2 {
  margin-top: 12px;
  font-family: var(--serif);
  font-size: clamp(36px, 4.6vw, 54px);
  line-height: 1.05;
  letter-spacing: -.045em;
  font-weight: 500;
}
.contact-lead { margin-top: 16px; max-width: 540px; font-size: 12px; line-height: 1.85; color: var(--ink-2); }
.contact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 30px; }
.contact-link {
  display: flex; align-items: center; gap: 11px;
  padding: 13px;
  border: 1px solid var(--line);
  background: var(--paper-2);
  transition: border-color .2s, background .2s;
}
.contact-link:hover { border-color: var(--accent); background: #fffdf8; }
.contact-icon { width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; background: var(--ink); color: #f5efe3; }
.contact-icon .icon { width: 15px; height: 15px; }
.contact-link small { display: block; font-family: var(--mono); font-size: 7px; letter-spacing: .1em; color: var(--muted); }
.contact-link strong { display: block; font-size: 10px; font-weight: 500; margin-top: 2px; }
.contact-arrow { margin-left: auto; color: #999285; }
.contact-link:hover .contact-arrow { color: var(--accent); }

.footer {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 18px 0 4px;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 8px;
  color: var(--muted);
}
.footer a:hover { color: var(--accent); }

[data-reveal] { opacity: 1; transform: none; }

@media (max-width: 1080px) {
  .page { grid-template-columns: 300px minmax(0,1fr); }
  .rail { height: 100vh; min-height: 100vh; max-height: 100vh; }
  main { padding: 46px 40px 30px; }
  .rail { padding: 26px 24px; }
  .rail h1 { font-size: 34px; }
  .project-grid { grid-template-columns: 1fr; }
  .project { min-height: 0; }
  .split-section { grid-template-columns: 1fr; gap: 18px; }
  .hero-meta { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
  .page { display: block; }
  .rail { position: relative; height: auto; min-height: 100vh; padding: 22px 20px 20px; }
  .rail-top { padding-right: 78px; }
  .rail-intro { margin-top: 28px; }
  .rail h1 { font-size: 38px; }
  .rail-bio { max-width: none; }
  .rail-nav { margin-top: 24px; display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
  .rail-nav a { padding: 8px 0; }
  .rail-bottom { margin-top: 20px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
  .status { margin: 0; }
  .rail-icons { margin-left: auto; }
  .print-btn { width: auto; margin: 0; padding: 0 10px; }
  main { padding: 36px 20px 26px; }
  .hero { padding-top: 8px; }
  .hero h2 { font-size: 46px; }
  .hero-meta { grid-template-columns: 1fr; gap: 10px; }
  .section { padding: 44px 0; }
  .section-head { display: block; }
  .section-head > p { margin-top: 7px; text-align: left; }
  .project-grid { grid-template-columns: 1fr; }
  .toolkit { grid-template-columns: 1fr; }
  .tool-current { display: block; }
  .tool-current p { margin-top: 5px; }
  .contact-grid { grid-template-columns: 1fr; }
  .footer { display: block; line-height: 2; }
  .footer span { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
  [data-reveal] { opacity: 1; transform: none; }
}

@media print {
  body { background: #fff; color: #111; font-size: 11px; }
  .page { display: block; width: 100%; }
  .rail { display: none; }
  main { padding: 0; }
  .hero h2 { font-size: 44px; }
  .section, .contact-section { padding: 22px 0; break-inside: avoid; }
  .project, .contact-link { break-inside: avoid; background: #fff; }
  .project:hover { transform: none; box-shadow: none; }
  .hero-actions, .rail, .print-btn, .footer a { display: none; }
  .footer { border-top: 1px solid #ccc; }
  [data-reveal] { opacity: 1; transform: none; }
}

/* ---------- avatar, heatmap, daily, quick access ---------- */
.rail { overflow-y: auto; scrollbar-width: thin; scrollbar-color: #3a3e35 transparent; }
.avatar-link {
  position: relative;
  width: 56px; height: 56px;
  display: block;
  overflow: hidden;
  border: 1px solid rgba(233,227,214,.55);
  background: #242720;
  transition: border-color .2s, transform .2s;
}
.avatar-link:hover { border-color: var(--accent); transform: translateY(-1px); }
.avatar-link img { width: 100%; height: 100%; object-fit: cover; display: block; filter: saturate(.85); }
.avatar-fallback {
  display: none;
  position: absolute; inset: 0;
  align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 14px; color: #f4efe3;
}
.avatar-link.is-fallback .avatar-fallback { display: flex; }
.rail-heatmap {
  display: block;
  margin-bottom: 13px;
  padding: 8px;
  background: #1a1d18;
  border: 1px solid #34382f;
  transition: border-color .2s;
}
.rail-heatmap:hover { border-color: #5c6255; }
.heatmap-grid {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 3.8px);
  grid-auto-columns: 3.8px;
  gap: 1px;
  justify-content: center;
  width: 100%;
}
.heat-cell {
  width: 3.8px;
  height: 3.8px;
  background: #2b2f28;
  transition: background .15s;
}
.heat-cell:hover { background: #d8d1c3; }
.heat-cell.level-1 { background: #5a342d; }
.heat-cell.level-2 { background: #7b3d31; }
.heat-cell.level-3 { background: #9a4938; }
.heat-cell.level-4 { background: #bf5b45; }
.rail-heatmap.is-empty { display: none; }

.daily { margin: 0; border-bottom: 1px solid var(--line); padding: 22px 0 18px; }
.daily-media {
  position: relative;
  height: 220px;
  overflow: hidden;
  background: #e7e1d4;
  border: 1px solid var(--line);
}
.daily-media img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  filter: saturate(.76) contrast(.96) brightness(.9);
  transition: transform 1.2s ease;
}
.daily:hover .daily-media img { transform: scale(1.015); }
.daily-media::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(23,23,20,.02) 30%, rgba(23,23,20,.34) 100%);
  pointer-events: none;
}
.daily-stamp {
  position: absolute; left: 13px; bottom: 12px; z-index: 1;
  font-family: var(--mono); font-size: 8px; letter-spacing: .14em;
  color: #f7f2e7;
  border: 1px solid rgba(247,242,231,.55);
  padding: 4px 7px;
  backdrop-filter: blur(3px);
}
.daily figcaption {
  display: flex; align-items: baseline; justify-content: space-between; gap: 14px;
  margin-top: 8px;
  font-family: var(--mono); font-size: 8px; color: var(--muted);
}
.daily figcaption #dailyTitle { color: var(--ink-2); letter-spacing: .02em; }

.quick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; }
.quick-link {
  display: flex; align-items: center; gap: 10px;
  min-height: 64px;
  padding: 10px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  transition: border-color .2s, background .2s, transform .2s;
}
.quick-link:hover { border-color: var(--accent); background: #fffdf8; transform: translateY(-2px); }
.quick-icon {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  background: var(--ink); color: #f5efe3;
  flex: 0 0 auto;
}
.quick-icon .icon { width: 15px; height: 15px; }
.quick-link strong { display: block; font-size: 11px; font-weight: 600; letter-spacing: .01em; }
.quick-link small { display: block; font-family: var(--mono); font-size: 7px; color: var(--muted); margin-top: 2px; }
.quick-arrow { margin-left: auto; color: #9a9386; }
.quick-link:hover .quick-arrow { color: var(--accent); }
#repoStatus { font-family: var(--mono); font-size: 7px; letter-spacing: .08em; color: var(--accent); }

@media (max-width: 1080px) {
  .rail { height: auto; min-height: 100vh; }
  .quick-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .daily-media { height: 180px; }
  .daily figcaption { display: block; line-height: 1.8; }
  .quick-grid { grid-template-columns: 1fr; }
  .rail-heatmap { max-width: 320px; }
}
@media print {
  .daily, .quick-grid, .rail { display: none; }
}

/* ---------- local music player ---------- */
.music-player {
  margin-top: 24px;
  padding: 11px;
  background: #1d201a;
  border: 1px solid #34382f;
}
.music-head {
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--mono); font-size: 7px; letter-spacing: .1em; color: #8c9186;
}
.music-body { display: flex; align-items: center; gap: 11px; margin-top: 10px; }
.music-disc {
  width: 52px; height: 52px; flex: 0 0 auto;
  border-radius: 50%;
  background: repeating-radial-gradient(circle at 50% 50%, #2a2d26 0 1px, #191b17 1px 2px);
  border: 1px solid #3d4137;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.music-disc::after {
  content: ""; position: absolute; inset: 7px; border: 1px solid #3a3e34; border-radius: 50%;
}
.music-disc span {
  position: relative; z-index: 1;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); color: #f6efe2;
  font-family: var(--mono); font-size: 6px;
  display: flex; align-items: center; justify-content: center;
}
.music-disc.is-playing { animation: spin 9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.music-copy { min-width: 0; }
.music-copy strong {
  display: block;
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 500;
  color: #f1ecdf;
  letter-spacing: -.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.music-copy small {
  display: block;
  margin-top: 3px;
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: .08em;
  color: #8c9186;
}
.music-track {
  display: block;
  width: 100%;
  height: 12px;
  margin-top: 10px;
  padding: 5px 0;
  background: transparent;
  cursor: pointer;
  position: relative;
}
.music-track::before {
  content: ""; position: absolute; left: 0; right: 0; top: 5px; height: 1px; background: #3b4036;
}
.music-track span {
  display: block; height: 2px; width: 0; background: var(--accent);
  position: relative; z-index: 1;
  transition: width .2s linear;
}
.music-controls { display: flex; align-items: center; gap: 5px; margin-top: 4px; }
.music-controls button {
  background: transparent;
  width: 25px; height: 25px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid #3b4036;
  color: #c3c6ba;
  transition: color .2s, border-color .2s, background .2s;
}
.music-controls button:hover { color: #fff; border-color: #656b5e; }
.music-controls button .icon { width: 12px; height: 12px; }
.music-play { background: var(--accent); border-color: var(--accent) !important; color: #fff !important; }
.music-play:hover { background: #b84534; }
.music-time { margin-left: auto; font-family: var(--mono); font-size: 7px; color: #8c9186; letter-spacing: .04em; }

/* rail density: keep the full profile including print action inside one viewport */
.rail { padding: 24px 26px 18px; }
.rail-intro { margin-top: 36px; }
.rail-bio { margin-top: 14px; }
.rail-nav { margin-top: 26px; }
.rail-nav a { padding: 7px 0; }
.music-player { margin-top: 16px; padding: 9px; }
.music-disc { width: 46px; height: 46px; }
.music-copy strong { font-size: 18px; }
.music-track { margin-top: 7px; }
.rail-heatmap { padding: 7px; margin-bottom: 9px; }
.status { margin-bottom: 8px; }
.print-btn { margin-top: 10px; height: 30px; }
.music-controls button.music-play { background: var(--accent); border-color: var(--accent); color: #fff; }
.music-controls button.music-play:hover { background: #b84534; border-color: #b84534; }

/* ---------- palettes ---------- */
html[data-theme="jade"] {
  --paper: #e8eee7;
  --paper-2: #f6faf4;
  --ink: #15211a;
  --ink-2: #3d4c41;
  --muted: #6c7b70;
  --line: #ccd7cb;
  --line-dark: #26342b;
  --accent: #2f6b53;
  --rail: #101b15;
  --rail-text: #e8f0e8;
  --green: #2f6b53;
  --heat-0: #27312a;
  --heat-1: #244f3d;
  --heat-2: #2f6b53;
  --heat-3: #46876b;
  --heat-4: #67a888;
}
html[data-theme="indigo"] {
  --paper: #e9edf3;
  --paper-2: #f8faff;
  --ink: #151b2b;
  --ink-2: #40495d;
  --muted: #6d7689;
  --line: #cfd6e2;
  --line-dark: #252d40;
  --accent: #3e5f8a;
  --rail: #121827;
  --rail-text: #e8edf6;
  --green: #3e6b78;
  --heat-0: #293140;
  --heat-1: #2f4668;
  --heat-2: #3e5f8a;
  --heat-3: #5b7da8;
  --heat-4: #7e9cc2;
}
html[data-theme="clay"] {
  --paper: #f0e9df;
  --paper-2: #fbf7f0;
  --ink: #271f19;
  --ink-2: #4b4037;
  --muted: #7b6c5e;
  --line: #ddd0c0;
  --line-dark: #33271e;
  --accent: #a05a32;
  --rail: #1d1712;
  --rail-text: #f1e8dc;
  --green: #4f6b4f;
  --heat-0: #332a22;
  --heat-1: #5a3b28;
  --heat-2: #7d4b2e;
  --heat-3: #a05a32;
  --heat-4: #c27a4b;
}
.heat-cell { background: var(--heat-0, #2b2f28); }
.heat-cell.level-1 { background: var(--heat-1, #5a342d); }
.heat-cell.level-2 { background: var(--heat-2, #7b3d31); }
.heat-cell.level-3 { background: var(--heat-3, #9a4938); }
.heat-cell.level-4 { background: var(--heat-4, #bf5b45); }

.theme-switcher {
  position: fixed;
  top: 14px;
  right: 18px;
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 8px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  box-shadow: 0 6px 16px rgba(23, 23, 20, .06);
}
.theme-label {
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: .12em;
  color: var(--muted);
  margin-right: 2px;
}
.theme-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: conic-gradient(var(--dot) 0 50%, var(--dot-bg) 50% 100%);
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.theme-dot:hover { transform: scale(1.16); }
.theme-dot.is-active { box-shadow: 0 0 0 2px var(--paper), 0 0 0 3px var(--accent); }
@media (max-width: 760px) {
  .theme-switcher { top: 10px; right: 10px; padding: 5px 7px; }
  .theme-label { display: none; }
}
@media print { .theme-switcher { display: none; } }

/* ---------- live code demo ---------- */
.lab { padding: 26px 0 38px; border-bottom: 1px solid var(--line); }
.lab-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 12px; }
.lab-head h2 {
  margin-top: 4px;
  font-family: var(--serif);
  font-size: 28px;
  line-height: 1.1;
  letter-spacing: -.03em;
  font-weight: 500;
}
.lab-run {
  display: inline-flex; align-items: center; gap: 7px;
  height: 30px; padding: 0 10px;
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: .08em;
  color: var(--muted);
  background: transparent;
  transition: color .2s, border-color .2s;
}
.lab-run:hover { color: var(--text); border-color: var(--accent); }
.lab-run .icon { width: 10px; height: 10px; }
.terminal { background: #121511; border: 1px solid #30352c; color: #d8e2d4; }
.terminal-bar { display: flex; align-items: center; justify-content: space-between; padding: 8px 11px; border-bottom: 1px solid #2b3028; }
.terminal-file { font-family: var(--mono); font-size: 8px; color: #929b8d; letter-spacing: .06em; }
.terminal-dots { display: flex; gap: 4px; }
.terminal-dots i { width: 4px; height: 4px; border-radius: 50%; background: #41473c; }
.terminal-code {
  margin: 0;
  padding: 13px 15px;
  min-height: 190px;
  font-family: var(--mono);
  font-size: 9px;
  line-height: 1.75;
  color: #cbd8c5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.terminal-code code { font: inherit; }
.code-caret {
  display: inline-block;
  width: 5px; height: 11px;
  margin-left: 2px;
  background: #c96a51;
  vertical-align: -1px;
  animation: caretBlink .9s step-end infinite;
}
@keyframes caretBlink { 50% { opacity: 0; } }
.terminal-output {
  min-height: 0;
  padding: 0 15px;
  font-family: var(--mono);
  font-size: 9px;
  line-height: 1.85;
  color: #7fb894;
  white-space: pre-wrap;
}
.terminal-output.is-run { padding-bottom: 13px; }
.terminal-output.is-run::before { content: ""; display: block; height: 1px; background: #2b3028; margin-bottom: 9px; }
@media (max-width: 760px) {
  .lab-head { display: block; }
  .lab-run { margin-top: 10px; }
  .terminal-code { min-height: 210px; font-size: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .code-caret { animation: none; }
}

/* ---------- selected work page ---------- */
.projects-main { padding: 58px 64px 38px; min-width: 0; }
.projects-hero { padding: 14px 0 30px; border-bottom: 1px solid var(--line); }
.projects-hero h1 {
  margin-top: 12px;
  font-family: var(--serif);
  font-size: clamp(44px, 5.4vw, 68px);
  line-height: 1;
  letter-spacing: -.05em;
  font-weight: 500;
}
.projects-hero > p { max-width: 560px; margin-top: 16px; font-size: 12px; line-height: 1.85; color: var(--ink-2); }
.back-link {
  display: inline-flex; align-items: center; gap: 7px;
  margin-top: 20px;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: .06em;
  color: var(--muted);
}
.back-link .icon { width: 13px; height: 13px; transform: rotate(180deg); }
.back-link:hover { color: var(--accent); }
.projects-main .section { border-bottom: 0; padding-top: 34px; }
.projects-main .section-head { margin-bottom: 22px; }
.projects-main .footer { margin-top: 10px; }
@media (max-width: 1080px) {
  .projects-main { padding: 46px 40px 30px; }
  .projects-hero { padding-top: 5px; }
}
@media (max-width: 760px) {
  .projects-main { padding: 36px 20px 26px; }
  .projects-hero h1 { font-size: 48px; }
}

.projects-status {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
  font-family: var(--mono);
  font-size: 8px;
  color: var(--muted);
}
.projects-status #repoStatus { color: var(--accent); letter-spacing: .08em; }
@media (max-width: 760px) {
  .projects-status { display: block; line-height: 1.8; }
}

/* landscape tablets: keep the first screen ending at the daily frame */
@media (orientation: landscape) and (min-width: 900px) {
  .first-screen { min-height: calc(100vh - 58px); }
  .hero { padding: 8px 0 22px; }
  .hero h2 { margin-top: 14px; font-size: clamp(38px, 4.8vw, 62px); }
  .hero-lead { margin-top: 14px; line-height: 1.7; }
  .hero-actions { margin-top: 16px; }
  .hero-meta { margin-top: 22px; padding-top: 12px; }
  .daily { position: relative; padding: 10px 0 0; }
  .daily-media { height: clamp(180px, 25vh, 220px); }
  .daily figcaption {
    position: absolute; left: 0; right: 0; bottom: 0;
    margin: 0; padding: 7px 10px;
    color: #f7f2e7;
    background: linear-gradient(180deg, transparent, rgba(23,23,20,.55));
    text-shadow: 0 1px 2px rgba(0,0,0,.5);
  }
}
@media (orientation: landscape) and (min-width: 900px) and (max-width: 1080px) {
  .first-screen { min-height: calc(100vh - 46px); }
}

/* run button states */
.lab-run:disabled { opacity: .48; cursor: wait; }
.lab-run.is-ready { color: var(--accent); border-color: var(--accent); }
.terminal.is-running { border-color: #6b3c31; box-shadow: 0 0 0 1px rgba(163,58,43,.25); }
.terminal-stage { position: relative; min-height: 200px; overflow: hidden; }
.terminal-output {
  position: absolute; right: 10px; top: 9px; z-index: 3;
  font-family: var(--mono); font-size: 7px; letter-spacing: .08em;
  color: #d8b08f; opacity: 0; transition: opacity .25s ease;
}
.terminal.is-running .terminal-output { opacity: 1; }
@media (max-width: 760px) {
  .terminal-stage { min-height: 190px; }
  .terminal-code { font-size: 8px; }
}

/* adaptive first screen: let the daily image fill the leftover height */
@media (orientation: landscape) and (min-width: 900px) {
  .first-screen {
    height: calc(100vh - 58px);
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  .first-screen .daily {
    flex: 1 1 auto;
    min-height: 160px;
    margin-top: 12px;
    padding: 0;
    display: flex;
    flex-direction: column;
  }
  .first-screen .daily-media {
    flex: 1 1 auto;
    height: auto;
    min-height: 150px;
  }
}
@media (orientation: landscape) and (min-width: 900px) and (max-width: 1080px) {
  .first-screen { height: calc(100vh - 46px); }
}

/* ---------- pull-cord tools ---------- */
.pull-tools {
  position: fixed;
  top: 0;
  right: 160px;
  z-index: 85;
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.pull-cord {
  width: 32px;
  height: 112px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.pull-cord.is-dragging { cursor: grabbing; }
.cord-line {
  width: 1px;
  height: calc(58px + var(--pull, 0) * 1px);
  background: linear-gradient(180deg, var(--line), var(--accent));
  transition: height .42s cubic-bezier(.18, 1.4, .3, 1);
}
.pull-cord.is-dragging .cord-line { transition: none; }
.cord-knob {
  position: relative;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper-2);
  border: 1px solid var(--line);
  color: var(--accent);
  box-shadow: 0 5px 14px rgba(23, 23, 20, .12);
  transition: transform .42s cubic-bezier(.18, 1.4, .3, 1), border-color .2s, background .2s;
}
.pull-cord.is-dragging .cord-knob { transition: none; }
.pull-cord:hover .cord-knob { border-color: var(--accent); }
.cord-knob .icon { width: 14px; height: 14px; }
.cord-hint {
  position: absolute;
  top: 34px;
  font-family: var(--mono);
  font-size: 6px;
  letter-spacing: .1em;
  color: var(--muted);
  opacity: 0;
  transition: opacity .2s;
  white-space: nowrap;
}
.pull-cord:hover .cord-hint, .pull-cord:focus-visible .cord-hint { opacity: 1; }
.pull-cord:focus-visible { outline: 1px solid var(--accent); outline-offset: 3px; }
.cord-sun { display: block; color: #d9a441; }
.cord-moon { display: none; color: #7fa8c9; }
html[data-mode="dark"] .cord-sun { display: none; }
html[data-mode="dark"] .cord-moon { display: block; }

/* ---------- dark mode ---------- */
html[data-mode="dark"] {
  --paper: #0f1411;
  --paper-2: #161d18;
  --ink: #e8efe6;
  --ink-2: #b8c4b9;
  --muted: #7f8c81;
  --line: #2e3a31;
  --line-dark: #d6e0d5;
  --accent: #d07058;
  --rail: #080c09;
  --rail-text: #e8efe6;
  --green: #76b594;
  --heat-0: #253028;
  --heat-1: #4a2d26;
  --heat-2: #7d3f32;
  --heat-3: #ad5742;
  --heat-4: #d47a5f;
}
html[data-mode="dark"] body { background: var(--paper); color: var(--ink); }
html[data-mode="dark"] .rail { background: #060907; }
html[data-mode="dark"] .hero { border-color: var(--line); }
html[data-mode="dark"] .btn-dark { background: var(--ink); border-color: var(--ink); color: var(--paper); }
html[data-mode="dark"] .btn-line { color: var(--ink); }
html[data-mode="dark"] .project-icon,
html[data-mode="dark"] .quick-icon,
html[data-mode="dark"] .contact-icon { color: var(--paper); }
html[data-mode="dark"] .project { background: var(--paper-2); }
html[data-mode="dark"] .project:hover { background: #1b241d; }
html[data-mode="dark"] .contact-link:hover { background: #1b241d; }
html[data-mode="dark"] .daily-media { border-color: var(--line); }
html[data-mode="dark"] .theme-switcher { background: var(--paper-2); }
html[data-mode="dark"] .theme-dot.is-active { box-shadow: 0 0 0 2px var(--paper), 0 0 0 3px var(--accent); }
html[data-mode="dark"] .terminal { border-color: #3b453b; }

@media (max-width: 760px) {
  .pull-tools { left: 50%; right: auto; transform: translateX(-50%); gap: 12px; }
  .pull-cord { height: 100px; }
  .cord-line { height: calc(50px + var(--pull, 0) * 1px); }
}
@media print { .pull-tools { display: none; } }

.terminal.is-running .terminal-code { opacity: 0; pointer-events: none; }
.terminal.is-running .terminal-output { opacity: 1; }

/* ASCII banner result: deterministic block layout, no continuous animation */
.terminal-output {
  position: absolute;
  inset: 0;
  z-index: 3;
  margin: 0;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-family: "DejaVu Sans Mono", monospace;
  font-size: clamp(9px, 1.35vw, 15px);
  line-height: 1.12;
  letter-spacing: .02em;
  color: #d7e1d1;
  white-space: pre;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease;
}
.terminal.is-running .terminal-output { opacity: 1; }
.terminal-output .agent-line {
  display: block !important;
  width: 100%;
  white-space: pre !important;
  text-align: center;
  opacity: 0;
  transform: translateY(2px);
  animation: asciiIn .22s ease forwards;
}
@keyframes asciiIn { to { opacity: 1; transform: none; } }
@media (max-width: 760px) {
  .terminal-output { font-size: 8px; padding: 10px; }
}

/* ASCII marquee: one block of symbols, repeated for a seamless left flow */
.terminal-output {
  display: block;
  padding: 0;
  overflow: hidden;
  align-items: initial;
  justify-content: initial;
  text-align: left;
}
.ascii-window {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent);
}
.ascii-track {
  display: flex;
  width: max-content;
  will-change: transform;
  animation: asciiFlow 18s linear infinite;
}
.ascii-block {
  flex: 0 0 auto;
  margin: 0 72px 0 0;
  font-family: "DejaVu Sans Mono", monospace;
  font-size: clamp(9px, 1.35vw, 15px);
  line-height: 1.08;
  letter-spacing: .03em;
  white-space: pre;
  text-align: left;
  color: #d7e1d1;
}
@keyframes asciiFlow {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}
@media (prefers-reduced-motion: reduce) {
  .ascii-track { animation: none; }
  .terminal-output { justify-content: center; }
}
@media (max-width: 760px) {
  .ascii-block { font-size: 9px; margin-right: 44px; }
}

/* keep the whole rail inside a short landscape viewport */
@media (orientation: landscape) and (min-width: 900px) and (max-height: 840px) {
  .print-btn { display: none; }
  .rail { padding-bottom: 12px; }
}
@media (orientation: landscape) and (min-width: 900px) and (max-height: 700px) {
  .rail { padding: 14px 22px 10px; }
  .rail-intro { margin-top: 18px; }
  .rail h1 { font-size: 30px; }
  .rail-bio { display: none; }
  .rail-nav { margin-top: 14px; }
  .rail-nav a { padding: 5px 0; }
  .music-player { margin-top: 10px; padding: 7px; }
  .music-disc { width: 38px; height: 38px; }
  .music-copy strong { font-size: 16px; }
  .music-track { margin-top: 5px; }
  .rail-heatmap { padding: 5px; margin-bottom: 6px; }
  .status { margin-bottom: 5px; }
  .rail-icons a { width: 28px; height: 28px; }
}

/* very short landscape: drop optional rail modules instead of making the rail scroll */
@media (orientation: landscape) and (max-height: 640px) {
  .rail-bio,
  .music-player,
  .rail-heatmap,
  .print-btn { display: none; }
  .rail { padding: 14px 22px 10px; }
  .rail-intro { margin-top: 14px; }
  .rail h1 { font-size: 30px; }
  .rail-nav { margin-top: 12px; }
  .rail-nav a { padding: 5px 0; }
  .rail-bottom { margin-top: auto; }
}

/* Clawd, the Claude Code pixel pet — original GIF, transparent whitespace cropped by CSS */
.clawd-pet {
  position: fixed;
  right: 24px;
  bottom: 18px;
  z-index: 75;
  width: 100px;
  height: 70px;
  display: block;
  overflow: hidden;
  filter: drop-shadow(0 4px 5px rgba(0, 0, 0, .12));
  animation: clawdBob 3.4s ease-in-out infinite;
  transition: transform .2s ease;
}
.clawd-pet:hover { transform: translateY(-2px) scale(1.04); }
.clawd-window { display: block; width: 100%; height: 100%; position: relative; overflow: hidden; }
.clawd-window img {
  position: absolute;
  width: 260px;
  height: auto;
  left: -82px;
  top: -174px;
  image-rendering: pixelated;
  display: block;
}
@keyframes clawdBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@media (max-width: 760px) {
  .clawd-pet { width: 74px; height: 52px; right: 12px; bottom: 10px; }
  .clawd-window img { width: 190px; left: -60px; top: -126px; }
}
@media (prefers-reduced-motion: reduce) {
  .clawd-pet { animation: none; }
}
@media print { .clawd-pet { display: none; } }
