:root {
    --bg: #14120F;
    --bg-elev: #1C1915;
    --ink: #EDE6D8;
    --ink-dim: #A69C89;
    --ink-faint: #6E6656;
    --accent: #E2A33D;
    --accent-2: #7C9C8E;
    --line: #38332B;
    --serif: 'Fraunces', Georgia, serif;
    --sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --mono: 'IBM Plex Mono', 'SF Mono', Menlo, monospace;
  }

  :root:not([data-theme="light"]) {
    color-scheme: dark;
  }

  @media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
      --bg: #FAF7F0;
      --bg-elev: #F1ECE0;
      --ink: #1E1B15;
      --ink-dim: #5B5343;
      --ink-faint: #8C8268;
      --accent: #B87A1E;
      --accent-2: #4E6E60;
      --line: #DDD5C2;
    }
  }

  :root[data-theme="light"] {
    --bg: #FAF7F0;
    --bg-elev: #F1ECE0;
    --ink: #1E1B15;
    --ink-dim: #5B5343;
    --ink-faint: #8C8268;
    --accent: #B87A1E;
    --accent-2: #4E6E60;
    --line: #DDD5C2;
  }

  * { box-sizing: border-box; }

  html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
  }

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

  body {
    min-height: 100vh;
  }

  a {
    color: inherit;
  }

  ::selection {
    background: var(--accent);
    color: var(--bg);
  }

  .wrap {
    max-width: 680px;
    margin: 0 auto;
    padding: 0 28px;
  }

  /* ---------- Nav ---------- */
  nav {
    position: sticky;
    top: 0;
    z-index: 10;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--line);
  }
  nav .wrap {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 16px;
    padding-bottom: 16px;
  }
  nav .name {
    font-family: var(--serif);
    font-weight: 500;
    font-size: 17px;
    letter-spacing: 0.01em;
    text-decoration: none;
  }
  nav .links {
    display: flex;
    gap: 22px;
    font-size: 14px;
  }
  nav .links a {
    text-decoration: none;
    color: var(--ink-dim);
    transition: color 0.15s ease;
  }
  nav .links a:hover {
    color: var(--accent);
  }

  /* ---------- Hero ---------- */
  header.hero {
    padding: 72px 0 48px;
    position: relative;
    overflow: hidden;
  }
  .wave-svg {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 8px;
    width: 100%;
    height: 90px;
    opacity: 0.55;
    pointer-events: none;
  }
  .wave-path {
    fill: none;
    stroke: var(--accent);
    stroke-width: 1.4;
    stroke-linecap: round;
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    animation: draw 2.4s cubic-bezier(0.65, 0, 0.35, 1) forwards 0.3s;
  }
  @media (prefers-reduced-motion: reduce) {
    .wave-path { animation: none; stroke-dashoffset: 0; }
  }
  @keyframes draw {
    to { stroke-dashoffset: 0; }
  }

  h1.display {
    font-family: var(--serif);
    font-weight: 500;
    font-size: clamp(40px, 7vw, 60px);
    line-height: 1.02;
    letter-spacing: -0.01em;
    margin: 0 0 14px;
    position: relative;
  }
  .tagline {
    font-family: var(--mono);
    font-size: 14px;
    color: var(--accent-2);
    margin: 0 0 34px;
    letter-spacing: 0.01em;
  }
  .lede {
    font-size: 17px;
    color: var(--ink);
    max-width: 58ch;
    margin: 0 0 30px;
  }
  .lede .accent-word {
    color: var(--accent);
  }

  .quicklinks {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
    font-size: 14px;
    position: relative;
  }
  .quicklinks a {
    text-decoration: none;
    color: var(--ink-dim);
    border-bottom: 1px solid var(--line);
    padding-bottom: 2px;
    transition: color 0.15s ease, border-color 0.15s ease;
  }
  .quicklinks a:hover {
    color: var(--accent);
    border-color: var(--accent);
  }
  .quicklinks a.primary {
    color: var(--accent);
    border-color: var(--accent);
  }

  /* ---------- Section headers ---------- */
  section {
    padding: 44px 0;
    border-top: 1px solid var(--line);
    scroll-margin-top: 64px;
  }
  h2.section-title {
    font-family: var(--serif);
    font-weight: 500;
    font-style: italic;
    font-size: 22px;
    margin: 0 0 24px;
    color: var(--ink);
  }

  /* ---------- About ---------- */
  #about p {
    font-size: 16px;
    color: var(--ink);
    max-width: 62ch;
    margin: 0 0 16px;
  }
  #about p:last-child { margin-bottom: 0; }
  #about a {
    color: var(--accent-2);
    text-decoration: underline;
    text-decoration-color: var(--line);
    text-underline-offset: 3px;
  }
  #about a:hover {
    text-decoration-color: var(--accent-2);
  }

  /* ---------- Work log ---------- */
  .entry {
    padding: 22px 0;
    border-bottom: 1px solid var(--line);
  }
  .entry:last-child { border-bottom: none; padding-bottom: 0; }
  .entry:first-child { padding-top: 0; }
  .entry-meta {
    font-family: var(--mono);
    font-size: 12.5px;
    color: var(--ink-faint);
    margin-bottom: 8px;
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
  }
  .entry-tag {
    color: var(--accent-2);
  }
  h3.entry-title {
    font-family: var(--serif);
    font-weight: 500;
    font-size: 20px;
    margin: 0 0 10px;
  }
  .entry p {
    font-size: 15px;
    color: var(--ink-dim);
    max-width: 60ch;
    margin: 0 0 10px;
  }
  .entry p:last-of-type { margin-bottom: 0; }
  .entry-links {
    margin-top: 12px;
    display: flex;
    gap: 16px;
    font-size: 14px;
  }
  .entry-links a {
    text-decoration: none;
    color: var(--accent);
    border-bottom: 1px solid transparent;
  }
  .entry-links a:hover {
    border-color: var(--accent);
  }
  .placeholder-note {
    font-size: 13px;
    color: var(--ink-faint);
    font-style: italic;
  }

  /* ---------- Open media/code/link slots ---------- */
  .media-row {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    justify-content: center;
    margin: 16px 0 4px;
  }
  .media-slot {
    flex: 1 1 200px;
    aspect-ratio: 4 / 3;
    border: 1px dashed var(--line);
    border-radius: 3px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--ink-faint);
    font-family: var(--mono);
    font-size: 12px;
    text-align: center;
    padding: 12px;
  }
  .media-slot.video {
    aspect-ratio: 16 / 9;
    flex-basis: 100%;
  }
  .media-slot .slot-icon {
    font-size: 20px;
    opacity: 0.55;
  }
  .media-photo {
    flex: 1 1 200px;
    max-width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 3px;
    border: 1px solid var(--line);
    display: block;
  }
  .media-photo.no-crop {
    object-fit: contain;
    background: #fff;
  }
  .media-photo.media-natural {
    flex: 0 1 auto;
    aspect-ratio: auto;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 480px;
    object-fit: contain;
    background: transparent;
  }
  video.media-photo {
    flex-basis: 100%;
    aspect-ratio: auto;
    width: auto;
    max-width: 100%;
    max-height: 520px;
    object-fit: contain;
    background: #000;
    margin: 0 auto;
  }
  .media-chart {
    flex-basis: 100%;
    aspect-ratio: auto;
    width: auto;
    max-width: 100%;
    max-height: 420px;
    object-fit: contain;
    background: #fff;
    margin: 0 auto;
  }
  .code-slot {
    border: 1px dashed var(--line);
    border-radius: 3px;
    padding: 16px 18px;
    font-family: var(--mono);
    font-size: 12.5px;
    line-height: 1.7;
    color: var(--ink-faint);
    white-space: pre-wrap;
    margin: 16px 0 4px;
  }
  .code-slot .slot-label {
    display: block;
    color: var(--accent-2);
    margin-bottom: 8px;
  }
  .code-details {
    margin: 14px 0 4px;
  }
  .code-details summary {
    cursor: pointer;
    font-family: var(--mono);
    font-size: 13px;
    color: var(--accent);
    padding: 4px 0;
    list-style: revert;
  }
  .code-details summary:hover {
    text-decoration: underline;
  }
  .code-details[open] summary {
    margin-bottom: 4px;
  }
  .code-details .code-slot {
    margin-top: 10px;
  }
  .text-details {
    margin: 4px 0 0;
  }
  .text-details summary {
    cursor: pointer;
    font-family: var(--sans);
    font-size: 14px;
    font-weight: 500;
    color: var(--accent);
    padding: 2px 0;
    list-style: revert;
  }
  .text-details summary:hover {
    text-decoration: underline;
  }
  .text-details p {
    margin-top: 10px;
  }
  .link-slot {
    color: var(--ink-faint);
    font-style: italic;
    border-bottom: 1px dashed var(--ink-faint);
    padding-bottom: 1px;
  }

  /* ---------- Contact ---------- */
  #contact p {
    font-size: 16px;
    color: var(--ink-dim);
    max-width: 56ch;
    margin: 0 0 22px;
  }
  .contact-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 22px;
    font-size: 15px;
  }
  .contact-links a {
    text-decoration: none;
    color: var(--ink);
    border-bottom: 1px solid var(--line);
    padding-bottom: 2px;
  }
  .contact-links a:hover {
    color: var(--accent);
    border-color: var(--accent);
  }

  /* ---------- Poster overlay ---------- */
  .poster-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: var(--bg);
    display: flex;
    flex-direction: column;
  }
  .poster-overlay[hidden] {
    display: none;
  }
  .poster-topbar {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--line);
    background: var(--bg-elev);
    flex: 0 0 auto;
  }
  .poster-back {
    font-family: var(--sans);
    font-size: 14px;
    color: var(--accent);
    background: none;
    border: 1px solid var(--line);
    border-radius: 3px;
    padding: 7px 14px;
    cursor: pointer;
  }
  .poster-back:hover {
    border-color: var(--accent);
  }
  .poster-overlay-title {
    font-family: var(--serif);
    font-size: 15px;
    color: var(--ink-dim);
  }
  .poster-download {
    margin-left: auto;
    font-family: var(--sans);
    font-size: 13px;
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid var(--line);
  }
  .poster-download:hover {
    border-color: var(--accent);
  }
  .poster-scroll {
    flex: 1 1 auto;
    overflow: auto;
    background: #fff;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
  }
  .poster-img {
    max-width: 100%;
    width: auto;
    height: auto;
    flex-shrink: 0;
    display: block;
  }

  footer {
    padding: 30px 0 50px;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--ink-faint);
  }

  @media (max-width: 520px) {
    .wrap { padding: 0 20px; }
    header.hero { padding: 52px 0 36px; }
    nav .links { gap: 14px; font-size: 13px; }
  }
