:root {
  --held-responsive-page-gutter: clamp(10px, 2.4vw, 30px);
  --held-dock-clearance: calc(102px + env(safe-area-inset-bottom));
}

html,
body {
  width: 100%;
  max-width: 100%;
}

.held-responsive-page {
  width: 100%;
  max-width: none;
  min-width: 0;
  margin-inline: auto;
}

.held-responsive-page :where(img, video, svg),
.held-app-shell :where(img, video, svg) {
  max-width: 100%;
}

/* A device viewport is the app window. The document never becomes a loose
   sketchbook sheet; scrolling belongs to the content surface inside it. */
body.held-app-shell {
  width: 100%;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  overscroll-behavior: none;
}

body.held-fixed-shell {
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

body.held-fixed-shell > .phone {
  width: 100%;
  max-width: none;
  height: 100dvh;
  min-height: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

body.held-fixed-shell > .phone > .stage {
  min-width: 0;
  min-height: 0;
}

body.held-fixed-shell > .phone .screen {
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}

/* HELDOS: the browser chrome is the frame. Only its book area scrolls. */
body.held-miniroom-shell {
  height: 100dvh;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  background: #eaf0f4;
}

body.held-miniroom-shell > .sparkle {
  display: none;
}

body.held-miniroom-shell > .browser {
  display: flex;
  width: 100%;
  max-width: none;
  height: 100dvh;
  min-height: 0;
  flex-direction: column;
  margin: 0;
  border-right: 0;
  border-bottom: 0;
  border-left: 0;
  border-radius: 0;
  box-shadow: none;
}

body.held-miniroom-shell .browser-bar {
  flex: 0 0 auto;
  padding-top: max(9px, env(safe-area-inset-top));
}

body.held-miniroom-shell .book-zone {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: clamp(10px, 2.2vw, 24px) clamp(8px, 2.4vw, 28px) var(--held-dock-clearance);
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}

body.held-miniroom-shell .book {
  width: min(calc(100% - 42px), 980px);
  margin-right: auto;
  margin-left: auto;
}

body.held-miniroom-shell .shop {
  max-width: min(680px, 100%);
}

/* On phones the HELDOS browser remains visible, while the paper inside it
   becomes the app canvas. The preserved binder styling must not subtract
   another 80px from an already narrow viewport. */
@media (max-width: 640px) {
  body.held-miniroom-shell .browser-bar {
    min-height: 46px;
    padding: max(8px, env(safe-area-inset-top)) 10px 8px;
  }

  body.held-miniroom-shell .browser-bar .tl,
  body.held-miniroom-shell .browser-bar .win-ico {
    display: flex;
    flex: 0 0 auto;
  }

  body.held-miniroom-shell .browser-bar .win-ico {
    font-size: 9px;
    letter-spacing: 1px;
  }

  body.held-miniroom-shell .addr {
    min-height: 34px;
    padding: 7px 11px;
    font-size: 12px;
  }

  body.held-miniroom-shell .book-zone {
    padding: 0 0 calc(66px + env(safe-area-inset-bottom));
  }

  body.held-miniroom-shell .book {
    width: 100%;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  body.held-miniroom-shell .book-in {
    margin: 0;
    padding-left: 0;
    border-radius: 0;
  }

  body.held-miniroom-shell .rings {
    display: none;
  }

  body.held-miniroom-shell .side-tabs {
    position: fixed;
    z-index: 80;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    width: 100%;
    max-width: none;
    min-height: 58px;
    align-items: stretch;
    gap: 4px;
    padding: 6px 7px max(7px, env(safe-area-inset-bottom));
    overflow-x: auto;
    flex-direction: row;
    background: rgba(237, 243, 248, .96);
    border-top: 1px solid #a8b0c8;
    box-shadow: 0 -8px 24px rgba(74, 83, 120, .16);
    scrollbar-width: none;
    backdrop-filter: blur(16px);
  }

  body.held-miniroom-shell .side-tabs::-webkit-scrollbar {
    display: none;
  }

  body.held-miniroom-shell .side-tabs > #customTabs {
    display: contents;
  }

  body.held-miniroom-shell .stab {
    display: grid;
    min-width: 52px;
    min-height: 46px;
    flex: 1 0 52px;
    place-items: center;
    margin: 0;
    padding: 5px 7px;
    border: 1px solid #9fb4c6;
    border-radius: 12px;
    font-size: 12px;
    line-height: 1.15;
  }

  body.held-miniroom-shell .stab.on {
    transform: none;
  }

  body.held-miniroom-shell .mh-top {
    gap: 7px;
    padding: 11px 10px;
  }

  body.held-miniroom-shell .today,
  body.held-miniroom-shell .mh-url {
    font-size: 11px;
  }

  body.held-miniroom-shell .mh-title {
    font-size: 15px;
  }

  body.held-miniroom-shell .room-tabs,
  body.held-miniroom-shell .sec-top,
  body.held-miniroom-shell .mini-btn,
  body.held-miniroom-shell .gb-input input,
  body.held-miniroom-shell .gb-input button {
    font-size: 12px;
  }

  body.held-miniroom-shell :where(button, input, textarea, select, .mini-btn) {
    min-height: 44px;
  }

  body.held-miniroom-shell :where(p, li, blockquote) {
    font-size: max(13px, 1em);
  }

  body.held-miniroom-shell small {
    font-size: max(11px, .82em);
  }
}

/* Portal-style pages fill phones/tablets; desktop content receives a quiet
   readable measure without reviving the 390px device mockup. */
body.held-wide-shell {
  display: block;
  min-height: 100dvh;
  padding: 0;
  background: var(--paper, var(--bg, #f6f9fb));
}

body.held-wide-shell > :is(.phone, .app) {
  width: 100%;
  max-width: 1100px;
  min-height: 100dvh;
  margin: 0 auto;
  padding-bottom: var(--held-dock-clearance);
  border-right: 0;
  border-left: 0;
}

/* Mockup roots used by the live routes. The viewport scrolls through one
   continuous app canvas, instead of a rounded phone floating in a grey mat. */
body.held-dev-shell {
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  background: var(--bg, #f3f8fa);
}

body.held-dev-shell > .stage {
  display: block;
  width: 100%;
  height: 100dvh;
  min-height: 0;
  padding: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}

body.held-dev-shell .dev,
body.held-dev-shell .dev.pc {
  width: 100%;
  max-width: 1100px;
  min-height: 100dvh;
  margin: 0 auto;
  padding-bottom: var(--held-dock-clearance);
  border-radius: 0;
  box-shadow: none;
}

/* First-page static fallback follows the same device-native rule. */
body.held-home-shell {
  height: 100dvh;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  background: #fdfcf8;
}

body.held-home-shell > .held-responsive-page {
  width: 100%;
  max-width: none;
  height: 100dvh;
  min-height: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

body.held-home-shell .screen {
  min-height: 0;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}

@media (min-width: 700px) {
  body.held-fixed-shell > .phone .screen {
    padding-right: var(--held-responsive-page-gutter);
    padding-left: var(--held-responsive-page-gutter);
  }

  body.held-miniroom-shell .book-in {
    padding-left: 28px;
  }

  body.held-wordroom-shell .l3-cols {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow: visible;
  }

  body.held-wordroom-shell .l3-col {
    min-width: 0;
  }

  body.held-wide-shell > :is(.phone, .app) {
    padding-right: clamp(18px, 3vw, 38px);
    padding-left: clamp(18px, 3vw, 38px);
  }
}

@media (min-width: 1024px) {
  body.held-miniroom-shell .book-zone {
    padding-right: 42px;
    padding-left: 42px;
  }

  body.held-fixed-shell > .phone .screen {
    padding-right: max(32px, calc((100vw - 1040px) / 2));
    padding-left: max(32px, calc((100vw - 1040px) / 2));
  }
}

@media (max-width: 699px) {
  body.held-miniroom-shell .browser-bar {
    min-height: 44px;
    padding: max(8px, env(safe-area-inset-top)) 12px 8px;
    background: var(--titlebar, #edf3f8);
  }

  body.held-miniroom-shell .browser-bar .addr > .dim {
    display: none;
  }

  body.held-miniroom-shell .browser-bar .tl {
    display: flex;
    flex: 0 0 auto;
    gap: 4px;
  }

  body.held-miniroom-shell .browser-bar .tl i {
    width: 11px;
    height: 11px;
  }

  body.held-miniroom-shell .browser-bar .win-ico {
    display: block;
    flex: 0 0 auto;
    font-size: 8px;
    letter-spacing: 1px;
  }

  body.held-miniroom-shell .browser-bar .addr {
    min-height: 28px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    padding: 4px 2px;
    font-size: 12px;
  }

  body.held-miniroom-shell .browser-bar .addr::before {
    content: "‹ 미니룸 · held://";
    color: var(--ink, #4a5378);
  }

  body.held-miniroom-shell .browser-bar .addr {
    font-size: 0;
  }

  body.held-miniroom-shell .browser-bar .addr b {
    color: var(--ink, #4a5378);
    font-size: 12px;
  }

  body.held-miniroom-shell .book-zone {
    padding: 0 0 calc(68px + env(safe-area-inset-bottom));
  }

  body.held-miniroom-shell .book {
    width: 100%;
    margin-right: 0;
    margin-left: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  body.held-miniroom-shell .book-in {
    margin: 0;
    padding-left: 0;
    border-radius: 0;
  }

  body.held-miniroom-shell .rings {
    display: none;
  }

  body.held-miniroom-shell .side-tabs {
    position: fixed;
    z-index: 30;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    width: 100%;
    min-height: calc(62px + env(safe-area-inset-bottom));
    padding: 5px 6px max(5px, env(safe-area-inset-bottom));
    flex-direction: row;
    align-items: stretch;
    gap: 2px;
    overflow-x: auto;
    background: rgba(237, 243, 248, .96);
    border-top: 1px solid var(--bd, #9fb4c6);
    box-shadow: 0 -6px 18px rgba(74, 83, 120, .14);
  }

  body.held-miniroom-shell .side-tabs .stab {
    display: grid;
    min-width: 54px;
    min-height: 50px;
    padding: 5px 4px;
    place-items: center;
    border: 0;
    border-radius: 10px;
    box-shadow: none;
    font-size: 12px;
    line-height: 1.2;
  }

  body.held-miniroom-shell .side-tabs .stab.on {
    transform: none;
  }

  body.held-miniroom-shell .iso-room {
    width: calc(100% - 16px);
    height: clamp(300px, 70vw, 430px);
    margin: 8px auto 0;
  }

  body.held-miniroom-shell .mh-top,
  body.held-miniroom-shell .profile,
  body.held-miniroom-shell .news,
  body.held-miniroom-shell .room-tabs,
  body.held-miniroom-shell .mr-menu,
  body.held-miniroom-shell .sec-in,
  body.held-miniroom-shell .sec-top {
    font-size: max(11px, 1em);
  }

  body.held-miniroom-shell :where(button, input, textarea, select, .mini-btn, .visit-btn, .stab) {
    min-height: 44px;
  }

  body.held-wide-shell > :is(.phone, .app) {
    padding-right: 0;
    padding-left: 0;
  }
}

/* Final HELDOS device contract: phone/tablet uses the whole screen. Browser
   chrome is optional, but the Cyworld-style side tabs stay visible. */

@media (max-width: 1024px) {
  body.held-miniroom-shell .browser-bar {
    display: none;
  }

  body.held-miniroom-shell.held-chrome-visible .browser-bar {
    display: flex;
    min-height: 46px;
    padding: max(8px, env(safe-area-inset-top)) 12px 8px;
  }

  body.held-miniroom-shell.held-chrome-visible .browser-bar .tl {
    display: flex;
  }

  body.held-miniroom-shell.held-chrome-visible .browser-bar .win-ico {
    display: block;
  }

  body.held-miniroom-shell.held-chrome-visible .browser-bar .addr {
    min-height: 34px;
    padding: 6px 11px;
    border: 1px solid var(--bd, #9fb4c6);
    border-radius: 999px;
    background: linear-gradient(180deg, #fff, #edf2f8);
    box-shadow: inset 0 1px 3px rgba(74, 83, 120, .18);
    font-size: 10px;
  }

  body.held-miniroom-shell.held-chrome-visible .browser-bar .addr::before {
    content: none;
  }

  body.held-miniroom-shell.held-chrome-visible .browser-bar .addr > .dim {
    display: inline;
  }

  body.held-miniroom-shell .book-zone {
    padding: 0 34px calc(30px + env(safe-area-inset-bottom)) 0;
  }

  body.held-miniroom-shell .book {
    width: 100%;
    max-width: none;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  body.held-miniroom-shell .book-in {
    margin: 0;
    padding-left: 0;
    border-radius: 0;
  }

  body.held-miniroom-shell .rings {
    display: none;
  }

  body.held-miniroom-shell .side-tabs {
    position: absolute;
    z-index: 80;
    top: 64px;
    right: 0;
    bottom: auto;
    left: auto;
    display: flex;
    width: 36px;
    min-height: 0;
    padding: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 3px;
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
    opacity: 1;
    visibility: visible;
    transform: none;
    pointer-events: auto;
    backdrop-filter: none;
  }

  body.held-miniroom-shell .side-tabs > #customTabs {
    display: flex;
    flex-direction: column;
    gap: 3px;
  }

  body.held-miniroom-shell .side-tabs .stab {
    display: block;
    min-width: 0;
    min-height: 44px;
    flex: 0 0 auto;
    margin: 0;
    padding: 7px 1px;
    border: 2px solid var(--bd, #9fb4c6);
    border-left: 0;
    border-radius: 0 7px 7px 0;
    background: rgba(111, 151, 183, .92);
    color: #fff;
    box-shadow: 0 2px 5px rgba(74, 83, 120, .2);
    font-size: 9px;
    line-height: 1.12;
    cursor: pointer;
  }

  body.held-miniroom-shell .side-tabs .stab.on {
    background: #fff;
    color: var(--ink, #4a5378);
    transform: translateX(2px);
  }

  body.held-miniroom-shell.held-side-tabs-classic .book-zone {
    padding-right: 44px;
  }

  body.held-miniroom-shell.held-side-tabs-classic .side-tabs {
    width: 42px;
    gap: 5px;
  }

  body.held-miniroom-shell.held-side-tabs-classic .side-tabs > #customTabs {
    gap: 5px;
  }

  body.held-miniroom-shell.held-side-tabs-classic .side-tabs .stab {
    padding: 8px 2px;
    border-radius: 0 8px 8px 0;
    font-size: 10px;
    line-height: 1.2;
  }

  body.held-miniroom-shell.held-miniroom-font-large .book :where(p, li, blockquote, .hint, .sn, .gb-row, input, textarea, select),
  body.held-miniroom-shell.held-miniroom-font-large .sec-top,
  body.held-miniroom-shell.held-miniroom-font-large .mini-btn {
    font-size: 14px !important;
  }

  body.held-miniroom-shell.held-miniroom-font-xlarge .book :where(p, li, blockquote, .hint, .sn, .gb-row, input, textarea, select),
  body.held-miniroom-shell.held-miniroom-font-xlarge .sec-top,
  body.held-miniroom-shell.held-miniroom-font-xlarge .mini-btn {
    font-size: 16px !important;
  }
}
