:root {
  --paper: #fff;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --line: #d2d2d7;
  --light-line: #e8e8ed;
  --accent: #0071e3;
  --accent-deep: #0058b0;
  --accent-bright: #2997ff;
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: #f5f5f7;
  scrollbar-gutter: stable;
}

html:has(.lightbox[open]) { overflow: hidden; }

body {
  position: relative;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang TC",
    "Hiragino Sans", "Noto Sans TC", "Noto Sans JP", "Helvetica Neue", Arial, sans-serif;
  font-size: 9.6pt;
  line-height: 1.52;
  text-rendering: optimizeLegibility;
}

button { font: inherit; }

.screen-toolbar {
  position: sticky;
  top: 12px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(210mm, calc(100vw - 24px));
  margin: 16px auto 12px;
  padding: 8px 9px 8px 14px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.07);
  backdrop-filter: blur(18px);
}

.toolbar-actions,
.language-switch { display: flex; align-items: center; }
.toolbar-actions { gap: 8px; }

.language-switch {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.language-switch button,
.print-button {
  min-height: 34px;
  border: 0;
  cursor: pointer;
  transition: color 180ms ease, background-color 180ms ease, box-shadow 180ms ease,
    transform 180ms var(--ease-out-expo);
}

.language-switch button {
  min-width: 54px;
  padding: 6px 11px;
  color: #666;
  background: #fff;
  font-weight: 650;
}

.language-switch button + button { border-left: 1px solid #cfcfcb; }

.language-switch button[aria-pressed="true"] {
  color: #fff;
  background: var(--accent);
}

.print-button {
  padding: 7px 14px;
  color: #fff;
  background: var(--accent);
  border-radius: 999px;
  font-weight: 700;
}

.language-switch button:hover,
.print-button:hover { transform: translateY(-1px); }
.print-button:hover { background: var(--accent-deep); }
.language-switch button:focus-visible,
.print-button:focus-visible,
.contact a:focus-visible,
.visual-trigger:focus-visible,
.lightbox-button:focus-visible {
  outline: 2px solid var(--accent-bright);
  outline-offset: 3px;
}

.resume {
  display: grid;
  gap: 22px;
  padding-bottom: 42px;
}

.page {
  position: relative;
  width: 210mm;
  min-height: 297mm;
  margin: 0 auto;
  padding: 17mm 18mm 14mm;
  overflow: hidden;
  background: var(--paper);
  box-shadow: 0 12px 38px rgba(0, 0, 0, 0.09);
  animation: page-arrival 720ms var(--ease-out-expo) both;
}

.page:nth-child(2) { animation-delay: 90ms; }
.page:nth-child(3) { animation-delay: 180ms; }

.page::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 1.8mm;
  background: var(--accent);
  transform-origin: left;
  animation: color-bar-enter 900ms var(--ease-out-expo) both;
}

.page-one,
.page-two,
.page-three { display: flex; flex-direction: column; gap: 10mm; }

.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14mm;
  align-items: end;
  padding: 3mm 0 7mm;
  border-bottom: 1px solid var(--ink);
}

h1, h2, h3, p { margin: 0; }

.eyebrow,
.section-label {
  color: var(--accent);
  font-size: 7.8pt;
  font-weight: 700;
}

h1 {
  margin-top: 2mm;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang TC",
    "Hiragino Sans", "Noto Sans TC", sans-serif;
  font-size: 30pt;
  line-height: 1.05;
  font-weight: 600;
  letter-spacing: 0;
}

.tagline {
  margin-top: 3mm;
  color: #4f4f4f;
  font-size: 9.4pt;
  font-weight: 500;
}

.contact {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 18mm;
  grid-template-rows: repeat(3, auto);
  column-gap: 4mm;
  row-gap: 1.4mm;
  justify-items: end;
  align-items: center;
  width: 67mm;
  min-width: 67mm;
  color: var(--muted);
  font-size: 8.3pt;
  font-style: normal;
  text-align: right;
}

.contact > :not(.resume-qr) { grid-column: 1; }

.contact a {
  position: relative;
  color: inherit;
  text-decoration: none;
  transition: color 180ms ease;
}

.contact > a:not(.resume-qr)::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -0.4mm;
  left: 0;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 320ms var(--ease-out-expo);
}

.contact a:hover { color: var(--accent); }
.contact > a:not(.resume-qr):hover::after { transform: scaleX(1); transform-origin: left; }

.resume-qr {
  display: grid;
  grid-column: 2;
  grid-row: 1 / -1;
  justify-items: end;
  align-self: center;
  gap: 1mm;
  width: 18mm;
  min-width: 18mm;
  max-width: 18mm;
  justify-self: end;
  overflow: hidden;
  transition: opacity 180ms ease;
}

.resume-qr:hover { opacity: 0.72; }

.contact .resume-qr img {
  display: block;
  width: 18mm;
  min-width: 18mm;
  max-width: 18mm;
  height: 18mm;
  max-height: 18mm;
  object-fit: contain;
  image-rendering: pixelated;
}

.resume-qr span {
  width: 100%;
  font-size: 6.8pt;
  font-weight: 650;
  text-align: center;
}

.summary {
  display: grid;
  grid-template-columns: 27mm minmax(0, 1fr);
  gap: 8mm;
  align-items: start;
}

.summary-copy {
  max-width: 132mm;
  color: #2b2b2b;
  font-size: 10.3pt;
  line-height: 1.62;
}

.section-block,
.project,
.mini-project-list article { break-inside: avoid; page-break-inside: avoid; }

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 8mm;
  margin-bottom: 4.5mm;
  padding: 0 0 2mm 3mm;
  border-bottom: 1px solid var(--ink);
  border-left: 2mm solid var(--accent);
}

.section-heading > div { display: flex; align-items: baseline; gap: 3mm; }

h2 {
  font-size: 10.2pt;
  line-height: 1.2;
  font-weight: 700;
}

.company-row {
  display: grid;
  grid-template-columns: 1fr 82mm;
  gap: 13mm;
  margin-bottom: 5mm;
}

.company-name h3,
.project h3,
.mini-project-list h3,
.bottom-grid h3 {
  font-size: 11pt;
  line-height: 1.35;
  font-weight: 650;
}

.company-name p { margin-top: 1mm; color: var(--muted); font-size: 8.3pt; }

.career-path { display: grid; gap: 1.3mm; margin: 0; padding: 0; list-style: none; }
.career-path li {
  display: flex;
  justify-content: space-between;
  gap: 5mm;
  color: var(--muted);
  font-size: 8.15pt;
}
.career-path strong { color: var(--ink); font-weight: 650; }

.achievement-list { margin: 0; padding: 0; list-style: none; }

.achievement-list li {
  position: relative;
  margin-bottom: 2.8mm;
  padding-left: 4mm;
}

.achievement-list li::before {
  content: "";
  position: absolute;
  top: 0.7em;
  left: 0;
  width: 1.2mm;
  height: 1.2mm;
  background: var(--accent);
  border-radius: 50%;
}

.two-column-list { columns: 2; column-gap: 10mm; }
.two-column-list li { break-inside: avoid; page-break-inside: avoid; }

.project {
  padding: 5mm 0 7mm;
  border-bottom: 1px solid var(--light-line);
}

.project:last-child { padding-bottom: 0; border-bottom: 0; }
.project-head { display: block; margin-bottom: 4mm; }
.project-meta { margin-top: 1.3mm; color: var(--muted); font-size: 8.35pt; font-weight: 550; }

.project-body {
  display: grid;
  grid-template-columns: 72mm minmax(0, 1fr);
  gap: 8mm;
  align-items: start;
}

.project-visual {
  margin: 0;
}

.visual-trigger {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  padding: 0;
  overflow: hidden;
  background: #f5f5f7;
  border: 1px solid #d2d2d2;
  cursor: zoom-in;
}

.project-visual img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 520ms var(--ease-out-expo);
}

.visual-trigger::after {
  content: "";
  position: absolute;
  right: 2.4mm;
  bottom: 2.4mm;
  width: 7mm;
  height: 7mm;
  background: rgba(255, 255, 255, 0.92) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231d1d1f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 4h5v5M9 20H4v-5M20 4l-6 6M4 20l6-6'/%3E%3C/svg%3E") center / 55% no-repeat;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 180ms ease, transform 320ms var(--ease-out-expo);
}

.visual-trigger:hover img,
.visual-trigger:focus-visible img { transform: scale(1.04); }

.visual-trigger:hover::after,
.visual-trigger:focus-visible::after { opacity: 1; transform: none; }

@media (hover: none) {
  .visual-trigger::after { opacity: 1; transform: none; }
}

.project-visual figcaption {
  margin-top: 1.6mm;
  color: #707070;
  font-size: 7.2pt;
  line-height: 1.4;
}

.flagship { padding: 1mm 0 0; }

.page-two .project { padding: 6mm 0 9mm; }
.page-two .project-head { margin-bottom: 5mm; }

.page-two .achievement-list {
  columns: 1;
  max-width: none;
}

.page-two .achievement-list li {
  margin-bottom: 2.8mm;
  padding-left: 4mm;
  font-size: 9.1pt;
  line-height: 1.5;
}

.mini-project-list { display: grid; gap: 0; }

.mini-project-list article {
  display: grid;
  grid-template-columns: 61mm 1fr;
  gap: 9mm;
  padding: 5.5mm 0;
  border-bottom: 1px solid var(--light-line);
}

.mini-project-list article:first-child { border-top: 1px solid var(--light-line); }
.mini-project-list h3 { font-size: 9.6pt; }
.mini-project-list .project-meta { margin-top: 1.3mm; }

.mini-project-list article > p:last-child {
  grid-column: 2;
  grid-row: 1 / span 2;
  color: #343434;
  font-size: 9pt;
  line-height: 1.58;
}

.bottom-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8mm;
  margin-top: 5mm;
  padding-top: 8mm;
  border-top: 1px solid var(--ink);
}

.compact-heading { margin-bottom: 3.5mm; }
.skills { display: grid; gap: 4mm; margin: 0; }
.skills div { display: grid; grid-template-columns: 25mm 1fr; gap: 4mm; }
.skills dt { color: var(--ink); font-size: 8.2pt; font-weight: 700; }
.skills dd { margin: 0; color: #4d4d4d; font-size: 8.1pt; }
html[lang="ja"] .skills div { grid-template-columns: 36mm 1fr; }
.education-copy { margin-top: 1.5mm; color: var(--muted); font-size: 8.3pt; }

.page-footer {
  position: absolute;
  right: 18mm;
  bottom: 7mm;
  left: 18mm;
  display: flex;
  justify-content: space-between;
  padding-top: 1.8mm;
  color: #888;
  border-top: 1px solid var(--light-line);
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: 7.1pt;
}

.noscript-message { max-width: 600px; margin: 30px auto; padding: 20px; background: #fff; }

@media (prefers-reduced-motion: no-preference) {
  .reveal {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 640ms ease, transform 820ms var(--ease-out-expo);
    transition-delay: var(--reveal-delay, 0ms);
  }

  .reveal.is-visible { opacity: 1; transform: none; }
}

.lightbox {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  color: #f5f5f7;
  background: transparent;
  border: 0;
  font-size: 13px;
}

.lightbox[open] { display: grid; place-items: center; }
.lightbox::backdrop { background: rgba(12, 12, 14, 0.9); backdrop-filter: blur(6px); }
.lightbox[open]::backdrop { animation: lightbox-fade 280ms ease both; }

.lightbox-figure {
  display: grid;
  justify-items: center;
  gap: 14px;
  margin: 0;
  padding: 64px 84px 28px;
  animation: lightbox-zoom 420ms var(--ease-out-expo) both;
}

.lightbox-image {
  display: block;
  width: min(calc(100vw - 168px), 1600px, calc((100dvh - 170px) * 16 / 9));
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.lightbox-caption {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 4px 12px;
  line-height: 1.5;
  text-align: center;
}

.lightbox-caption strong { font-weight: 650; }
.lightbox-caption span { color: rgba(245, 245, 247, 0.7); }
.lightbox-counter { font-variant-numeric: tabular-nums; }

.lightbox-button {
  position: absolute;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  color: #f5f5f7;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 180ms ease, transform 180ms var(--ease-out-expo);
}

.lightbox-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lightbox-button:hover { background: rgba(255, 255, 255, 0.24); }
.lightbox-close { top: 16px; right: 16px; }
.lightbox-nav { top: 50%; transform: translateY(-50%); }
.lightbox-nav:hover { transform: translateY(-50%) scale(1.06); }
.lightbox-prev { left: 20px; }
.lightbox-next { right: 20px; }

@keyframes lightbox-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes lightbox-zoom {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: none; }
}

@keyframes page-arrival {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

@keyframes color-bar-enter {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

@page { size: A4; margin: 0; }

@media print {
  html, body { width: 210mm; background: #fff; }
  body { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .screen-toolbar, .noscript-message { display: none; }
  .resume { display: block; padding: 0; }
  .page {
    width: 210mm;
    min-height: 297mm;
    height: 297mm;
    margin: 0;
    box-shadow: none;
    animation: none;
    break-after: page;
    page-break-after: always;
  }
  .page::before { animation: none; }
  .page:last-child { break-after: auto; page-break-after: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .visual-trigger::after, .lightbox { display: none; }
  .project-visual img { transform: none; transition: none; }
  .section-block, .project, .mini-project-list article, .achievement-list li {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}

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

@media screen and (max-width: 900px) {
  .screen-toolbar { top: 6px; width: calc(100vw - 20px); margin-top: 10px; }
  .screen-toolbar > strong { display: none; }
  .toolbar-actions { width: 100%; justify-content: space-between; }
  .page { width: calc(100vw - 20px); min-height: auto; padding: 28px 24px 50px; }
  .page-one, .page-two, .page-three { gap: 34px; }
  .hero, .summary, .company-row, .bottom-grid { grid-template-columns: 1fr; }
  .contact {
    grid-template-columns: minmax(0, max-content) 18mm;
    width: 100%;
    min-width: 0;
    justify-content: start;
    justify-items: start;
    text-align: left;
  }
  .resume-qr { justify-self: start; justify-items: start; }
  .two-column-list { columns: 1; }
  .project-body { grid-template-columns: 1fr; }
  .mini-project-list article { grid-template-columns: 1fr; gap: 0; }
  .mini-project-list article > p:last-child { grid-column: 1; grid-row: auto; margin-top: 8px; }
  .page-footer { right: 24px; bottom: 16px; left: 24px; }
  .lightbox-figure { padding: 60px 12px 92px; }
  .lightbox-image { width: min(calc(100vw - 24px), calc((100dvh - 230px) * 16 / 9)); }
  .lightbox-nav { top: auto; bottom: 24px; transform: none; }
  .lightbox-nav:hover { transform: none; }
  .lightbox-prev { left: calc(50% - 56px); }
  .lightbox-next { right: calc(50% - 56px); }
}

/* Compact portrait media keeps the additional work on the third A4 page. */
.mini-project-list .media-project {
  grid-template-columns: 52mm minmax(0, 1fr);
  gap: 6mm;
  align-items: center;
  padding: 4mm 0;
}
.project-media { display: flex; justify-content: center; align-items: start; gap: 2mm; min-width: 0; }
.project-media .project-visual { flex: 1; min-width: 0; max-width: 29mm; }
.project-media .visual-trigger { aspect-ratio: auto; height: 40mm; border: 0; background: transparent; }
.project-media img { object-fit: contain; }
.project-media figcaption { text-align: center; font-size: 6.5pt; }
.mini-project-copy > p:not(.project-meta) { margin-top: 2mm; font-size: 8.5pt; line-height: 1.5; }
.video-link, .official-app-link { display: inline-block; margin-top: 2mm; color: var(--accent-deep); font-size: 8pt; text-underline-offset: 3px; }
.video-link:focus-visible, .official-app-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.mini-project-list .text-project { grid-template-columns: 1fr; }
.page-three { gap: 5mm; }
.page-three .bottom-grid { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 7mm; margin-top: 0; padding-top: 4mm; }
.page-three .skills { gap: 2.5mm; }
.lightbox-image { width: auto; max-width: calc(100vw - 168px); height: auto; max-height: calc(100dvh - 170px); aspect-ratio: auto; }
html:has(.video-dialog[open]) { overflow: hidden; }
.video-dialog { width: min(720px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 16px; border: 0; border-radius: 8px; background: #161618; color: white; }
.video-dialog::backdrop { background: rgb(0 0 0 / 85%); }
.video-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.video-heading button { cursor: pointer; padding: 8px 12px; flex-shrink: 0; white-space: nowrap; }
.video-dialog video { display: block; width: 100%; height: min(65dvh, 800px); background: black; }
.video-controls { display: grid; grid-template-columns: auto minmax(60px, 1fr) auto auto 70px; align-items: center; gap: 10px; margin-top: 12px; }
.video-controls button { padding: 8px 10px; cursor: pointer; }
.video-dialog .video-icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  color: #f5f5f7;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  transition: background-color 180ms ease, transform 180ms ease;
}
.video-dialog .video-icon-button:hover { background: rgba(255, 255, 255, 0.22); }
.video-dialog .video-icon-button:active { transform: scale(0.94); }
.video-dialog .video-icon-button:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 3px; }
.video-icon-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.video-play-icon { fill: currentColor; stroke: none; }
.video-pause-icon { display: none; stroke-width: 3; }
.is-playing .video-play-icon { display: none; }
.is-playing .video-pause-icon { display: block; }
.video-muted-icon { display: none; }
.is-muted .video-sound-icon { display: none; }
.is-muted .video-muted-icon { display: block; }
.video-controls input { width: 100%; min-width: 0; accent-color: var(--accent-bright); cursor: pointer; }
.video-controls output { font-size: 12px; font-variant-numeric: tabular-nums; }
.video-status { margin-top: 8px; font-size: 12px; }
@media (max-width: 520px) {
  .video-controls { grid-template-columns: auto minmax(60px, 1fr) auto; }
  .video-controls [data-video-volume] { max-width: 120px; }
}
@media screen and (max-width: 900px) {
  .mini-project-list .media-project { grid-template-columns: 1fr; gap: 16px; padding: 24px 0; }
  .project-media { gap: 12px; }
  .project-media .project-visual { max-width: 160px; }
  .project-media .visual-trigger { height: 260px; }
  .project-media figcaption { font-size: 11px; }
  .page-three .bottom-grid { grid-template-columns: 1fr; gap: 24px; }
  .lightbox-image { max-width: calc(100vw - 24px); max-height: calc(100dvh - 230px); }
}
@media print {
  .video-dialog { display: none; }
  .video-link { color: var(--ink); }
  html[lang="en"] .page-one { gap: 4mm; }
  html[lang="en"] .page-one .hero { padding-bottom: 5mm; }
}
.project-intro { margin-top: 3mm; color: var(--muted); font-size: 8pt; line-height: 1.5; }
