/* ==========================================================================
   ansen 作品集 v2
   三種風格共用同一套版面，只換 token、字體與少量裝飾。
   ========================================================================== */

/* ---------- Theme tokens ---------- */
:root,
[data-theme="modern"] {
  color-scheme: light;
  --bg: #f5f8fc;
  --bg-alt: #edf3fa;
  --surface: #ffffff;
  --surface-2: #f3f7fc;
  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(11, 99, 206, 0.28);
  --text: #0f172a;
  --text-2: #3f4c61;
  --muted: #6a778b;
  --accent: #0b63ce;
  --accent-2: #38bdf8;
  --accent-ink: #ffffff;
  --accent-soft: rgba(11, 99, 206, 0.08);
  --title-em: #0b63ce;
  --emblem: #0b63ce;
  --nav-bg: rgba(245, 248, 252, 0.78);

  --radius: 18px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px -12px rgba(15, 23, 42, 0.12);
  --shadow-hover: 0 2px 4px rgba(15, 23, 42, 0.05), 0 22px 44px -18px rgba(11, 99, 206, 0.3);

  --font-body: "Space Grotesk", "Noto Sans TC", system-ui, sans-serif;
  --font-display: "Space Grotesk", "Noto Sans TC", system-ui, sans-serif;
  --font-label: "JetBrains Mono", ui-monospace, monospace;
  --display-weight: 700;
  --label-tracking: 0.12em;
  --label-transform: uppercase;
  --label-size: 12px;
}

[data-theme="heist"] {
  color-scheme: dark;
  --bg: #0b0c0f;
  --bg-alt: #101217;
  --surface: #14171d;
  --surface-2: #1a1e26;
  --border: #252a33;
  --border-strong: #f2c84b;
  --text: #f3efe6;
  --text-2: #b9bdc7;
  --muted: #7d8492;
  --accent: #f2c84b;
  --accent-2: #d7263d;
  --accent-ink: #0b0c0f;
  --accent-soft: rgba(242, 200, 75, 0.1);
  --title-em: #f2c84b;
  --emblem: #f2c84b;
  --nav-bg: rgba(11, 12, 15, 0.8);

  --radius: 4px;
  --radius-sm: 2px;
  --shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), 0 14px 30px -18px rgba(0, 0, 0, 0.9);
  --shadow-hover: 6px 6px 0 0 #d7263d, 0 18px 40px -20px rgba(0, 0, 0, 0.9);

  --font-body: "Space Grotesk", "Noto Sans TC", system-ui, sans-serif;
  --font-display: "Bebas Neue", "Noto Sans TC", system-ui, sans-serif;
  --font-label: "Special Elite", "Courier New", monospace;
  --display-weight: 900;
  --label-tracking: 0.08em;
  --label-transform: uppercase;
  --label-size: 13px;
}

[data-theme="clow"] {
  color-scheme: light;
  --bg: #fcf8f1;
  --bg-alt: #fbf1ee;
  --surface: #fffdf9;
  --surface-2: #fdf5f0;
  --border: #f0dfd3;
  --border-strong: #d9a95c;
  --text: #4a3b3a;
  --text-2: #6c5c59;
  --muted: #9f8c87;
  --accent: #d47689;
  --accent-2: #c9a35a;
  --accent-ink: #ffffff;
  --accent-soft: rgba(212, 118, 137, 0.1);
  --title-em: #d47689;
  --emblem: #c9a35a;
  --nav-bg: rgba(252, 248, 241, 0.82);

  --radius: 24px;
  --radius-sm: 14px;
  --shadow: 0 1px 2px rgba(120, 80, 60, 0.05), 0 12px 30px -16px rgba(176, 120, 100, 0.25);
  --shadow-hover: 0 0 0 1px #e7c98f, 0 22px 44px -18px rgba(201, 163, 90, 0.45);

  --font-body: "LXGW WenKai TC", "Noto Sans TC", serif;
  --font-display: "LXGW WenKai TC", "Noto Sans TC", serif;
  --font-label: "Cormorant Garamond", "LXGW WenKai TC", serif;
  --display-weight: 700;
  --label-tracking: 0.14em;
  --label-transform: uppercase;
  --label-size: 14px;
}

/* ---------- Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 88px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4, p, ol, ul, dl, dd, blockquote {
  margin: 0;
}

ol, ul {
  padding: 0;
  list-style: none;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

strong {
  color: var(--text);
  font-weight: 700;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 8px 14px;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: var(--radius-sm);
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: none;
}

.container {
  width: 100%;
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 24px;
}

[data-lucide],
.lucide,
.icon-gh {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke-width: 1.9;
}

.eyebrow,
.kicker {
  font-family: var(--font-label);
  font-size: var(--label-size);
  letter-spacing: var(--label-tracking);
  text-transform: var(--label-transform);
  color: var(--accent);
  line-height: 1.4;
}

[data-theme="clow"] .eyebrow,
[data-theme="clow"] .kicker {
  font-style: italic;
  font-weight: 600;
  color: var(--accent-2);
}

/* ---------- Backdrop ---------- */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

.backdrop > * {
  position: absolute;
  inset: 0;
}

[data-theme="modern"] .backdrop-grid {
  background-image:
    linear-gradient(rgba(11, 99, 206, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(11, 99, 206, 0.06) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(ellipse 80% 60% at 70% 0%, #000 20%, transparent 75%);
}

[data-theme="modern"] .backdrop-glow {
  background:
    radial-gradient(600px 400px at 85% -5%, rgba(56, 189, 248, 0.18), transparent 70%),
    radial-gradient(500px 360px at 0% 30%, rgba(11, 99, 206, 0.08), transparent 70%);
}

[data-theme="heist"] .backdrop-grid {
  background-image: radial-gradient(rgba(242, 200, 75, 0.09) 1px, transparent 1.4px);
  background-size: 7px 7px;
  mask-image: linear-gradient(115deg, transparent 35%, #000 55%, transparent 80%);
}

[data-theme="heist"] .backdrop-glow {
  background:
    linear-gradient(115deg, transparent 0 58%, rgba(215, 38, 61, 0.1) 58% 66%, transparent 66%),
    radial-gradient(700px 500px at 80% 0%, rgba(242, 200, 75, 0.07), transparent 70%);
}

[data-theme="clow"] .backdrop-glow {
  background:
    radial-gradient(520px 420px at 90% 4%, rgba(232, 141, 156, 0.2), transparent 70%),
    radial-gradient(480px 380px at 4% 40%, rgba(223, 184, 108, 0.16), transparent 70%),
    radial-gradient(600px 400px at 60% 100%, rgba(170, 200, 230, 0.14), transparent 70%);
}

.petals {
  display: none;
}

[data-theme="clow"] .petals {
  display: block;
}

.petals span {
  position: absolute;
  top: -40px;
  width: 12px;
  height: 10px;
  background: #f4b7c2;
  border-radius: 12px 0 12px 0;
  opacity: 0.55;
  animation: fall linear infinite;
}

@keyframes fall {
  to {
    transform: translate3d(-120px, 110vh, 0) rotate(540deg);
  }
}

/* ---------- Nav ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  transition: background-color 0.3s, box-shadow 0.3s, border-color 0.3s;
  border-bottom: 1px solid transparent;
}

.nav.scrolled,
.nav.open {
  background: var(--nav-bg);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom-color: var(--border);
}

.nav-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  max-width: 1160px;
  height: 72px;
  margin: 0 auto;
  padding: 0 24px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  font-size: 19px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

[data-theme="heist"] .logo {
  font-size: 24px;
  letter-spacing: 0.04em;
}

.logo-mark {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

[data-theme="heist"] .logo-mark {
  border-radius: 0;
  background: var(--accent);
  box-shadow: 3px 3px 0 var(--accent-2);
  transform: rotate(-6deg);
}

[data-theme="clow"] .logo-mark {
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff 0 18%, var(--accent) 19% 60%, var(--accent-2) 61%);
}

.nav-links {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.nav-links a {
  position: relative;
  padding: 8px 14px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-2);
  border-radius: 999px;
  transition: color 0.2s, background-color 0.2s;
}

.nav-links a:hover {
  color: var(--text);
  background: var(--accent-soft);
}

.nav-links a.active {
  color: var(--accent);
}

.nav-links a.active::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  transform: translateX(-50%);
}

.theme-switch {
  display: inline-flex;
  flex-shrink: 0;
  padding: 4px;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow);
}

[data-theme="heist"] .theme-switch {
  border-radius: var(--radius);
}

.theme-switch button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  border-radius: 999px;
  transition: color 0.2s, background-color 0.2s;
}

[data-theme="heist"] .theme-switch button {
  border-radius: var(--radius-sm);
}

.theme-switch button [data-lucide],
.theme-switch button .lucide {
  width: 15px;
  height: 15px;
}

.theme-switch button:hover {
  color: var(--text);
}

.theme-switch button[aria-checked="true"] {
  background: var(--accent);
  color: var(--accent-ink);
}

/* 語言切換：一顆球，顯示目前語言，點一下翻面切換 */
.lang-ball {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin-left: -10px;
  font-family: var(--font-label);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--accent-ink);
  background: radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.35), transparent 55%), var(--accent);
  border-radius: 50%;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
}

.lang-ball:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

[data-theme="heist"] .lang-ball {
  background: var(--accent);
  box-shadow: 3px 3px 0 var(--accent-2);
}

[data-theme="clow"] .lang-ball {
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.55) 0 14%, transparent 40%), linear-gradient(135deg, var(--accent), var(--accent-2));
}

.lang-ball.flip span {
  animation: ball-flip 0.45s ease;
}

@keyframes ball-flip {
  0% { transform: rotateY(0); }
  50% { transform: rotateY(90deg); }
  100% { transform: rotateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .lang-ball.flip span {
    animation: none;
  }
}

.logo-sub {
  margin-left: 0.3em;
}

.nav-toggle {
  display: none;
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 22px;
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  border-radius: 999px;
  border: 1px solid transparent;
  transition: transform 0.2s, box-shadow 0.2s, background-color 0.2s, border-color 0.2s, color 0.2s;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 10px 24px -12px var(--accent);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 30px -14px var(--accent);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: progress;
  transform: none;
}

.btn-ghost {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost:hover {
  border-color: var(--border-strong);
  color: var(--accent);
}

[data-theme="heist"] .btn {
  border-radius: var(--radius);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

[data-theme="heist"] .btn-primary {
  box-shadow: 4px 4px 0 var(--accent-2);
}

[data-theme="heist"] .btn-primary:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 var(--accent-2);
}

[data-theme="clow"] .btn-primary {
  background: linear-gradient(135deg, #e08a9b, #d47689);
  box-shadow: 0 10px 24px -12px rgba(212, 118, 137, 0.9), inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

/* ---------- Hero ---------- */
.hero {
  padding: 56px 0 24px;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 56px;
  align-items: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  margin-bottom: 24px;
  font-family: var(--font-label);
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
}

.badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 4px var(--accent-soft);
}

[data-theme="heist"] .badge {
  border-radius: 0;
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
  transform: rotate(-1.5deg);
}

[data-theme="heist"] .badge::before {
  background: var(--accent-2);
  box-shadow: none;
}

.hero-title {
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  font-size: clamp(40px, 6.2vw, 76px);
  line-height: 1.08;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.hero-title em {
  font-style: normal;
  color: var(--title-em);
}

[data-theme="modern"] .hero-title em {
  background: linear-gradient(100deg, #0b63ce 10%, #38bdf8 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

[data-theme="heist"] .hero-title {
  font-size: clamp(38px, 5.4vw, 66px);
  line-height: 1.12;
  letter-spacing: 0.01em;
}

[data-theme="heist"] .hero-title em {
  text-shadow: 3px 3px 0 var(--accent-2);
}

[data-theme="clow"] .hero-title {
  font-size: clamp(38px, 5.4vw, 64px);
  line-height: 1.2;
  letter-spacing: 0.02em;
}

[data-theme="clow"] .hero-title em {
  background: linear-gradient(transparent 68%, rgba(223, 184, 108, 0.35) 68% 90%, transparent 90%);
}

.hero-lead {
  max-width: 34em;
  margin-top: 24px;
  font-size: 17px;
  color: var(--text-2);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 32px;
}

.hero-panel {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 460px;
}

.emblem {
  position: absolute;
  inset: 50% auto auto 50%;
  width: 118%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  color: var(--emblem);
  opacity: 0.55;
}

[data-theme="heist"] .emblem {
  opacity: 0.35;
}

.emblem svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.emblem .spin {
  transform-origin: 200px 200px;
  animation: spin 80s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.panel {
  position: relative;
  width: 100%;
  max-width: 420px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

[data-theme="heist"] .panel {
  border: 1px solid #343a45;
  box-shadow: 8px 8px 0 #000, 0 0 0 1px #000;
}

[data-theme="heist"] .panel::before {
  content: "CONFIDENTIAL";
  position: absolute;
  top: 18px;
  right: -12px;
  padding: 2px 10px;
  font-family: var(--font-label);
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--accent-2);
  border: 2px solid var(--accent-2);
  transform: rotate(8deg);
  background: var(--surface);
}

[data-theme="clow"] .panel {
  border-color: #ecd5b4;
  box-shadow: var(--shadow), inset 0 0 0 6px var(--surface), inset 0 0 0 7px #f1e2c8;
}

.panel-title {
  margin-top: 10px;
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  font-size: 24px;
  line-height: 1.3;
}

[data-theme="heist"] .panel-title {
  font-size: 28px;
  letter-spacing: 0.02em;
}

.panel-desc {
  margin-top: 10px;
  font-size: 15px;
  color: var(--text-2);
}

.panel-flow {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 20px 0;
}

.panel-flow li {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.panel-flow li span {
  font-family: var(--font-label);
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
}

.panel-stack {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--border);
}

.panel-stack div {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  align-items: baseline;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.panel-stack div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.panel-stack dt {
  font-weight: 700;
}

.panel-stack dd {
  font-family: var(--font-label);
  font-size: 12.5px;
  color: var(--muted);
}

[data-theme="clow"] .panel-stack dd {
  font-family: var(--font-body);
}

/* Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-top: 56px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stats div {
  padding: 22px 24px;
}

.stats div + div {
  border-left: 1px solid var(--border);
}

.stats dt {
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  font-size: 34px;
  line-height: 1.1;
  color: var(--accent);
}

[data-theme="heist"] .stats dt {
  font-size: 44px;
}

[data-theme="clow"] .stats dt {
  font-family: var(--font-label);
  font-style: italic;
  font-weight: 600;
  font-size: 38px;
  color: var(--accent-2);
}

.stats dd {
  margin-top: 4px;
  font-size: 14px;
  color: var(--text-2);
}

/* ---------- Sections ---------- */
.section {
  padding: 96px 0 0;
}

.section-head {
  max-width: 640px;
  margin-bottom: 40px;
}

.section-head h2,
.contact-copy h2 {
  margin-top: 10px;
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  font-size: clamp(30px, 4vw, 44px);
  line-height: 1.2;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

[data-theme="heist"] .section-head h2,
[data-theme="heist"] .contact-copy h2 {
  font-size: clamp(34px, 4.6vw, 54px);
  letter-spacing: 0.02em;
}

.section-desc {
  margin-top: 14px;
  color: var(--text-2);
}

.section-desc a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.sub-title,
.box-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: var(--display-weight);
}

.sub-title {
  margin: 56px 0 20px;
  font-size: 24px;
}

.sub-title [data-lucide],
.sub-title .lucide,
.box-title [data-lucide],
.box-title .lucide {
  color: var(--accent);
}

[data-theme="heist"] .sub-title {
  font-size: 30px;
  letter-spacing: 0.03em;
}

/* Services */
.services {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.service {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform 0.25s, box-shadow 0.25s, border-color 0.25s;
}

.service:hover {
  transform: translateY(-4px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-hover);
}

.service-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 18px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 12px;
}

[data-theme="heist"] .service-icon {
  border-radius: 0;
  color: var(--accent-ink);
  background: var(--accent);
}

[data-theme="clow"] .service-icon {
  border-radius: 50%;
  color: var(--accent-2);
  background: #fbf0dc;
}

.service-no {
  position: absolute;
  top: 22px;
  right: 24px;
  font-family: var(--font-label);
  font-size: 13px;
  color: var(--muted);
}

.service h3 {
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  font-size: 19px;
}

[data-theme="heist"] .service h3 {
  font-size: 24px;
  letter-spacing: 0.02em;
}

.service p {
  margin-top: 8px;
  font-size: 15px;
  color: var(--text-2);
}

.service .service-stack {
  margin-top: auto;
  padding-top: 16px;
  font-family: var(--font-label);
  font-size: 12px;
  color: var(--muted);
}

/* ---------- Projects ---------- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 28px;
}

.filters button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: color 0.2s, background-color 0.2s, border-color 0.2s;
}

[data-theme="heist"] .filters button {
  border-radius: var(--radius);
}

.filters button b {
  min-width: 22px;
  padding: 0 6px;
  font-family: var(--font-label);
  font-size: 12px;
  font-weight: 500;
  line-height: 20px;
  text-align: center;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 999px;
}

.filters button:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.filters button[aria-selected="true"] {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
}

.filters button[aria-selected="true"] b {
  color: inherit;
  background: rgba(255, 255, 255, 0.22);
}

[data-theme="heist"] .filters button[aria-selected="true"] b {
  background: rgba(0, 0, 0, 0.15);
}

.projects {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.project {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.3s, border-color 0.3s;
}

.project[hidden] {
  display: none;
}

.project:hover,
.project:focus-within {
  transform: translateY(-6px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-hover);
}

[data-theme="heist"] .project:hover,
[data-theme="heist"] .project:focus-within {
  transform: translate(-3px, -3px) rotate(-0.4deg);
}

.project.pop {
  animation: pop 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
}

.project-media {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.project-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.project:hover .project-media img {
  transform: scale(1.05);
}

.project-flag,
.project-no {
  position: absolute;
  top: 14px;
  font-family: var(--font-label);
  font-size: 12px;
  line-height: 1;
  padding: 6px 10px;
  border-radius: 999px;
}

.project-flag {
  left: 14px;
  color: var(--accent-ink);
  background: var(--accent);
}

.project-no {
  right: 14px;
  color: var(--text-2);
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: blur(6px);
}

[data-theme="heist"] .project-flag {
  border-radius: 0;
  background: var(--accent-2);
  color: #fff;
  transform: rotate(-4deg);
}

[data-theme="heist"] .project-no {
  border-radius: 0;
}

[data-theme="heist"] .project::after {
  content: "CLASSIFIED";
  position: absolute;
  top: 38%;
  left: 50%;
  padding: 4px 14px;
  font-family: var(--font-label);
  font-size: 20px;
  letter-spacing: 0.18em;
  color: var(--accent-2);
  border: 3px solid var(--accent-2);
  transform: translate(-50%, -50%) rotate(-12deg) scale(1.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  background: rgba(11, 12, 15, 0.7);
}

[data-theme="heist"] .project:hover::after {
  opacity: 1;
  transform: translate(-50%, -50%) rotate(-12deg) scale(1);
}

.project-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 20px 22px 4px;
}

.project-body h3 {
  margin-top: 8px;
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  font-size: 19px;
  line-height: 1.35;
}

[data-theme="heist"] .project-body h3 {
  font-size: 23px;
  letter-spacing: 0.02em;
}

.project-open {
  text-align: left;
  font: inherit;
  line-height: inherit;
}

.project-open::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}

.project-open:focus-visible {
  outline: none;
}

.project:has(.project-open:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.project-desc {
  margin-top: 8px;
  font-size: 14.5px;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

.tags li {
  padding: 3px 10px;
  font-family: var(--font-label);
  font-size: 12px;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
}

[data-theme="heist"] .tags li {
  border-radius: 0;
}

[data-theme="clow"] .tags li {
  font-family: var(--font-body);
  font-size: 13px;
  font-style: normal;
}

.project-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding: 14px 22px;
  border-top: 1px dashed var(--border);
}

.link-strong {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
}

.link-strong:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.link-soft {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  color: var(--muted);
  transition: color 0.2s;
}

.link-soft [data-lucide],
.link-soft .lucide {
  width: 16px;
  height: 16px;
  transition: transform 0.2s;
}

.project:hover .link-soft {
  color: var(--text);
}

.project:hover .link-soft .lucide {
  transform: translate(2px, -2px);
}

/* ---------- About ---------- */
.about-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.about-body p {
  font-size: 17px;
  color: var(--text-2);
}

.about-body p + p {
  margin-top: 16px;
}

.belief {
  margin-top: 28px;
  padding: 24px 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
}

[data-theme="clow"] .belief {
  border-left-color: var(--accent-2);
}

.belief-label {
  font-family: var(--font-label);
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.belief-quote {
  margin-top: 6px;
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  font-size: 22px;
  line-height: 1.4;
}

[data-theme="heist"] .belief-quote {
  font-family: "Noto Sans TC", sans-serif;
}

.belief-body {
  margin-top: 8px;
  font-size: 15px;
  color: var(--text-2);
}

.about-side {
  display: grid;
  gap: 16px;
}

.box {
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.box-title {
  margin-bottom: 14px;
  font-size: 18px;
}

[data-theme="heist"] .box-title {
  font-size: 24px;
  letter-spacing: 0.03em;
}

.stack-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.stack-label ~ .stack-label {
  margin-top: 16px;
}

.stack-label + .tags {
  margin-top: 8px;
}

.timeline {
  position: relative;
  display: grid;
  gap: 18px;
  padding-left: 22px;
}

.timeline::before {
  content: "";
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 5px;
  width: 2px;
  background: var(--border);
}

.timeline li {
  position: relative;
}

.timeline li::before {
  content: "";
  position: absolute;
  top: 7px;
  left: -22px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--accent);
}

[data-theme="heist"] .timeline li::before {
  border-radius: 0;
  transform: rotate(45deg);
}

.tl-year {
  display: block;
  font-family: var(--font-label);
  font-size: 12px;
  color: var(--accent);
}

.timeline strong {
  display: block;
  font-size: 15px;
  line-height: 1.5;
}

.tl-org {
  display: block;
  font-size: 13px;
  color: var(--muted);
}

.timeline p {
  margin-top: 4px;
  font-size: 14px;
  color: var(--text-2);
}

.creds {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.cred {
  display: flex;
  gap: 14px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.cred-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 50%;
}

[data-theme="heist"] .cred-icon {
  border-radius: 0;
}

[data-theme="clow"] .cred-icon {
  color: var(--accent-2);
  background: #fbf0dc;
}

.cred h4 {
  margin-top: 4px;
  font-size: 16px;
  line-height: 1.4;
}

.cred p:last-child {
  margin-top: 4px;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-2);
}

/* ---------- Contact ---------- */
.contact {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 48px;
  padding: 48px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 8px);
  box-shadow: var(--shadow);
}

[data-theme="heist"] .contact {
  border-radius: var(--radius);
  background:
    repeating-linear-gradient(-45deg, rgba(242, 200, 75, 0.05) 0 10px, transparent 10px 20px),
    var(--surface);
  box-shadow: 10px 10px 0 #000;
}

[data-theme="clow"] .contact {
  box-shadow: var(--shadow), inset 0 0 0 8px var(--surface), inset 0 0 0 9px #f1e2c8;
}

.contact-links {
  display: grid;
  gap: 10px;
  margin-top: 28px;
}

.contact-links a {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  color: var(--text);
}

.contact-links a:hover {
  color: var(--accent);
}

.contact-links [data-lucide],
.contact-links .lucide,
.contact-links .icon-gh {
  color: var(--accent);
}

.form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.field {
  display: grid;
  gap: 6px;
}

.field-full {
  grid-column: 1 / -1;
}

.field label {
  font-size: 14px;
  font-weight: 600;
}

.field input,
.field textarea {
  width: 100%;
  padding: 12px 14px;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}

.field textarea {
  resize: vertical;
  min-height: 132px;
}

.field input::placeholder,
.field textarea::placeholder {
  color: var(--muted);
  opacity: 0.8;
}

.field input:focus,
.field textarea:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.form.validated :invalid {
  border-color: #d7263d;
}

.form-foot {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.form-note {
  font-size: 13px;
  color: var(--muted);
}

.form-status {
  grid-column: 1 / -1;
  min-height: 1.5em;
  font-size: 14px;
  font-weight: 600;
}

.form-status[data-state="busy"] {
  color: var(--muted);
}

.form-status[data-state="ok"] {
  color: #1a9c5b;
}

[data-theme="heist"] .form-status[data-state="ok"] {
  color: var(--accent);
}

.form-status[data-state="err"] {
  color: #d7263d;
}

/* ---------- Footer ---------- */
.footer {
  margin-top: 96px;
  padding: 28px 0 40px;
  border-top: 1px solid var(--border);
  font-size: 14px;
  color: var(--muted);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.to-top {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-label);
  font-size: 12px;
}

.to-top:hover {
  color: var(--accent);
}

/* ---------- Dialog ---------- */
.dialog {
  width: min(920px, calc(100% - 32px));
  max-height: calc(100% - 48px);
  padding: 0;
  color: var(--text);
  background: transparent;
  border: 0;
  overflow: visible;
}

.dialog::backdrop {
  background: rgba(10, 12, 18, 0.55);
  backdrop-filter: blur(6px);
}

.dialog[open] {
  animation: dlg-in 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes dlg-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
}

.dialog-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.5);
}

[data-theme="heist"] .dialog-card {
  border-color: #343a45;
  box-shadow: 12px 12px 0 var(--accent-2);
}

.dialog-media {
  background: var(--surface-2);
}

.dialog-media img {
  width: 100%;
  height: 100%;
  min-height: 320px;
  object-fit: cover;
}

.dialog-body {
  display: flex;
  flex-direction: column;
  padding: 36px 32px 32px;
}

.dialog-body h3 {
  margin-top: 8px;
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  font-size: 28px;
  line-height: 1.25;
}

[data-theme="heist"] .dialog-body h3 {
  font-size: 34px;
  letter-spacing: 0.02em;
}

.dialog-desc {
  margin-top: 14px;
  color: var(--text-2);
}

.dialog-facts {
  display: grid;
  gap: 12px;
  margin-top: 20px;
  padding: 16px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}

.dialog-facts dt {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
}

.dialog-facts dd {
  font-size: 15px;
}

.dialog-actions {
  display: flex;
  gap: 12px;
  margin-top: auto;
  padding-top: 28px;
}

.dialog-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  box-shadow: var(--shadow);
}

.dialog-close:hover {
  color: var(--accent);
}

/* ---------- Reveal ---------- */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.7s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.reveal.in {
  opacity: 1;
  transform: none;
}

/* ---------- Theme transition ---------- */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.45s;
}

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .services,
  .creds {
    grid-template-columns: repeat(2, 1fr);
  }

  .projects {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .nav-toggle {
    display: inline-flex;
  }

  .nav-links {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    display: none;
    flex-direction: column;
    gap: 4px;
    padding: 12px 16px 20px;
    /* 父層 .nav 已有 backdrop-filter，這裡的模糊不會生效，所以用實色 */
    background: var(--bg);
    border-bottom: 1px solid var(--border);
  }

  .nav.open .nav-links {
    display: flex;
  }

  .nav-links a {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 16px;
  }

  .nav-links a.active::after {
    display: none;
  }

  .theme-switch {
    margin-left: auto;
  }

  .hero-grid,
  .about-grid,
  .contact {
    grid-template-columns: 1fr;
  }

  .hero-grid {
    gap: 40px;
  }

  .hero-panel {
    min-height: 0;
    padding: 24px 0;
  }

  .emblem {
    width: 100%;
    max-width: 520px;
  }

  .panel {
    max-width: none;
  }

  .stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .stats div:nth-child(3) {
    border-left: 0;
  }

  .stats div:nth-child(n + 3) {
    border-top: 1px solid var(--border);
  }

  .contact {
    padding: 32px;
    gap: 32px;
  }

  .dialog-card {
    grid-template-columns: 1fr;
  }

  .dialog-media img {
    min-height: 0;
    aspect-ratio: 16 / 10;
  }
}

@media (max-width: 640px) {
  .container,
  .nav-inner {
    padding: 0 16px;
  }

  .nav-inner {
    gap: 12px;
    height: 64px;
  }

  .logo {
    min-width: 0;
    font-size: 17px;
  }

  [data-theme="heist"] .logo {
    font-size: 20px;
  }

  .theme-switch button {
    padding: 7px 9px;
  }

  .theme-switch button span {
    display: none;
  }

  .lang-ball {
    width: 38px;
    height: 38px;
    margin-left: -4px;
    font-size: 13px;
  }

  .hero {
    padding-top: 32px;
  }

  .hero-lead {
    font-size: 16px;
  }

  [data-theme="heist"] .hero-title,
  [data-theme="clow"] .hero-title {
    font-size: 33px;
  }

  .filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin: 0 -16px 24px;
    padding: 2px 16px;
    scrollbar-width: none;
  }

  .filters::-webkit-scrollbar {
    display: none;
  }

  .filters button {
    flex-shrink: 0;
  }

  .hero-actions .btn {
    flex: 1 1 auto;
  }

  .panel {
    padding: 22px;
  }

  .panel-stack div {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .section {
    padding-top: 72px;
  }

  .services,
  .creds,
  .projects,
  .form {
    grid-template-columns: 1fr;
  }

  .stats div {
    padding: 18px;
  }

  .stats dt {
    font-size: 28px;
  }

  .contact {
    padding: 24px 20px;
  }

  .form-foot {
    flex-direction: column;
    align-items: stretch;
  }

  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .dialog-body {
    padding: 24px 20px;
  }

  .dialog-body h3 {
    font-size: 24px;
  }

  [data-theme="heist"] .panel::before {
    right: 8px;
  }
}

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

  .reveal {
    opacity: 1;
    transform: none;
  }

  .petals {
    display: none !important;
  }
}

/* 窄螢幕上方列放不下完整 logo，只留 ansen */
@media (max-width: 480px) {
  .logo-sub {
    display: none;
  }
}
