html, body { height: 100%; }
html { overflow: hidden; }
body {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: auto 1fr auto auto;
  grid-template-areas:
    "top  top"
    "nav  main"
    "stat stat"
    "copy copy";
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
@media (max-width: 820px) {
  html { overflow: auto; }
  body { grid-template-columns: 1fr; grid-template-areas: "top" "nav" "main" "stat" "copy"; height: auto; overflow: visible; }
  .sidenav { position: static; height: auto; max-height: 300px; z-index: 5; }
  main { overflow: visible !important; height: auto !important; }
}

/* top bar */
.topbar {
  grid-area: top;
  display: flex; align-items: center; gap: 14px; padding: 8px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-raised);
  font-size: var(--fs-sm);
  z-index: 20;
}
.topbar .brand { color: var(--accent); font-weight: 600; }
.topbar .sep { color: var(--fg-dimmer); }
.topbar .path { color: var(--fg-dim); }
.topbar .path .cur { color: var(--fg); }
.topbar .spacer { flex: 1; }
.topbar .hint { color: var(--fg-dimmer); font-size: var(--fs-xs); }

/* sidenav */
.sidenav {
  grid-area: nav;
  border-right: 1px solid var(--border);
  background: var(--bg-raised);
  padding: 14px 0;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.sidenav .group-head { flex: none; }
.sidenav .nav-item   { flex: none; }
.sidenav hr          { flex: none; }
.sidenav .side-meta  { margin-top: auto; padding-top: 16px; }
.sidenav .side-fill  { flex: 1; min-height: 14px; }
.sidenav .group-head {
  padding: 0 16px 6px; color: var(--fg-dimmer);
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.1em;
}
.sidenav a.nav-item {
  display: flex; align-items: baseline; gap: 10px;
  padding: 5px 16px; color: var(--fg-dim);
  font-size: var(--fs-sm);
  border-left: 2px solid transparent;
  border-bottom: 0 !important;
  position: relative;
}
.sidenav a.nav-item .n {
  color: var(--fg-dimmer); font-variant-numeric: tabular-nums;
  font-size: var(--fs-xs); min-width: 22px;
}
.sidenav a.nav-item .lbl { flex: 1; }
.sidenav a.nav-item .k {
  color: var(--fg-dimmer); font-size: var(--fs-xs);
  opacity: 0; transition: opacity .15s;
}
.sidenav a.nav-item:hover {
  color: var(--fg); background: color-mix(in oklab, var(--accent) 8%, transparent);
}
.sidenav a.nav-item:hover .k { opacity: 1; }
.sidenav a.nav-item.active {
  color: var(--fg); border-left-color: var(--accent);
  background: color-mix(in oklab, var(--accent) 15%, transparent);
}
.sidenav a.nav-item.active .n { color: var(--accent); }
.sidenav a.nav-item.active::before {
  content: "❯"; position: absolute; left: 4px; color: var(--accent);
  font-size: var(--fs-xs);
}
.sidenav hr {
  border: 0; border-top: 1px dashed var(--border); margin: 14px 10px;
}
.sidenav .side-meta {
  padding: 0 16px; font-size: var(--fs-xs); color: var(--fg-dimmer);
  margin-top: 10px;
}
.sidenav .side-meta .row { display: flex; justify-content: space-between; padding: 2px 0; }
.sidenav .side-meta .row .v { color: var(--fg-dim); }

/* main */
main {
  grid-area: main;
  padding: 32px 42px 80px;
  width: 100%;
  min-width: 0; min-height: 0;
  overflow-y: auto;
}
main > .view { max-width: 860px; }
@media (max-width: 720px) { main { padding: 24px 20px 60px; } }

/* sections */
.view {
  display: none;
  animation: fade .25s ease-out;
  outline: none;
}
.view.active { display: block; }
@keyframes fade {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.view-head {
  padding-bottom: 12px; margin-bottom: 24px;
  border-bottom: 1px dashed var(--border);
}
.view-head .crumb {
  color: var(--fg-dimmer); font-size: var(--fs-sm); margin-bottom: 6px;
}
.view-head h2 {
  margin: 0; font-size: var(--fs-2xl); font-weight: 500;
  color: var(--fg); letter-spacing: -0.3px;
}
.view-head h2 .n { color: var(--accent); margin-right: 8px; font-weight: 400; }
.view-head .sub {
  color: var(--fg-dim); margin-top: 6px; font-size: var(--fs-md);
}

/* HOME intro — CSS hides content before first paint; JS removes [data-intro] to reveal */
#hero-cmd { opacity: 0; }
section[data-view="home"][data-intro] h1,
section[data-view="home"][data-intro] .role,
section[data-view="home"][data-intro] .secondary,
section[data-view="home"][data-intro] .meta,
section[data-view="home"][data-intro] .hero-art,
section[data-view="home"][data-intro] .section-title,
section[data-view="home"][data-intro] #featured-grid,
section[data-view="home"][data-intro] .about-grid,
section[data-view="home"][data-intro] .skills-grid { opacity: 0; }
section[data-view="home"].home-revealing h1,
section[data-view="home"].home-revealing .role,
section[data-view="home"].home-revealing .secondary,
section[data-view="home"].home-revealing .meta,
section[data-view="home"].home-revealing .hero-art,
section[data-view="home"].home-revealing .section-title,
section[data-view="home"].home-revealing #featured-grid,
section[data-view="home"].home-revealing .about-grid,
section[data-view="home"].home-revealing .skills-grid { transition: opacity 0.4s ease; }

/* HOME */
.hero {
  display: grid; grid-template-columns: 1fr auto; gap: 28px;
  align-items: start;
}
.hero-text { min-width: 0; }
.hero-tag {
  color: var(--fg-dimmer); font-size: var(--fs-sm); margin-bottom: 8px;
}
.hero h1 {
  margin: 4px 0 10px; font-size: var(--fs-3xl); font-weight: 500;
  letter-spacing: -0.5px; color: var(--fg); line-height: 1.15;
}
.hero h1 .at { color: var(--accent); }
.hero .role {
  font-size: var(--fs-lg); color: var(--accent-2); margin-bottom: 4px;
}
.hero .secondary {
  color: var(--fg-dim); font-size: var(--fs-md);
  max-width: 62ch; margin-bottom: 20px;
}
.hero .meta {
  display: flex; flex-wrap: wrap; gap: 14px 22px;
  font-size: var(--fs-sm); color: var(--fg-dim);
  padding: 12px 0; border-top: 1px dashed var(--border);
  border-bottom: 1px dashed var(--border); margin-bottom: 12px;
}
.hero .meta .muted { color: var(--fg-dimmer); margin-right: 6px; }
.hero-art {
  margin: 0;
  padding: 6px 8px;
  border: 1px solid var(--green);
  border-radius: 3px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 4.5px; line-height: 1.05; letter-spacing: 0;
  color: var(--green); opacity: 0.85;
  background: transparent;
  white-space: pre; overflow: hidden;
  user-select: none; pointer-events: none;
  align-self: center;
}
:root[data-theme="latte"] .hero-art {
  color: var(--base);
  background: var(--subtext1);
  border-color: var(--green);
  opacity: 1;
}
@media (max-width: 1100px) {
  .hero-art { font-size: 3.5px; }
}
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .hero-art { display: none; }
}

/* featured grid */
.section-title {
  display: flex; align-items: baseline; gap: 12px; margin: 20px 0 14px;
}
.section-title h3 {
  margin: 0; font-size: var(--fs-md); color: var(--fg);
  font-weight: 600;
}
.section-title h3 .hash { color: var(--accent); margin-right: 6px; }
.section-title .rule-fill {
  flex: 1; color: var(--border-hi); overflow: hidden;
  white-space: nowrap; letter-spacing: -1px;
}
.section-title .n { color: var(--fg-dimmer); font-size: var(--fs-sm); }

.featured-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
@media (max-width: 720px) { .featured-grid { grid-template-columns: 1fr; } }
.card {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-raised); padding: 14px 16px;
  display: flex; flex-direction: column; gap: 6px; position: relative;
  overflow: hidden; transition: border-color .15s, transform .15s;
  color: inherit; text-decoration: none;
}
.card:hover { border-color: var(--accent); transform: translateY(-1px); }
.card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px;
  background: var(--accent); opacity: 0.8;
}
.card[data-kind="setup"]::before    { background: var(--teal); }
.card[data-kind="work"]::before     { background: var(--peach); }
.card[data-kind="dotfiles"]::before { background: var(--mauve); }
.card h4 {
  margin: 0; font-size: var(--fs-md); color: var(--fg); font-weight: 600;
}
.card .meta {
  font-size: var(--fs-xs); color: var(--fg-dimmer);
  letter-spacing: 0.05em; text-transform: uppercase;
}
.card p {
  margin: 4px 0 0; color: var(--fg-dim);
  font-size: var(--fs-sm); line-height: 1.5;
}
.card .stack {
  display: flex; gap: 4px; flex-wrap: wrap; margin-top: auto; padding-top: 6px;
}

/* shortcuts grid on home */
.shortcuts {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  margin-top: 10px;
}
@media (max-width: 720px) { .shortcuts { grid-template-columns: 1fr 1fr; } }
.shortcut {
  display: block; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-raised); color: var(--fg);
  border-bottom: 1px solid var(--border) !important;
  transition: border-color .15s, background .15s;
}
.shortcut:hover {
  border-color: var(--accent); background: color-mix(in oklab, var(--accent) 10%, var(--bg-raised));
}
.shortcut .n { color: var(--fg-dimmer); font-size: var(--fs-xs); display: block; margin-bottom: 2px; }
.shortcut .lbl { color: var(--fg); font-size: var(--fs-sm); font-weight: 500; }
.shortcut .desc { color: var(--fg-dim); font-size: var(--fs-xs); margin-top: 3px; display: block; }

/* ABOUT */
.about-grid {
  display: grid; grid-template-columns: 2fr 1fr; gap: 28px;
}
@media (max-width: 720px) { .about-grid { grid-template-columns: 1fr; } }
.about-text { color: var(--fg-dim); font-size: var(--fs-md); line-height: 1.7; }
.about-bio {
  margin: 0; padding-left: 14px;
  border-left: 2px solid var(--green);
}
.about-bio p { margin: 0 0 10px; }
.about-bio p:last-child { margin-bottom: 0; }

.stats {
  font-size: var(--fs-sm); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; align-self: start;
}
.stats .row {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 6px 12px; border-bottom: 1px solid var(--border);
}
.stats .row:last-child { border-bottom: 0; }
.stats .row .k { color: var(--fg-dim); }
.stats .row .v { color: var(--fg); font-weight: 500; }

.skills-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px 28px;
  margin-top: 28px;
}
@media (max-width: 720px) { .skills-grid { grid-template-columns: 1fr; } }
.skills-col h5 {
  margin: 0 0 6px; font-size: var(--fs-xs); color: var(--accent);
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em;
}
.skills-col ul { margin: 0; padding: 0; list-style: none; }
.skills-col li {
  color: var(--fg-dim); padding: 2px 0; font-size: var(--fs-sm);
}
.skills-col li::before { content: "· "; color: var(--accent); }

/* WORK */
.timeline { border-left: 1px dashed var(--border-hi); padding-left: 22px; margin-left: 8px; }
.job { margin-bottom: 24px; position: relative; }
.job::before {
  content: "▸"; position: absolute; left: -28px; top: 0;
  color: var(--accent); font-size: 0.85em;
}
.job-head {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px;
  margin-bottom: 4px;
}
.job-head .role { color: var(--fg); font-weight: 600; font-size: var(--fs-md); }
.job-head .org { color: var(--accent-2); }
.job-head .dates {
  color: var(--fg-dimmer); font-size: var(--fs-sm);
  margin-left: auto; font-variant-numeric: tabular-nums;
}
.job-head .loc { color: var(--fg-dimmer); font-size: var(--fs-sm); }
.job ul {
  margin: 6px 0 0; padding-left: 18px;
  color: var(--fg-dim); font-size: var(--fs-sm);
}
.job ul li { padding: 2px 0; }
.job ul li::marker { color: var(--fg-dimmer); content: "└ "; }

/* CREDITS TABS */
.tab-bar {
  display: flex; align-items: center; gap: 4px;
  margin-bottom: 14px;
}
.tab-bar .tab {
  background: none; border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--fg-dim); font-size: var(--fs-xs); padding: 3px 12px;
  cursor: pointer; font-family: inherit; letter-spacing: 0.04em;
  transition: color .15s, border-color .15s, box-shadow .15s;
  outline: none;
}
.tab-bar .tab:hover { color: var(--fg); border-color: var(--fg-dimmer); }
.tab-bar .tab.active {
  color: var(--accent); border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
  background: color-mix(in oklab, var(--accent) 8%, transparent);
}
.tab-bar .tab-hint { color: var(--fg-dimmer); font-size: var(--fs-xs); margin-left: 8px; }
.tab-bar .tab-hint kbd { font-family: inherit; }

/* CREDITS */
.credits-table {
  font-size: var(--fs-sm); width: 100%; border-collapse: collapse;
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.credits-table thead { background: color-mix(in oklab, var(--bg-deep) 30%, var(--bg-raised)); }
.credits-table th {
  text-align: left; padding: 6px 12px; font-weight: 600; color: var(--fg-dim);
  border-bottom: 1px solid var(--border); font-size: var(--fs-xs);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.credits-table td {
  padding: 6px 12px; color: var(--fg-dim);
  border-bottom: 1px solid color-mix(in oklab, var(--border) 50%, transparent);
}
.credits-table tr:last-child td { border-bottom: 0; }
.credits-table tr:hover td { background: color-mix(in oklab, var(--accent) 7%, transparent); }
.credits-table .yr { color: var(--peach); font-variant-numeric: tabular-nums; width: 70px; }
.credits-table .artist { color: var(--fg); }
.credits-table .title { color: var(--accent-2); }
.credits-table .roles { color: var(--fg-dimmer); font-size: var(--fs-xs); }
.credits-table .type-badge { color: var(--fg-dimmer); font-size: var(--fs-xs); font-variant: small-caps; letter-spacing: 0.06em; }

/* EDUCATION */
.edu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
@media (max-width: 720px) { .edu-grid { grid-template-columns: 1fr; } }
.edu-list .item, .cert-list .item {
  padding: 8px 0; border-bottom: 1px dashed var(--border);
}
.edu-list .item:last-child, .cert-list .item:last-child { border-bottom: 0; }
.edu-list .school { color: var(--fg); font-weight: 500; }
.edu-list .meta {
  color: var(--fg-dimmer); font-size: var(--fs-sm);
  display: flex; gap: 10px; flex-wrap: wrap;
}
.edu-list .degree { color: var(--accent-2); }
.cert-list .item {
  color: var(--fg-dim); font-size: var(--fs-sm);
  display: flex; gap: 10px;
}
.cert-list .item::before { content: "✓"; color: var(--green); }

/* NOTES */
.posts a.post {
  display: grid; grid-template-columns: 100px 1fr auto;
  gap: 14px; padding: 8px 10px; border-radius: var(--radius);
  color: var(--fg); align-items: baseline;
  border-bottom: 0 !important;
  border-left: 2px solid transparent;
}
.posts a.post:hover, .posts a.post:focus-visible {
  background: var(--bg-raised); border-left-color: var(--accent); outline: 0;
}
.posts .date { color: var(--fg-dimmer); font-variant-numeric: tabular-nums; font-size: var(--fs-sm); }
.posts .title { color: var(--fg); }
.posts .tag {
  color: var(--accent); font-size: var(--fs-xs);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.posts a.post-stub { opacity: 0.55; }
.posts a.post-stub .title::after {
  content: " · draft"; color: var(--fg-dimmer);
  font-size: var(--fs-xs); letter-spacing: 0.08em; text-transform: uppercase;
}

/* single post */
.post-body {
  max-width: 72ch; margin-top: 8px;
  color: var(--fg-dim); font-size: var(--fs-md); line-height: 1.65;
  outline: none; padding-left: 14px;
  border-left: 2px solid transparent;
  transition: border-color .15s;
}
.post-body:focus-visible, .post-body:focus {
  border-left-color: var(--accent);
}
.post-body h3 {
  margin: 28px 0 8px; color: var(--fg);
  font-size: var(--fs-md); font-weight: 600; letter-spacing: 0.02em;
}
.post-body h3:first-child { margin-top: 4px; }
.post-body p { margin: 10px 0; }
.post-body ul { margin: 10px 0; padding-left: 18px; }
.post-body li { margin: 4px 0; }
.post-body li::marker { color: var(--accent); }
.post-back {
  display: inline-block; margin-top: 28px;
  color: var(--fg-dim); font-size: var(--fs-sm);
  border-bottom: 1px dashed transparent;
}
.post-back:hover { color: var(--accent); border-bottom-color: var(--accent); }

.np-foot {
  color: var(--fg-dimmer); font-size: var(--fs-xs);
}
.np-foot .np-dot { color: var(--fg-dimmer); }
.np-foot .np-dot.live { color: var(--green); }

/* status */
footer.status {
  grid-area: stat;
  border-top: 1px solid var(--border); background: var(--bg-raised);
  padding: 6px 20px; font-size: var(--fs-xs); color: var(--fg-dimmer);
  display: flex; gap: 16px; align-items: center;
}
footer .accent { color: var(--accent); }
footer .mode {
  color: var(--crust); background: var(--peach); font-weight: 700;
  padding: 1px 8px; border-radius: 2px; letter-spacing: 0.05em;
}
footer .mode[data-mode="insert"] { background: var(--green); }
footer .mode[data-mode="visual"] { background: var(--lavender); }
footer .spacer { flex: 1; }
footer .theme { cursor: pointer; }
footer .theme:hover { color: var(--accent); }

.copyright {
  grid-area: copy;
  text-align: center; padding: 4px 20px;
  font-size: 10px; color: var(--overlay0);
  background: var(--bg-raised); border-top: 1px solid var(--border);
}

/* Tweaks panel */
#tweaks {
  position: fixed; right: 16px; bottom: 56px;
  width: 280px; z-index: 10000;
  background: var(--bg-raised); border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  font-family: var(--font-mono); font-size: var(--fs-xs);
  color: var(--fg); box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  display: none;
}
#tweaks.on { display: block; }
#tweaks .tw-head {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-bottom: 1px solid var(--border);
  background: var(--bg-deep); border-radius: var(--radius) var(--radius) 0 0;
}
#tweaks .tw-head .dot { color: var(--red); }
#tweaks .tw-head .dot:nth-child(2) { color: var(--yellow); }
#tweaks .tw-head .dot:nth-child(3) { color: var(--green); }
#tweaks .tw-title { color: var(--fg-dim); font-weight: 600; margin-left: 4px; }
#tweaks .tw-x {
  margin-left: auto; cursor: pointer; color: var(--fg-dimmer); padding: 0 4px;
}
#tweaks .tw-x:hover { color: var(--red); }
#tweaks .tw-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 10px; }
#tweaks .row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
#tweaks .row label { color: var(--fg-dim); flex: 1; }
#tweaks .row .v { color: var(--accent); font-variant-numeric: tabular-nums; min-width: 4ch; text-align: right; }
#tweaks input[type=range] { flex: 1.2; accent-color: var(--accent); }
#tweaks .seg {
  display: inline-flex; border: 1px solid var(--border); border-radius: 3px; overflow: hidden;
}
#tweaks .seg button {
  background: transparent; border: 0; color: var(--fg-dim);
  font-family: inherit; font-size: var(--fs-xs); padding: 2px 8px; cursor: pointer;
}
#tweaks .seg button.on { background: var(--accent); color: var(--crust); }
#tweaks .swatches { display: flex; gap: 4px; }
#tweaks .swatches button {
  width: 18px; height: 18px; border-radius: 50%; border: 2px solid transparent;
  cursor: pointer; padding: 0;
}
#tweaks .swatches button.on { border-color: var(--fg); }

/* spatial-nav focus */
.card:focus-visible,
.shortcut:focus-visible,
#credits-table-music tr.linked .title { text-decoration: underline; text-decoration-color: color-mix(in oklab, var(--accent-2) 50%, transparent); text-underline-offset: 3px; }
#credits-table-music tr:focus-visible,
#credits-table-film tr:focus-visible {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
#credits-table-music tr:focus-visible td,
#credits-table-film tr:focus-visible td { background: color-mix(in oklab, var(--accent) 12%, transparent); }
