:root {
  --bg: #f4f2ee;
  --surface: #fcfbf8;
  --surface-strong: #e5e7f0;
  --ink: #252a31;
  --muted: #69717a;
  --line: #3f4751;
  --accent: #8396bc;
  --accent-2: #d7ddbd;
  --accent-ink: #ffffff;
  --inverse: #29323a;
  --inverse-ink: #f3f4f0;
  --header-bg: rgba(244, 242, 238, .91);
  --shadow: 8px 8px 0 #3f4751;
}

html[data-theme="sun"] {
  --bg: #f7eee2;
  --surface: #fcf7f0;
  --surface-strong: #ead9c5;
  --ink: #45352b;
  --muted: #7c6b5e;
  --line: #68564a;
  --accent: #c78f7c;
  --accent-2: #dfe0ae;
  --accent-ink: #fffaf7;
  --inverse: #4c4139;
  --inverse-ink: #fff7ed;
  --header-bg: rgba(247, 238, 226, .91);
  --shadow: 8px 8px 0 #68564a;
}

html[data-theme="cyber"] {
  --bg: #172126;
  --surface: #222d31;
  --surface-strong: #314047;
  --ink: #ecf0eb;
  --muted: #b0bfbb;
  --line: #aabdb7;
  --accent: #9babb4;
  --accent-2: #c2ceb1;
  --accent-ink: #192225;
  --inverse: #334047;
  --inverse-ink: #f0f2ed;
  --header-bg: rgba(23, 33, 38, .92);
  --shadow: 8px 8px 0 #aabdb7;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 6rem; }
body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(to right, color-mix(in srgb, var(--line) 7%, transparent) 1px, transparent 1px),
    linear-gradient(to bottom, color-mix(in srgb, var(--line) 7%, transparent) 1px, transparent 1px),
    var(--bg);
  background-size: 32px 32px;
  font-family: Inter, "Noto Sans SC", "Microsoft YaHei", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.65;
  overflow-x: hidden;
  transition: color .2s ease, background-color .2s ease;
}
a { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
img { max-width: 100%; display: block; }

.skip-link {
  position: fixed;
  left: 1rem;
  top: -5rem;
  z-index: 100;
  padding: .75rem 1rem;
  background: var(--accent);
  color: var(--accent-ink);
}
.skip-link:focus { top: 1rem; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.section-shell { width: min(1220px, calc(100% - 2rem)); margin-inline: auto; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: 76px;
  display: grid;
  grid-template-columns: minmax(210px, 1fr) auto minmax(210px, 1fr);
  align-items: center;
  padding: .7rem clamp(1rem, 4vw, 4rem);
  border-bottom: 2px solid var(--line);
  background: var(--header-bg);
  backdrop-filter: blur(15px);
}
.brand { width: fit-content; display: flex; align-items: center; gap: .8rem; text-decoration: none; }
.brand-mark { font-size: 1.45rem; font-weight: 950; letter-spacing: -.07em; }
.brand-mark span { color: var(--accent); }
.brand-note { font-size: .76rem; color: var(--muted); letter-spacing: .08em; }
.site-nav { display: flex; align-items: center; gap: 1.2rem; }
.site-nav a { position: relative; font-size: .85rem; font-weight: 780; text-decoration: none; white-space: nowrap; }
.site-nav a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -.28rem;
  width: 100%;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .18s ease;
}
.site-nav a:hover::after, .site-nav a:focus-visible::after { transform: scaleX(1); }
.header-actions { justify-self: end; display: flex; align-items: center; gap: .65rem; }
.theme-picker { display: flex; border: 1.5px solid var(--line); }
.theme-picker button, .lang-button, .mobile-theme-button {
  min-width: 36px;
  min-height: 36px;
  border: 0;
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
}
.theme-picker button { border-right: 1.5px solid var(--line); }
.theme-picker button:last-child { border-right: 0; }
.theme-picker button[aria-pressed="true"] { color: var(--accent-ink); background: var(--accent); }
.lang-button, .mobile-theme-button { border: 1.5px solid var(--line); font-size: .8rem; font-weight: 850; }
.mobile-theme-button, .nav-toggle { display: none; }

.hero {
  min-height: calc(100vh - 76px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, .92fr);
  gap: clamp(2rem, 5vw, 5rem);
  align-items: center;
  padding-block: clamp(4rem, 9vh, 7rem);
}
.hero-copy { position: relative; z-index: 2; }
.eyebrow, .section-no, .card-kicker {
  margin: 0 0 1rem;
  font-family: "Courier New", monospace;
  font-size: .78rem;
  font-weight: 850;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.eyebrow, .section-no { color: var(--accent); }
.hero h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(3.1rem, 6.6vw, 6.5rem);
  line-height: .98;
  letter-spacing: -.065em;
  text-wrap: balance;
}
.hero-intro { max-width: 700px; margin: 2rem 0; color: var(--muted); font-size: clamp(1.05rem, 1.7vw, 1.28rem); }
.hero-links { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; }
.primary-link {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  min-width: 210px;
  padding: .9rem 1rem;
  border: 2px solid var(--line);
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: var(--shadow);
  font-weight: 850;
  text-decoration: none;
  transition: transform .18s ease, box-shadow .18s ease;
}
.primary-link:hover { transform: translate(4px, 4px); box-shadow: 4px 4px 0 var(--line); }
.text-link { font-weight: 820; text-underline-offset: .28rem; }
.hero-visual { position: relative; height: clamp(520px, 56vw, 720px); margin: 0; align-self: center; border: 2px solid var(--line); background: var(--inverse); overflow: hidden; box-shadow: 12px 12px 0 var(--accent); }
.hero-visual img { width: 100%; height: 100%; object-fit: cover; object-position: 66% center; }
.hero-visual figcaption {
  position: absolute;
  left: 1rem;
  right: 1rem;
  bottom: 1rem;
  padding: .72rem .85rem;
  color: #fff;
  background: rgba(8, 12, 16, .82);
  border: 1px solid rgba(255,255,255,.5);
  font-size: .8rem;
  backdrop-filter: blur(8px);
}

.status-band { border-block: 2px solid var(--line); background: var(--accent-2); color: #101317; }
.status-grid { display: grid; grid-template-columns: repeat(4, 1fr); }
.status-grid div { padding: 1.15rem; border-right: 1.5px solid #101317; }
.status-grid div:last-child { border-right: 0; }
.status-grid span { display: block; margin-bottom: .25rem; font: 800 .72rem/1 "Courier New", monospace; letter-spacing: .1em; }
.status-grid strong { font-size: .95rem; }

.content-section { padding-block: clamp(5rem, 9vw, 8rem); }
.section-heading { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, .62fr); gap: 3rem; margin-bottom: 3rem; align-items: end; }
.section-heading h2, .about-section h2, .contact-section h2 { margin: 0; font-size: clamp(2.5rem, 5vw, 5rem); line-height: 1.03; letter-spacing: -.055em; text-wrap: balance; }
.section-heading > p { margin: 0; color: var(--muted); }

.environment-section { padding-top: clamp(4rem, 7vw, 6rem); }
.environment-gallery { display: grid; grid-template-columns: 1fr 1fr .72fr; gap: 1rem; }
.media-card { overflow: hidden; border: 1.5px solid var(--line); background: var(--surface); box-shadow: 6px 6px 0 color-mix(in srgb, var(--accent) 55%, transparent); }
.media-card img { width: 100%; display: block; background: var(--surface-strong); object-fit: cover; }
.environment-card img { aspect-ratio: 16 / 10; }
.environment-card:nth-child(3) img { height: auto; aspect-ratio: auto; object-fit: contain; object-position: center; }
.media-card-copy { padding: 1.1rem 1.15rem 1.25rem; }
.media-card-copy .card-kicker { display: block; margin-bottom: .75rem; color: var(--accent); font-size: .68rem; }
.media-card-copy h3 { margin: 0 0 .45rem; font-size: 1.32rem; line-height: 1.1; }
.media-card-copy p { margin: 0; color: var(--muted); font-size: .92rem; }

.service-grid { display: grid; grid-template-columns: repeat(2, 1fr); border: 2px solid var(--line); }
.service-card { min-height: 330px; display: flex; flex-direction: column; padding: clamp(1.4rem, 3vw, 2.2rem); background: var(--surface); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.service-card:nth-child(2n) { border-right: 0; }
.service-card:nth-last-child(-n+2) { border-bottom: 0; }
.service-top { display: flex; justify-content: space-between; gap: 1rem; }
.service-number { font: 900 2.1rem/1 "Courier New", monospace; color: var(--accent); }
.service-card h3 { max-width: 540px; margin: 3rem 0 1rem; font-size: clamp(1.5rem, 2.5vw, 2.2rem); line-height: 1.1; }
.service-card p { margin: 0; color: var(--muted); }
.deliverables { margin-top: auto; padding-top: 1.5rem; display: flex; flex-wrap: wrap; gap: .5rem; }
.deliverables span { padding: .28rem .52rem; border: 1px solid var(--line); font-size: .75rem; font-weight: 780; }

.inverse-block { position: relative; color: var(--inverse-ink); }
.inverse-block::before { content: ""; position: absolute; inset: 0; z-index: -1; background: var(--inverse); }
.inverse-block .section-heading > p { color: color-mix(in srgb, var(--inverse-ink) 70%, transparent); }
.project-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.project-card { min-height: 410px; display: flex; flex-direction: column; padding: 1.5rem; border: 1.5px solid currentColor; background: color-mix(in srgb, var(--inverse) 84%, var(--accent)); }
.project-tag { width: fit-content; padding: .28rem .55rem; color: #101317; background: var(--accent-2); font: 800 .72rem/1.2 "Courier New", monospace; }
.project-card h3 { margin: 3.5rem 0 1rem; font-size: 1.8rem; line-height: 1.08; }
.project-card p { margin: 0; color: color-mix(in srgb, var(--inverse-ink) 72%, transparent); }
.project-meta { margin-top: auto; padding-top: 1rem; border-top: 1px solid currentColor; font: 700 .76rem/1.5 "Courier New", monospace; }
.deck-intro { display: grid; grid-template-columns: minmax(0, 1fr) minmax(250px, .62fr); gap: 2rem; align-items: end; margin: clamp(4rem, 8vw, 6rem) 0 1.5rem; padding-top: 1.4rem; border-top: 1px solid color-mix(in srgb, var(--inverse-ink) 46%, transparent); }
.deck-intro .section-no { margin-bottom: .75rem; color: var(--accent-2); }
.deck-intro h3 { margin: 0; font-size: clamp(1.9rem, 3.8vw, 3.2rem); line-height: 1; letter-spacing: -.045em; }
.deck-intro > p { margin: 0; color: color-mix(in srgb, var(--inverse-ink) 72%, transparent); }
.deck-gallery { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
.deck-card { overflow: hidden; border: 1px solid color-mix(in srgb, var(--inverse-ink) 72%, transparent); color: var(--inverse-ink); background: color-mix(in srgb, var(--inverse) 78%, var(--accent)); text-decoration: none; transition: transform .18s ease, box-shadow .18s ease; }
.deck-card:hover, .deck-card:focus-visible { transform: translateY(-5px); box-shadow: 6px 6px 0 var(--accent-2); }
.deck-card img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: #fff; }
.deck-copy { display: grid; gap: .6rem; padding: 1rem; }
.deck-copy .card-kicker { margin: 0; color: var(--accent-2); font-size: .64rem; }
.deck-copy h3 { margin: 0; font-size: 1.22rem; line-height: 1.1; }
.deck-copy p { min-height: 2.9em; margin: 0; color: color-mix(in srgb, var(--inverse-ink) 74%, transparent); font-size: .82rem; }
.deck-copy > div { display: flex; justify-content: space-between; gap: .7rem; padding-top: .7rem; border-top: 1px solid color-mix(in srgb, var(--inverse-ink) 45%, transparent); font: 800 .7rem/1.3 "Courier New", monospace; }
.deck-copy strong { color: var(--accent-2); }

.process-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(5, 1fr); border-block: 2px solid var(--line); }
.process-item { min-height: 260px; padding: 1.35rem; border-right: 1px solid var(--line); }
.process-item:last-child { border-right: 0; }
.process-item span { font: 900 2.2rem/1 "Courier New", monospace; color: var(--accent); }
.process-item h3 { margin: 3.2rem 0 .8rem; font-size: 1.2rem; }
.process-item p { margin: 0; color: var(--muted); font-size: .92rem; }

.lab-section { color: #101317; background: var(--accent-2); border-block: 2px solid #101317; }
.lab-heading { display: grid; grid-template-columns: .45fr 1.1fr 1fr; gap: 2rem; align-items: end; margin-bottom: 3rem; }
.lab-heading .section-no { color: #101317; }
.lab-heading h2 { margin: 0; font-size: clamp(3.5rem, 8vw, 8rem); line-height: .82; letter-spacing: -.08em; }
.lab-heading > p:last-child { margin: 0; }
.lab-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.lab-card { min-height: 290px; display: flex; flex-direction: column; padding: 1.4rem; border: 2px solid #101317; color: #101317; background: rgba(255,255,255,.32); text-decoration: none; transition: transform .18s ease, box-shadow .18s ease, background .18s ease; }
.lab-card:hover, .lab-card:focus-visible { transform: translateY(-6px); background: rgba(255,255,255,.58); box-shadow: 7px 7px 0 #101317; }
.lab-card h3 { margin: 2.8rem 0 .8rem; font-size: 1.55rem; }
.lab-card p { margin: 0; }
.lab-state { font: 800 .72rem/1 "Courier New", monospace; letter-spacing: .08em; }
.lab-cta { margin-top: auto; padding-top: 1.5rem; font-weight: 850; text-decoration: underline; text-underline-offset: .25rem; }
.lab-detail-list { display: grid; gap: 1rem; margin-top: 4rem; padding-top: 2rem; border-top: 2px solid #101317; }
.lab-detail { scroll-margin-top: 7rem; display: grid; grid-template-columns: .34fr 1fr auto; gap: 2rem; align-items: start; padding: clamp(1.4rem, 3vw, 2.3rem); border: 2px solid #101317; background: var(--surface); color: var(--ink); }
.lab-detail-index { display: grid; gap: 1rem; font-family: "Courier New", monospace; }
.lab-detail-index span { font-size: .75rem; font-weight: 850; }
.lab-detail-index strong { color: var(--accent); font-size: .86rem; }
.lab-detail-copy h3 { margin: 0 0 1rem; font-size: clamp(1.65rem, 3vw, 2.55rem); line-height: 1.08; }
.lab-detail-copy p { margin: 0; color: var(--muted); }
.lab-detail-meta { margin-top: 1.3rem; padding-top: 1rem; border-top: 1px solid var(--line); font: 750 .78rem/1.5 "Courier New", monospace; }
.lab-back { font-size: .8rem; font-weight: 850; white-space: nowrap; text-underline-offset: .25rem; }

.about-section { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(2rem, 7vw, 7rem); align-items: start; }
.about-copy { font-size: 1.05rem; }
.about-copy p { margin: 0 0 1.3rem; }
.about-rule { padding-top: 1.2rem; border-top: 2px solid var(--line); font-weight: 820; }

.social-section { border-block: 2px solid var(--line); background: var(--surface-strong); }
.social-gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(1rem, 3vw, 2rem); max-width: 930px; }
.social-card { display: grid; grid-template-columns: minmax(180px, .75fr) 1fr; align-items: stretch; background: var(--surface); }
.social-card img { height: auto; min-height: 0; aspect-ratio: auto; object-fit: contain; object-position: center; }
.social-card .media-card-copy { display: flex; flex-direction: column; padding: clamp(1.3rem, 3vw, 2.1rem); }
.social-card h3 { margin-top: auto; font-size: clamp(1.5rem, 3vw, 2rem); }
.scan-cta { margin-top: 1.35rem; color: var(--accent); font: 850 .78rem/1.2 "Courier New", monospace; letter-spacing: .05em; }

.contact-section { color: var(--inverse-ink); background: var(--inverse); }
.contact-layout { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(2rem, 6vw, 6rem); align-items: end; }
.contact-lead { max-width: 650px; margin: 2rem 0 0; color: color-mix(in srgb, var(--inverse-ink) 72%, transparent); font-size: clamp(1.1rem, 2vw, 1.45rem); }
.contact-panel { padding: 1.5rem; color: #101317; background: var(--accent-2); border: 2px solid var(--inverse-ink); box-shadow: 8px 8px 0 var(--accent); }
.contact-panel dl { margin: 0; }
.contact-panel dl div { display: grid; grid-template-columns: 120px 1fr; gap: 1rem; padding: 1rem 0; border-bottom: 1px solid #101317; }
.contact-panel dl div:last-child { border-bottom: 0; }
.contact-panel dt { font-size: .8rem; opacity: .72; }
.contact-panel dd { margin: 0; font-weight: 820; }

.site-footer { display: grid; grid-template-columns: 1fr auto auto; gap: 2rem; padding: 2rem clamp(1rem, 4vw, 4rem); border-top: 2px solid var(--line); font: 800 .76rem/1.5 "Courier New", monospace; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

@media (max-width: 1040px) {
  .site-header { grid-template-columns: minmax(0, 1fr) auto; }
  .nav-toggle { display: grid; gap: 4px; min-width: 42px; min-height: 42px; place-content: center; border: 1.5px solid var(--line); color: var(--ink); background: var(--surface); cursor: pointer; }
  .nav-toggle span:not(.sr-only) { width: 18px; height: 2px; background: currentColor; }
  .site-nav { position: absolute; left: 0; right: 0; top: 100%; display: none; padding: 1rem; border-bottom: 2px solid var(--line); background: var(--bg); }
  .site-nav.is-open { display: grid; grid-template-columns: repeat(3, 1fr); }
  .header-actions { margin-left: .7rem; }
  .brand-note { display: none; }
  .hero { grid-template-columns: 1fr; }
  .hero-visual { min-height: 480px; }
  .project-grid { grid-template-columns: 1fr; }
  .project-card { min-height: 300px; }
  .environment-gallery { grid-template-columns: 1fr 1fr; }
  .environment-card:nth-child(3) { grid-column: span 2; display: grid; grid-template-columns: minmax(240px, .8fr) 1fr; }
  .environment-card:nth-child(3) img { height: auto; align-self: center; }
  .deck-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .social-gallery { max-width: none; }
  .social-card { grid-template-columns: minmax(145px, .72fr) 1fr; }
  .process-list { grid-template-columns: repeat(3, 1fr); }
  .process-item:nth-child(3) { border-right: 0; }
  .process-item:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
  .lab-heading { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .site-header { padding-inline: .75rem; }
  .header-actions { gap: .4rem; margin-left: 0; }
  .theme-picker { display: none; }
  .mobile-theme-button { display: block; }
  .section-shell { width: min(100% - 1.25rem, 1220px); }
  .hero { padding-top: 3rem; gap: 2rem; }
  .hero h1 { font-size: clamp(2.7rem, 14vw, 4.6rem); }
  .hero-visual { min-height: 360px; box-shadow: 6px 6px 0 var(--accent); }
  .status-grid { grid-template-columns: 1fr 1fr; }
  .status-grid div:nth-child(2) { border-right: 0; }
  .status-grid div:nth-child(-n+2) { border-bottom: 1px solid #101317; }
  .section-heading, .about-section, .contact-layout { grid-template-columns: 1fr; gap: 1.5rem; }
  .service-grid { grid-template-columns: 1fr; }
  .service-card { min-height: 290px; border-right: 0; border-bottom: 1px solid var(--line) !important; }
  .service-card:last-child { border-bottom: 0 !important; }
  .process-list { grid-template-columns: 1fr; }
  .process-item { min-height: auto; border-right: 0; border-bottom: 1px solid var(--line) !important; }
  .process-item:last-child { border-bottom: 0 !important; }
  .process-item h3 { margin-top: 1.5rem; }
  .lab-grid { grid-template-columns: 1fr; }
  .environment-gallery, .deck-gallery, .social-gallery { grid-template-columns: 1fr; }
  .environment-card:nth-child(3), .social-card { display: block; grid-column: auto; }
  .environment-card:nth-child(3) img, .social-card img { height: auto; min-height: 0; aspect-ratio: auto; }
  .environment-card img { aspect-ratio: 16 / 10; }
  .social-card img { width: 100%; object-fit: contain; }
  .deck-intro { grid-template-columns: 1fr; gap: 1rem; margin-top: 3.5rem; }
  .lab-detail { grid-template-columns: 1fr; gap: 1.2rem; }
  .lab-detail-index { display: flex; justify-content: space-between; }
  .lab-back { justify-self: start; }
  .contact-panel dl div { grid-template-columns: 1fr; gap: .2rem; }
  .site-footer { grid-template-columns: 1fr; gap: .8rem; }
}

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