/* Small-screen journey: artwork first, then deliberately chosen actions.
   Hotspots enter document flow so rotating or enlarging text cannot overlap them. */
@media (max-width: 1024px) and (orientation: portrait), (max-width: 1100px) and (max-height: 600px) {
  :root { --edge: 20px; --top-space: calc(122px + env(safe-area-inset-top, 0px)); --bottom-space: calc(76px + env(safe-area-inset-bottom, 0px)); }
  html { -webkit-text-size-adjust: 100%; }
  body { overflow: hidden; }
  .site-header { padding: calc(10px + env(safe-area-inset-top, 0px)) max(var(--edge), env(safe-area-inset-right, 0px)) 8px max(var(--edge), env(safe-area-inset-left, 0px)); gap: 10px; }
  .site-header .brand { gap: 7px; flex-shrink: 0; }
  .site-header .brand img { width: 22px; height: 28px; }
  .site-header .brand span { font-size: .8rem; letter-spacing: .06em; }
  .site-header .header-end { gap: 12px; padding: 0 10px; }
  .site-header .overview-return, .site-header .menu-trigger { min-height: 44px; font-size: .875rem; }
  .site-header .menu-lines { display: none; }
  .development-note { top: calc(68px + env(safe-area-inset-top, 0px)); left: max(var(--edge), env(safe-area-inset-left, 0px)); max-width: calc(100% - 2 * var(--edge)); font-size: .75rem; line-height: 1.5; }
  #scene, body[data-scene="legacy"] #scene { height: 100vh; height: 100dvh; padding: var(--top-space) max(var(--edge), env(safe-area-inset-right, 0px)) var(--bottom-space) max(var(--edge), env(safe-area-inset-left, 0px)); overflow-y: auto; overflow-x: hidden; scroll-padding-block: var(--top-space) var(--bottom-space); overscroll-behavior-y: contain; }
  .scene-content, .scene-content.atmosphere, body[data-scene="street"] .scene-content { display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; min-height: 0; padding-bottom: 12px; gap: 18px; }
  .scene-content > * { min-width: 0; max-width: 100%; }
  .scene-content.atmosphere, body[data-scene="street"] .scene-content { padding-top: clamp(160px, 29svh, 330px); }
  .scene-content.atmosphere > .hotspot { order: 1; }
  .atmosphere-copy, .legacy-caption { order: 2; }
  .scene-content.atmosphere > .location-note, .scene-content.atmosphere > .room-label { order: 3; }
  .scene-step { order: 4; }
  .scene-intro { padding-top: clamp(100px, 20svh, 220px); padding-bottom: 0; }
  .scene-intro, .atmosphere-copy, .legacy-caption { width: 100%; max-width: 100%; margin: 0; padding: 24px; border: 1px solid #eed6a62b; border-radius: 8px; background: linear-gradient(140deg, #102e32ef, #102e32dc); backdrop-filter: blur(10px); }
  .scene-intro { margin-top: clamp(100px, 20svh, 220px); }
  body[data-scene="street"] .atmosphere-copy { margin: 0; max-width: 100%; background: #faf5eaed; border-color: #b4ac9366; }
  h1, .atmosphere-copy h1, body[data-scene="street"] .atmosphere-copy h1, body[data-scene="study"] .atmosphere-copy h1, body[data-scene="salon"] .atmosphere-copy h1, .legacy-caption h1 { font-size: clamp(2.3rem, 8vw, 3.6rem); max-width: 100%; line-height: 1.08; margin-bottom: 18px; }
  .eyebrow { margin-bottom: 14px; }
  .lead, .atmosphere-copy .lead, body[data-scene="street"] .atmosphere-copy .lead, .legacy-caption .lead { font-size: 1rem; line-height: 1.7; max-width: 100%; }
  .intro-footnote { opacity: .85; font-size: .875rem; }
  .atmosphere-copy { pointer-events: auto; }
  .hotspot, .hotspot.mobile-lift, .hotspot.hidden-spot { position: relative; inset: auto !important; align-self: flex-start; max-width: 100%; min-height: 48px; padding: 12px 16px; font-size: .875rem; white-space: normal; text-align: left; line-height: 1.5; background: #143a3eef; }
  .hotspot.featured { background: #faf2df; }
  .hotspot.hidden-spot .hotspot-label { max-width: none; overflow: visible; }
  .map-pin.dimmed { display: none; }
  .scene-step { position: static; display: block; margin: 0; text-align: left; }
  .scene-step .step-hint { display: block; max-width: none; margin: 0 0 10px; text-shadow: 0 1px 5px #071d23; font-size: .875rem; }
  body[data-scene="street"] .step-hint { color: var(--ink); text-shadow: none; background: #faf5eae8; padding: 8px 12px; border-radius: 4px; }
  .scene-step .button, .scene-intro .button, .legacy-caption .button { width: 100%; white-space: normal; }
  .button { min-height: 48px; font-size: .9375rem; gap: 16px; overflow-wrap: anywhere; }
  .location-note, body[data-scene="street"] .location-note, .room-label { position: static; width: 100%; max-width: none; margin: 0; padding: 18px; border-radius: 6px; background: #12353aeb; text-align: left; font-size: .9375rem; line-height: 1.7; }
  body[data-scene="street"] .location-note { background: #faf5eaf2; }
  .location-note strong { font-size: 1.5rem; }
  .room-label small, .location-note .over { opacity: 1; font-size: .75rem; }
  .shade, body[data-scene="interior"] .shade, body[data-scene="study"] .shade, body[data-scene="salon"] .shade { background: linear-gradient(180deg, #09262a55, transparent 28%, #09262a22 60%, #09262a88); }
  body[data-scene="street"] .backdrop > img { object-position: 60% 42%; }
  .journey-footer { padding: 8px max(var(--edge), env(safe-area-inset-right, 0px)) calc(8px + env(safe-area-inset-bottom, 0px)) max(var(--edge), env(safe-area-inset-left, 0px)); gap: 12px; background: #102e32f2; color: #fff9eb; border-top: 1px solid #eddab52b; backdrop-filter: blur(12px); }
  body.interface .journey-footer, body[data-scene="street"] .journey-footer { background: #f4efe4f5; color: var(--ink); }
  .journey-footer .quiet { min-height: 44px; opacity: 1; font-size: .875rem; }
  .chapter-mark { margin-left: auto; gap: 8px; min-width: 0; }
  .chapter-rule, .chapter-mark #chapter-label { display: none; }
  #chapter-number::after { content: ' / 10'; opacity: .7; }
  .view-controls { gap: 12px; }
  .view-controls #view-art { display: inline-block; }
  .view-controls #hide-controls { display: none; }
  #restore-controls { bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
  body.clean .development-note { opacity: 0; }
  .workspace, .book-detail-layout, .reader-layout, .patron-layout { width: 100%; margin: 0; min-width: 0; }
  .page-heading { display: block; }
  .page-heading h1, .book-detail h1, .patron-info h1 { font-size: clamp(2.3rem, 7vw, 3.5rem); }
  .search-box { width: 100%; min-width: 0; margin-top: 20px; }
  .search-box input { font-size: 1rem; }
  .catalog { grid-template-columns: 1fr; gap: 16px; }
  .catalog .book-card { display: grid; grid-template-columns: minmax(80px, 30%) minmax(0, 1fr); }
  .book-crop { height: 100%; min-height: 180px; }
  .book-meta { padding: 16px; }
  .book-meta p { font-size: .9375rem; }
  .book-meta .book-bottom { flex-wrap: wrap; font-size: .875rem; gap: 6px; }
  .catalog-footer { flex-direction: column; align-items: stretch; }
  .book-detail-layout, .reader-layout, .patron-layout { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .still-life { aspect-ratio: 1.6; max-height: 320px; }
  .edition-panel { min-height: 0; }
  .edition-tabs { flex-wrap: wrap; gap: 12px 20px; }
  .edition-tabs button, .reader-tools button, .text-link { min-height: 44px; font-size: .875rem; }
  .reader-toolbar { flex-wrap: wrap; align-items: center; }
  .reader-toolbar > span { max-width: none; font-size: .875rem; }
  .reader-tools button { min-width: 44px; }
  .reader-page { padding: 8px 28px 16px 0; }
  .reader-page h1 { font-size: 2.3rem; }
  .annotation-dot { right: -29px; }
  .annotation-dot::before { content: ''; position: absolute; inset: -16px; }
  .reader-end { flex-wrap: wrap; }
  .patron-portrait { min-height: 0; height: 300px; max-width: 420px; width: 100%; justify-self: center; }
  .portrait-signature { display: none; }
  .rank-identity { gap: 18px; }
  .rank-ring { width: 76px; height: 76px; }
  .contributions { gap: 12px; }
  .contributions span, .micro { font-size: .8125rem; line-height: 1.6; }
  .field-filter { flex-wrap: wrap; }
  .field-filter button { min-height: 44px; }
  .menu-dialog, .detail-dialog, .detail-dialog.wide, .detail-dialog.annotation-guide { width: calc(100% - 24px); max-width: 760px; max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 24px); padding: 24px 20px 0; overflow-y: auto; overscroll-behavior: contain; overflow-wrap: anywhere; border-radius: 10px; }
  .menu-dialog nav, .panel-split, .vision-grid, .annotation-spread, .transfer-conversation { grid-template-columns: minmax(0, 1fr); }
  .menu-dialog h2, .detail-dialog h2 { font-size: clamp(1.9rem, 6vw, 2.7rem); }
  .panel-actions { position: sticky; bottom: 0; z-index: 4; margin: 24px -4px 0; padding: 14px 4px max(16px, env(safe-area-inset-bottom, 0px)); gap: 10px; background: var(--paper); box-shadow: 0 -12px 18px var(--paper); }
  .panel-actions .button, .detail-dialog .panel-actions .button { margin: 0; min-height: 48px; font-size: .875rem; padding: 12px; gap: 10px; }
  .panel-actions .panel-back { min-width: 78px; }
  .panel-actions > .dark { max-width: none; min-width: 0; flex: 1; }
  .guide-steps { grid-template-columns: 1fr 1fr; }
  .guide-steps button { min-height: 48px; font-size: .875rem; }
  .guide-demonstration { padding: 12px; }
  .new-layer { padding-left: 0; padding-top: 16px; border-left: 0; border-top: 1px dashed #aebca4; }
  .panel-split > img { max-height: 250px; aspect-ratio: 1.6; }
  .record-list li { grid-template-columns: minmax(65px, 25%) minmax(0, 1fr); gap: 12px; }
  .art-dialog > img { height: calc(100% - 100px - env(safe-area-inset-bottom, 0px)); }
  .art-close { top: auto; right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); min-height: 44px; }
  .art-dialog > p { bottom: calc(10px + env(safe-area-inset-bottom, 0px)); left: 16px; right: 125px; text-align: left; font-size: .75rem; }
}

/* Short landscape: keep the art on the left and scroll content on the right. */
@media (max-width: 1100px) and (max-height: 600px) and (orientation: landscape) {
  :root { --edge: 24px; --top-space: calc(108px + env(safe-area-inset-top, 0px)); --bottom-space: calc(66px + env(safe-area-inset-bottom, 0px)); }
  .development-note { top: calc(62px + env(safe-area-inset-top, 0px)); }
  .scene-content.atmosphere, body[data-scene="street"] .scene-content { padding-top: 12px; padding-left: 43%; gap: 14px; }
  .scene-intro { width: 56%; margin: 12px 0 0 auto; padding: 22px; }
  .atmosphere-copy, .legacy-caption { padding: 22px; }
  h1, .atmosphere-copy h1, body[data-scene="street"] .atmosphere-copy h1, body[data-scene="study"] .atmosphere-copy h1, body[data-scene="salon"] .atmosphere-copy h1, .legacy-caption h1 { font-size: 2.5rem; }
  .backdrop > img { object-position: 40% 50%; }
  .journey-footer { padding-top: 4px; padding-bottom: calc(4px + env(safe-area-inset-bottom, 0px)); }
  .chapter-mark #chapter-label { display: inline; max-width: 220px; }
  .book-detail-layout, .patron-layout { grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); }
  .patron-portrait { height: 350px; }
  .catalog { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .catalog .book-card { grid-template-columns: 1fr; }
  .book-crop { height: 160px; min-height: 0; }
  .menu-dialog nav { grid-template-columns: 1fr 1fr; gap: 0 24px; }
  .menu-dialog, .detail-dialog, .detail-dialog.wide, .detail-dialog.annotation-guide { width: min(760px, 90%); }
  .art-dialog > img { height: calc(100% - 68px - env(safe-area-inset-bottom, 0px)); }
}
@media (max-width: 380px) and (orientation: portrait) {
  :root { --edge: 14px; }
  .site-header .brand span { display: none; }
  .scene-intro, .atmosphere-copy, .legacy-caption { padding: 20px; }
  .book-meta { padding: 12px; }
  .source-choices { grid-template-columns: 1fr; }
}
