html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  position: fixed;
  inset: 0;
  min-height: 0;
}

.site-shell {
  display: grid;
  grid-template-rows: 86px minmax(0, 1fr) 52px;
  height: 100vh;
  height: 100svh;
  height: 100dvh;
  padding:
    env(safe-area-inset-top, 0px)
    env(safe-area-inset-right, 0px)
    env(safe-area-inset-bottom, 0px)
    env(safe-area-inset-left, 0px);
}

.site-header, footer { min-height: 0; height: auto; }

.profile {
  min-height: 0;
  height: 100%;
  padding: clamp(18px, 3.4vh, 42px) 0;
  overflow: hidden;
}

.photo-stage, .profile-copy { min-height: 0; }

.photo-stage {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
}

.photo-frame {
  width: auto;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  aspect-ratio: 3 / 4;
}

.profile-copy {
  max-height: 100%;
  overflow: hidden;
}

@media (min-width: 861px) and (max-height: 850px) {
  .profile { gap: clamp(38px, 5vw, 72px); padding: 18px 0 20px; }
  .overline { margin-bottom: 10px; }
  .intro h1 { font-size: clamp(3.5rem, 8.3vh, 5.25rem); }
  .identity-line { margin-top: 14px; font-size: 1rem; }
  .bio { margin-top: 8px; font-size: 0.74rem; line-height: 1.45; }
  .links { margin-top: 17px; }
  .social-link { min-height: 46px; }
  .music-card { margin-top: 15px; }
  .cute-kicker { margin-bottom: 7px; }
  .cute-player .turntable { grid-template-columns: 82px minmax(0, 1fr); }
  .cute-player .record-deck { width: 82px; height: 82px; }
  .cute-player .record-button { top: 7px; left: 7px; width: 68px; height: 68px; }
  .cute-player .tonearm { top: -3px; right: -6px; transform: rotate(-27deg) scale(0.68); }
  .music-playing .cute-player .tonearm { transform: rotate(19deg) scale(0.68); }
  .seek-control { margin-top: 5px; }
  .volume-control { margin-top: 7px; padding-top: 6px; }
  .autoplay-note { margin-top: 5px; }
}

@media (max-width: 860px) {
  .site-shell {
    width: min(100% - 20px, 680px);
    grid-template-rows: 56px minmax(0, 1fr);
  }

  .site-header { height: 56px; }
  footer { display: none; }

  .profile {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 35%) minmax(0, 65%);
    gap: 9px;
    padding: 9px 0 8px;
  }

  .photo-stage {
    width: 100%;
    height: 100%;
    grid-template-rows: minmax(0, 1fr);
  }

  .photo-frame {
    width: auto;
    max-width: 100%;
    height: 100%;
    margin: 0 auto;
  }

  .image-caption { display: none; }

  .profile-copy {
    display: flex;
    width: min(100%, 560px);
    height: 100%;
    margin: 0 auto;
    flex-direction: column;
  }

  .overline { display: none; }

  .intro {
    width: 100%;
    padding: 2px 8px 0;
    text-align: center;
  }

  .intro h1 {
    margin-inline: auto;
    font-size: clamp(2.65rem, 11.6vw, 3.7rem);
    line-height: 0.9;
    letter-spacing: -0.065em;
  }

  .intro h1 em { display: inline-block; }

  .identity-line {
    display: flex;
    margin-top: 9px;
    align-items: center;
    justify-content: center;
    gap: 0.3em;
    font-size: 0.95rem;
  }

  .word-window {
    min-width: 0;
    text-align: left;
  }

  .bio {
    display: -webkit-box;
    overflow: hidden;
    max-width: 42ch;
    margin: 6px auto 0;
    font-size: 0.78rem;
    line-height: 1.45;
    text-align: center;
    text-overflow: ellipsis;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .links {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
    margin-top: 8px;
    border-top: 0;
  }

  .links.social-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .social-link {
    display: flex;
    min-height: 34px;
    padding: 0 5px;
    border: 1px solid var(--line);
    border-radius: 8px;
    justify-content: center;
  }

  .social-link::before { border-radius: 7px; }
  .social-link:hover { padding: 0 5px; }
  .link-index, .link-note, .link-arrow { display: none; }
  .link-name { font-size: 0.62rem; text-align: center; }

  .cute-player {
    min-height: 0;
    margin-top: 7px;
    padding: 7px 9px 8px;
  }

  .cute-kicker { display: none; }
  .cute-player .turntable { grid-template-columns: 70px minmax(0, 1fr); gap: 9px; }
  .cute-player .record-deck { width: 70px; height: 70px; }
  .cute-player .record-button { top: 6px; left: 6px; width: 58px; height: 58px; }
  .cute-player .record-label { width: 25px; height: 25px; }
  .cute-player .record-label b { top: 5px; font-size: 0.28rem; }
  .cute-player .record-label small { bottom: 4px; font-size: 0.14rem; }
  .cute-player .tonearm { top: -9px; right: -10px; transform: rotate(-27deg) scale(0.57); }
  .music-playing .cute-player .tonearm { transform: rotate(19deg) scale(0.57); }
  .track-topline p { font-size: 0.5rem; }
  .track-copy h2 { margin-top: 4px; font-size: 1rem; }
  .track-artist { font-size: 0.58rem; }
  .cute-player .audio-timeline { margin-top: 8px; }
  .audio-meta { margin-top: 6px; font-size: 0.4rem; }
  .seek-control { margin-top: 4px; font-size: 0.48rem; }
  .volume-control { margin-top: 5px; padding-top: 4px; font-size: 0.48rem; }
  .autoplay-note { display: none; }
}

@media (max-width: 860px) and (min-height: 701px) {
  .seek-control input[type="range"],
  .volume-control input[type="range"] { height: 24px; }
  .seek-control input[type="range"]::-webkit-slider-thumb,
  .volume-control input[type="range"]::-webkit-slider-thumb {
    width: 15px;
    height: 15px;
    margin-top: -6px;
  }
  .seek-control input[type="range"]::-moz-range-thumb,
  .volume-control input[type="range"]::-moz-range-thumb {
    width: 13px;
    height: 13px;
  }
}

@media (max-width: 860px) and (max-height: 700px) and (orientation: portrait) {
  .site-shell { grid-template-rows: 48px minmax(0, 1fr); }
  .site-header { height: 48px; }
  .profile { grid-template-rows: minmax(0, 29%) minmax(0, 71%); gap: 7px; padding: 7px 0 6px; }
  .intro { padding-inline: 5px; }
  .intro h1 { font-size: clamp(2.35rem, 10.8vw, 3.05rem); line-height: 0.92; }
  .identity-line { margin-top: 7px; font-size: 0.86rem; }
  .bio { margin-top: 5px; font-size: 0.72rem; line-height: 1.4; }
  .links { margin-top: 8px; }
  .social-link { min-height: 30px; }
  .cute-player { margin-top: 5px; }
}

@media (max-width: 860px) and (orientation: landscape) {
  .site-shell { width: min(100% - 24px, 900px); grid-template-rows: 48px minmax(0, 1fr); }
  .site-header { height: 48px; }
  .profile {
    grid-template-columns: minmax(190px, 0.8fr) minmax(300px, 1.2fr);
    grid-template-rows: minmax(0, 1fr);
    gap: 22px;
    padding: 8px 0;
  }
  .intro h1 { font-size: clamp(2.2rem, 8.8vh, 3.5rem); }
  .bio { max-width: 42ch; }
  .links { margin-top: 7px; }
  .links.social-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cute-player { margin-top: 7px; }
}

/* Small phones in landscape need their own composition, not a squeezed portrait layout. */
@media (max-width: 860px) and (max-height: 400px) and (orientation: landscape) {
  .site-shell {
    width: min(100% - 18px, 900px);
    grid-template-rows: 44px minmax(0, 1fr);
  }

  .site-header { height: 44px; }
  .status { font-size: 0.48rem; }
  .share-button { width: 34px; height: 34px; }

  .profile {
    grid-template-columns: minmax(165px, 0.76fr) minmax(275px, 1.24fr);
    gap: 14px;
    padding: 4px 0;
  }

  .intro h1 { font-size: clamp(1.9rem, 11vh, 2.55rem); }
  .identity-line { display: none; }
  .bio { display: none; }

  .links.social-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
    margin-top: 4px;
  }

  .channels-head { display: none; }

  .social-grid .channel-card {
    grid-template-columns: 38px minmax(0, 1fr) auto;
    min-height: 48px;
    padding: 4px 7px 4px 5px;
    column-gap: 7px;
  }

  .social-grid .channel-card:hover { padding: 4px 7px 4px 5px; }

  .channel-icon {
    width: 36px;
    height: 36px;
    scale: 1;
  }

  .brand-icon { width: 20px; height: 20px; }
  .channel-handle,
  .channel-stat small { display: none; }
  .social-grid .link-name { font-size: 0.8rem; }
  .channel-stat strong { font-size: 0.7rem; }

  .cute-player {
    margin-top: 4px;
    padding: 5px 7px 6px;
  }

  .cute-player .turntable {
    grid-template-columns: 54px minmax(0, 1fr);
    gap: 7px;
  }

  .cute-player .record-deck { width: 54px; height: 54px; }
  .cute-player .record-button { top: 5px; left: 5px; width: 44px; height: 44px; }
  .cute-player .record-label { width: 19px; height: 19px; }
  .cute-player .record-label b { top: 3px; font-size: 0.22rem; }
  .cute-player .record-label small { display: none; }
  .cute-player .tonearm { top: -17px; right: -17px; transform: rotate(-27deg) scale(0.44); }
  .music-playing .cute-player .tonearm { transform: rotate(19deg) scale(0.44); }
  .track-copy h2 { margin-top: 2px; font-size: 0.7rem; }
  .track-artist { display: none; }
  .cute-player .audio-timeline { margin-top: 5px; }
  .audio-meta { margin-top: 3px; }
  .seek-control { margin-top: 2px; }
  .volume-control { margin-top: 2px; padding-top: 2px; }
}

/* Ultra-short landscape becomes a readable channel hub instead of shrinking everything. */
@media (max-width: 860px) and (max-height: 280px) and (orientation: landscape) {
  .site-shell {
    width: min(100% - 20px, 720px);
    grid-template-rows: minmax(0, 1fr);
  }

  .site-header,
  .photo-stage,
  .intro,
  .music-card { display: none; }

  .profile {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr);
    gap: 0;
    padding: 6px 0;
  }

  .profile-copy {
    width: min(100%, 680px);
    height: auto;
    justify-content: center;
  }

  .links.social-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 0;
  }

  .channels-head {
    display: flex;
    height: 24px;
    font-size: 0.62rem;
  }

  .social-grid .channel-card {
    grid-template-columns: 50px minmax(0, 1fr) auto;
    min-height: 64px;
    padding: 7px 10px 7px 7px;
    column-gap: 10px;
  }

  .social-grid .channel-card:hover { padding: 7px 10px 7px 7px; }

  .channel-icon {
    width: 46px;
    height: 46px;
    border-radius: 13px;
  }

  .brand-icon { width: 25px; height: 25px; }
  .channel-handle { display: block; font-size: 0.56rem; }
  .social-grid .link-name { font-size: 0.94rem; }
  .channel-stat strong { font-size: 0.8rem; }
}

/* desktop-photo-fit */
@media (min-width: 861px) {
  .photo-frame {
    width: min(100%, 520px, calc((100dvh - 198px) * 0.75));
    height: auto;
  }
}

/* short-desktop-full-bottom: keep the complete player and footer inside the viewport */
@media (min-width: 861px) and (max-height: 650px) {
  .site-shell { grid-template-rows: 64px minmax(0, 1fr) 36px; }
  .site-header { height: 64px; }
  .profile { gap: clamp(34px, 4vw, 56px); padding: 7px 0 8px; }
  .overline, .bio { display: none; }
  .intro h1 { font-size: clamp(2.75rem, 8.5vh, 3.35rem); }
  .identity-line { margin-top: 7px; font-size: 0.82rem; }
  .links { margin-top: 8px; }
  .social-link { min-height: 34px; }
  .link-name { font-size: 0.73rem; }
  .link-note { font-size: 0.43rem; }
  .cute-player { margin-top: 8px; padding: 9px 11px 8px; }
  .cute-kicker { display: none; }
  .cute-player .turntable { grid-template-columns: 70px minmax(0, 1fr); gap: 10px; }
  .cute-player .record-deck { width: 70px; height: 70px; }
  .cute-player .record-button { top: 6px; left: 6px; width: 58px; height: 58px; }
  .cute-player .record-label { width: 25px; height: 25px; }
  .cute-player .record-label b { top: 5px; font-size: 0.28rem; }
  .cute-player .record-label small { bottom: 4px; font-size: 0.14rem; }
  .cute-player .tonearm { top: -9px; right: -10px; transform: rotate(-27deg) scale(0.57); }
  .music-playing .cute-player .tonearm { transform: rotate(19deg) scale(0.57); }
  .track-topline p { font-size: 0.4rem; }
  .track-copy h2 { margin-top: 3px; font-size: 0.78rem; }
  .track-artist { font-size: 0.45rem; }
  .cute-player .audio-timeline { margin-top: 7px; }
  .audio-meta { margin-top: 5px; font-size: 0.33rem; }
  .seek-control { margin-top: 3px; }
  .volume-control { margin-top: 4px; padding-top: 4px; }
  .autoplay-note { display: none; }
  footer {
    min-height: 0;
    height: 36px;
    overflow: hidden;
    font-size: 0.42rem;
  }
  footer > span { white-space: nowrap; }
}
