:root {
  color-scheme: light;
  --desk: #d9d1bf;
  --paper: #f3eedf;
  --paper-raised: #f8f4e9;
  --ink: #16263a;
  --muted: #5a5952;
  --faint: rgba(22, 38, 58, 0.2);
  --rule: rgba(22, 38, 58, 0.38);
  --accent: #c94f36;
  --accent-secondary: #a83c2c;
  --mustard: #b17c17;
  --sage: #6b874f;
  --blue: #3d76a4;
  --pink: #b74e78;
  --shadow: rgba(52, 43, 28, 0.2);
  --grain: rgba(43, 37, 28, 0.025);
  --focus: #1b6fa8;
  --font-body: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-hand: "Caveat", "Comic Sans MS", cursive;
}

:root[data-theme="dark"] {
  /* Keep native image compositing stable; all visible controls are themed below. */
  color-scheme: light;
  --desk: #030a15;
  --paper: #071426;
  --paper-raised: #10223d;
  --ink: #f1eee6;
  --muted: #a8b2c1;
  --faint: rgba(200, 215, 235, 0.14);
  --rule: rgba(200, 215, 235, 0.34);
  --accent: #e36a9d;
  --accent-secondary: #f093b9;
  --mustard: #e0b84f;
  --sage: #85c46c;
  --blue: #6aa8e3;
  --pink: #e36a9d;
  --shadow: rgba(0, 0, 0, 0.42);
  --grain: rgba(255, 255, 255, 0.018);
  --focus: #f3cc59;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background: var(--desk);
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--desk);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
}

a:focus-visible,
button:focus-visible,
select:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 4px;
}

.skip-link {
  position: fixed;
  z-index: 50;
  top: 12px;
  left: 12px;
  padding: 8px 12px;
  color: var(--paper);
  background: var(--ink);
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.notebook-shell {
  position: relative;
  display: grid;
  grid-template-columns: minmax(250px, 300px) minmax(0, 1fr);
  max-width: 1440px;
  min-height: 100vh;
  margin: 0 auto;
  background-color: var(--paper);
  background-image:
    repeating-linear-gradient(0deg, transparent 0 4px, var(--grain) 5px, transparent 6px),
    radial-gradient(circle at 18% 26%, var(--grain) 0 1px, transparent 1.5px);
  background-size: auto, 14px 14px;
  box-shadow: 0 0 48px var(--shadow);
  transition: color 180ms ease, background-color 180ms ease;
}

.notebook-shell::after {
  content: "";
  position: absolute;
  z-index: 2;
  top: 0;
  bottom: 0;
  left: 300px;
  width: 1px;
  background: var(--faint);
  box-shadow: 6px 0 12px rgba(0, 0, 0, 0.05);
  pointer-events: none;
}

.identity {
  position: relative;
  padding: 54px 42px 40px;
}

.identity__inner {
  position: sticky;
  top: 42px;
}

.wordmark,
.section-heading p,
.section-heading h2,
.hand-label {
  font-family: var(--font-hand);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.wordmark {
  display: inline-block;
  color: var(--ink);
  font-size: 30px;
  line-height: 1;
  text-decoration: none;
  transform: rotate(-1deg);
}

.role {
  margin: 10px 0 0;
  color: var(--accent);
  font-family: var(--font-hand);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.2;
}

.pencil-rule {
  width: 100%;
  height: 1px;
  margin: 30px 0 26px;
  background: var(--rule);
  transform: rotate(-0.4deg);
}

.intro-copy {
  max-width: 195px;
  font-family: var(--font-hand);
  font-size: 18px;
  line-height: 1.25;
}

.intro-copy p {
  margin: 0 0 14px;
}

.index-nav {
  display: grid;
  gap: 10px;
  margin-top: 28px;
}

.index-nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  width: fit-content;
  text-decoration: none;
  text-underline-offset: 4px;
}

.index-nav a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.nav-icon {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 1px solid var(--rule);
  border-radius: 2px;
  font-family: ui-monospace, monospace;
  font-size: 11px;
}

.social-links {
  display: flex;
  gap: 18px;
}

.social-links a,
.site-footer a {
  color: var(--muted);
  text-underline-offset: 4px;
}

.social-links a:hover,
.site-footer a:hover {
  color: var(--accent);
}

.theme-control {
  display: grid;
  gap: 4px;
  width: fit-content;
  margin-top: 30px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.theme-control select {
  min-height: 34px;
  padding: 4px 28px 4px 8px;
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: var(--paper-raised);
  font: 500 12px var(--font-body);
}

.workbench {
  min-width: 0;
  padding: 48px 54px 24px;
}

.section-heading {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 18px;
}

.section-heading p,
.section-heading h2 {
  flex: 0 0 auto;
  margin: 0;
  color: var(--accent);
  font-size: 19px;
  line-height: 1;
}

.heading-line {
  width: 100%;
  height: 1px;
  background: var(--rule);
  transform: rotate(-0.2deg);
}

.projects {
  display: grid;
}

.project {
  --project-accent: var(--blue);
  display: grid;
  grid-template-columns: minmax(190px, 0.36fr) minmax(350px, 1fr);
  gap: clamp(28px, 4vw, 58px);
  padding: 26px 0 38px;
  border-bottom: 1px solid var(--faint);
}

.project--green {
  --project-accent: var(--sage);
}

.project__copy {
  align-self: center;
}

.project__number {
  margin: 0 0 4px;
  color: var(--accent);
  font-family: var(--font-hand);
  font-size: 22px;
  font-weight: 700;
}

.project__title {
  position: relative;
  display: inline-block;
  margin: 0 0 22px;
  font-family: var(--font-hand);
  font-size: clamp(34px, 3.1vw, 46px);
  font-weight: 700;
  line-height: 0.92;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.project__title::after {
  content: "";
  position: absolute;
  right: -5px;
  bottom: -8px;
  left: -2px;
  height: 2px;
  background: var(--project-accent);
  transform: rotate(-1.5deg);
}

.project__description,
.project__note {
  margin: 0;
  max-width: 27ch;
}

.project__note {
  margin-top: 3px;
  color: var(--muted);
}

.platform-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 18px 0;
  padding: 0;
  list-style: none;
}

.platform-list li {
  padding: 2px 8px;
  border: 1px solid var(--rule);
  border-radius: 3px;
  font-size: 12px;
  font-weight: 500;
}

.project__links {
  display: grid;
  gap: 7px;
  justify-items: start;
}

.text-link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.text-link:hover {
  color: var(--accent-secondary);
}

.text-link--secondary {
  color: var(--muted);
}

.project__visual {
  position: relative;
  display: grid;
  min-height: 330px;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--faint);
  border-radius: 2px;
  background-color: var(--paper-raised);
  background-image:
    linear-gradient(var(--faint) 1px, transparent 1px),
    linear-gradient(90deg, var(--faint) 1px, transparent 1px);
  background-size: 28px 28px;
  box-shadow: 0 12px 24px -20px var(--shadow);
  transform: rotate(0.3deg);
}

.project--green .project__visual {
  transform: rotate(-0.35deg);
}

.project__visual::before {
  content: "";
  position: absolute;
  width: 42%;
  aspect-ratio: 1;
  border: 1px solid var(--project-accent);
  border-radius: 50%;
  opacity: 0.25;
}

.project__image {
  position: relative;
  z-index: 1;
  width: min(38%, 210px);
  height: auto;
  border-radius: 22%;
  box-shadow: 0 18px 38px -18px var(--shadow);
}

.project--green .project__image {
  width: min(46%, 230px);
}

.tape {
  position: absolute;
  z-index: 3;
  top: -5px;
  left: 42%;
  width: 90px;
  height: 25px;
  background: rgba(202, 181, 132, 0.62);
  clip-path: polygon(2% 8%, 99% 0, 96% 94%, 0 100%);
  transform: rotate(2deg);
  mix-blend-mode: multiply;
}

:root[data-theme="dark"] .tape {
  background: rgba(169, 101, 155, 0.7);
  mix-blend-mode: normal;
}

.visual-note {
  position: absolute;
  right: 24px;
  bottom: 17px;
  margin: 0;
  color: var(--project-accent);
  font-family: var(--font-hand);
  font-size: 18px;
  line-height: 1.1;
  transform: rotate(-2deg);
}

.sketch-arrow {
  position: absolute;
  right: 30%;
  bottom: 34px;
  color: var(--project-accent);
  font-family: var(--font-hand);
  font-size: 30px;
  transform: rotate(11deg);
}

.making {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  gap: 28px;
  padding: 34px 0 22px;
}

.section-heading--small {
  margin-bottom: 8px;
}

.section-heading--small h2 {
  font-size: 17px;
}

.making-list {
  display: grid;
}

.making-row {
  --row-accent: var(--mustard);
  display: grid;
  grid-template-columns: 34px minmax(115px, 0.3fr) minmax(160px, 1fr) 24px;
  gap: 12px;
  align-items: center;
  min-height: 54px;
  padding: 7px 0;
  border-bottom: 1px solid var(--faint);
  text-decoration: none;
}

.making-row--blue {
  --row-accent: var(--blue);
}

.making-row--pink {
  --row-accent: var(--pink);
}

.making-row:hover strong,
.making-row:hover .making-row__arrow {
  color: var(--row-accent);
}

.making-row__icon {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  color: var(--row-accent);
  border: 1px solid var(--row-accent);
  border-radius: 3px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
}

.making-row__description {
  color: var(--muted);
  font-size: 13px;
}

.making-row__arrow {
  justify-self: end;
  font-size: 22px;
  transition: transform 150ms ease;
}

.making-row:hover .making-row__arrow {
  transform: translateX(3px);
}

.sticky-note {
  position: relative;
  align-self: end;
  min-height: 132px;
  padding: 32px 18px 14px;
  color: #29301d;
  background: #d8c27e;
  font-family: var(--font-hand);
  font-size: 19px;
  line-height: 1.1;
  box-shadow: 3px 5px 9px var(--shadow);
  transform: rotate(1.8deg);
}

.sticky-note::before {
  content: "";
  position: absolute;
  top: -9px;
  left: 42%;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #a8546f;
  box-shadow: 1px 3px 4px rgba(0, 0, 0, 0.35);
}

.note-arrow {
  display: block;
  margin: 4px 8px 0 0;
  text-align: right;
  font-size: 28px;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 30px 0 10px;
  color: var(--muted);
  border-top: 1px solid var(--faint);
  font-size: 12px;
}

.noscript-message {
  position: fixed;
  z-index: 10;
  right: 16px;
  bottom: 16px;
  max-width: 420px;
  padding: 16px;
  color: var(--ink);
  border: 1px solid var(--rule);
  background: var(--paper-raised);
}

/* Debug tools page */
.tools-page {
  min-height: 100vh;
  padding: 40px 20px;
  background-color: var(--desk);
  background-image: repeating-linear-gradient(90deg, transparent 0 38px, var(--grain) 39px, transparent 40px);
}

.tool-sheet {
  position: relative;
  max-width: 980px;
  min-height: calc(100vh - 80px);
  margin: 0 auto;
  padding: 42px clamp(28px, 7vw, 82px) 26px;
  background-color: var(--paper);
  background-image: repeating-linear-gradient(0deg, transparent 0 28px, var(--faint) 29px, transparent 30px);
  box-shadow: 0 18px 45px var(--shadow);
}

.tool-sheet::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 24px;
  width: 1px;
  background: color-mix(in srgb, var(--accent) 45%, transparent);
}

.tool-sheet__header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: start;
}

.back-link {
  color: var(--muted);
  text-underline-offset: 4px;
}

.back-link:hover {
  color: var(--accent);
}

.theme-control--inline {
  margin-top: 0;
}

.tool-intro {
  max-width: 680px;
  margin: 80px 0 70px;
}

.hand-label {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 20px;
}

.tool-intro h1 {
  max-width: 12ch;
  margin: 0 0 22px;
  font-family: var(--font-hand);
  font-size: clamp(46px, 7vw, 76px);
  line-height: 0.93;
}

.tool-intro > p:last-child {
  max-width: 58ch;
  color: var(--muted);
  font-size: 17px;
}

.tool-index {
  border-top: 1px solid var(--rule);
}

.tool-entry {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 145px;
  gap: 24px;
  padding: 34px 0 44px;
  border-bottom: 1px solid var(--rule);
}

.tool-entry__number {
  color: var(--accent);
  font-family: var(--font-hand);
  font-size: 23px;
  font-weight: 700;
}

.tool-entry__title {
  display: flex;
  gap: 16px;
  align-items: center;
}

.tool-entry h2 {
  margin: 0;
  font-family: var(--font-hand);
  font-size: 34px;
  line-height: 1;
}

.tool-entry p {
  max-width: 50ch;
  margin: 16px 0;
  color: var(--muted);
}

.tool-glyph {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  color: var(--paper);
  border-radius: 10px;
  background: var(--blue);
  font-family: var(--font-hand);
  font-size: 13px;
  transform: rotate(-2deg);
}

.margin-note {
  align-self: center;
  color: var(--mustard);
  font-family: var(--font-hand);
  font-size: 19px;
  line-height: 1.1;
  transform: rotate(2deg);
}

@media (max-width: 1080px) {
  .notebook-shell {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .notebook-shell::after {
    left: 240px;
  }

  .identity {
    padding: 44px 30px;
  }

  .workbench {
    padding: 42px 36px 24px;
  }

  .project {
    grid-template-columns: 180px minmax(300px, 1fr);
    gap: 28px;
  }

  .project__visual {
    min-height: 300px;
  }

  .making {
    grid-template-columns: 1fr;
  }

  .sticky-note {
    display: none;
  }
}

@media (max-width: 760px) {
  .notebook-shell {
    display: block;
  }

  .notebook-shell::after {
    display: none;
  }

  .identity {
    padding: 32px 24px 26px;
    border-bottom: 1px solid var(--faint);
  }

  .identity__inner {
    position: static;
  }

  .wordmark {
    font-size: 28px;
  }

  .role {
    font-size: 18px;
  }

  .pencil-rule {
    margin: 22px 0 18px;
  }

  .intro-copy {
    max-width: 35ch;
  }

  .intro-copy p {
    margin-bottom: 7px;
  }

  .index-nav {
    grid-template-columns: repeat(4, auto);
    justify-content: space-between;
    margin-top: 22px;
  }

  .index-nav a {
    gap: 5px;
    font-size: 13px;
  }

  .nav-icon {
    display: none;
  }

  .social-links,
  .theme-control {
    display: inline-flex;
    vertical-align: middle;
  }

  .social-links {
    margin-right: 18px;
  }

  .theme-control {
    margin-top: 18px;
  }

  .workbench {
    padding: 30px 24px 18px;
  }

  .project {
    grid-template-columns: 1fr;
    gap: 24px;
    padding: 22px 0 34px;
  }

  .project__description,
  .project__note {
    max-width: none;
  }

  .project__title {
    margin-bottom: 18px;
  }

  .project__visual {
    min-height: min(78vw, 380px);
  }

  .making-row {
    grid-template-columns: 34px minmax(100px, 0.5fr) 24px;
  }

  .making-row__description {
    display: none;
  }

  .site-footer {
    flex-direction: column;
  }

  .tools-page {
    padding: 0;
  }

  .tool-sheet {
    min-height: 100vh;
    padding: 28px 28px 22px 42px;
  }

  .tool-sheet::before {
    left: 20px;
  }

  .tool-intro {
    margin: 64px 0 52px;
  }

  .tool-entry {
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 12px;
  }

  .margin-note {
    display: none;
  }
}

@media (max-width: 430px) {
  .index-nav {
    grid-template-columns: repeat(2, 1fr);
  }

  .project__image {
    width: min(44%, 180px);
  }

  .project--green .project__image {
    width: min(52%, 205px);
  }

  .visual-note {
    right: 13px;
    bottom: 12px;
    font-size: 15px;
  }

  .sketch-arrow {
    display: none;
  }

  .tool-sheet__header {
    display: grid;
  }

  .theme-control--inline {
    display: grid;
  }

  .tool-entry {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  .theme-control,
  .skip-link {
    display: none;
  }

  body,
  .notebook-shell,
  .tool-sheet {
    background: white;
    color: black;
    box-shadow: none;
  }
}
