/* Mobile chat is a single viewport-sized reading surface. Keep original story and tool handlers. */
#bao-mobile-exit,#bao-mobile-status,#bao-mobile-memory,#bao-mobile-support,#bao-mobile-tools-tab,#bao-mobile-panel-close,#bao-mobile-composer-tools,#bao-mobile-composer-inspire{display:none}
@media(max-width:820px){
  body:has(#chat-view.active){overflow:hidden}
  body:has(#chat-view.active) .app-shell{width:100%!important;max-width:none!important}
  body:has(#chat-view.active) .app-shell>main{min-height:0}
  body:has(#chat-view.active) .app-shell>footer{display:none}

  /* The public-site navigation is useful outside a story, but wastes a large part of a phone screen while reading. */
  body:has(#chat-view.active) .topbar{display:none!important}

  /* The active story owns the whole visual viewport on phones. */
  #chat-view.active{
    position:fixed!important;
    inset:auto!important;
    top:var(--bao-mobile-viewport-top,0px)!important;
    left:var(--bao-mobile-viewport-left,0px)!important;
    right:auto!important;
    bottom:auto!important;
    display:flex!important;
    flex-direction:column!important;
    width:var(--bao-mobile-viewport-width,100%)!important;
    height:var(--bao-mobile-viewport-height,100dvh)!important;
    min-height:0!important;
    max-height:none!important;
    overflow:hidden!important;
    padding:0!important;
    margin:0!important;
    background:var(--yoru-night,#090b10);
  }
  #chat-view .chat-layout{
    display:grid!important;
    grid-template-columns:minmax(0,1fr)!important;
    grid-template-rows:minmax(0,1fr)!important;
    flex:1 1 0!important;
    width:100%!important;
    height:100%!important;
    min-height:0!important;
    max-height:100%!important;
    gap:0!important;
    overflow:hidden!important;
    border-radius:0!important;
    align-items:stretch!important;
  }

  /* Explicit grid rows are more reliable than flex ordering on Android browsers.
     Header / story / optional panels / feedback / composer. */
  #chat-view .chat-layout>.chat-main{
    grid-column:1!important;
    grid-row:1!important;
    align-self:stretch!important;
    width:100%!important;
    height:100%!important;
    min-height:0!important;
    max-height:100%!important;
    min-width:0!important;
    display:grid!important;
    grid-template-columns:minmax(0,1fr)!important;
    grid-template-rows:auto minmax(0,1fr) auto auto auto!important;
    overflow:hidden!important;
    border-radius:0!important;
    background:var(--yoru-story-surface-strong,rgba(14,14,17,.97));
  }

  #chat-view .chat-topline{
    grid-column:1!important;
    grid-row:1!important;
    display:flex!important;
    flex-wrap:nowrap!important;
    align-items:center!important;
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
    min-height:62px!important;
    padding:9px 12px calc(9px + env(safe-area-inset-top,0px))!important;
    gap:8px!important;
    margin:0!important;
    overflow:hidden!important;
    border-bottom:1px solid rgba(255,255,255,.075)!important;
    background:linear-gradient(180deg,rgba(20,19,22,.99),rgba(14,14,17,.97))!important;
    backdrop-filter:blur(18px);
    box-shadow:0 8px 28px rgba(0,0,0,.18);
  }
  #chat-view .chat-title-avatar{width:40px!important;height:40px!important;flex:0 0 40px!important;border-radius:12px!important}
  #chat-view .chat-title-copy{flex:1 1 auto!important;min-width:0!important;overflow:hidden!important}
  #chat-view .chat-title-copy h2{display:block;max-width:100%;font-size:clamp(16px,4.5vw,20px)!important;line-height:1.2;margin:0!important;font-weight:760;letter-spacing:.01em;white-space:nowrap!important;overflow:hidden!important;text-overflow:ellipsis!important}
  #chat-view .chat-topline .eyebrow{display:none!important}

  /* Hide desktop/mobile duplicate toolbars. They remain reachable from the drawer. */
  #chat-view #bao-reading-status-toggle,
  #chat-view #bao-chat-tool-shortcuts,
  #chat-view .story-mobile-tools,
  #chat-view #bao-chat-api-toolbar,
  #chat-view #bao-chat-cost-open,
  #chat-view #bao-chat-floating-actions{display:none!important}

  #chat-view #game-ui{display:none!important}
  #chat-view .chat-main.bao-mobile-panel-open #game-ui{
    display:block!important;
    grid-column:1!important;
    grid-row:3!important;
    min-height:0!important;
    max-height:30dvh!important;
    overflow:auto!important;
    border-top:1px solid var(--story-border,rgba(255,255,255,.1));
    border-bottom:1px solid var(--story-border,rgba(255,255,255,.1));
  }
  #chat-view #game-ui .ui-tabs{
    display:flex!important;
    align-items:center!important;
    gap:8px!important;
    min-width:0!important;
    padding:10px 12px!important;
    overflow-x:auto!important;
    overflow-y:hidden!important;
    overscroll-behavior-x:contain;
    scrollbar-width:thin;
  }
  #chat-view #bao-mobile-panel-close{
    display:inline-flex!important;
    align-items:center!important;
    justify-content:center!important;
    flex:0 0 40px!important;
    width:40px!important;
    min-width:40px!important;
    min-height:38px!important;
    margin-left:auto!important;
    position:sticky;
    right:8px;
    z-index:3;
    padding:0!important;
    border-color:rgba(255,157,165,.34)!important;
    background:#25171d!important;
    color:#ffb7bd!important;
    font-size:20px!important;
    line-height:1!important;
    font-weight:800!important;
    box-shadow:-10px 0 18px rgba(11,15,23,.92);
  }
  #chat-view #bao-mobile-memory.is-active{
    border-color:rgba(214,170,115,.18)!important;
    background:rgba(77,62,141,.58)!important;
    color:#fff!important;
  }

  /* This is the only expanding row. It can never collapse behind the composer. */
  #chat-view .chat-stream{
    grid-column:1!important;
    grid-row:2!important;
    width:100%!important;
    height:auto!important;
    min-height:0!important;
    max-height:none!important;
    min-width:0!important;
    overflow-x:hidden!important;
    overflow-y:auto!important;
    overscroll-behavior:contain;
    scrollbar-gutter:auto!important;
    padding:20px 18px 30px!important;
    margin:0!important;
  }
  #chat-view .usage-bar{display:none!important}
  #chat-view #bao-chat-send-feedback:not([hidden]){
    grid-column:1!important;
    grid-row:4!important;
    min-height:0!important;
    max-height:18dvh!important;
    overflow-y:auto!important;
    margin:0 10px 5px!important;
  }

  /* Composer is always the last row and never participates in story-height calculation. */
  #chat-view .composer{
    grid-column:1!important;
    grid-row:5!important;
    min-height:76px!important;
    max-height:31dvh!important;
    display:flex!important;
    align-items:flex-end!important;
    gap:8px!important;
    padding:9px 11px calc(11px + env(safe-area-inset-bottom,0px))!important;
    position:relative!important;
    inset:auto!important;
    margin:0!important;
    background:linear-gradient(180deg,rgba(16,16,19,.72),var(--yoru-tool,#101116) 34%)!important;
    border-top:0!important;
    box-shadow:0 -18px 34px rgba(0,0,0,.28);
    z-index:4!important;
  }
  #chat-view #bao-mobile-composer-tools,
  #chat-view #bao-mobile-composer-inspire{
    display:inline-flex!important;
    align-items:center!important;
    justify-content:center!important;
    flex:0 0 44px!important;
    width:44px!important;
    min-width:44px!important;
    height:52px!important;
    min-height:52px!important;
    padding:0!important;
    border:1px solid rgba(255,255,255,.13)!important;
    border-radius:16px!important;
    background:var(--yoru-tool-raised,#1b191e)!important;
    color:var(--story-text,#eeeae4)!important;
    font:inherit!important;
    font-size:20px!important;
    font-weight:800!important;
    cursor:pointer;
    box-shadow:inset 0 1px rgba(255,255,255,.035),0 8px 22px rgba(0,0,0,.16);
    touch-action:manipulation;
  }
  #chat-view #bao-mobile-composer-inspire{
    border-color:rgba(241,232,218,.10)!important;
    background:rgba(73,62,126,.32)!important;
    color:#ddd7ff!important;
    font-size:18px!important;
  }
  #chat-view #bao-mobile-composer-tools:focus-visible,
  #chat-view #bao-mobile-composer-inspire:focus-visible{outline:3px solid var(--yoru-lantern,#d6aa73);outline-offset:2px}
  #chat-view #bao-mobile-composer-inspire:disabled{opacity:.42;cursor:not-allowed}
  #chat-view .composer.story-request-pending #bao-mobile-composer-tools,
  #chat-view .composer.story-request-pending #bao-mobile-composer-inspire{display:none!important}

  #chat-view .composer textarea{
    flex:1 1 auto!important;
    min-width:0!important;
    width:auto!important;
    box-sizing:border-box!important;
    min-height:52px!important;
    max-height:min(26dvh,168px)!important;
    resize:none!important;
    overflow-y:hidden!important;
    font-size:16px!important;
    line-height:1.5!important;
    padding:14px 15px!important;
    border:1px solid rgba(255,255,255,.12)!important;
    border-radius:18px!important;
    background:rgba(30,28,32,.96)!important;
    box-shadow:inset 0 1px rgba(255,255,255,.035),0 8px 22px rgba(0,0,0,.18);
  }
  #chat-view .composer :is(.primary,.story-cancel-generation){
    width:auto!important;
    min-width:58px!important;
    flex:0 0 auto!important;
    min-height:52px!important;
    align-self:flex-end!important;
    height:52px!important;
    max-height:52px!important;
    padding:8px 12px!important;
    border-radius:16px!important;
    box-shadow:0 8px 24px rgba(0,0,0,.18);
  }
  #chat-view .composer .story-cancel-generation:not(.hidden){min-width:68px!important}

  #chat-view .message{max-width:100%;margin-bottom:24px}
  #chat-view .message.assistant .bubble{width:100%!important;max-width:100%!important;line-height:1.92;font-size:clamp(15px,4.15vw,17px)}
  #chat-view .message.user .bubble{max-width:88%!important;border-radius:18px 18px 5px 18px!important}
  #chat-view .story-message-tools{
    display:flex!important;
    flex-wrap:nowrap!important;
    align-items:center!important;
    gap:6px!important;
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
    overflow-x:auto!important;
    overflow-y:hidden!important;
    overscroll-behavior-x:contain;
    -webkit-overflow-scrolling:touch;
    scrollbar-width:thin;
    padding:5px 0 9px!important;
    margin-top:7px!important;
    opacity:1!important;
  }
  #chat-view .story-message-tools button{flex:0 0 auto;white-space:nowrap;min-height:39px;padding:7px 10px;font-size:12px}
  #chat-view .story-message-tools [data-edit]{order:10}
  #chat-view .story-message-tools [data-rewrite]{order:20}
  #chat-view .story-message-tools [data-regenerate]{order:30}
  #chat-view .story-message-tools [data-story-rollback]{order:40}
  #chat-view .story-message-tools [data-create-branch]{order:50}
  /* On phones, AI action inspiration belongs beside the composer. Keep the
     per-message version on desktop, but remove the duplicate mobile entry. */
  #chat-view .story-message-tools [data-inspire]{display:none!important}
  #chat-view .story-message-tools [data-copy]{order:70}
  #chat-view .story-variant-switcher{min-height:35px}

  /* Story is already the base mobile surface. Keep one Header「舞臺」entry
     and use Composer ＋ for Control Center; hide duplicate Story/Control tabs. */
  #chat-view #bao-surface-mode-toggle,
  #chat-view #bao-story-surface-story{display:none!important}
  #chat-view #bao-surface-controls{
    padding:0!important;
    border:0!important;
    background:transparent!important;
  }

  #bao-mobile-exit,
  #bao-mobile-status,
  #bao-mobile-memory,
  #bao-mobile-support,
  #bao-mobile-tools-tab{
    display:inline-flex!important;
    align-items:center!important;
    justify-content:center!important;
    flex:0 0 auto!important;
    min-height:40px!important;
    height:40px!important;
    padding:0 11px!important;
    border:1px solid rgba(255,255,255,.13)!important;
    border-radius:14px!important;
    background:var(--yoru-tool-raised,#1b191e)!important;
    color:var(--story-text,#eeeae4)!important;
    box-shadow:inset 0 1px rgba(255,255,255,.035);
    font-size:12px!important;
    font-weight:750!important;
    cursor:pointer;
    touch-action:manipulation;
  }
  #bao-mobile-exit{
    width:40px!important;
    min-width:40px!important;
    padding:0!important;
    border-radius:50%!important;
    font-size:18px!important;
  }
  #bao-mobile-status{min-width:54px!important}
  #bao-mobile-memory{min-width:54px!important}
  #bao-mobile-support{
    width:40px!important;
    min-width:40px!important;
    padding:0!important;
    text-decoration:none!important;
    font-size:18px!important;
  }
  #bao-mobile-support .bao-mobile-bun-icon{
    display:block;
    width:27px;
    height:27px;
    object-fit:contain;
  }
  #bao-mobile-tools-tab{
    width:40px!important;
    min-width:40px!important;
    padding:0!important;
    position:static!important;
    inset:auto!important;
    transform:none!important;
    margin:0!important;
  }
  #bao-mobile-tools-tab span:first-child{font-size:14px!important;line-height:1;letter-spacing:1px;transform:translateY(-2px)}
  #bao-mobile-exit:focus-visible,
  #bao-mobile-status:focus-visible,
  #bao-mobile-memory:focus-visible,
  #bao-mobile-support:focus-visible,
  #bao-mobile-tools-tab:focus-visible{outline:3px solid var(--yoru-lantern,#d6aa73);outline-offset:2px}
  #chat-view:not(.active) :is(#bao-mobile-exit,#bao-mobile-status,#bao-mobile-memory,#bao-mobile-support,#bao-mobile-tools-tab){display:none!important}

  #bao-chat-tool-drawer{inset:0!important;z-index:145!important;display:flex!important;align-items:flex-end!important;justify-content:center!important;padding:0!important;background:rgba(2,5,10,.68)!important;backdrop-filter:blur(10px)}
  #bao-chat-tool-drawer .bao-chat-tool-dialog{height:auto!important;max-height:86dvh!important;width:100%!important;max-width:560px!important;border-radius:24px 24px 0 0!important;border:1px solid rgba(255,255,255,.12)!important;border-bottom:0!important;background:var(--yoru-tool,#101116)!important;box-shadow:0 -18px 54px rgba(0,0,0,.48)!important;overflow:hidden}
  #bao-chat-tool-drawer .bao-chat-tool-dialog:before{content:'';display:block;width:42px;height:4px;margin:8px auto 0;border-radius:999px;background:rgba(255,255,255,.22)}
  #bao-chat-tool-drawer header{flex:0 0 auto;padding:10px 16px 12px!important}
  #bao-chat-tool-drawer header h2{font-size:18px!important}
  #bao-chat-tool-drawer .bao-chat-tool-dialog-body{flex:1 1 auto;min-height:0;display:block!important;padding:12px 14px calc(14px + env(safe-area-inset-bottom,0px))!important;overflow-y:auto!important;overscroll-behavior:contain}
  #bao-chat-tool-drawer .bao-chat-tool-dialog-body>details{margin-top:10px}
  #bao-chat-tool-drawer .bao-mobile-quick{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:9px;margin-bottom:14px;padding-bottom:14px;border-bottom:1px solid rgba(255,255,255,.09)}
  #bao-chat-tool-drawer .bao-mobile-quick button{width:100%;min-width:0;min-height:48px;padding:10px 9px;border-radius:14px;border:1px solid var(--story-border);background:var(--yoru-tool-raised,#1b191e);color:var(--story-text,#eeeae4);text-align:left;font-size:12px;font-weight:700;cursor:pointer;overflow-wrap:anywhere}
  #bao-chat-tool-drawer .bao-mobile-quick button:focus-visible{outline:2px solid #73e3d3;outline-offset:2px}
  #bao-chat-tool-drawer .bao-mobile-quick small,#bao-chat-tool-drawer .bao-mobile-quick .bao-mobile-usage{grid-column:1/-1;color:#9ea6b5;font-size:11px;line-height:1.55;overflow-wrap:anywhere}
  #bao-chat-tool-drawer .bao-mobile-support-link{grid-column:1/-1;display:flex;align-items:center;justify-content:center;gap:8px;min-height:46px;padding:10px;border:1px solid rgba(214,170,115,.32);border-radius:14px;background:rgba(214,170,115,.09);color:#f3d4aa;text-decoration:none;font-size:13px;font-weight:750}
  #bao-chat-tool-drawer .bao-mobile-support-link .bao-mobile-bun-icon{display:block;width:27px;height:27px;object-fit:contain;flex:none}
}
@media(max-width:360px){
  #chat-view .chat-stream{padding-left:14px!important;padding-right:14px!important}
  #chat-view #bao-mobile-composer-tools,
  #chat-view #bao-mobile-composer-inspire{flex-basis:44px!important;width:44px!important;min-width:44px!important;font-size:17px!important}
  #chat-view .composer :is(.primary,.story-cancel-generation){min-width:54px!important;font-size:12px!important;padding-left:9px!important;padding-right:9px!important}
  #chat-view .chat-title-avatar{width:34px!important;height:34px!important;flex-basis:34px!important}
  #chat-view .chat-topline{gap:6px!important;padding-left:8px!important;padding-right:8px!important}
  #bao-mobile-status{min-width:48px!important;padding:0 8px!important}
  #bao-mobile-exit,#bao-mobile-tools-tab{width:36px!important;min-width:36px!important;height:36px!important;min-height:36px!important}
  #bao-chat-tool-drawer .bao-chat-tool-dialog{width:100%!important}
}
@media(prefers-reduced-motion:reduce){#bao-mobile-tools-tab,#bao-chat-tool-drawer *{transition:none!important;animation:none!important}}

@media(max-width:430px){
  #chat-view .chat-topline{gap:6px!important}
  #bao-mobile-status,#bao-mobile-memory{min-width:46px!important;padding-inline:8px!important;font-size:11px!important}
  #bao-mobile-support,#bao-mobile-tools-tab,#bao-mobile-exit{width:38px!important;min-width:38px!important;height:38px!important;min-height:38px!important}
  #chat-view .chat-title-avatar{width:36px!important;height:36px!important;flex-basis:36px!important}
}


/* Focused AI-reply editing on phones: the normal chat composer is unrelated
   while revising an existing assistant reply, so give that space back to text. */
@media(max-width:820px){
  #chat-view.story-reply-editing .composer{
    display:none!important;
  }
  #chat-view.story-reply-editing .chat-stream{
    grid-row:2 / 6!important;
    padding-bottom:calc(12px + env(safe-area-inset-bottom,0px))!important;
  }
  #chat-view.story-reply-editing .story-message-tools,
  #chat-view.story-reply-editing .story-variant-switcher,
  #chat-view.story-reply-editing .story-inspiration-panel{
    display:none!important;
  }
  #chat-view.story-reply-editing .story-inline-editor{
    min-height:100%;
    gap:8px;
  }
  #chat-view.story-reply-editing .story-inline-editor textarea{
    min-height:min(46dvh,420px)!important;
    max-height:none!important;
    resize:none!important;
  }
  #chat-view.story-reply-editing .story-inline-actions{
    position:sticky;
    bottom:0;
    z-index:5;
    padding:8px 0 calc(4px + env(safe-area-inset-bottom,0px));
    background:linear-gradient(180deg,rgba(16,17,22,0),var(--yoru-tool,#101116) 28%);
  }
  #chat-view.story-reply-editing .story-inline-actions button{
    min-height:44px;
    padding-inline:16px;
  }
}


/* UX 3.0 Phase 3: only four high-frequency actions visible by default. */
@media(max-width:820px) {
  #bao-chat-tool-drawer .bao-mobile-quick > .bao-mobile-more {
    grid-column:1/-1;min-width:0;margin:0;border:1px solid var(--yoru-control-border,var(--story-border));
    border-radius:14px;background:var(--yoru-control,var(--yoru-tool-raised,#1b191e));overflow:hidden;
  }
  #bao-chat-tool-drawer .bao-mobile-more > summary {
    display:flex;align-items:center;justify-content:space-between;gap:8px;
    min-height:44px;padding:10px 13px;list-style:none;cursor:pointer;
    color:var(--yoru-text,var(--story-text,#eeeae4));font-size:13px;font-weight:700;
  }
  #bao-chat-tool-drawer .bao-mobile-more > summary::-webkit-details-marker{display:none}
  #bao-chat-tool-drawer .bao-mobile-more > summary::after {content:'⌄';color:var(--yoru-muted,#aba);font-size:17px}
  #bao-chat-tool-drawer .bao-mobile-more[open] > summary::after {content:'⌃'}
  #bao-chat-tool-drawer .bao-mobile-more > summary:focus-visible {
    outline:2px solid var(--yoru-lantern,#d6aa73);outline-offset:-3px;
  }
  #bao-chat-tool-drawer .bao-mobile-extra-actions {
    display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;
    padding:10px;border-top:1px solid var(--yoru-control-border,var(--story-border));
  }
  #bao-chat-tool-drawer .bao-mobile-extra-actions button {
    background:var(--yoru-tool-raised,#1b191e);color:var(--yoru-story-text,var(--story-text,#eeeae4));
  }
  #bao-chat-tool-drawer .bao-mobile-extra-actions .bao-mobile-support-link {
    grid-column:1/-1;
  }
  #bao-chat-tool-drawer [hidden] {display:none!important}
}

/* Long-story return-to-top remains a quiet one-tap action outside More. */
@media(max-width:820px) {
  #bao-chat-tool-drawer .bao-mobile-quick > .bao-mobile-go-top {
    grid-column:1/-1;width:100%;min-height:34px!important;
    padding:4px 8px!important;margin:0;border:0!important;border-radius:8px!important;
    background:transparent!important;color:var(--yoru-muted,#a7a5af)!important;
    font-size:12px!important;text-align:right!important;font-weight:600!important;
  }
  #bao-chat-tool-drawer .bao-mobile-quick > .bao-mobile-go-top:hover {
    color:var(--yoru-text,#eeeae4)!important;background:var(--yoru-control,#28252b)!important;
  }
}


/* Experience 3.0 / Phase 6 — mobile reader color continuity.
   Scope only platform chrome; never recolor authored story HTML or card UI. */
@media(max-width:820px) {
  html:is([data-yoru-theme="mist"],[data-yoru-theme="dawn"],[data-yoru-theme="dusk"],[data-yoru-theme="sunset"]) #chat-view.active,
  html:is([data-yoru-theme="mist"],[data-yoru-theme="dawn"],[data-yoru-theme="dusk"],[data-yoru-theme="sunset"]) #chat-view .chat-layout>.chat-main,
  html:is([data-yoru-theme="mist"],[data-yoru-theme="dawn"],[data-yoru-theme="dusk"],[data-yoru-theme="sunset"]) #chat-view .chat-stream {
    background:var(--yoru-reading)!important;
    color:var(--yoru-story-text);
  }
  html:is([data-yoru-theme="mist"],[data-yoru-theme="dawn"],[data-yoru-theme="dusk"],[data-yoru-theme="sunset"]) #chat-view .chat-topline {
    background:var(--yoru-tool)!important;
    border-bottom-color:var(--yoru-story-border)!important;
    box-shadow:0 4px 22px rgba(0,0,0,.08);
  }
  html:is([data-yoru-theme="mist"],[data-yoru-theme="dawn"],[data-yoru-theme="dusk"],[data-yoru-theme="sunset"]) #chat-view .chat-title-copy h2 {
    color:var(--yoru-text)!important;
  }
  html:is([data-yoru-theme="mist"],[data-yoru-theme="dawn"],[data-yoru-theme="dusk"],[data-yoru-theme="sunset"]) #chat-view .composer {
    background:var(--yoru-tool)!important;
    border-top:1px solid var(--yoru-story-border)!important;
    box-shadow:0 -9px 28px rgba(0,0,0,.09)!important;
  }
  /* The cinematic play-mode stylesheet uses two IDs with !important;
     match that scope so mist/rose are not defeated by the older night palette. */
  html:is([data-yoru-theme="mist"],[data-yoru-theme="dawn"],[data-yoru-theme="dusk"],[data-yoru-theme="sunset"]) #chat-view[data-bao-surface="play"] #user-input {
    background:var(--yoru-input)!important;
    color:var(--yoru-story-text)!important;
    border-color:var(--yoru-input-border)!important;
    box-shadow:none!important;
    caret-color:var(--yoru-story-text);
  }

  /* Cinematic play-mode also hard-codes the user's bubble and primary send
     control. Reclaim only these platform-owned surfaces in non-night themes. */
  html:is([data-yoru-theme="mist"],[data-yoru-theme="dawn"],[data-yoru-theme="dusk"],[data-yoru-theme="sunset"]) #chat-view[data-bao-surface="play"] .message.user .bubble {
    background:var(--yoru-player-bubble)!important;
    color:var(--yoru-story-text)!important;
    border-color:var(--yoru-story-border)!important;
  }
  html:is([data-yoru-theme="mist"],[data-yoru-theme="dawn"],[data-yoru-theme="dusk"],[data-yoru-theme="sunset"]) #chat-view[data-bao-surface="play"] .composer .primary {
    background:var(--yoru-lantern)!important;
    border-color:var(--yoru-control-border-hover)!important;
  }
  html:is([data-yoru-theme="mist"],[data-yoru-theme="dawn"],[data-yoru-theme="sunset"]) #chat-view[data-bao-surface="play"] .composer .primary{color:#fff!important}
  html[data-yoru-theme="dusk"] #chat-view[data-bao-surface="play"] .composer .primary{color:var(--yoru-night)!important}
  html:is([data-yoru-theme="mist"],[data-yoru-theme="dawn"],[data-yoru-theme="dusk"],[data-yoru-theme="sunset"]) #chat-view[data-bao-surface="play"] #bao-scene-meta {
    color:var(--yoru-muted)!important;
  }
  html:is([data-yoru-theme="mist"],[data-yoru-theme="dawn"],[data-yoru-theme="dusk"],[data-yoru-theme="sunset"]) #chat-view[data-bao-surface="play"] #user-input::placeholder {
    color:var(--yoru-story-muted)!important;
  }
  html:is([data-yoru-theme="mist"],[data-yoru-theme="dawn"],[data-yoru-theme="dusk"],[data-yoru-theme="sunset"]) #chat-view[data-bao-surface="play"] .composer #bao-mobile-composer-tools,
  html:is([data-yoru-theme="mist"],[data-yoru-theme="dawn"],[data-yoru-theme="dusk"],[data-yoru-theme="sunset"]) #chat-view[data-bao-surface="play"] .composer #bao-mobile-composer-inspire,
  html:is([data-yoru-theme="mist"],[data-yoru-theme="dawn"],[data-yoru-theme="dusk"],[data-yoru-theme="sunset"]) #bao-mobile-exit,
  html:is([data-yoru-theme="mist"],[data-yoru-theme="dawn"],[data-yoru-theme="dusk"],[data-yoru-theme="sunset"]) #bao-mobile-status,
  html:is([data-yoru-theme="mist"],[data-yoru-theme="dawn"],[data-yoru-theme="dusk"],[data-yoru-theme="sunset"]) #bao-mobile-memory,
  html:is([data-yoru-theme="mist"],[data-yoru-theme="dawn"],[data-yoru-theme="dusk"],[data-yoru-theme="sunset"]) #bao-mobile-tools-tab {
    background:var(--yoru-control)!important;
    color:var(--yoru-text)!important;
    border-color:var(--yoru-control-border)!important;
    box-shadow:none!important;
  }
  html:is([data-yoru-theme="mist"],[data-yoru-theme="dawn"],[data-yoru-theme="dusk"],[data-yoru-theme="sunset"]) #chat-view #bao-mobile-composer-inspire:disabled {
    opacity:.52;
  }
  html:is([data-yoru-theme="mist"],[data-yoru-theme="dawn"],[data-yoru-theme="dusk"],[data-yoru-theme="sunset"]) #chat-view #bao-mobile-panel-close {
    background:var(--yoru-control)!important;
    color:var(--yoru-text)!important;
    border-color:var(--yoru-control-border)!important;
    box-shadow:none!important;
  }
  html:is([data-yoru-theme="mist"],[data-yoru-theme="dawn"],[data-yoru-theme="dusk"],[data-yoru-theme="sunset"]) #bao-chat-tool-drawer .bao-chat-tool-dialog {
    border-color:var(--yoru-border)!important;
    color:var(--yoru-text)!important;
  }
  html:is([data-yoru-theme="mist"],[data-yoru-theme="dawn"],[data-yoru-theme="dusk"],[data-yoru-theme="sunset"]) #bao-chat-tool-drawer .bao-chat-tool-dialog:before {
    background:var(--yoru-control-border);
  }
  html:is([data-yoru-theme="mist"],[data-yoru-theme="dawn"],[data-yoru-theme="dusk"],[data-yoru-theme="sunset"]) #bao-chat-tool-drawer .bao-mobile-quick {
    border-bottom-color:var(--yoru-border);
  }
  html:is([data-yoru-theme="mist"],[data-yoru-theme="dawn"],[data-yoru-theme="dusk"],[data-yoru-theme="sunset"]) #bao-chat-tool-drawer .bao-mobile-quick button {
    background:var(--yoru-control);
    color:var(--yoru-text);
    border-color:var(--yoru-control-border);
  }
  html:is([data-yoru-theme="mist"],[data-yoru-theme="dawn"],[data-yoru-theme="dusk"],[data-yoru-theme="sunset"]) #bao-chat-tool-drawer .bao-mobile-quick small {
    color:var(--yoru-muted);
  }
}


/* Experience 3.0 / Phase 7 — mobile reply actions: reading comes first.
   "More" reuses the original buttons, not duplicate click handlers. */
@media(max-width:820px){
  #chat-view .story-message-tools > details.bao-message-more{
    order:90;flex:0 0 auto;align-self:flex-start;min-width:70px;max-width:100%;
    margin:0;border:1px solid var(--yoru-control-border,var(--story-border));
    border-radius:11px;background:var(--yoru-control,var(--yoru-tool-raised));
    color:var(--yoru-story-text,var(--story-text));overflow:hidden;
  }
  #chat-view .story-message-tools > details.bao-message-more[hidden]{display:none!important}
  #chat-view .story-message-tools .bao-message-more > summary{
    display:flex;align-items:center;justify-content:center;gap:7px;
    min-height:39px;padding:6px 11px;cursor:pointer;list-style:none;
    font-size:12px;font-weight:700;white-space:nowrap;
  }
  #chat-view .story-message-tools .bao-message-more > summary::-webkit-details-marker{display:none}
  #chat-view .story-message-tools .bao-message-more > summary::after{
    content:'⌄';color:var(--yoru-story-muted,var(--story-muted));font-size:15px;
  }
  #chat-view .story-message-tools .bao-message-more[open] > summary::after{content:'⌃'}
  #chat-view .story-message-tools .bao-message-more > summary:focus-visible{
    outline:2px solid var(--yoru-lantern,#d6aa73);outline-offset:-3px;
  }
  #chat-view .story-message-tools .bao-message-more-actions{
    display:flex;flex-wrap:wrap;align-items:center;gap:7px;padding:9px;
    border-top:1px solid var(--yoru-control-border,var(--story-border));
    max-width:min(285px,calc(100vw - 40px));
  }
  #chat-view .story-message-tools .bao-message-more-actions button{
    width:auto;max-width:100%;white-space:normal;
    text-align:left;overflow-wrap:anywhere;min-height:39px;
  }
  #chat-view .story-message-tools > button{
    border-color:var(--yoru-control-border,var(--story-border));
  }
}


/* Experience 3.0 · Phase 8: desktop Play reveals specialist reply tools
   only on demand. Studio and professional stay fully exposed. */
@media(min-width:821px){
  #chat-view[data-bao-surface="play"] .story-message-tools > details.bao-message-more {
    order:90;flex:0 0 auto;min-width:84px;max-width:100%;
    border:1px solid var(--yoru-control-border,var(--story-border));
    border-radius:10px;
    background:var(--yoru-control,var(--yoru-tool-raised));
    color:var(--yoru-story-text,var(--story-text));
    overflow:hidden;
  }
  #chat-view .story-message-tools > details.bao-message-more[hidden]{display:none!important}
  #chat-view .story-message-tools > details.bao-message-more > summary{
    display:flex;align-items:center;justify-content:center;gap:8px;
    min-height:36px;padding:7px 12px;cursor:pointer;list-style:none;
    font-size:12px;font-weight:700;white-space:nowrap;
  }
  #chat-view .story-message-tools > details.bao-message-more > summary::-webkit-details-marker{display:none}
  #chat-view .story-message-tools > details.bao-message-more > summary::after{
    content:'⌄';font-size:15px;color:var(--yoru-story-muted,var(--story-muted));
  }
  #chat-view .story-message-tools > details.bao-message-more[open] > summary::after{content:'⌃'}
  #chat-view .story-message-tools > details.bao-message-more > summary:focus-visible{
    outline:2px solid var(--yoru-lantern,#d6aa73);outline-offset:-3px;
  }
  #chat-view[data-bao-surface="play"] .story-message-tools > details.bao-message-more[open]{
    flex-basis:min(100%,610px);
  }
  #chat-view .story-message-tools .bao-message-more-actions{
    display:flex;gap:8px;flex-wrap:wrap;align-items:center;
    padding:11px;border-top:1px solid var(--yoru-control-border,var(--story-border));
  }
  #chat-view .story-message-tools .bao-message-more-actions button{
    min-height:36px;white-space:normal;text-align:left;
    max-width:100%;overflow-wrap:anywhere;
  }
  #chat-view .story-message-tools > button{
    min-height:36px;
    border-color:var(--yoru-control-border,var(--story-border));
  }
}

/* Short visual viewports: expanding first-party story status must not crowd
   out the reading stream or the composer. Authored story HTML is untouched. */
@media(max-width:820px){
  #chat-view.active #bao-inline-story-status[open]{
    min-height:0;
    max-height:min(180px,calc(var(--bao-mobile-viewport-height,100dvh) * .28))!important;
    overflow-y:auto!important;
    overscroll-behavior:contain;
  }
  #chat-view.active #bao-inline-story-status[open] > summary{
    position:sticky;
    top:0;
    z-index:2;
    background:var(--yoru-tool,#101116);
  }
  #chat-view.active[data-bao-keyboard-open="true"] #bao-inline-story-status[open]{
    max-height:min(104px,calc(var(--bao-mobile-viewport-height,100dvh) * .23))!important;
  }
}


/* #871 game-ui-ux + #873 Impeccable: expand the actual mobile story
   hit boxes, not their decorative icons. Preserve header actions, semantics
   and the original Stage/Phone/Story handlers. Keep this after compact
   breakpoints so <=360px does not silently shrink the click targets. */
@media(max-width:820px){
  #chat-view #bao-mobile-exit,
  #chat-view #bao-conversation-search-open,
  #chat-view #bao-surface-controls #bao-play-status-toggle{
    box-sizing:border-box!important;
    flex:0 0 44px!important;
    width:44px!important;
    min-width:44px!important;
    height:44px!important;
    min-height:44px!important;
    padding:0!important;
  }
  #chat-view #bao-mobile-panel-close{
    box-sizing:border-box!important;
    flex:0 0 44px!important;
    width:44px!important;
    min-width:44px!important;
    height:44px!important;
    min-height:44px!important;
    padding:0!important;
  }
}


/* The 44px mobile Search hit box must not spill "搜尋對話" over the
   neighboring Stage and Phone controls. Keep the original button, text,
   title, accessibility name and click handler; draw its existing icon only. */
@media (max-width:820px) {
  #chat-view #bao-conversation-search-open {
    font-size:0!important;
    white-space:nowrap!important;
    overflow:hidden!important;
    text-align:center;
  }
  #chat-view #bao-conversation-search-open::before {
    content:"⌕";
    display:inline-block;
    font-size:22px;
    line-height:1;
    color:var(--yoru-story-text,var(--story-text,#eeeae4));
  }
}
