/* Keep chat clearance inside the content so the sidebar reaches the page bottom. */
.game-frame .game-main { padding-bottom: 80px; }

.mail-grid { display:grid; grid-template-columns:minmax(210px, .8fr) minmax(0, 1.6fr); gap:22px; margin:28px 0 0; padding:0; border:0; min-width:0; }
.mail-list,.mail-thread { background:var(--theme-surface,#ffffffdc); border:1px solid var(--theme-line,#dbe8e4); border-radius:20px; padding:24px; min-width:0; }
.mail-thread { position:relative; }
/* Keep the displayed partner and thread together until the next read commits.
   Inert blocks stale input without introducing a blank frame or opacity change. */
.mail-contact[aria-busy="true"] { cursor:progress; }
/* A protected image can resolve after its surrounding text. Reserve its place
   before it exists in the DOM, including while a keyed partner image is replaced. */
.mail-avatar { display:block; flex:0 0 34px; width:34px; height:34px; overflow:hidden; border-radius:50%; background:var(--theme-soft,#dceff0); }
.peer-heading .mail-avatar { flex-basis:46px; width:46px; height:46px; }
.mail-avatar .peer-avatar { display:block; }
.mail-grid h2 { font-size:20px; margin:0 0 20px; }
.mail-grid label { display:block; margin:12px 0 8px; font-size:13px; }
.mail-search-context { margin:12px 0 8px; font-size:13px; }
.mail-grid input,.mail-grid textarea,.shoutbox input { width:100%; min-width:0; border:1px solid var(--theme-line,#bad2d5); border-radius:10px; padding:12px; font:inherit; color:var(--theme-ink,#193f4c); background:var(--theme-surface,#fff); }
.mail-grid textarea { resize:vertical; margin-bottom:10px; }
.mail-grid button,.shoutbox button { font:inherit; cursor:pointer; border:0; border-radius:10px; padding:11px 15px; color:white; background:#193f4c; }
.mail-grid button:disabled,.shoutbox button:disabled { opacity:.5; cursor:default; }
/* Channel reads lock actions without making the whole set of controls blink. */
.shoutbox[data-channel-switching="true"] button:disabled { opacity:1; }
.mail-grid button:focus-visible,.shoutbox button:focus-visible { outline:3px solid #eeab41; outline-offset:3px; }
.comm-compose { display:flex; gap:8px; align-items:center; }
.mail-grid .mail-contact { display:block; text-align:left; width:100%; background:var(--theme-soft,#eff7f6); color:var(--theme-ink,#193f4c); margin:10px 0; overflow-wrap:anywhere; }
.mail-contact.selected { box-shadow:inset 3px 0 #1997a1; background:var(--theme-hover,#dcf0ef); }
.mail-contact small { display:block; margin-top:7px; line-height:1.5; }
.mail-contact span { font-size:12px; }
.comm-badge { background:#e9ac45; color:var(--theme-ink,#193f4c); padding:3px 7px; border-radius:20px; font-size:11px; }

/* The scrollport starts at the latest entry in its very first paint. One inner
   block keeps chronological DOM/reading order; native anchoring preserves a
   reader's position when new entries arrive. No delayed server scroll call. */
.mail-history { display:flex; flex-direction:column-reverse; max-height:460px; overflow:auto; scrollbar-gutter:stable; margin:18px 0; padding:4px; }
.mail-history-entries { flex:none; min-width:0; }
.comm-message { padding:12px 14px; background:var(--theme-soft,#eef6f5); border-radius:12px; margin-bottom:10px; overflow-wrap:anywhere; }
.mail-history .mail-dialog-message { width:fit-content; max-width:86%; margin:0 auto 8px 0; padding:9px 12px; border:1px solid var(--theme-line,#dbe8e4); border-radius:12px 12px 12px 4px; }
.mail-history .mail-dialog-message.own { margin-left:auto; margin-right:0; background:color-mix(in srgb,var(--theme-accent,#168c95) 12%,var(--theme-soft,#eef6f5)); border-color:color-mix(in srgb,var(--theme-accent,#168c95) 40%,var(--theme-line,#dbe8e4)); border-radius:12px 12px 4px 12px; }
.mail-history .mail-dialog-message header { gap:3px 9px; line-height:1.4; }
.mail-history .mail-dialog-message p { margin-top:4px; line-height:1.5; }
.mail-history .mail-dialog-message:has(.report-form) { width:86%; }
@media(max-width:550px) { .mail-history .mail-dialog-message { max-width:92%; } .mail-history .mail-dialog-message:has(.report-form) { width:92%; } }
.comm-message header { display:flex; flex-wrap:wrap; align-items:center; gap:10px; font-size:13px; }
.comm-message time { font-size:11px; color:var(--theme-muted,#537480); }
.mail-history .comm-message.reportable { position:relative; }
.mail-history .comm-message.reportable>header { padding-right:58px; }
.mail-history .comm-message.reportable>.report-link { position:absolute; top:6px; right:8px; min-height:28px; line-height:18px; }
.mail-history .comm-message.reportable>.report-link:hover { text-decoration:underline; }
.mail-history .comm-message.reportable>.report-form { margin-top:10px; }
.comm-message p { white-space:pre-wrap; margin:7px 0 0; line-height:1.6; font-size:14px; }
.mail-thread>p,.mail-thread-content>p,.mail-list>p { line-height:1.7; color:var(--theme-muted,#537480); }
.shoutbox { position:fixed; bottom:0; right:24px; width:min(520px, calc(100vw - 48px)); z-index:80; border:1px solid var(--theme-line,#bad2d5); border-bottom:0; border-radius:18px 18px 0 0; background:var(--theme-surface,#f7fcfc); box-shadow:0 -8px 38px #193f4c20; overflow:hidden; }
.shout-header { display:flex; align-items:center; justify-content:space-between; gap:8px; padding:8px 12px; background:var(--theme-soft,#def1f3); min-height:56px; }
.shout-header a { font-size:12px; color:var(--theme-ink,#193f4c); }
.shout-header button { background:transparent; color:var(--theme-ink,#193f4c); font-size:13px; font-weight:600; }
.shout-history { height:min(260px, 34dvh); overflow:auto; padding:12px; overscroll-behavior:contain; }
.shout-compose { padding:10px 12px max(12px, env(safe-area-inset-bottom)); border-top:1px solid var(--theme-line,#dbe8e4); }
.shout-input { flex:1; min-width:0; }
.shoutbox input { font-size:16px; }
.shout-error { color:var(--theme-danger,#9d3543); font-size:13px; padding:0 12px; }
.shout-empty { color:var(--theme-muted,#537480); padding:16px; }
.sr-only { position:absolute; width:1px; height:1px; padding:0; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }
@media(max-width:1000px) { .mail-grid { grid-template-columns:1fr; } }
@media(max-width:550px) { .shoutbox { right:0; width:100%; } .mail-list,.mail-thread { padding:18px; } .mail-grid .comm-compose { flex-wrap:wrap; } }

.mail-list .mail-list-heading{font-size:13px;margin:24px 0 10px;padding-top:16px;border-top:1px solid var(--theme-line,#cfe4e7)}
.mail-contact:focus-visible{outline:2px solid var(--theme-accent,#11818d);outline-offset:2px}

/* The resize grip grows the panel up and left; the bottom-right anchor stays put. */
.shoutbox:not(.collapsed){width:min(var(--shout-width,520px),calc(100vw - 48px));height:min(var(--shout-height,440px),calc(var(--shout-viewport,calc(100dvh - 128px)) - env(safe-area-inset-bottom,0px)));display:flex;flex-direction:column}
.shoutbox:not(.collapsed) .shout-header{padding-left:48px;flex-shrink:0}
.shoutbox #shout-content:not([hidden]){display:flex;flex-direction:column;min-height:0;flex:1}
.shoutbox #shout-content[hidden]{display:none}
.shoutbox .shout-history{height:auto;min-height:0;flex:1}
.shoutbox .shout-channel-tabs,.shoutbox .shout-compose,.shoutbox .shout-size-controls{flex-shrink:0}
.shoutbox .shout-resize{position:absolute;top:0;left:0;display:grid;place-items:center;width:44px;height:44px;padding:0;border:0;background:none;color:var(--theme-muted,#537480);border-radius:20px 0 12px 0;cursor:nwse-resize;touch-action:none;user-select:none;-webkit-user-select:none;z-index:2}
.shoutbox .shout-resize svg{width:19px;height:19px;pointer-events:none;position:relative}
.shoutbox.collapsed .shout-resize{display:none}
.shout-resizing{user-select:none}
.shout-size-controls{display:none;justify-content:flex-end;gap:4px;padding:4px 12px;border-bottom:1px solid var(--theme-line,#bad2d5)}
.shoutbox .shout-size-controls button{padding:4px 8px;font-size:11px;color:var(--theme-muted,#537480);background:none;border:1px solid transparent}
.shoutbox .shout-mobile-size{display:none}
@media(max-width:550px){
 .shoutbox:not(.collapsed){right:0;width:100%;height:min(440px,58dvh,calc(var(--shout-viewport,calc(100dvh - 128px)) - env(safe-area-inset-bottom,0px)))}
 .shoutbox[data-mobile-size="large"]:not(.collapsed){height:min(82dvh,calc(var(--shout-viewport,calc(100dvh - 128px)) - env(safe-area-inset-bottom,0px)))}
 .shoutbox .shout-resize,.shoutbox .shout-reset-size{display:none}
 .shoutbox:not(.collapsed) .shout-header{padding-left:12px}
 .shout-size-controls{display:flex}
 .shoutbox .shout-mobile-size{display:block}
 .shoutbox .shout-mobile-size[aria-pressed="true"]{color:var(--theme-ink,#193f4c);background:var(--theme-soft,#def1f3);border-color:var(--theme-line,#bad2d5)}
}

/* Dense chat rows keep reporting in the metadata line, not below every message. */
.shout-header-actions{display:flex;align-items:center;gap:2px;min-width:0}
.shout-header .shout-reset-size{display:inline-flex;align-items:center;justify-content:center;flex:0 0 28px;width:28px;height:28px;padding:4px;color:var(--theme-muted,#537480)}
.shout-header .shout-reset-size:hover{background:var(--theme-hover,#dcf0ef);color:var(--theme-ink,#193f4c)}
.shoutbox.collapsed .shout-reset-size{display:none}
.shoutbox .shout-history{padding:8px}
.shoutbox .shout-message{padding:8px 10px;margin-bottom:6px;gap:8px;border-radius:10px}
.shoutbox .shout-message:last-child{margin-bottom:0}
.shout-message-body{position:relative}
.shoutbox .shout-message header{gap:3px 8px;min-height:18px;line-height:1.35}
.shoutbox .shout-message header>a{min-width:0}
.shoutbox .shout-message time{white-space:nowrap}
.shoutbox .shout-message p{margin:2px 0 0;line-height:1.4}
.shout-message-body.has-report>header{padding-right:54px}
.shoutbox .shout-message .report-link{position:absolute;right:-3px;top:-3px;min-height:24px;line-height:18px;color:var(--theme-muted,#537480)!important}
.shoutbox .shout-message .report-link:hover{text-decoration:underline;color:var(--theme-ink,#193f4c)!important}
.shoutbox .shout-message .report-form{margin-top:8px}
@media(max-width:550px){.shout-header .shout-reset-size{display:none}}
.shout-delete-confirm{margin-top:8px;padding:10px;border:1px solid var(--theme-border,#b6d7df);border-radius:8px;background:var(--theme-surface,#fff)}
.shout-delete-confirm>p{margin:0 0 6px}.shout-delete-confirm>small{display:block;color:var(--theme-muted,#537480)}
.shout-delete-confirm>div{display:flex;flex-wrap:wrap;gap:8px;margin-top:10px}
.shout-delete-confirm button{font-size:12px;min-height:36px;padding:6px 10px}
.shout-moderation-notice{margin:8px 12px;font-size:12px;color:var(--theme-ink,#193f4c)}

/* One compact collapsed header everywhere; equal visible padding at both ends. */
.game-frame .shoutbox.collapsed{width:min(320px,calc(100vw - 24px));right:12px;left:auto}
.game-frame .shoutbox.collapsed .shout-header{min-height:42px;padding:6px 12px;gap:10px}
.game-frame .shoutbox.collapsed .shout-header>a{flex:none;white-space:nowrap}
.game-frame .shoutbox.collapsed .shout-header-actions{justify-content:flex-end;flex:1}
.game-frame .shoutbox.collapsed .shout-header button{padding:6px 0;font-size:12px;text-align:right;line-height:1.4;white-space:normal}
@media(max-width:600px){.game-frame .shoutbox.collapsed{width:auto;left:8px;right:8px}}
