:root {
  --bg: #f5f3ee;
  --surface: #fbfaf7;
  --ink: #1b1a17;
  --muted: #6d695f;
  --line: #dedad0;
  --tint: #ebe7de;
  --accent: #d9483f;

  /* アイコンの部品塗り分け */
  --c0: #d9483f;
  --c1: #d99a0f;
  --c2: #23866f;
  --c3: #3a66cc;
  --c4: #b4559a;

  --sans: "Zen Kaku Gothic New", system-ui, -apple-system, "Hiragino Sans", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", monospace;
  --radius: 12px;
  --gutter: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141311;
    --surface: #1b1a17;
    --ink: #ece8df;
    --muted: #9b968a;
    --line: #2f2d28;
    --tint: #24221e;
    --accent: #f06a5f;
    --c0: #f06a5f;
    --c1: #f0b53a;
    --c2: #4cc0a3;
    --c3: #7c9df0;
    --c4: #e08cc6;
    color-scheme: dark;
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "palt";
}

a { color: inherit; }
p, h1, h2, h3, ul, ol, dl, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }

.wrap {
  width: 100%;
  max-width: 1080px;
  margin-inline: auto;
  padding-inline: var(--gutter);
}
@media (min-width: 720px) { :root { --gutter: 32px; } }

.muted { color: var(--muted); }

/* ---------- アイコン ---------- */

.ico {
  width: 1em;
  height: 1em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ico > * { transition: stroke .25s ease; }

/* 部品ごとに塗る。ホバー・フォーカス・自動ハイライトで共通 */
:is(.tile.on, .tile:hover, .work-link:hover, .work-link:focus-visible) .ico .p0 { stroke: var(--c0); }
:is(.tile.on, .tile:hover, .work-link:hover, .work-link:focus-visible) .ico .p1 { stroke: var(--c1); }
:is(.tile.on, .tile:hover, .work-link:hover, .work-link:focus-visible) .ico .p2 { stroke: var(--c2); }
:is(.tile.on, .tile:hover, .work-link:hover, .work-link:focus-visible) .ico .p3 { stroke: var(--c3); }
:is(.tile.on, .tile:hover, .work-link:hover, .work-link:focus-visible) .ico .p4 { stroke: var(--c4); }

/* ---------- ヘッダー ---------- */

.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 56px;
  padding-inline: var(--gutter);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.mark {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 15px;
  letter-spacing: .02em;
  text-decoration: none;
}
.mark::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: 1px;
}
.bar nav { display: flex; gap: 4px; }
.bar nav a {
  font-size: 14px;
  text-decoration: none;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 8px;
}
.bar nav a:hover { color: var(--ink); background: var(--tint); }

/* ---------- ヒーロー ---------- */

.hero {
  display: grid;
  gap: 40px;
  padding-block: 48px 64px;
}
@media (min-width: 860px) {
  .hero {
    grid-template-columns: 1fr 360px;
    align-items: center;
    gap: 64px;
    padding-block: 88px 72px;
  }
}

.eyebrow {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  letter-spacing: .04em;
}
.hero h1 {
  display: flex;
  flex-direction: column;
  margin-top: 8px;
}
.name {
  font-size: clamp(56px, 14vw, 112px);
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: .02em;
}
.handle {
  font-family: var(--mono);
  font-weight: 500;
  font-size: clamp(20px, 4.4vw, 28px);
  color: var(--accent);
  line-height: 1.4;
  margin-top: 4px;
}
.handle::before { content: "a.k.a. "; color: var(--muted); font-weight: 400; }

.lead {
  margin-top: 28px;
  font-size: clamp(18px, 2.4vw, 21px);
  font-weight: 700;
  line-height: 1.6;
}
.sub {
  margin-top: 8px;
  color: var(--muted);
  max-width: 34em;
}

.hero-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding-inline: 20px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid var(--ink);
  transition: background .2s, color .2s;
}
.btn .ico { font-size: 18px; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--ink); }
.btn:not(.ghost):hover { background: var(--accent); border-color: var(--accent); }

/* 標本箱 */
.specimen figcaption {
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
}
.specimen figcaption a { text-underline-offset: 3px; }

.tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
@media (max-width: 859px) {
  .specimen { max-width: 420px; }
  .tile { aspect-ratio: 4 / 3; }
}
.tile {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  background: var(--surface);
  font-size: clamp(36px, 10vw, 54px);
  cursor: default;
  transition: background .25s;
}
.tile.on, .tile:hover { background: var(--bg); }
.tile .ico { stroke-width: 1.6; }

/* 線を描くように出す */
@media (prefers-reduced-motion: no-preference) {
  .tile .ico > * {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    opacity: 0;
    animation: draw 1.1s cubic-bezier(.6, 0, .3, 1) forwards;
    animation-delay: calc(var(--i, 0) * 90ms + 150ms);
  }
  .tile:nth-child(2) { --i: 1; }
  .tile:nth-child(3) { --i: 2; }
  .tile:nth-child(4) { --i: 3; }
  .tile:nth-child(5) { --i: 4; }
  .tile:nth-child(6) { --i: 5; }
  .tile:nth-child(7) { --i: 6; }
  .tile:nth-child(8) { --i: 7; }
  .tile:nth-child(9) { --i: 8; }
}
@keyframes draw {
  0% { stroke-dashoffset: 1; opacity: 0; }
  10% { opacity: 1; }
  100% { stroke-dashoffset: 0; opacity: 1; }
}

/* ---------- セクション共通 ---------- */

.section { padding-block: 56px; }
@media (min-width: 720px) { .section { padding-block: 80px; } }

.section-head {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding-top: 20px;
  margin-bottom: 32px;
  border-top: 2px solid var(--ink);
}
.section-head h2 {
  font-size: clamp(28px, 5vw, 40px);
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: .01em;
}
.section-head p { color: var(--muted); font-size: 14px; }

/* ---------- Works ---------- */

.works {
  display: grid;
  gap: 16px;
}
@media (min-width: 760px) {
  .works { grid-template-columns: 1fr 1fr; gap: 20px; }
}

.work-link {
  display: flex;
  gap: 18px;
  height: 100%;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  transition: border-color .2s;
}
.work-link:hover,
.work-link:focus-visible { border-color: var(--ink); outline: none; }

.work-ico {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  flex: none;
  border-radius: 10px;
  background: var(--tint);
  font-size: 30px;
}
.work-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.work-no {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  line-height: 1;
}
.work-title {
  margin-top: 6px;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.4;
}
.work-desc {
  margin-top: 6px;
  font-size: 14.5px;
  line-height: 1.75;
  color: var(--muted);
}
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}
.tags span {
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1;
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.work-url {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: auto;
  padding-top: 16px;
  font-family: var(--mono);
  font-size: 13px;
  overflow-wrap: anywhere;
}
.work-url .ico { transition: transform .2s; }
.work-link:hover .work-url .ico { transform: translate(2px, -2px); }

@media (max-width: 479px) {
  .work-link { gap: 14px; padding: 18px 16px; }
  .work-ico { width: 44px; height: 44px; font-size: 24px; border-radius: 8px; }
}

/* Lab */
.lab { margin-top: 48px; }
.lab h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}
.lab h3 span {
  margin-left: 10px;
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
}
.lab li {
  display: grid;
  grid-template-columns: 24px 1fr;
  column-gap: 12px;
  align-items: baseline;
  padding-block: 14px;
  border-bottom: 1px solid var(--line);
  font-size: 14.5px;
}
.lab li .ico { font-size: 20px; color: var(--muted); align-self: center; grid-row: span 2; }
.lab li b { font-weight: 700; }
.lab li span { color: var(--muted); line-height: 1.7; }
@media (min-width: 720px) {
  .lab li { grid-template-columns: 24px 220px 1fr; }
  .lab li .ico { grid-row: auto; }
}

/* ---------- Profile ---------- */

.profile {
  display: grid;
  gap: 32px;
}
@media (min-width: 860px) {
  .profile { grid-template-columns: 1.2fr 1fr; gap: 64px; }
}
.bio p + p { margin-top: 1em; }
.bio p { font-size: 16.5px; line-height: 1.95; }

.facts > div {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 12px;
  padding-block: 12px;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}
.facts > div:first-child { border-top: 1px solid var(--line); }
.facts dt {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  padding-top: 3px;
}
.facts dd { margin: 0; }
.facts .muted { margin-left: 6px; font-size: 13px; }

/* ---------- Links ---------- */

.links { border-top: 1px solid var(--line); }
.links a {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: 14px;
  min-height: 64px;
  padding-inline: 4px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  transition: padding .2s, color .2s;
}
.links .ico { font-size: 22px; }
.links .link-name { font-weight: 700; font-size: 17px; }
.links .link-id {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.links a > .ico:last-child { font-size: 18px; color: var(--muted); transition: transform .2s, color .2s; }
.links a:hover { padding-left: 10px; }
.links a:hover > .ico:last-child { color: var(--accent); transform: translate(2px, -2px); }

@media (max-width: 479px) {
  .links a { grid-template-columns: auto 1fr auto; row-gap: 0; padding-block: 12px; }
  .links .link-name { grid-column: 2; }
  .links .link-id { grid-column: 2; grid-row: 2; }
  .links a > .ico:first-child { grid-row: span 2; }
  .links a > .ico:last-child { grid-column: 3; grid-row: 1 / span 2; }
}

/* ---------- フッター ---------- */

.foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  padding-block: 32px 48px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}
.foot a { text-underline-offset: 3px; }
