/* Shared phone/tablet presentation. app-core owns all layout classes.
   Existing components, media and data remain mounted across layout changes.
   This replaces styles-tablet.css; desktop and authored HTML are not restyled. */
.mobile-creator-toggle, .library-touch-menu { display: none; }

html.is-mobile-layout, html body.is-mobile-layout {
  width: 100%; min-width: 0 !important; max-width: 100%; overflow-x: clip;
}
html body.is-mobile-layout {
  --tryva-sidebar-width: 220px;
  --mobile-gutter: clamp(16px, 3vw, 28px);
  --tryva-page-gutter: var(--mobile-gutter);
  --mobile-bottom: max(12px, env(safe-area-inset-bottom, 0px));
  --mobile-top: max(12px, env(safe-area-inset-top, 0px));
  --mobile-composer-height: 116px;
  --mobile-composer-bottom: var(--mobile-bottom);
  --mobile-insight-width: clamp(188px, 25vw, 296px);
  --mobile-play-edge: max(16px, env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
  --mobile-surface: #111018ed;
  --mobile-hairline: #ffffff1f;
  -webkit-text-size-adjust: 100%;
}
html body.is-mobile-layout .hidden { display: none !important; }
html body.is-mobile-layout :is(button, input, textarea, select) { touch-action: manipulation; }
html body.is-mobile-layout :is(button:not(.catalog-card-add):not(.tryva-unified-story-card-action), input:not([type=checkbox]):not([type=radio]):not([type=range]), select) {
  min-height: 44px;
}
html body.is-mobile-layout :is(input, textarea, select) { font-size: 16px; }
html body.is-mobile-layout :is(button, a, input, textarea, select):focus-visible {
  outline: 2px solid #d5b9ff; outline-offset: 3px;
}
html body.is-mobile-layout .app-shell {
  display: grid !important; grid-template-columns: 220px minmax(0, 1fr) !important;
  width: 100% !important; min-width: 0 !important; max-width: none !important;
  height: var(--tryva-app-height, 100dvh) !important; overflow: hidden;
}
html body.is-mobile-layout .workspace:not(:has(> :is(#catalogFlow,#libraryView):not(.hidden))) {
  width: 100% !important; min-width: 0 !important; max-width: none !important;
  height: 100% !important; overflow-x: hidden !important; overflow-y: auto !important;
}
html body.is-mobile-layout:not(.has-compact-navigation) .nav-shell {
  position: relative !important; inset: auto !important; width: 220px !important;
  min-width: 0 !important; height: 100% !important; transform: none !important;
  visibility: visible !important; pointer-events: auto !important;
}
html body.is-mobile-layout:not(.has-compact-navigation) :is(.mobile-nav-toggle, .mobile-nav-backdrop) { display: none !important; }
html body.has-compact-navigation .app-shell { display: block !important; }
html body.has-compact-navigation .nav-shell {
  display: flex !important; position: fixed !important; inset: 0 auto 0 0 !important;
  width: min(320px, 86vw) !important; min-width: 0 !important; max-width: 86vw !important;
  height: var(--tryva-app-height, 100dvh) !important; padding-top: var(--mobile-top);
  z-index: 1400 !important; overflow-y: auto; visibility: hidden;
  transform: translateX(-105%) !important; pointer-events: none !important;
}
html body.has-compact-navigation.mobile-nav-open .nav-shell {
  transform: none !important; visibility: visible !important; pointer-events: auto !important;
}
html body.has-compact-navigation .mobile-nav-toggle {
  display: grid !important; position: fixed; top: var(--mobile-top); left: 16px;
  width: 44px; height: 44px; z-index: 1402;
}
html body.has-compact-navigation:is(.detail-active,.story-asset-detail-active) .mobile-nav-toggle { display: none !important; }
html body.has-compact-navigation:is(.account-dialog-open,.modal-open) .mobile-nav-toggle { display: none !important; }
html body.has-compact-navigation .mobile-nav-backdrop {
  display: none !important; position: fixed; inset: 0; z-index: 1399;
  background: rgba(0,0,0,.55); backdrop-filter: blur(4px);
}
html body.has-compact-navigation.mobile-nav-open .mobile-nav-backdrop { display: block !important; }
html body.is-mobile-layout:not(.chat-active) .workspace:not(:has(> :is(#catalogFlow,#libraryView):not(.hidden))) > .view {
  min-width: 0 !important; max-width: 100% !important; box-sizing: border-box;
}
html body.has-compact-navigation:not(.chat-active) :is(.home-topbar, .explore-topbar, .library-header) {
  padding-top: calc(var(--mobile-top) + 52px) !important;
}

/* Recent conversations share the workspace scroller. The search field may
   wrap below the title, but cannot consume its entire row on landscape phones. */
html body.is-mobile-layout #recentConversationsView { height: auto; min-height: 100%; overflow: visible !important; }
html body.is-mobile-layout .recent-page-head { display: flex !important; flex-wrap: wrap; align-items: center; gap: 16px; padding: 0 0 20px !important; }
html body.is-mobile-layout .recent-page-head > div { flex: 1 1 240px; }
html body.is-mobile-layout .recent-page-head h1 { font-size: 28px; line-height: 1.2; }
html body.is-mobile-layout .recent-search { flex: 1 1 260px; width: auto !important; max-width: 390px !important; margin: 0; }

/* Play: the stage occupies the window, controls remain CSS-pixel sized. */
html body.is-mobile-layout.chat-active .app-shell { display: block !important; height: var(--mobile-stage-height, 100dvh) !important; }
html body.is-mobile-layout.chat-active :is(.nav-shell, .mobile-nav-toggle, .mobile-nav-backdrop, .fullscreen-header-reveal-zone) { display: none !important; }
html body.is-mobile-layout.chat-active .workspace:not(:has(> :is(#catalogFlow,#libraryView):not(.hidden))) { padding: 0 !important; overflow: hidden !important; }
html body.is-mobile-layout.chat-active #chatView {
  position: fixed !important; inset: var(--tryva-mobile-top, 0px) 0 auto !important;
  display: grid; grid-template-columns: minmax(0,1fr) var(--mobile-insight-width) !important; gap: 0 !important;
  grid-template-rows: minmax(0, 1fr) !important;
  width: 100% !important; height: var(--mobile-stage-height, 100dvh) !important;
  min-height: 0 !important; max-height: none !important; padding: 0 !important; overflow: hidden !important;
}
html body.is-mobile-layout.has-compact-insight.chat-active #chatView { grid-template-columns: minmax(0,1fr) !important; }
html body.is-mobile-layout.chat-active #chatView .chat-panel {
  position: relative !important; display: block !important; min-width: 0 !important;
  width: 100% !important; height: 100% !important; min-height: 0 !important;
  padding: 0 !important; border: 0 !important; border-radius: 0 !important; overflow: hidden !important;
}
html body.is-mobile-layout.chat-active #chatView .chat-header {
  position: absolute !important; inset: 0 0 auto !important; z-index: 1010 !important;
  display: flex !important; align-items: center; gap: 8px; width: 100% !important;
  min-height: 64px !important; height: auto !important;
  padding: var(--mobile-top) max(12px, env(safe-area-inset-right)) 12px max(12px, env(safe-area-inset-left)) !important;
  opacity: 1 !important; transform: none !important; visibility: visible !important; pointer-events: auto !important;
  border: 0 !important; background: none !important;
}
/* No bar behind the play controls: the scene runs to the top edge. Each control
   carries its own soft shadow instead, so it stays readable on a white sky. */
html body.is-mobile-layout.chat-active #chatView .chat-header :is(#chatRoomTitle, #statusText) {
  text-shadow: 0 0 2px rgba(0,0,0,.9), 0 1px 3px rgba(0,0,0,.55) !important;
}
html body.is-mobile-layout.chat-active #chatView .chat-header #chatRoomTitle { color: #fff !important; }
html body.is-mobile-layout.chat-active #chatView .chat-header :is(#newRoomBtn, #fullscreenBtn, #mobileInsightBtn, #autoBtn) {
  color: #fff !important;
  filter: drop-shadow(0 0 1.5px rgba(0,0,0,.9)) drop-shadow(0 1px 3px rgba(0,0,0,.5)) !important;
}
html body.is-mobile-layout.chat-active #chatView .chat-title-block { flex: 1; min-width: 0; }
html body.is-mobile-layout.chat-active #chatRoomTitle { font-size: clamp(15px, 2vw, 19px) !important; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html body.is-mobile-layout.chat-active #statusText { font-size: 11px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
html body.is-mobile-layout.chat-active #chatView .chat-header .controls { display: flex !important; flex-wrap: nowrap !important; gap: 6px; width: auto !important; }
html body.is-mobile-layout.chat-active #chatView .chat-header :is(button, .tool-button) { flex: 0 0 auto; min-width: 44px; min-height: 44px; padding: 8px 10px !important; font-size: 12px !important; }
/* Keep translated text as the accessible name; compact icons only on mobile. */
html body.is-mobile-layout.chat-active #chatView .chat-header :is(#fullscreenBtn, #mobileInsightBtn, #problemReportBtn) {
  position: relative; width: 44px !important; height: 44px !important;
  font-size: 0 !important; color: #fff !important;
  border: 0 !important; border-radius: 12px !important;
  background: transparent !important; box-shadow: none !important;
}
html body.is-mobile-layout.chat-active #chatView .chat-header :is(#fullscreenBtn, #mobileInsightBtn, #problemReportBtn) span { font-size: 0 !important; }
html body.is-mobile-layout.chat-active #chatView .chat-header :is(#fullscreenBtn, #mobileInsightBtn, #problemReportBtn)::before {
  content: ""; position: absolute; inset: 11px; background: currentColor;
  mask: var(--mobile-control-icon) center / contain no-repeat;
  -webkit-mask: var(--mobile-control-icon) center / contain no-repeat;
}
html body.is-mobile-layout #fullscreenBtn {
  --mobile-control-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 3H3v5m13-5h5v5M3 16v5h5m13-5v5h-5'/%3E%3C/svg%3E");
}
html body.is-mobile-layout #fullscreenBtn[aria-pressed=true] {
  --mobile-control-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 8h5V3m8 0v5h5M8 21v-5H3m18 0h-5v5'/%3E%3C/svg%3E");
}
html body.is-mobile-layout #mobileInsightBtn {
  --mobile-control-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round'%3E%3Cpath d='M5 6h14M5 12h14M5 18h14'/%3E%3C/svg%3E");
}
html body.is-mobile-layout.chat-active #chatView .chat-header #newRoomBtn {
  display: inline-flex !important; align-items: center; justify-content: center;
  position: static !important; inset: auto !important; transform: none !important;
  margin: 0 !important; width: 44px !important; height: 44px !important; flex: 0 0 44px;
  font-size: 30px !important; line-height: 1; background: transparent !important;
  border: 0 !important; box-shadow: none !important;
}
html body.is-mobile-portrait.chat-active #chatView #fullscreenBtn,
html body.is-mobile-layout.chat-active #chatView :is(#fullscreenBtn, #autoBtn)[hidden] { display: none !important; }
html body.is-mobile-landscape.chat-active #chatView #fullscreenBtn:not([hidden]) { display: inline-flex !important; }
html body.is-mobile-layout.chat-active #chatView .chat-title-row { min-width: 0; }
html body.is-mobile-layout.chat-active #chatRoomTitle { min-width: 0; margin: 0 !important; }
html body.is-mobile-layout.chat-active #chatView .vn-stage-shell {
  position: absolute !important; inset: 0 0 auto !important; width: 100% !important;
  height: var(--mobile-stage-height, 100%) !important; min-height: 0 !important; z-index: 0 !important;
}
html body.is-mobile-layout.chat-active #vnStageRuntimeCanvas {
  position: absolute !important; inset: 0 !important; width: 100% !important; height: 100% !important;
  transform: none !important; min-height: 0 !important;
}
html body.is-mobile-layout.chat-active #vnStage {
  height: 100% !important; min-height: 0 !important; width: 100% !important;
  overflow: hidden !important; border-radius: 0 !important; background-position: center !important; background-size: cover !important;
}
html body.is-mobile-layout.chat-active #vnStage .vn-presentation-layer {
  position: absolute; display: flex !important; flex-direction: column; justify-content: flex-end;
  left: var(--mobile-play-edge); right: var(--mobile-play-edge);
  bottom: calc(var(--mobile-composer-height) + var(--mobile-composer-bottom) + 12px);
  max-height: calc(var(--mobile-stage-height, 100dvh) - var(--mobile-composer-height) - var(--mobile-composer-bottom) - 96px);
  z-index: 100; pointer-events: none;
}
html body.is-mobile-layout.chat-active #vnStage :is(.vn-dialogue-box, .vn-scene-card) {
  position: relative !important; inset: auto !important; transform: none !important;
  width: min(100%, 760px) !important; max-width: 100% !important; min-width: 0 !important;
  min-height: 0 !important; max-height: 100% !important; margin: 0 auto !important;
  padding: 18px 20px 24px !important; border: 1px solid #ffffff1a !important;
  border-radius: 18px !important; background: #0d0d16dc !important;
  box-shadow: 0 12px 48px #0004 !important; pointer-events: auto;
  overflow-y: auto !important; overscroll-behavior: contain; touch-action: pan-y;
}
html body.is-mobile-layout.chat-active #vnStage .vn-dialogue-name {
  position: static !important; display: block; width: auto !important; min-width: 0 !important;
  padding: 0 !important; margin-bottom: 10px; background: none !important;
  border: none !important; box-shadow: none !important; font-size: 16px !important; color: #d5b9ff;
}
html body.is-mobile-layout.chat-active #vnStage .vn-presentation-text {
  font-size: clamp(17px, 2vw, 21px) !important; line-height: 1.65 !important;
  color: #fff !important; overflow-wrap: anywhere; text-shadow: 0 2px 6px #0008;
  max-height: none !important;
}
html body.is-mobile-layout.chat-active #vnStage .vn-advance-indicator { position: static !important; display: block; text-align: right; font-size: 12px !important; margin-top: 8px; }
/* "Waiting for a reply" under the player's own line, not on top of it: the
   phone dialogue box has almost no bottom padding for the desktop overlay. */
html body.is-mobile-layout.chat-active #vnStage .vn-player-waiting { position: static !important; display: block; text-align: right; font-size: 12px !important; margin-top: 8px; }
/* Keep the line reserved while text types: showing the "next" hint used to
   add a line under the finished text and push it up ~27px. */
html body.is-mobile-layout.chat-active #vnStage .vn-advance-indicator.hidden { display: block !important; visibility: hidden; animation: none; }
html body.is-mobile-portrait.chat-active #vnStage .vn-presentation-layer::before {
  /* The shade runs to the bottom of the screen (behind the input box) on any
     height; it used to stop 100px below the text and show a bare strip. Same
     fade as before, measured from the top of the shade. */
  content: ""; position: absolute; inset: -110px -28px -100dvh; z-index: -1;
  background: linear-gradient(transparent 0, #07070bc9 124px, #07070be6 326px, #07070be6 100%); pointer-events: none;
}
html body.is-mobile-portrait.chat-active #vnStage :is(.vn-dialogue-box, .vn-scene-card) {
  padding: 16px 12px 8px !important; border: 0 !important; border-radius: 0 !important;
  background: transparent !important; box-shadow: none !important; backdrop-filter: none !important;
}
html body.is-mobile-portrait.chat-active #vnStage:not([data-layout-engine="on"]) .vn-character {
  width: 100% !important; max-width: none !important;
  height: 120% !important; top: -16% !important; bottom: auto !important;
}
html body.is-mobile-layout.chat-active #vnStage .vn-standing { max-width: none !important; max-height: none !important; }
html body.is-mobile-layout.chat-active #userForm {
  position: absolute !important; inset: auto var(--mobile-play-edge) var(--mobile-composer-bottom) var(--mobile-play-edge) !important;
  display: grid !important; grid-template-columns: 44px minmax(0,1fr) 44px !important;
  gap: 8px !important; width: auto !important; min-width: 0 !important; max-width: 760px !important;
  margin: 0 auto !important; padding: 12px !important; height: auto !important;
  min-height: 0 !important; border: 1px solid var(--mobile-hairline) !important; border-radius: 18px !important;
  z-index: 1011 !important; background: var(--mobile-surface) !important; box-shadow: 0 8px 28px #0003;
}
html body.is-mobile-layout.chat-active #userInput {
  grid-column: 1 / -1; grid-row: 1; width: 100% !important; min-width: 0 !important;
  max-height: min(140px, calc(var(--mobile-stage-height, 100dvh) * .22)) !important; padding: 6px 4px !important;
  border: 0 !important; font-size: 16px !important; background: transparent !important;
}
html body.is-mobile-layout.chat-active #userForm #starInsertBtn { grid-column: 1; grid-row: 2; }
html body.is-mobile-layout.chat-active #userForm #contactBtn { grid-column: 2; grid-row: 2; justify-self: start; }
html body.is-mobile-layout.chat-active #userForm button[type=submit] { grid-column: 3; grid-row: 2; }
html body.is-mobile-layout.chat-active #userForm > button { position: static !important; width: auto !important; min-width: 44px; height: 44px !important; min-height: 44px !important; margin: 0 !important; border-radius: 12px !important; }
html body.is-mobile-layout.chat-active #userForm :is(#starInsertBtn, #contactBtn) {
  background: transparent !important; border-color: transparent !important; box-shadow: none !important;
}
html body.is-mobile-layout.chat-active #userInput { box-shadow: none !important; resize: none; line-height: 1.5; }
html body.is-mobile-layout.chat-active #userInput::placeholder { color: #a5a0af; opacity: 1; }
html body.is-mobile-layout.chat-active #storyPresentationRuntime { z-index: 1100 !important; background: #090910c9; height: var(--mobile-stage-height, 100dvh) !important; }
html body.is-mobile-layout.chat-active #chatView.has-authored-presentation .vn-stage-shell { z-index: 1020 !important; }
html body.is-mobile-layout.chat-active #storyPresentationRuntimeFrame {
  position: absolute; left: 50%; top: 50%; width: 1667px !important; height: 900px !important;
  max-width: none !important; max-height: none !important; transform-origin: center;
  transform: translate(-50%, -50%) scale(var(--tryva-stage-logical-scale, 1));
}
html body.is-mobile-layout.chat-active .story-presentation-runtime-actions { position: absolute; bottom: var(--mobile-bottom); left: 16px; right: 16px; z-index: 2; }
html body.is-mobile-layout.chat-active .story-presentation-runtime-actions button { min-height: 44px; font-size: 16px; }

/* One insight panel: sidebar when it fits, modal drawer otherwise. */
html body.is-mobile-layout.chat-active #chatInsightPanel {
  min-width: 0 !important; height: 100% !important; max-height: none !important;
  overflow: hidden !important; border-radius: 0 !important;
}
html body.is-mobile-layout.chat-active #chatInsightPanel > :is(.insight-tabs, .insight-subtabs, .mobile-insight-close) { flex: 0 0 auto !important; }
/* A landscape phone uses the same side panel; labels must not split syllables. */
html body.is-mobile-layout.chat-active #chatInsightPanel .insight-tabs {
  padding-inline: 8px !important; overflow-x: auto; scrollbar-width: thin;
}
html body.is-mobile-layout.chat-active #chatInsightPanel .insight-tabs button {
  flex: 1 0 auto !important; min-width: 0 !important; padding-inline: 8px !important;
  white-space: nowrap; word-break: keep-all;
}
html body.is-mobile-layout.chat-active #chatInsightPanel .insight-settings-head > div {
  flex-wrap: wrap; gap: 4px 8px;
}
html body.is-mobile-layout.chat-active #chatInsightPanel .insight-settings-head strong {
  flex-shrink: 0; white-space: nowrap;
}
html body.is-mobile-layout.chat-active #chatInsightPanel .insight-settings-head > div > span {
  word-break: keep-all;
}

html body.is-mobile-layout.chat-active #chatInsightPanel > .insight-pane {
  flex: 1 1 0 !important; min-height: 0 !important; overflow-y: auto !important;
}
html body.is-mobile-layout.chat-active #chatInsightPanel > #chatLogPanel {
  grid-template-rows: minmax(0, 1fr) !important; overflow: hidden !important;
}
html body.is-mobile-layout.chat-active #chatLogPanel > #messages {
  display: flex !important; flex-direction: column; min-height: 0 !important;
  height: 100% !important; max-height: none !important; box-sizing: border-box;
  overflow-x: hidden !important; overflow-y: auto !important; overscroll-behavior-y: contain;
}
html body.is-mobile-layout:not(.has-compact-insight).chat-active #chatInsightPanel {
  position: relative !important; inset: auto !important; display: flex !important;
  width: var(--mobile-insight-width) !important; transform: none !important; visibility: visible !important;
}
html body.is-mobile-layout:not(.has-compact-insight) :is(#mobileInsightBtn, #mobileInsightCloseBtn, #mobileInsightBackdrop) { display: none !important; }
html body.has-compact-insight.chat-active #chatInsightPanel {
  position: fixed !important; inset: var(--tryva-mobile-top, 0px) 0 auto auto !important;
  display: flex !important; width: min(420px, 92vw) !important; max-width: 92vw !important;
  height: var(--mobile-stage-height, 100dvh) !important; z-index: 1501 !important;
  padding-top: var(--mobile-top); padding-bottom: var(--mobile-bottom);
  transform: translateX(105%) !important; visibility: hidden; pointer-events: none;
  background: #111019 !important; box-shadow: -20px 0 70px #0007;
}
html body.has-compact-insight.mobile-insight-open.chat-active #chatInsightPanel {
  transform: none !important; visibility: visible !important; pointer-events: auto !important;
}
html body.has-compact-insight.chat-active #mobileInsightBtn { display: inline-flex !important; }
/* Reserve the close control beside the tab strip, including long translated tabs. */
html body.has-compact-insight.chat-active #chatInsightPanel > .insight-tabs { margin-right: 52px; }
html body.has-compact-insight.chat-active #mobileInsightCloseBtn { display: grid !important; position: absolute; top: var(--mobile-top); right: 4px; place-items: center; width: 44px; height: 44px; min-width: 44px; min-height: 44px; padding: 0; }
html body.has-compact-insight.chat-active #mobileInsightBackdrop { display: none !important; position: fixed; inset: 0; z-index: 1500; background: #0008; }
html body.has-compact-insight.mobile-insight-open.chat-active #mobileInsightBackdrop { display: block !important; }

/* Short landscape windows keep the PC-style horizontal stage and compact input. */
html body.is-mobile-landscape { --mobile-composer-bottom: var(--mobile-bottom); }
html body.is-mobile-landscape.chat-active #userForm { grid-template-columns: 44px minmax(0,1fr) 44px 44px !important; padding: 8px !important; left: var(--mobile-play-edge) !important; }
html body.is-mobile-landscape.chat-active #userInput { grid-column: 2; grid-row: 1; }
html body.is-mobile-landscape.chat-active #userForm #starInsertBtn { grid-column: 1; grid-row: 1; }
html body.is-mobile-landscape.chat-active #userForm #contactBtn { grid-column: 3; grid-row: 1; }
html body.is-mobile-landscape.chat-active #userForm button[type=submit] { grid-column: 4; grid-row: 1; }
/* Don't reserve an empty contact column when no separated character exists. */
html body.is-mobile-landscape.chat-active #userForm:has(#contactBtn.hidden) { grid-template-columns: 44px minmax(0,1fr) 44px !important; }
html body.is-mobile-landscape.chat-active #userForm:has(#contactBtn.hidden) button[type=submit] { grid-column: 3; }
html body.is-mobile-landscape.chat-active #vnStage .vn-presentation-layer { bottom: calc(var(--mobile-composer-height) + var(--mobile-bottom) + 12px); max-height: calc(var(--mobile-stage-height, 100dvh) - var(--mobile-composer-height) - 100px); }
html body.is-mobile-landscape.chat-active #vnStage .vn-presentation-text { font-size: 17px !important; line-height: 1.5 !important; }
/* Landscape phones/pads use the PC dialogue look: name tab on the top edge,
   PC colours and shape. Portrait keeps its own full-bleed text. The box stays
   visible so the tab is not clipped; long text scrolls inside the text. */
html body.is-mobile-landscape.chat-active #vnStage .vn-presentation-layer { padding-top: 18px; }
html body.is-mobile-landscape.chat-active #vnStage :is(.vn-dialogue-box, .vn-scene-card) {
  padding: 24px 26px 10px !important; border: 1px solid #d3c9e91a !important; border-radius: 20px !important;
  background: #0a0912e0 !important; box-shadow: 0 18px 44px #00000061 !important; overflow: visible !important;
}
html body.is-mobile-landscape.chat-active #vnStage .vn-dialogue-name {
  position: absolute !important; top: -16px !important; left: 24px !important; margin: 0; padding: 7px 14px !important;
  background: #32284ceb !important; border: 1px solid #a38bdc33 !important; border-radius: 12px;
  box-shadow: 0 8px 20px #00000047 !important; font-size: 13px !important; color: #f4f0fb; text-align: center;
}
html body.is-mobile-landscape.chat-active #vnStage .vn-dialogue-box.is-player .vn-dialogue-name { left: auto !important; right: 24px !important; }
html body.is-mobile-landscape.chat-active #vnStage .vn-presentation-text {
  max-height: calc(var(--mobile-stage-height, 100dvh) - var(--mobile-composer-height) - 204px) !important; overflow-y: auto;
}
/* Keyboard overlays the unchanged play screen. Only the existing textarea
   leaves its grid cell; keep its value, focus, selection and IME composition. */
html body.is-mobile-layout.mobile-composer-overlay.chat-active #userForm {
  height: var(--mobile-composer-height) !important; box-sizing: border-box;
  grid-template-rows: minmax(0, 1fr) 44px !important;
  overflow: visible !important;
}
html body.is-mobile-landscape.mobile-composer-overlay.chat-active #userForm { grid-template-rows: minmax(0, 1fr) !important; }
html body.is-mobile-layout.mobile-composer-overlay.chat-active #userForm #userInput {
  position: absolute !important; top: auto !important; left: 0 !important; right: 0 !important;
  bottom: calc(var(--mobile-stage-occlusion, 0px) - var(--mobile-composer-bottom) + 8px) !important;
  width: 100% !important; height: 44px !important; min-height: 44px !important; max-height: 44px !important;
  box-sizing: border-box; margin: 0 !important; padding: 10px 12px !important;
  border: 1px solid var(--mobile-hairline) !important; border-radius: 12px !important;
  background: var(--mobile-surface) !important; color: #fff !important;
  line-height: 22px !important; overflow-y: auto !important; overscroll-behavior: contain;
  transform: none !important; transition: none !important; z-index: 2;
}

/* Phone home banner (data-banner-layout="stacked", set by applyHomeBannerSlideLayouts
   from the layout profile). The PC banner is a wide strip with text on the left
   and the picture on the right; squeezed into a phone it stacked text over a
   sliver of picture. Here the picture fills a 2:1 card and the text sits on its
   lower edge. The admin crops only in the PC frame: the picture keeps that
   crop's centre and shows more above and below (reframeCoverLayout). Tapping
   the banner opens the item, so there is no add button; "1 / N" counts slides. */
html body.is-mobile-layout.has-compact-navigation {
  /* Clear the fixed menu button (16px + 44px + 8px) from the gutter edge. */
}

/* Detail and editor geometry; card collections are sized in styles-system.css. */
html body.is-mobile-layout :is(.tryva-unified-detail-dialog, .account-modal, .site-dialog) { max-width: calc(100vw - 24px) !important; max-height: calc(var(--tryva-app-height, 100dvh) - 24px) !important; overflow-y: auto; }
html body.is-mobile-portrait .tryva-detail-hero { grid-template-columns: minmax(0,1fr) !important; }
html body.is-mobile-portrait .tryva-detail-media { min-height: 260px !important; max-height: 45dvh; }
/* Character, world and lorebook creators share one compact header and gutter. */
html body.is-mobile-layout:is(.create-active,.story-asset-create-active) .workspace:not(:has(> :is(#catalogFlow,#libraryView):not(.hidden))) { padding: 0 !important; }
html body.is-mobile-layout:is(.create-active,.story-asset-create-active) { --creator-header-leading: var(--mobile-gutter); }
html body.has-compact-navigation:is(.create-active,.story-asset-create-active) { --creator-header-leading: 72px; }
html body.is-mobile-layout :is(#createView,#storyAssetCreateView) .story-asset-create-head {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 72px; height: auto; margin: 0;
  padding: var(--mobile-top) var(--mobile-gutter) 12px var(--creator-header-leading);
}
html body.is-mobile-layout :is(#createView,#storyAssetCreateView) .story-asset-create-head > div { flex: 1 1 auto; min-width: 0; }
html body.is-mobile-layout :is(#createView,#storyAssetCreateView) .story-asset-create-head > div > :is(span,p) { display: none; }
html body.is-mobile-layout :is(#createView,#storyAssetCreateView) .story-asset-create-head h1 { margin: 0; overflow: hidden; font-size: clamp(18px,3.2vw,23px); line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
html body.is-mobile-layout :is(#createView,#storyAssetCreateView) .story-asset-create-head .mobile-creator-toggle { margin-top: 0; flex: 0 0 auto; }
/* The workspace is the single vertical scroller. Match the legacy creator
   shell's specificity so its fixed height/overflow cannot clip the form. */
html body.is-mobile-layout:is(.create-active,.story-asset-create-active) :is(#createView, #storyAssetCreateView).story-asset-create-view { height: auto !important; min-height: 100%; overflow: visible !important; }
html body.is-mobile-layout :is(#createView, #storyAssetCreateView) .story-asset-create-main {
  display: grid !important; grid-template-columns: 160px minmax(0,1fr) 258px !important;
  height: auto !important; min-height: 0 !important; overflow: visible !important;
}
html body.is-mobile-layout :is(#createView, #storyAssetCreateView) .story-asset-create-form { min-width: 0; overflow: visible !important; padding: 24px var(--mobile-gutter) 100px !important; }
html body.is-mobile-layout :is(#createView, #storyAssetCreateView) .story-asset-create-actions { position: sticky !important; bottom: 0; z-index: 20; padding-bottom: var(--mobile-bottom); background: #121019f5; }
html body.is-mobile-layout .library-view:not(.library-selection-mode) .library-touch-menu { display: grid; position: absolute; top: 8px; right: 8px; z-index: 40; min-width: 44px; min-height: 44px; border-radius: 12px; background: #171320e8; color: white; border: 1px solid #ffffff2b; }
html body.is-mobile-layout .library-context-menu { max-width: calc(100vw - 24px); z-index: 1600; }
html body.is-mobile-layout .library-context-menu button { min-height: 44px; }
.library-move-dialog { color: #f1ebfa; background: #15121e; border: 1px solid #ffffff26; border-radius: 20px; padding: 20px; width: min(440px, calc(100vw - 32px)); max-height: 80dvh; }
.library-move-dialog::backdrop { background: #0009; }
.library-move-dialog form { display: grid; gap: 16px; }
.library-move-dialog select { width: 100%; min-height: 44px; }
.library-move-dialog footer { display: flex; justify-content: flex-end; gap: 12px; }
.library-move-dialog button { min-height: 44px; }

@media (max-width: 1199px) {
  html body.is-mobile-layout :is(#createView, #storyAssetCreateView) .story-asset-create-main { grid-template-columns: minmax(0,1fr) !important; }
  html body.is-mobile-layout .story-asset-create-steps { position: static !important; width: 100% !important; max-height: none !important; overflow: auto !important; overscroll-behavior-y: auto; }
  html body.is-mobile-layout :is(.story-asset-create-step-list, #storyAssetStepList) { display: flex !important; gap: 8px; overflow-x: auto; padding: 12px 16px; }
  html body.is-mobile-layout :is(.story-asset-create-step-list, #storyAssetStepList) > button { flex: 0 0 auto; width: auto !important; min-width: 96px; }
  html body.is-mobile-layout .story-asset-create-steps small { display: none; }
  html body.is-mobile-layout .story-asset-create-preview { display: none !important; }
  html body.is-mobile-layout .creator-progress-open .story-asset-create-preview { display: block !important; grid-row: 2; width: 100%; max-height: 50dvh; overflow-y: auto; padding: 16px; }
  html body.is-mobile-layout .mobile-creator-toggle { display: inline-flex; align-items: center; min-height: 44px; margin-top: 12px; }
}
@media (max-width: 599px) {
  html body.is-mobile-layout :is(.story-field-grid.two, .cw-two-column-settings, .cw-field-row, .character-world-position-grid) { grid-template-columns: minmax(0,1fr) !important; }
  html body.is-mobile-layout.chat-active #fullscreenBtn { max-width: 70px; }
}
@media (prefers-reduced-motion: reduce) {
  html body.is-mobile-layout :is(.nav-shell, #chatInsightPanel) { transition: none !important; }
}

/* Reporting follows the same compact tool-button treatment as other play controls. */
html body.is-mobile-layout #problemReportBtn {
  --mobile-control-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 21V4m0 0c4-4 10 4 14 0v10c-4 4-10-4-14 0'/%3E%3C/svg%3E");
}

html body.is-mobile-layout.chat-active #chatView .chat-header #problemReportBtn.tool-button {
  color:#ee9da9!important;
  background:rgba(166,53,80,.12)!important;
  border:1px solid rgba(209,83,110,.34)!important;
}
html body.is-mobile-layout.chat-active #chatView .chat-header #problemReportBtn.tool-button:hover {
  color:#ffd5dd!important;
  background:rgba(166,53,80,.24)!important;
}
/* Short action labels stay on one line on narrow phones. */
html body.is-mobile-layout :is(.mobile-creator-toggle, #libraryNewFolderBtn) {
  white-space: nowrap !important;
  flex-shrink: 0;
}
@media (max-width: 359px) {
  html body.is-mobile-layout .mobile-creator-toggle { padding-inline: 12px !important; font-size: 13px !important; }
}
/* The title accent bar sat on top of the subtitle. */
html body.is-mobile-layout #recentConversationsView h1 { margin-bottom: 14px !important; }
/* Play settings: 8-9.5px captions are below phone legibility. */
html body.is-mobile-layout.chat-active #chatInsightPanel :is(small > span, i > span, output > span, #responseCostEstimateMeta) {
  font-size: 11px !important;
}

/* Admin observation replaces the composer with read-only room controls. */
html body.is-mobile-layout.admin-observing.chat-active #adminObservationBar {
  position: absolute; inset: auto var(--mobile-play-edge) var(--mobile-composer-bottom) var(--mobile-play-edge);
  z-index: 1011; margin: 0 auto; max-width: 760px; border: 1px solid var(--mobile-hairline); border-radius: 14px;
  background: var(--mobile-surface); box-shadow: 0 8px 28px #0003;
}
