:root {
  --profile-ink: #1f2522;
  --profile-muted: #737a75;
  --profile-line: #e6e8e5;
  --profile-soft: #f5f6f3;
  --profile-radius: 18px;
}

button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
[hidden] { display: none !important; }

.profile-hero {
  padding: clamp(44px, 7vw, 92px) 0 clamp(30px, 5vw, 62px);
}

.profile-kicker {
  margin: 0 0 8px;
  color: var(--profile-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .18em;
}

.profile-hero h1 {
  margin: 0;
  color: var(--profile-ink);
  font-size: clamp(38px, 7vw, 82px);
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -.035em;
}

.profile-sub {
  display: flex;
  align-items: center;
  gap: .42em;
  margin: 14px 0 0;
  color: var(--profile-muted);
  font-size: 14px;
  line-height: 1.4;
}

.profile-sub > span {
  display: inline-flex;
  align-items: center;
  min-height: 1.4em;
}

.profile-sub-sex {
  font-family: Arial, sans-serif;
  font-size: .96em;
  line-height: 1;
}

/* Top gallery: no track, transform or animation. */
.top-gallery { max-width: 1040px; margin: 0 auto clamp(72px, 11vw, 132px); }
.top-stage {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: var(--profile-radius);
  background: var(--profile-soft);
  cursor: zoom-in;
}

.top-stage img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: var(--profile-radius);
}

.top-thumbs {
  display: flex;
  justify-content: center;
  gap: 9px;
  margin-top: 12px;
  padding: 2px 1px 8px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  touch-action: pan-x;
}

.top-thumb {
  flex: 0 0 clamp(58px, 7vw, 80px);
  aspect-ratio: 4 / 5;
  padding: 2px;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 9px;
  background: transparent;
  cursor: pointer;
  scroll-snap-align: center;
}

.top-thumb.is-active { border-color: var(--profile-ink); }
.top-thumb:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
.top-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 7px;
  object-fit: cover;
  background: var(--profile-soft);
}

.photo-section,
.profile-section {
  padding: clamp(50px, 8vw, 96px) 0;
  border-top: 1px solid var(--profile-line);
}

.photo-head,
.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}

.photo-head h2,
.section-head h2 {
  margin: 0;
  color: var(--profile-ink);
  font-size: clamp(25px, 3.3vw, 40px);
  font-weight: 500;
  letter-spacing: -.025em;
}

.photo-count {
  min-width: 34px;
  padding: 6px 9px;
  border: 1px solid var(--profile-line);
  border-radius: 999px;
  color: var(--profile-muted);
  font-size: 12px;
  text-align: center;
}

.photo-layout {
  display: block;
}

.photo-representative,
.photo-tile {
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 14px;
  background: var(--profile-soft);
  cursor: zoom-in;
}

.photo-representative {
  grid-column: span 2;
}
.photo-representative img,
.photo-tile img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 14px;
  object-fit: contain;
}
.photo-representative.is-face img,
.photo-tile.is-face img { object-position: 50% 28%; }

/* 代表写真を大きくし、残りを右側と下へ隙間なく詰める。 */
.photo-masonry {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: 8px;
  grid-auto-flow: dense;
  gap: clamp(10px, 1.5vw, 18px);
}
.photo-tile {
  margin: 0;
  align-self: start;
}

.photo-more {
  display: block;
  min-width: 148px;
  margin: 26px auto 0;
  padding: 11px 22px;
  border: 1px solid var(--profile-ink);
  border-radius: 999px;
  background: transparent;
  color: var(--profile-ink);
  cursor: pointer;
}

.section-link,
.back-area a { color: var(--profile-ink); text-underline-offset: 4px; }
.content-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
.magazine-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.story-card,
.magazine-card {
  overflow: hidden;
  border: 1px solid var(--profile-line);
  border-radius: 14px;
  color: inherit;
  text-decoration: none;
}

/* Timeline is a compact horizontal band, not a full gallery section. */
.timeline-band {
  margin: 0;
  padding: 28px clamp(16px, 3vw, 34px);
  border: 1px solid var(--profile-line);
  border-radius: var(--profile-radius);
  background: var(--profile-soft);
}

.timeline-band .section-head {
  margin-bottom: 14px;
}

.timeline-band .section-head h2 {
  font-size: clamp(20px, 2.4vw, 28px);
}

.timeline-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  max-height: 116px;
  gap: 12px;
  padding-right: 6px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-block: contain;
  scrollbar-width: thin;
}

.timeline-grid .story-card {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  min-width: 0;
  min-height: 92px;
  background: #fff;
}

.timeline-grid .card-visual {
  height: 100%;
  aspect-ratio: auto;
}

.timeline-grid .card-body {
  align-self: center;
  padding: 11px 13px;
}

.timeline-grid .card-body p {
  display: none;
}

.card-visual { aspect-ratio: 16 / 10; overflow: hidden; background: var(--profile-soft); }
.magazine-card .card-visual { aspect-ratio: 3 / 4; }
.card-visual img { width: 100%; height: 100%; border-radius: 14px; object-fit: cover; }
.card-fallback { display: grid; height: 100%; place-items: center; color: var(--profile-muted); font-size: 11px; letter-spacing: .12em; }
.card-body { padding: 16px; }
.card-meta { display: block; margin-bottom: 8px; color: var(--profile-muted); font-size: 11px; }
.card-body strong { display: block; color: var(--profile-ink); line-height: 1.5; }
.card-body p { margin: 8px 0 0; color: var(--profile-muted); font-size: 13px; line-height: 1.7; }

.related-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.related-card {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--profile-line);
  border-radius: 14px;
  color: inherit;
  text-decoration: none;
}
.related-card img { width: 78px; height: 78px; border-radius: 10px; object-fit: cover; background: var(--profile-soft); }
.related-card strong,
.related-card span { display: block; }
.related-card span { margin-top: 4px; color: var(--profile-muted); font-size: 12px; }
.empty-message { grid-column: 1 / -1; color: var(--profile-muted); }
.back-area { margin: 24px 0 80px; }

.photo-modal {
  position: fixed;
  inset: 0;
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: #fff;
  color: var(--profile-ink);
}
.photo-modal::backdrop { background: #fff; }
.modal-scroll {
  width: 100%;
  height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scroll-behavior: auto !important;
}
.photo-modal figure {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 14px max(48px, env(safe-area-inset-right)) 0 max(48px, env(safe-area-inset-left));
  box-sizing: border-box;
}
.modal-image-frame {
  position: relative;
  display: grid;
  width: 100%;
  min-height: min(72dvh, 720px);
  height: auto;
  overflow: hidden;
  place-items: center;
  background: #f4f5f4;
  border-radius: 14px;
}

.modal-image-frame img {
  display: block;
  width: auto;
  height: auto;
  object-position: center;
  max-width: 100%;
  max-height: calc(100dvh - 170px);
  object-fit: contain;
  border-radius: 12px;
}

.modal-image-frame.is-landscape img {
  width: auto;
  height: auto;
}

.modal-image-frame.is-portrait img {
  width: auto;
  height: auto;
}

.modal-image-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #777d77;
  font-size: 11px;
  letter-spacing: .12em;
}

.modal-image-frame:not(.is-loading) .modal-image-loading {
  display: none;
}

.modal-image-frame:not(.is-loading) {
  min-height: 0;
}

.modal-image-frame.is-loading img {
  visibility: hidden;
}
.photo-modal figcaption { display: grid; gap: 5px; padding: 12px 52px 14px; text-align: center; }
.photo-modal figcaption > span { color: var(--profile-muted); font-size: 12px; }
.modal-tags { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; }
.modal-tags span { padding: 3px 8px; border: 1px solid var(--profile-line); border-radius: 999px; }
.modal-compare-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  margin: 10px auto 0;
  padding: 0 20px;
  border: 1px solid var(--profile-line);
  border-radius: 999px;
  color: var(--profile-ink);
  text-decoration: none;
  font-size: 11px;
  font-weight: 800;
}
.modal-close,
.modal-nav {
  position: fixed;
  z-index: 1;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--profile-ink);
  cursor: pointer;
}
.modal-close {
  top: max(8px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  font-size: 36px;
  line-height: 1;
}
.modal-nav { top: 50%; font-size: 54px; transform: translateY(-50%); }
.modal-prev { left: 20px; }
.modal-next { right: 20px; }
.modal-nav { display: none !important; }
.modal-open { overflow: hidden; }

.modal-related {
  padding: 20px clamp(16px, 4vw, 52px) 52px;
  border-top: 1px solid var(--profile-line);
}

.modal-related h3 {
  margin: 0 0 18px;
  color: var(--profile-ink);
  font-size: clamp(18px, 2.4vw, 26px);
  font-weight: 500;
}

.modal-related-grid {
  columns: 3;
  column-gap: 12px;
}

.modal-related-item {
  display: block;
  width: 100%;
  margin: 0 0 12px;
  padding: 0;
  overflow: hidden;
  break-inside: avoid;
  border: 0;
  border-radius: 12px;
  background: var(--profile-soft);
  cursor: zoom-in;
}

.modal-related-item img {
  display: block;
  width: 100%;
  height: auto;
}

@media (hover: hover) and (pointer: fine) {
  .photo-more:hover { background: var(--profile-ink); color: #fff; }
  .story-card:hover,
  .magazine-card:hover,
  .related-card:hover { border-color: #b9beba; }
}

@media (max-width: 900px) {
  .content-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .magazine-grid,
  .related-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .timeline-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .profile-hero { padding-top: 34px; }
  .top-gallery { margin-bottom: 70px; }
  .top-stage { aspect-ratio: 4 / 5; border-radius: 12px; }
  .top-thumbs {
    justify-content: flex-start;
    gap: 7px;
    overflow-x: hidden;
  }
  .top-thumb {
    flex: 0 0 calc((100% - 28px) / 5);
    max-width: none;
  }

  .top-thumb img {
    object-fit: cover;
  }
  .photo-section,
  .profile-section { padding: 56px 0; }
  .timeline-band {
    padding: 20px 16px;
  }
  .timeline-grid {
    grid-template-columns: 1fr;
    max-height: 220px;
  }
  .photo-head,
  .section-head { margin-bottom: 20px; }
  .photo-layout { display: block; }
  .photo-masonry {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .photo-representative {
    grid-column: 1 / -1;
  }
  .content-grid,
  .magazine-grid { grid-template-columns: 1fr; }
  .related-grid { grid-template-columns: 1fr; }
  .photo-modal figcaption { padding-inline: 10px; }
  .photo-modal figure {
    padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left));
  }
  .modal-image-frame {
    min-height: 64dvh;
  }
  .modal-image-frame:not(.is-loading) {
    min-height: 0;
  }
  .modal-image-frame img {
    max-height: calc(100dvh - 135px);
  }
  .modal-related {
    padding: 16px 10px 42px;
  }
  .modal-related-grid {
    columns: 2;
    column-gap: 8px;
  }
  .modal-related-item {
    margin-bottom: 8px;
    border-radius: 9px;
  }
}
