/* Size small controls independently of the theme's large action-button padding. */
.ps1-theme :is(#chatCollapse, #chatExpand, .sheet-head button[id$="Close"], #setClose, #bugClose, #aboutClose, #patchClose, #custClose, #spClose, #partyCloseBtn, #premiumX) {
  display:inline-flex; align-items:center; justify-content:center; flex:0 0 auto;
  box-sizing:border-box; width:32px; height:32px; min-width:32px; min-height:32px;
  padding:0 !important; line-height:1; letter-spacing:0; text-align:center;
}
#chatCollapse svg { width:14px; height:14px; display:block; pointer-events:none; }
.ps1-theme #chatBox {
  --chat-scale:calc(var(--ui-scale,1) * var(--sc-chat,1));
  box-sizing:border-box; width:min(460px, calc((var(--chat-vw,100vw) - 16px) / var(--chat-scale))) !important;
  max-width:none !important; max-height:calc((var(--chat-vh,100dvh) - var(--chat-inset,101px) - 12px) / var(--chat-scale));
  bottom:var(--chat-bottom,101px); flex-direction:column; gap:0;
}
.ps1-theme #chatTabs { display:grid; grid-template-columns:minmax(0,1fr) auto auto; gap:6px; flex:0 0 auto; }
.ps1-theme #chatTabs.sheet-drag::before { display:none; }
.chatChannels { display:flex; flex-wrap:wrap; align-items:center; gap:4px; min-width:0; }
.ps1-theme .chatChannels .chatTab { display:inline-flex; align-items:center; justify-content:center; gap:3px; padding:5px 7px; min-height:28px; box-sizing:border-box; }
.ps1-theme .chatChannels .chatTab[data-tab="dev"]:not(.on) { display:none; }
.ps1-theme #chatCollapse { margin:0; align-self:start; }
.ps1-theme #chatLog { flex:0 1 214px; min-height:32px; height:214px; overflow:auto; overscroll-behavior:contain; }
#chatInputRow, #voiceRow { flex:0 0 auto; min-width:0; }
.ps1-theme #chatSend, .ps1-theme #bbEmote { display:inline-flex; align-items:center; justify-content:center; gap:6px; padding:6px 9px; min-height:36px; box-sizing:border-box; line-height:1; }
#voiceRow { flex-wrap:wrap; gap:6px; }
#voiceRow select { min-width:0; max-width:130px; }
.ps1-theme #chatTranslate { display:inline-flex; align-items:center; justify-content:center; box-sizing:border-box; width:32px; height:32px; padding:0 !important; border:1px solid #71654c !important; border-radius:7px !important; background:transparent !important; color:#c8bea7 !important; box-shadow:none !important; text-shadow:none !important; opacity:.75; }
.ps1-theme #chatTranslate:hover, .ps1-theme #chatTranslate:focus-visible { opacity:1; }
.ps1-theme #chatTranslate[aria-pressed="true"] { opacity:1; color:#a7d6ec !important; border-color:#7da9bc !important; background:#28414b !important; }
#chatTranslate svg { width:20px; height:20px; pointer-events:none; }
#chatTranslationOptions { flex:0 0 auto; font:12px/1.4 system-ui,sans-serif; padding:5px 0 8px; color:#c9bea8; }
#chatTranslationOptions[hidden] { display:none; }
#chatTranslationOptions label { display:flex; flex-wrap:wrap; align-items:center; gap:6px; }
#chatLanguage { flex:1 1 110px; min-width:0; max-width:100%; padding:5px; background:#211b14; color:#e9dfc6; border:1px solid #71654c; border-radius:5px; }
#chatTranslationStatus { margin-top:4px; font-size:11px; overflow-wrap:anywhere; }
.chatOriginal { font:11px/1.4 system-ui,sans-serif; color:#bcb198; }
.chatOriginal summary { cursor:pointer; display:inline; opacity:.8; }
.chatOriginal p { margin:2px 0 5px; overflow-wrap:anywhere; }
.chatText { unicode-bidi:plaintext; }
#chatLog .mentionLine { background:rgba(240,204,110,.09); box-shadow:inset 2px 0 0 rgba(240,204,110,.65); padding:1px 4px 1px 6px; border-radius:3px; }
/* Border frames count toward panel width; short windows scroll inside the panel. */
.ps1-theme :is(#charPanel,#invPanel,#statsPanel,#bankPanel,#stationPanel,#petPanel,#vendorPanel,#repairPanel,#marketPanel,#wikiPanel,#tradePanel,#hubPanel,#inspectPanel) {
  box-sizing:border-box; max-width:calc(100vw - 16px); max-height:min(68vh,calc(100dvh - 174px));
}
.sheet-head { min-width:0; flex:0 0 auto; }
.sheet-head > :is(span,div) { min-width:0; overflow-wrap:anywhere; }
.sheet-body { min-height:0; }
.ps1-theme :is(#settingsPanel,#bugPanel,#aboutPanel,#patchPanel,#customizePanel > .panel,#skinPaintPanel > .panel) {
  box-sizing:border-box; max-width:calc(100vw - 16px) !important; max-height:calc(100dvh - 24px) !important; overflow:auto;
}
@media (max-width:600px) {
  .ps1-theme :is(#settingsPanel,#bugPanel,#aboutPanel,#patchPanel) { padding:44px 14px 16px; }
  #settingsPanel .setSection label { flex-wrap:wrap; }
  #setTabs { flex-wrap:wrap; }
  .ps1-theme #setTabs .setTab { flex:1 1 80px; min-width:0; }
  #settingsPanel :is(input[type=range],select) { min-width:0; max-width:100%; }
}
@media (max-width:600px), (max-height:520px) {
  .ps1-theme #chatBox { left:8px; }
  .ps1-theme :is(#charPanel,#invPanel,#statsPanel,#bankPanel,#stationPanel,#petPanel,#vendorPanel,#repairPanel,#marketPanel,#wikiPanel,#tradePanel,#hubPanel,#inspectPanel) { bottom:12px; max-height:calc(100dvh - 24px); }
  .ps1-theme #chatSend { font-size:11px; padding:6px; }
}
#chatBox.chatKeyboard #voiceRow { display:none; }
