/* Long translated labels can wrap to their own row without shrinking their icons. */
.rail-header{flex-wrap:wrap;gap:10px;flex-shrink:0}
.rail-header .rail-title{flex:0 0 auto;max-width:100%}
.rail-header .new-chat{flex:1 0 auto;min-width:0;max-width:100%;min-height:40px;padding:10px 12px;font-size:13px;line-height:1.3;white-space:normal;text-align:center}
.rail-header .new-chat-label{min-width:0;overflow-wrap:anywhere}
.rail-header .new-chat svg,.rail-header .rail-title svg{flex:none}

/* Memory belongs to the fixed chat toolbar, outside the message scroller. */
.chat-header .header-identity{flex:1;min-width:0}
.chat-header .header-avatar,.chat-header .menu{flex-shrink:0}
.chat-header .header-identity .online{min-width:0}
.chat-header .header-identity .online span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.chat-header .header-actions{align-items:center;flex:none}
.chat-header .session-banner{position:static;inset:auto;transform:none;width:auto;max-width:none;min-height:0;padding:0;border:0;border-radius:0;background:none;box-shadow:none;backdrop-filter:none;z-index:auto;flex:none}
.chat-header .session-banner[hidden]{display:none}
.chat-header .session-banner .header-memory-button{position:relative;display:flex;align-items:center;justify-content:center;gap:6px;min-height:34px;padding:7px 10px;border:1px solid #80577088;border-radius:999px;background:#513048;color:#f5d2e9;white-space:nowrap;font-size:12px;line-height:1.25}
.chat-header .session-banner .header-memory-button:hover{background:#69435f}
.chat-header .session-banner .header-memory-button:focus-visible{outline:2px solid #ef9bd1;outline-offset:3px}
.chat-header .header-memory-button svg{width:14px;height:14px;flex:none}
.header-memory-count{font-size:10px;background:#ffffff1a;border-radius:7px;padding:2px 5px;font-variant-numeric:tabular-nums}
.novel-choose-character [data-icon]{display:none}
.main .messages{padding-top:20px}
#chatBack{display:none}
#deleteChat .delete-label,#railAccount:empty,#railChatActions:empty{display:none}
#desktopLanguage:empty{display:none}
#desktopLanguage #languageBar{
 position:relative;inset:auto;z-index:auto;height:auto;gap:6px;
 padding:3px 0;border:0;background:none;box-shadow:none;
}
#desktopLanguage #languageBar label{font-size:0;gap:0}
#desktopLanguage #languageBar label span{font-size:19px;color:#d5b1cb}
#desktopLanguage #languageSelect{
 flex:1;min-width:0;width:100%;max-width:none;height:38px;padding:0 5px;
 border-color:#574052;border-radius:9px;font-size:13px;
}
.sidebar-collapsed #desktopLanguage #languageBar{
 width:42px;height:42px;justify-content:center;padding:0;border-radius:10px;
}
.sidebar-collapsed #desktopLanguage #languageBar:hover{background:#29242a}
.sidebar-collapsed #desktopLanguage #languageBar:focus-within{outline:2px solid #f17ac6;outline-offset:-2px}
.sidebar-collapsed #desktopLanguage #languageSelect{position:absolute;inset:0;height:100%;opacity:0}
@media(min-width:1024px){
 .app:not(.chapter-role-choosing) .chat-header{padding-inline:max(32px,calc((100% - 760px)/2))}
}
@media (max-width:760px), (max-width:1023px) and (hover:none) and (pointer:coarse){
 #conversationRail{
   padding-block:max(12px,env(safe-area-inset-top)) max(12px,env(safe-area-inset-bottom));
 }
 #conversationRail .rail-header{gap:8px;margin-bottom:12px}
 #conversationRail :is(#closeRail,#newChat){min-height:44px}
 #conversationRail #closeRail{width:44px}
 #conversationRail .search-box{height:44px}
 #conversationRail .chat-list{
   max-height:clamp(140px,36dvh,350px);overflow:auto;
 }
 #conversationRail .chat-list:empty{display:none}
 #conversationRail .rail-options{
   display:grid;gap:8px;margin-top:12px;padding-top:8px;border-top:1px solid #302b30;
 }
 #conversationRail :is(#railNav,#railAccount .account-bar){margin:0}
 #conversationRail #navSections{gap:6px}
 #conversationRail #railLanguage{order:0}
 #chatBack{display:inline-flex;width:44px;height:44px;border-radius:10px;background:#251e27;color:#f5dbef}
 #chatBack:hover,#chatBack:active{background:#382739}
 #chatBack svg{width:21px;height:21px}
 body.compact-chat:has(.app-topbar){--topbar-height:0px}
 .compact-chat #catalogTopbar{display:none}
 .compact-chat .app .chat-header{
   height:calc(56px + env(safe-area-inset-top));gap:4px;
   padding:env(safe-area-inset-top) max(6px,env(safe-area-inset-right)) 0 max(6px,env(safe-area-inset-left));
 }
 .compact-chat .chat-header :is(#menu,#rename,#toggleDetails){
   display:inline-flex;align-items:center;justify-content:center;min-width:40px;min-height:44px;
 }
 .compact-chat .chat-header .session-banner{display:none}
 .compact-chat .header-identity strong{max-width:none}
 .compact-chat .chat-header .diamond-balance{align-self:center;min-height:36px;padding:4px 8px;gap:4px}
 .compact-chat .chat-header .diamond-balance strong{font-size:13px}
 .compact-chat .chat-header .diamond-balance:has(strong:not([hidden])) .diamond-unit{display:none}
 #railAccount .account-bar{justify-content:space-between;gap:6px;padding:8px 2px 0;border-top:1px solid #302b30}
 #railAccount #accountName{max-width:100%}
 #railChatActions #deleteChat{width:100%;min-height:44px;justify-content:flex-start;gap:8px;border-radius:10px;padding:0 10px}
 #railChatActions #deleteChat .delete-label{display:inline;font-size:12px}
 #railChatActions #novelChooseCharacter{justify-content:flex-start;width:100%;max-width:none;min-height:44px;margin-top:6px}
}
@media(max-width:760px){
 .app .chat-header{gap:5px;padding-inline:8px}
 .chat-header .menu,.chat-header .header-actions .icon-button{width:36px;height:40px}
 .details .detail-top{position:sticky;top:0;z-index:2;margin-top:-14px;padding-block:5px;background:#141414}
 .details .detail-top #hideDetails{width:40px;height:40px}
 #modal:not(.character-picker) .modal-box{display:flex;flex-direction:column;overflow:hidden}
 #modal:not(.character-picker) :is(.modal-head,.modal-footer){flex:none}
 #modal:not(.character-picker) #modalBody{min-height:0;overflow:auto;overscroll-behavior:contain}
 #modal .field :is(input,textarea,select),.rail #chatSearch,.discovery-search-controls input{font-size:16px}
}
@media(max-width:480px){
 .chat-header .session-banner .header-memory-button{width:36px;height:36px;padding:8px}
 .chat-header .header-memory-label,.chat-header .header-memory-count{display:none}
 .chat-header .session-banner.has-memory .header-memory-button::after{content:"";position:absolute;top:4px;right:4px;width:6px;height:6px;border-radius:50%;background:#ff9bda;border:1px solid #513048}
 .chat-header .novel-choose-character{width:36px;height:36px;padding:0}
 .chat-header .novel-choose-character [data-icon]{display:inline-flex}
 .chat-header .novel-choose-character svg{width:16px;height:16px}
 .chat-header .novel-choose-character .novel-choice-label{display:none}
 .main .messages{padding-top:14px}
}
@media(max-width:360px){.chat-header .header-avatar{display:none}}
@media(hover:none) and (pointer:coarse){.hint .keyboard-hint{display:none}}
