/* ==========================================================================
   Craft Brutal — Tim G personal hub
   Soft-brutal structure + terracotta accent + warm paper / charcoal
   ========================================================================== */

:root {
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --space-5: 48px;
  --space-6: 64px;
  --space-7: 96px;

  --radius: 10px;
  --radius-sm: 8px;
  --border-w: 1.5px;
  --border-card: 1px;

  --content-max: 1080px;
  --gutter: clamp(16px, 4vw, 40px);
  --section-pad: clamp(64px, 10vw, 120px);
  --top-bar-h: 56px;

  --font: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-display: Georgia, "Iowan Old Style", "Palatino Linotype", Palatino, "Times New Roman", serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Light — paper + ink + one accent */
  --bg: #f3eee4;
  --bg-card: #faf6ee;
  --ink: #12100e;
  --mute: #5a534c;
  --faint: #8a8278;
  --line: #12100e;
  --accent: #c45c3e;
  --accent-soft: rgba(196, 92, 62, 0.14);
  --on-accent: #f3eee4; /* paper text on terracotta (light) */
  --shadow: 3px 3px 0 #12100e;
  --shadow-hover: 5px 5px 0 #12100e;
  --focus: 0 0 0 3px var(--bg), 0 0 0 5px var(--accent);

  /*
    Motion system (iOS-adjacent, restrained)
    — only opacity + transform (never box-shadow)
    — short press, medium hover, longer entrance
    — Apple-like decelerate curves, minimal overshoot
  */
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-sheet: cubic-bezier(0.32, 0.72, 0, 1);
  --dur-press: 100ms;
  --dur: 220ms;
  --dur-enter: 560ms;
  --dur-sheet: 420ms;
  --lift: 2px;
  --lift-strong: 3px;
}

/*
  Dark — invert the same craft language, not a flat charcoal wash:
  deep espresso page, lifted warm cards, bone-hard edges, true black offsets.
*/
html[data-theme="dark"] {
  --bg: #13110f;
  --bg-card: #1e1b18;
  --ink: #f5f0e6;
  --mute: #b7aea3;
  --faint: #8f867c;
  --line: #e6dfd3;
  --accent: #e07a56;
  --accent-soft: rgba(224, 122, 86, 0.18);
  --on-accent: #12100e; /* deep ink on terracotta for dark contrast */
  --shadow: 3px 3px 0 #050403;
  --shadow-hover: 5px 5px 0 #050403;
  --focus: 0 0 0 3px var(--bg), 0 0 0 5px var(--accent);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  /* Native scroll only — CSS smooth-scroll feels laggy on mobile trackpads */
  scroll-padding-top: calc(var(--top-bar-h) + 16px);
}

body {
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--ink);
  background-color: var(--bg);
  /* paper grain */
  background-image:
    radial-gradient(ellipse 120% 80% at 100% -20%, var(--accent-soft), transparent 50%),
    url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition:
    background-color 0.35s var(--ease-out),
    color 0.35s var(--ease-out);
}

html[data-theme="dark"] body {
  background-image:
    radial-gradient(ellipse 120% 80% at 0% -15%, rgba(224, 122, 86, 0.12), transparent 52%),
    radial-gradient(ellipse 70% 50% at 100% 100%, rgba(224, 122, 86, 0.05), transparent 48%),
    url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
}

/* SVG noise filters are expensive while scrolling — skip on touch devices */
@media (pointer: coarse) {
  body,
  html[data-theme="dark"] body {
    background-image:
      radial-gradient(ellipse 120% 80% at 100% -20%, var(--accent-soft), transparent 50%);
  }
  html[data-theme="dark"] body {
    background-image:
      radial-gradient(ellipse 120% 80% at 0% -15%, rgba(224, 122, 86, 0.12), transparent 52%),
      radial-gradient(ellipse 70% 50% at 100% 100%, rgba(224, 122, 86, 0.05), transparent 48%);
  }
}

body.controls-open {
  overflow: hidden;
}

img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
ul[role="list"] { list-style: none; }
button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-radius: var(--radius-sm);
}

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: var(--space-2);
  top: var(--space-2);
  z-index: 200;
  padding: 8px 12px;
  background: var(--bg-card);
  border: var(--border-w) solid var(--line);
  box-shadow: var(--shadow);
  transform: translateY(-150%);
}
.skip-link:focus { transform: none; }

.container {
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* ---------- Top bar ---------- */
.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  padding: calc(var(--space-2) + env(safe-area-inset-top, 0px)) var(--gutter) var(--space-2);
  pointer-events: none;
}
.top-bar__inner {
  max-width: var(--content-max);
  margin-inline: auto;
  display: flex;
  justify-content: flex-end;
  pointer-events: auto;
}
.control-cluster { position: relative; }

.controls-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: var(--bg-card);
  border: var(--border-w) solid var(--line);
  box-shadow: 3px 3px 0 var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  transition:
    transform var(--dur-press) var(--ease-out),
    background-color var(--dur) var(--ease-out),
    color var(--dur) var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .controls-trigger:hover {
    transform: translate3d(0, -1px, 0);
    box-shadow: 4px 4px 0 var(--line);
  }
}
.controls-trigger:active {
  transform: scale(0.94);
  box-shadow: 2px 2px 0 var(--line);
}
.controls-trigger[aria-expanded="true"] {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--line);
}

.controls-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(18, 16, 14, 0.4);
  opacity: 0;
  transition: opacity var(--dur-sheet) var(--ease-out);
}
.controls-backdrop[hidden] {
  display: none !important;
}
.controls-backdrop:not([hidden]) {
  display: block;
}
.controls-backdrop.is-visible {
  opacity: 1;
}

/*
  Mobile prefs sheet
  ─────────────────
  Layers (hoisted to <body> on mobile so fixed = viewport):
    backdrop z-90  → dimmed page (visible ABOVE the sheet only)
    panel    z-100 → entire menu; moves as one unit on drag

  Drag: whole panel translates (up = rubber-band, down = dismiss).
  ::after paints the same cream below the panel so a pull-up gap stays
  menu-colored — without covering the dimmed page above the sheet.
*/
.controls-panel {
  --sheet-radius: 20px; /* iOS-like top corners */
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  display: block;
  margin: 0;
  padding: 0;
  border: none;
  background-color: var(--bg-card);
  background-image: none;
  border-radius: var(--sheet-radius) var(--sheet-radius) 0 0;
  box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.12);
  /* Visible so ::after can paint under the sheet when it lifts */
  overflow: visible;
  transform: translate3d(0, 100%, 0);
  transition: transform var(--dur-sheet) var(--ease-sheet);
  will-change: transform;
}
.controls-panel[hidden] { display: none !important; }
.controls-panel.is-raised {
  transform: translate3d(0, 0, 0);
}
.controls-panel.is-dragging {
  transition: none !important;
}

/* Cream extension under the sheet — rides with the panel on drag */
.controls-panel::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 100vh;
  height: 100dvh;
  background-color: var(--bg-card);
  background-image: none;
  pointer-events: none;
  z-index: -1;
}

.controls-panel__surface {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-height: min(85vh, 620px);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 0 var(--space-3) calc(var(--space-4) + env(safe-area-inset-bottom, 0px));
  background-color: var(--bg-card);
  background-image: none;
  border: none;
  /* Match panel radius so the inner cream doesn’t square off the top corners */
  border-radius: var(--sheet-radius) var(--sheet-radius) 0 0;
  box-shadow: none;
  color: var(--ink);
}

/*
  iOS-style drag dismiss zone: grabber pill + Preferences title.
  Entire zone is the swipe/drag hit target (data-sheet-grab).
*/
.controls-panel__dragzone {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  margin: 0;
  padding: 0 0 4px;
  border: none;
  background: transparent;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.controls-panel__dragzone:active {
  cursor: grabbing;
}
.controls-panel__grab {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 28px;
  margin: 0;
  padding: 0;
  pointer-events: none; /* drag handled by parent zone */
}
.controls-panel__grab::after {
  content: "";
  width: 40px;
  height: 5px;
  background: var(--line);
  border-radius: 99px;
  opacity: 0.35;
  pointer-events: none;
}
.controls-backdrop {
  transition: opacity 0.2s var(--ease-out);
}
.controls-panel__title {
  text-align: center;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  margin: 2px 0 0;
  pointer-events: none; /* part of drag zone, not a separate control */
}
.controls-section { display: flex; flex-direction: column; gap: 8px; }
.controls-section__label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

/* Language picker — craft trigger + macOS-style menu (unified across platforms) */
.lang-picker {
  position: relative;
  width: 100%;
  z-index: 5;
}

.lang-picker__trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  background: var(--bg-card);
  border: var(--border-w) solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: 2px 2px 0 var(--line);
  cursor: pointer;
  touch-action: manipulation;
  transition:
    transform var(--dur-press) var(--ease-out),
    background-color var(--dur) var(--ease-out);
}
.lang-picker__trigger:active {
  transform: scale(0.98);
  box-shadow: 1px 1px 0 var(--line);
}
.lang-picker__trigger:focus-visible {
  box-shadow: var(--focus);
}
.lang-picker__trigger[aria-expanded="true"] {
  background: var(--accent-soft);
}
.lang-picker__value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lang-picker__chevron {
  flex-shrink: 0;
  opacity: 0.7;
  transition: transform var(--dur) var(--ease-out);
}
.lang-picker__trigger[aria-expanded="true"] .lang-picker__chevron {
  transform: rotate(180deg);
}

.lang-picker__menu {
  list-style: none;
  margin: 8px 0 0;
  padding: 5px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow:
    0 10px 32px rgba(0, 0, 0, 0.16),
    0 0 0 0.5px rgba(0, 0, 0, 0.1);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  backdrop-filter: blur(20px) saturate(1.4);
  transform-origin: top center;
  opacity: 1;
  transform: scale(1) translate3d(0, 0, 0);
  transition:
    opacity var(--dur) var(--ease-out),
    transform var(--dur) var(--ease-out);
}
.lang-picker__menu[hidden] {
  display: none !important;
}
/* Desktop open: brief scale-in (applied via JS class before un-hiding is hard;
   use animation when becoming visible via .is-open on picker) */
.lang-picker.is-open .lang-picker__menu:not([hidden]) {
  animation: lang-menu-in var(--dur) var(--ease-out);
}
@keyframes lang-menu-in {
  from {
    opacity: 0;
    transform: scale(0.96) translate3d(0, -4px, 0);
  }
  to {
    opacity: 1;
    transform: scale(1) translate3d(0, 0, 0);
  }
}

html[data-theme="dark"] .lang-picker__menu {
  background: rgba(44, 44, 46, 0.94);
  box-shadow:
    0 12px 36px rgba(0, 0, 0, 0.45),
    0 0 0 0.5px rgba(255, 255, 255, 0.1);
}

.lang-picker__option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 32px;
  padding: 6px 10px 6px 8px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color var(--dur-press) var(--ease), transform var(--dur-press) var(--ease-out);
}
.lang-picker__option:active {
  transform: scale(0.99);
}
html[data-theme="dark"] .lang-picker__option {
  color: #f5f5f7;
}

.lang-picker__check {
  display: flex;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  opacity: 0;
  color: inherit;
}
.lang-picker__option.is-selected .lang-picker__check,
.lang-picker__option[aria-selected="true"] .lang-picker__check {
  opacity: 1;
}

.lang-picker__option.is-selected,
.lang-picker__option[aria-selected="true"] {
  background: #0a84ff;
  color: #ffffff;
}
.lang-picker__option:hover:not(.is-selected):not([aria-selected="true"]),
.lang-picker__option:focus-visible:not(.is-selected):not([aria-selected="true"]) {
  background: rgba(0, 0, 0, 0.06);
  outline: none;
}
html[data-theme="dark"] .lang-picker__option:hover:not(.is-selected):not([aria-selected="true"]),
html[data-theme="dark"] .lang-picker__option:focus-visible:not(.is-selected):not([aria-selected="true"]) {
  background: rgba(255, 255, 255, 0.1);
}
.lang-picker__option.is-selected:hover,
.lang-picker__option[aria-selected="true"]:hover,
.lang-picker__option.is-selected:focus-visible,
.lang-picker__option[aria-selected="true"]:focus-visible {
  background: #0a84ff;
  color: #ffffff;
  outline: none;
}

.lang-picker__option-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/*
  Mobile: language options always expanded in the sheet (no nested popup).
  Desktop keeps the compact trigger + dropdown menu.
*/
@media (max-width: 767px) {
  .lang-picker__trigger {
    display: none !important;
  }
  .lang-picker__menu,
  .lang-picker__menu[hidden] {
    display: block !important;
    margin-top: 0;
    position: static;
  }
  .lang-picker__option {
    min-height: 44px;
    padding: 10px 12px;
    font-size: 0.95rem;
  }
}

/* Theme toggle */
.pref-switcher {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/*
  Project host switcher (Main Cloudflare / Backup GitHub).
  - Mobile: settings sheet (.project-host--sheet), below theme
  - Desktop: Projects section header (.project-host--section)
  - Chinese dual-link: both hidden via [hidden]
*/
.project-host {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}
.project-host[hidden] {
  display: none !important;
}
/* Mobile-first: section control off; sheet control on */
.project-host--section {
  display: none !important;
}
.project-host--sheet {
  max-width: none;
}
.project-host__label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0;
}
/* Sheet uses controls-section__label styles when both classes present */
.project-host--sheet .project-host__label {
  color: var(--accent);
}
.host-switcher {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
}
.host-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  min-height: 52px;
  padding: 10px 12px;
  border: var(--border-w) solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  box-shadow: 2px 2px 0 var(--line);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  transition:
    background-color var(--dur) var(--ease-out),
    transform var(--dur-press) var(--ease-out),
    box-shadow var(--dur) var(--ease-out);
}
.host-option:active {
  transform: scale(0.98);
  box-shadow: 1px 1px 0 var(--line);
}
.host-option:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}
.host-option.is-selected {
  background: var(--accent-soft);
  box-shadow: 3px 3px 0 var(--line);
}
.host-option__kicker {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
}
.host-option.is-selected .host-option__kicker {
  color: var(--accent);
}
.host-option__name {
  font-size: 0.92rem;
  font-weight: 750;
  letter-spacing: -0.01em;
}
.pref-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: var(--border-w) solid var(--line);
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  box-shadow: 2px 2px 0 var(--line);
  font-weight: 600;
  text-align: left;
  transition:
    background-color var(--dur) var(--ease-out),
    transform var(--dur-press) var(--ease-out);
}
.pref-btn:active {
  transform: scale(0.98);
  box-shadow: 1px 1px 0 var(--line);
}
.pref-btn__icon {
  display: flex;
  width: 22px;
  height: 22px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-out);
}
.pref-btn__label { font-size: 0.95rem; }
/* Icon + mobile label = destination mode (not current state) */
.pref-btn__icon--moon { display: none; }
.pref-btn__label--dark { display: none; }
html[data-theme="light"] #theme-toggle .pref-btn__icon--sun { display: none; }
html[data-theme="light"] #theme-toggle .pref-btn__icon--moon { display: flex; }
html[data-theme="light"] #theme-toggle .pref-btn__label--light { display: none; }
html[data-theme="light"] #theme-toggle .pref-btn__label--dark { display: inline; }
html[data-theme="dark"] #theme-toggle .pref-btn__icon--sun { display: flex; }
html[data-theme="dark"] #theme-toggle .pref-btn__icon--moon { display: none; }
html[data-theme="dark"] #theme-toggle .pref-btn__label--light { display: inline; }
html[data-theme="dark"] #theme-toggle .pref-btn__label--dark { display: none; }

/* Desktop controls */
@media (min-width: 768px) {
  .controls-trigger,
  .controls-backdrop,
  .controls-panel__dragzone,
  .controls-panel__grab,
  .controls-panel__title,
  .controls-section__label {
    display: none !important;
  }
  /* Host control lives in Projects header on desktop, not the top bar */
  .project-host--sheet {
    display: none !important;
  }
  .project-host--section:not([hidden]) {
    display: flex !important;
  }
  .controls-panel {
    position: static !important;
    display: block !important;
    max-height: none;
    overflow: visible;
    padding: 0;
    background: transparent !important;
    border: none;
    border-radius: 0;
    box-shadow: none;
    transform: none !important;
    transition: none !important;
    will-change: auto;
  }
  .controls-panel::after {
    display: none !important; /* no cream extension on desktop chrome */
  }
  .controls-panel[hidden] { display: block !important; }
  .controls-panel__surface {
    display: flex !important;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    max-height: none;
    overflow: visible;
    padding: 0;
    background: transparent !important;
    border: none;
    border-radius: 0;
    box-shadow: none !important;
  }
  .controls-section { flex-direction: row; gap: 10px; }
  .lang-picker {
    width: auto;
    z-index: 60;
  }
  .lang-picker__trigger {
    width: auto;
    min-width: 7.25rem;
    min-height: 40px;
    padding: 8px 12px;
    font-size: 0.8rem;
  }
  .lang-picker__menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    left: auto;
    min-width: 11rem;
    margin-top: 0;
    z-index: 120;
  }
  /* Single icon control — match language trigger height */
  .pref-switcher {
    display: contents;
  }
  .pref-btn {
    width: 40px;
    height: 40px;
    min-height: 40px;
    padding: 0;
    justify-content: center;
    gap: 0;
    background: var(--bg-card);
    border: var(--border-w) solid var(--line);
    box-shadow: 2px 2px 0 var(--line);
    border-radius: var(--radius-sm);
    overflow: hidden;
  }
  /* Beat theme-specific label rules — desktop is icon-only */
  .pref-btn__label,
  html[data-theme="light"] #theme-toggle .pref-btn__label--light,
  html[data-theme="light"] #theme-toggle .pref-btn__label--dark,
  html[data-theme="dark"] #theme-toggle .pref-btn__label--light,
  html[data-theme="dark"] #theme-toggle .pref-btn__label--dark {
    display: none !important;
  }
  .pref-btn:hover {
    background: var(--accent-soft);
  }
}

/* ---------- Hero ---------- */
.hero {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  padding: calc(var(--space-7) + var(--top-bar-h)) var(--gutter) var(--space-6);
}
.hero__inner {
  max-width: var(--content-max);
  margin-inline: auto;
  width: 100%;
}
.hero__eyebrow {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: var(--accent);
  color: var(--on-accent);
  padding: 6px 10px;
  border: var(--border-w) solid var(--line);
  box-shadow: 3px 3px 0 var(--line);
  margin-bottom: var(--space-3);
}
.hero__name {
  font-family: var(--font-display);
  font-size: clamp(3.25rem, 12vw, 5.75rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.02;
  margin-bottom: var(--space-3);
}

.hero__name-text {
  font-family: inherit;
  font-weight: inherit;
  color: var(--ink);
}
.hero__tagline {
  font-size: clamp(1.05rem, 2.5vw, 1.3rem);
  color: var(--mute);
  max-width: 22em;
  margin-bottom: var(--space-5);
  font-weight: 500;
  border-left: 4px solid var(--accent);
  padding-left: var(--space-2);
}
.scroll-cue {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink);
  border: var(--border-w) solid var(--line);
  background: var(--bg-card);
  padding: 10px 14px;
  box-shadow: 3px 3px 0 var(--line);
  border-radius: var(--radius-sm);
  transition: transform var(--dur) var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .scroll-cue.is-settled:hover {
    transform: translate3d(0, calc(var(--lift) * -1), 0);
    box-shadow: 5px 5px 0 var(--line);
  }
  .scroll-cue.is-settled:hover .scroll-cue__icon {
    transform: translate3d(0, 2px, 0);
  }
}
.scroll-cue__icon {
  transition: transform var(--dur) var(--ease-out);
  display: flex;
}
.scroll-cue:active {
  transform: scale(0.97);
  box-shadow: 2px 2px 0 var(--line);
}

/* ---------- Sections ---------- */
.section { padding-block: var(--section-pad); }
.section__header { margin-bottom: var(--space-4); max-width: 36rem; }
.section__header-copy { min-width: 0; }

/* Projects header: title + line switcher (desktop sits them side by side) */
.section__header--projects {
  max-width: none;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-3);
}
@media (min-width: 768px) {
  .section__header--projects {
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-4);
  }
  .section__header--projects .section__header-copy {
    flex: 1 1 auto;
    max-width: 36rem;
  }
  .section__header--projects .project-host {
    width: auto;
    max-width: none;
    flex: 0 0 auto;
    align-items: flex-end;
    margin-bottom: 2px; /* optical align with title baseline */
  }
  .section__header--projects .project-host__label {
    text-align: right;
    width: 100%;
  }
  /* Compact segmented control next to the heading */
  .section__header--projects .host-switcher {
    display: inline-grid;
    grid-template-columns: auto auto;
    gap: 0;
    width: auto;
    border: var(--border-w) solid var(--line);
    border-radius: var(--radius-sm);
    box-shadow: 2px 2px 0 var(--line);
    overflow: hidden;
    background: var(--bg-card);
  }
  .section__header--projects .host-option {
    min-height: 44px;
    min-width: 6.25rem;
    padding: 6px 14px;
    border: none;
    border-radius: 0;
    box-shadow: none !important;
    align-items: center;
    justify-content: center;
    gap: 1px;
  }
  .section__header--projects .host-option + .host-option {
    border-left: var(--border-w) solid var(--line);
  }
  .section__header--projects .host-option:active {
    transform: none;
    box-shadow: none !important;
  }
  .section__header--projects .host-option.is-selected {
    background: var(--accent-soft);
    box-shadow: none !important;
  }
  .section__header--projects .host-option:not(.is-selected):hover {
    background: color-mix(in srgb, var(--ink) 4%, var(--bg-card));
  }
  .section__header--projects .host-option__kicker {
    font-size: 0.55rem;
    letter-spacing: 0.08em;
    line-height: 1.1;
  }
  .section__header--projects .host-option__name {
    font-size: 0.78rem;
    line-height: 1.15;
  }
  html[data-theme="dark"] .section__header--projects .host-switcher {
    box-shadow: var(--shadow);
  }
}

.section__label {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--bg);
  background: var(--ink);
  padding: 4px 8px;
  margin-bottom: var(--space-2);
}
.section__title {
  font-size: clamp(1.75rem, 4vw, 2.35rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  text-wrap: balance;
}
.about__body { max-width: 36rem; }
.about__text {
  color: var(--mute);
  font-size: 1.1rem;
  margin-bottom: var(--space-2);
  font-weight: 500;
}

/* Interests */
.interests__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-2);
}
@media (min-width: 560px) {
  .interests__grid { grid-template-columns: 1fr 1fr; gap: var(--space-3); }
}
@media (min-width: 900px) {
  .interests__grid { grid-template-columns: 1fr 1fr 1fr; }
}

.interest-card {
  background: var(--bg-card);
  border: var(--border-card) solid var(--line);
  box-shadow: 2px 2px 0 var(--line);
  border-radius: var(--radius);
  padding: var(--space-3);
  /* Static cards: hover only — no press (not interactive) */
  transition: transform var(--dur) var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .interest-card.is-settled:hover {
    transform: translate3d(0, calc(var(--lift) * -1), 0);
    box-shadow: 3px 3px 0 var(--line);
  }
  .interest-card.is-settled:hover .interest-card__icon {
    transform: scale(1.06);
  }
}
.interest-card__icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: var(--border-card) solid var(--line);
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-2);
  transition: transform var(--dur) var(--ease-out);
}
.interest-card__title {
  font-size: 1.1rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.interest-card__desc {
  font-size: 0.9rem;
  color: var(--mute);
  font-weight: 500;
  line-height: 1.45;
}

/* Featured projects */
.featured-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.featured-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
  position: relative;
  background: var(--bg-card);
  border: var(--border-w) solid var(--line);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  padding: var(--space-4);
  overflow: hidden;
  transition: transform var(--dur) var(--ease-out);
}
@media (min-width: 720px) {
  .featured-card {
    grid-template-columns: 1.35fr 1fr;
    align-items: center;
    min-height: 220px;
  }
}
/* Single-host: full-card hit target (real link); CTA is visual only */
.featured-card__hit {
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: inherit;
  /* Keep hit in tab order; label via aria-labelledby on the element */
}
html[data-project-links="dual"] .featured-card__hit {
  display: none !important;
}
html[data-project-links="single"] .featured-card:has(.featured-card__hit:focus-visible) {
  outline: none;
  box-shadow: var(--focus);
}
@media (hover: hover) and (pointer: fine) {
  html[data-project-links="single"] .featured-card.is-settled:hover {
    transform: translate3d(0, calc(var(--lift-strong) * -1), 0);
    box-shadow: var(--shadow-hover);
  }
  html[data-project-links="single"] .featured-card.is-settled:hover .featured-card__cta--single svg {
    transform: translate3d(3px, 0, 0);
  }
  html[data-project-links="dual"] .featured-card.is-settled:hover {
    /* Dual: card is not a single target */
    transform: none;
    box-shadow: var(--shadow);
  }
}
.featured-card__cta svg,
.project-line__arrow {
  transition: transform var(--dur) var(--ease-out);
  flex-shrink: 0;
}
/* Single: press feedback on card while hit is active */
html[data-project-links="single"] .featured-card:has(.featured-card__hit:active) {
  transform: scale(0.99);
  box-shadow: 2px 2px 0 var(--line);
}
.featured-card__badge {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
  z-index: 1;
  pointer-events: none;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: var(--accent);
  color: var(--on-accent);
  border: var(--border-w) solid var(--line);
  padding: 4px 10px;
  box-shadow: 2px 2px 0 var(--line);
}
.featured-card__badge--alt {
  background: var(--ink);
  color: var(--bg);
}
.featured-card__content {
  padding-top: var(--space-4);
  position: relative;
  z-index: 1;
  pointer-events: none; /* clicks pass to hit in single mode */
}
html[data-project-links="dual"] .featured-card__content {
  pointer-events: auto;
}
.featured-card__title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
}
.featured-card__desc {
  font-size: 0.92rem;
  color: var(--mute);
  font-weight: 500;
  margin-bottom: var(--space-2);
  max-width: 28rem;
}
.featured-card__cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  transition: color var(--dur) var(--ease-out);
  position: relative;
  z-index: 1;
}

/*
  Project link modes (set on <html>):
  - single (en/es/ja): one CTA + host preference
  - dual (zh): Main (Cloudflare) left + Backup (GitHub) right
  Default (no attr / single): hide dual lines so no flash of both.
*/
.featured-card__lines {
  display: none;
}
html[data-project-links="dual"] .featured-card__cta--single {
  display: none !important;
}
html[data-project-links="dual"] .featured-card__lines {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 2px;
  position: relative;
  z-index: 3;
  pointer-events: auto;
}
/* Very narrow: keep two columns if possible; allow wrap only when necessary */
@media (max-width: 360px) {
  html[data-project-links="dual"] .featured-card__lines {
    grid-template-columns: 1fr;
  }
}

.project-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 52px;
  padding: 10px 12px;
  border: var(--border-w) solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: 2px 2px 0 var(--line);
  text-decoration: none;
  color: inherit;
  transition:
    transform var(--dur-press) var(--ease-out),
    background-color var(--dur) var(--ease-out),
    box-shadow var(--dur) var(--ease-out);
}
.project-line--main {
  background: var(--accent-soft);
  color: var(--ink);
}
.project-line--backup {
  background: var(--bg);
  color: var(--ink);
}
.project-line__meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.project-line__kicker {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
}
.project-line--main .project-line__kicker {
  color: var(--accent);
}
.project-line__name {
  font-size: 0.88rem;
  font-weight: 750;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.project-line__arrow {
  color: var(--faint);
}
.project-line--main .project-line__arrow {
  color: var(--accent);
}
@media (hover: hover) and (pointer: fine) {
  .project-line:hover {
    transform: translate3d(0, calc(var(--lift) * -1), 0);
    box-shadow: 3px 3px 0 var(--line);
  }
  .project-line:hover .project-line__arrow {
    transform: translate3d(2px, 0, 0);
  }
}
.project-line:active {
  transform: scale(0.98);
  box-shadow: 1px 1px 0 var(--line);
}
.project-line:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}
.featured-card__visual {
  position: relative;
  z-index: 1;
  pointer-events: none;
  min-height: 140px;
  border: var(--border-w) solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--line) 8%, transparent);
}
.featured-card__visual--usa {
  background:
    radial-gradient(circle at 78% 28%, var(--accent-soft), transparent 42%),
    linear-gradient(160deg, color-mix(in srgb, var(--accent) 8%, var(--bg)) 0%, var(--bg) 70%);
}
.featured-card__visual--japan {
  background:
    radial-gradient(circle at 50% 42%, var(--accent-soft), transparent 48%),
    linear-gradient(200deg, color-mix(in srgb, var(--ink) 4%, var(--bg)) 0%, var(--bg) 75%);
}
.featured-card__visual--kit {
  background:
    linear-gradient(135deg, var(--accent-soft) 0%, transparent 45%),
    linear-gradient(0deg, color-mix(in srgb, var(--ink) 3%, var(--bg)) 0%, var(--bg) 100%);
}
.featured-art {
  width: 100%;
  height: auto;
  max-height: 180px;
  display: block;
}

/* Links */
.link-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-2);
}
@media (min-width: 560px) {
  .link-grid { grid-template-columns: 1fr 1fr; gap: var(--space-3); }
}
.link-card {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 88px;
  padding: var(--space-3);
  background: var(--bg-card);
  border: var(--border-w) solid var(--line);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  transition: transform var(--dur) var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  a.link-card:hover,
  .link-card--copy:hover {
    transform: translate3d(0, calc(var(--lift) * -1), 0);
    box-shadow: var(--shadow-hover);
  }
  a.link-card:hover .link-card__icon,
  .link-card--copy:hover .link-card__icon {
    transform: scale(1.05);
  }
  a.link-card:hover .link-card__arrow,
  .link-card--copy:hover .link-card__arrow {
    transform: translate3d(2px, -2px, 0);
    color: var(--accent);
  }
}
a.link-card:active,
.link-card--copy:active {
  transform: scale(0.99);
  box-shadow: 2px 2px 0 var(--line);
}
.link-card__icon {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: var(--border-w) solid var(--line);
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--radius-sm);
  transition: transform var(--dur) var(--ease-out);
}
.link-card__arrow {
  transition:
    transform var(--dur) var(--ease-out),
    color var(--dur) var(--ease-out);
}
.link-card__text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.link-card__label { font-weight: 750; letter-spacing: -0.01em; }
.link-card__sub { font-size: 0.85rem; color: var(--faint); font-family: var(--font-mono); }
.link-card__arrow { color: var(--faint); flex-shrink: 0; }
.social-icon[hidden],
.social-arrow--external[hidden],
.social-arrow--copy[hidden] {
  display: none !important;
}
.link-card--copy { cursor: pointer; }
.link-card--copy.is-copied .link-card__sub { color: var(--accent); font-weight: 700; }

/* Footer */
.footer {
  padding: var(--space-6) 0 var(--space-7);
  border-top: var(--border-w) solid var(--line);
}
.footer__inner {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}
.footer__signoff { font-size: 1.2rem; font-weight: 750; letter-spacing: -0.02em; }
.footer__contact { font-size: 0.9rem; color: var(--mute); font-weight: 500; }
.footer__email {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color var(--dur) var(--ease-out), opacity var(--dur) var(--ease-out);
}
.footer__legal {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 600;
}
.footer__legal a {
  border-bottom: 2px solid var(--line);
  padding-bottom: 1px;
  transition:
    color var(--dur) var(--ease-out),
    border-color var(--dur) var(--ease-out);
}
.footer__legal a:hover { color: var(--accent); border-color: var(--accent); }
.footer__copy {
  font-size: 0.75rem;
  color: var(--faint);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}
.footer__dot { opacity: 0.5; }

/* ---------- Scroll entrance ----------
   opacity + translate only; settle frees will-change for hover.
*/
.reveal {
  opacity: 0;
  transform: translate3d(0, 14px, 0);
  transition:
    opacity var(--dur-enter) var(--ease-out),
    transform var(--dur-enter) var(--ease-out);
  transition-delay: calc(var(--stagger, 0) * 48ms);
  will-change: opacity, transform;
}
.reveal.is-visible {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}
.reveal.is-settled {
  will-change: auto;
  transition: transform var(--dur) var(--ease-out);
  transition-delay: 0ms;
}
.reveal-delay-1 { transition-delay: 70ms; }
.reveal-delay-2 { transition-delay: 120ms; }
.reveal-delay-3 { transition-delay: 170ms; }

.section__header.reveal.is-settled,
.about__body.reveal.is-settled,
.footer__inner.reveal.is-settled {
  transition: none;
}

html:not(.js) .reveal,
html.reveal-fallback .reveal {
  opacity: 1 !important;
  transform: none !important;
  transition: none !important;
  will-change: auto !important;
}

@media (prefers-reduced-motion: reduce) {
  .reveal {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
    will-change: auto !important;
  }
  .reveal.is-settled {
    transition: none !important;
  }
  .controls-panel {
    transform: none !important;
    transition: none !important;
  }
  .controls-panel.is-raised {
    transform: none !important;
  }
  .controls-backdrop {
    transition: none !important;
  }
  .controls-backdrop.is-visible {
    opacity: 1 !important;
  }
  .qr-modal,
  .qr-modal__panel {
    transition: none !important;
    transform: none !important;
  }
  .qr-modal.is-shown {
    opacity: 1 !important;
  }
  .qr-modal.is-shown .qr-modal__panel {
    transform: none !important;
  }
  .lang-picker.is-open .lang-picker__menu:not([hidden]) {
    animation: none !important;
  }
}

@media (max-width: 480px) {
  .hero { padding-top: calc(var(--space-6) + 72px); }
}

/* ---------- Duolingo QR card ---------- */
/* Full-width row under GitHub / social (class preferred; :has is backup) */
.link-grid > li.link-grid__full,
.link-grid > li:has(.duolingo-card) {
  grid-column: 1 / -1;
}

.duolingo-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-3) var(--space-4);
  padding: var(--space-3);
  background: var(--bg-card);
  border: var(--border-w) solid var(--line);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
}

.duolingo-card__body {
  flex: 1 1 12rem;
  min-width: min(100%, 12rem);
  max-width: 22rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.duolingo-card__header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.duolingo-card__icon {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: var(--border-card) solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
  font-size: 0.95rem;
}

.duolingo-card__text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.duolingo-card__label {
  font-weight: 750;
  letter-spacing: -0.01em;
}

.duolingo-card__sub {
  font-size: 0.85rem;
  color: var(--faint);
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.duolingo-card__hint {
  font-size: 0.8rem;
  color: var(--mute);
  text-align: left;
  font-weight: 500;
  line-height: 1.45;
}

.duolingo-card__profile {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  font-size: 0.8rem;
  font-weight: 750;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--accent);
  width: fit-content;
}
.duolingo-card__profile:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* QR thumb — full export, never cropped (contain + black plate) */
.duolingo-card__qr {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  color: inherit;
  font: inherit;
  border-radius: var(--radius-sm);
  touch-action: manipulation;
}
.duolingo-card__qr:focus-visible {
  box-shadow: var(--focus);
}

.duolingo-card__frame {
  display: block;
  width: 112px;
  /* Match full Duolingo export aspect so nothing is clipped */
  aspect-ratio: 936 / 1229;
  padding: 0;
  background: #000000;
  border: var(--border-w) solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: 2px 2px 0 var(--line);
  overflow: hidden;
  line-height: 0;
  transition: transform var(--dur) var(--ease-out);
}

.duolingo-card__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  background: #000000;
}

/* Theme-specific QR assets: light export keeps original profile colors */
.duolingo-card__img--light { display: none; }
html[data-theme="light"] .duolingo-card__frame {
  background: #ffffff;
}
html[data-theme="light"] .duolingo-card__img--dark { display: none; }
html[data-theme="light"] .duolingo-card__img--light {
  display: block;
  background: #ffffff;
}
html[data-theme="dark"] .duolingo-card__img--light { display: none; }
html[data-theme="dark"] .duolingo-card__img--dark { display: block; }

.duolingo-card__expand {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
  transition: color var(--dur) var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .duolingo-card__qr:hover .duolingo-card__frame {
    transform: translate3d(0, calc(var(--lift) * -1), 0);
    box-shadow: 4px 4px 0 var(--line);
  }
  .duolingo-card__qr:hover .duolingo-card__expand {
    color: var(--accent);
  }
}

.duolingo-card__qr:active .duolingo-card__frame {
  transform: scale(0.97);
  box-shadow: 1px 1px 0 var(--line);
}

@media (min-width: 560px) {
  .duolingo-card {
    padding: var(--space-3) var(--space-4);
    gap: var(--space-4) var(--space-5);
  }

  .duolingo-card__frame {
    width: 128px;
  }
}

/* ---------- QR large-view modal ---------- */
.qr-modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  opacity: 0;
  transition: opacity var(--dur) var(--ease-out);
}
.qr-modal[hidden] {
  display: none !important;
}
.qr-modal.is-shown {
  opacity: 1;
}

.qr-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(12, 10, 8, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: none;
  cursor: pointer;
}

.qr-modal__panel {
  position: relative;
  z-index: 1;
  width: min(100%, 420px);
  max-height: min(92dvh, 920px);
  overflow: auto;
  padding: var(--space-3);
  background: var(--bg-card);
  border: var(--border-w) solid var(--line);
  border-radius: var(--radius);
  box-shadow: 6px 6px 0 var(--line);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  transform: scale(0.96) translate3d(0, 10px, 0);
  transition: transform var(--dur-sheet) var(--ease-out);
}
.qr-modal.is-shown .qr-modal__panel {
  transform: scale(1) translate3d(0, 0, 0);
}

.qr-modal__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.qr-modal__title {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.qr-modal__close {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: var(--border-w) solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  box-shadow: 2px 2px 0 var(--line);
  flex-shrink: 0;
  transition:
    background-color var(--dur) var(--ease-out),
    transform var(--dur-press) var(--ease-out);
}
.qr-modal__close:hover {
  background: var(--accent-soft);
}
.qr-modal__close:active {
  transform: scale(0.94);
  box-shadow: 1px 1px 0 var(--line);
}

.qr-modal__hint {
  font-size: 0.85rem;
  color: var(--mute);
  font-weight: 500;
  line-height: 1.45;
}

.qr-modal__frame {
  width: 100%;
  background: #000000;
  border: var(--border-w) solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  line-height: 0;
  box-shadow: 3px 3px 0 var(--line);
}

.qr-modal__img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  background: #000000;
}

.qr-modal__img--light { display: none; }
html[data-theme="light"] .qr-modal__frame {
  background: #ffffff;
}
html[data-theme="light"] .qr-modal__img--dark { display: none; }
html[data-theme="light"] .qr-modal__img--light {
  display: block;
  background: #ffffff;
}
html[data-theme="dark"] .qr-modal__img--light { display: none; }
html[data-theme="dark"] .qr-modal__img--dark { display: block; }

.qr-modal__profile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 14px;
  border: var(--border-w) solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.85rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  box-shadow: 2px 2px 0 var(--line);
  text-align: center;
  transition: transform var(--dur) var(--ease-out);
}
.qr-modal__profile:hover {
  transform: translate3d(0, -1px, 0);
  box-shadow: 3px 3px 0 var(--line);
}
.qr-modal__profile:active {
  transform: scale(0.98);
}

body.qr-modal-open {
  overflow: hidden;
}

/* ---------- Dark theme component polish ---------- */
/* Hard craft edges like light: bone border + true-black offset, slight lift */
html[data-theme="dark"] .interest-card,
html[data-theme="dark"] .featured-card,
html[data-theme="dark"] .link-card,
html[data-theme="dark"] .duolingo-card,
html[data-theme="dark"] .scroll-cue,
html[data-theme="dark"] .controls-trigger,
html[data-theme="dark"] .lang-picker__trigger,
html[data-theme="dark"] .pref-btn,
html[data-theme="dark"] .host-option,
html[data-theme="dark"] .project-line,
html[data-theme="dark"] .qr-modal__panel,
html[data-theme="dark"] .qr-modal__close {
  border-color: var(--line);
  box-shadow: var(--shadow);
}

html[data-theme="dark"] .featured-card,
html[data-theme="dark"] .link-card,
html[data-theme="dark"] .duolingo-card {
  background:
    linear-gradient(
      165deg,
      color-mix(in srgb, var(--ink) 4%, var(--bg-card)) 0%,
      var(--bg-card) 42%
    );
}

html[data-theme="dark"] .interest-card.is-settled:hover,
html[data-theme="dark"] .scroll-cue.is-settled:hover,
html[data-theme="dark"] .controls-trigger:hover {
  box-shadow: 4px 4px 0 #050403;
}

html[data-theme="dark"][data-project-links="single"] .featured-card.is-settled:hover,
html[data-theme="dark"] .link-card:hover,
html[data-theme="dark"] .duolingo-card__qr:hover .duolingo-card__frame {
  box-shadow: var(--shadow-hover);
}
html[data-theme="dark"] .project-line:hover {
  box-shadow: 3px 3px 0 #050403;
}
html[data-theme="dark"] .host-option.is-selected {
  background: color-mix(in srgb, var(--accent) 22%, var(--bg-card));
}

/* Icon wells: warmer tint, clearer edge */
html[data-theme="dark"] .interest-card__icon,
html[data-theme="dark"] .link-card__icon,
html[data-theme="dark"] .duolingo-card__icon {
  background: color-mix(in srgb, var(--accent) 22%, var(--bg-card));
  border-color: color-mix(in srgb, var(--line) 70%, var(--accent));
  color: #f0a88a;
}

/* Section chip: keep high-contrast cream plate on dark (mirror light) */
html[data-theme="dark"] .section__label {
  background: var(--ink);
  color: var(--bg);
  box-shadow: 2px 2px 0 color-mix(in srgb, var(--line) 55%, transparent);
}

/* Tagline bar + secondary text a touch brighter for long reads */
html[data-theme="dark"] .hero__tagline {
  border-left-color: var(--accent);
  color: var(--mute);
}
html[data-theme="dark"] .about__text,
html[data-theme="dark"] .interest-card__desc,
html[data-theme="dark"] .featured-card__desc {
  color: color-mix(in srgb, var(--mute) 92%, var(--ink));
}

/* Featured visual panels — more depth, less flat charcoal */
html[data-theme="dark"] .featured-card__visual {
  border-color: var(--line);
  background: color-mix(in srgb, var(--ink) 3%, #181512);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 5%, transparent);
}
html[data-theme="dark"] .featured-card__visual--usa {
  background:
    radial-gradient(circle at 78% 28%, rgba(224, 122, 86, 0.22), transparent 44%),
    linear-gradient(160deg, #2a221c 0%, #181512 70%);
}
html[data-theme="dark"] .featured-card__visual--japan {
  background:
    radial-gradient(circle at 50% 42%, rgba(224, 122, 86, 0.2), transparent 50%),
    linear-gradient(200deg, #241f1b 0%, #181512 75%);
}
html[data-theme="dark"] .featured-card__visual--kit {
  background:
    linear-gradient(135deg, rgba(224, 122, 86, 0.16) 0%, transparent 48%),
    linear-gradient(0deg, #1c1916 0%, #181512 100%);
}

/* Controls expanded trigger: readable on accent */
html[data-theme="dark"] .controls-trigger[aria-expanded="true"] {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--line);
}

/* Footer divider + links */
html[data-theme="dark"] .footer {
  border-top-color: color-mix(in srgb, var(--line) 55%, transparent);
}
html[data-theme="dark"] .footer__legal a {
  border-bottom-color: color-mix(in srgb, var(--line) 65%, transparent);
}
html[data-theme="dark"] .footer__legal a:hover {
  color: #f0a88a;
  border-bottom-color: #f0a88a;
}
html[data-theme="dark"] .footer__email {
  color: #f0a88a;
}

/* QR / modal: crisp frame against dark UI */
html[data-theme="dark"] .duolingo-card__frame,
html[data-theme="dark"] .qr-modal__frame {
  border-color: var(--line);
  box-shadow: 3px 3px 0 #050403;
}
html[data-theme="dark"] .qr-modal__backdrop {
  background: rgba(8, 6, 5, 0.78);
}
html[data-theme="dark"] .qr-modal__panel {
  background: var(--bg-card);
  border-color: var(--line);
  box-shadow: 6px 6px 0 #050403;
}

/* Mobile prefs sheet */
html[data-theme="dark"] .controls-panel {
  background-color: var(--bg-card);
  box-shadow: 0 -10px 32px rgba(0, 0, 0, 0.4);
}
html[data-theme="dark"] .controls-panel::after {
  background-color: var(--bg-card);
}
html[data-theme="dark"] .controls-panel__surface {
  background-color: var(--bg-card);
  box-shadow: none;
}
html[data-theme="dark"] .controls-backdrop:not([hidden]) {
  background: rgba(8, 6, 5, 0.55);
}

/* Selection */
html[data-theme="dark"] ::selection {
  background: rgba(224, 122, 86, 0.35);
  color: var(--ink);
}
