:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", sans-serif;
  --accent: #296bcc;
  --border: #304b6c14;
  --muted: #64758a;
  --glass: #ffffffb8;
  --ink: #24364c;
  color: var(--ink);
  background: #e8eef5;
}
.message-translate { display: block; padding: 5px 0 0; background: none; color: #305fa1; font-size: 11px; }
.translation-note { font-size: 12px; color: #53677e; margin: 8px 0 16px; }
.translation-consent { display: flex; gap: 8px; align-items: start; line-height: 1.5; }
.translation-consent input { width: auto; margin: 3px 0 0; }
#translation-dialog { max-height: 90dvh; overflow: auto; }
#translation-status { font-size: 13px; }
body {
  background: radial-gradient(ellipse at 0% 5%, #c3d9f4 0, transparent 50%),
    radial-gradient(ellipse at 100% 90%, #ccdfda 0, transparent 48%), #edf0f6;
}
.app-shell { background: #ffffff45; }
.sidebar { background: #f3f7fc85; color: var(--ink); border-right: 1px solid #fff9; backdrop-filter: blur(28px) saturate(125%); }
.logo { color: #fff; background: linear-gradient(145deg, #608dde, #3766ae); border: 1px solid #ffffff80; box-shadow: inset 0 1px 1px #fff8, 0 5px 14px #30548622; }
.sidebar .nav-button { color: #586c86; border: 1px solid transparent; border-radius: 16px; }
.sidebar .nav-button:hover { background: #ffffff80; }
.sidebar .nav-button.selected { color: #245bac; background: #ffffffd9; border-color: #fff; box-shadow: 0 5px 18px #334d7010, inset 0 1px 0 #fff; }
.sidebar .nav-button b { background: #e3ebf7; color: #365a87; border-radius: 8px; }
.sidebar .profile { border-color: var(--border); color: var(--ink); }
.sidebar .profile small { color: var(--muted); }
.page-header, .thread-header { background: #ffffff85; backdrop-filter: blur(22px); border-color: var(--border); }
.page-header h1 { color: #263b57; font-weight: 650; letter-spacing: -.7px; }
.conversation-pane { background: #f9fbfde0; border-color: #fff9; }
.search-wrap { border: 0; padding-bottom: 12px; }
.search-wrap input { background: #e8edf3b0; border: 1px solid #ffffffc0; border-radius: 12px; color: var(--ink); }
.search-wrap select { background: transparent; color: #5b6e85; }
.chat-folders { border: 0; }
.chat-folders button { background: transparent; color: #60738c; font-size: 12px; font-weight: 600; }
.chat-folders button.selected { background: #e1eaf7; color: #295f9d; box-shadow: inset 0 1px 0 #fff9; }
.folder-tools { padding-top: 0; }
.folder-tools button { color: #476b9c; }
#messenger-tabs button { background: #ffffffb0; border-color: #fff; box-shadow: 0 2px 5px #334d7008; border-radius: 14px; }
#messenger-tabs button.selected { background: #405f88; box-shadow: inset 0 1px 0 #fff4, 0 5px 12px #334d7020; }
.list-options select { background: #ffffff80; border-color: #dfe6ee; border-radius: 9px; color: #53677e; }
.list-options label { color: #53677e; }
.conversation-list { padding: 4px 8px 12px; scrollbar-width: thin; scrollbar-color: #adbccf80 transparent; }
.conversation-item { background: transparent; border-bottom: 0; border-radius: 14px; margin: 3px 0; }
.conversation-item:hover { background: #fff9; }
.conversation-item.active { background: #e0eafb; box-shadow: inset 0 0 0 1px #c8d9f6; }
.conversation-item strong { font-size: 13px; color: #293c54; font-weight: 650; }
.conversation-item p { color: #66768c; }
.conversation-item time { color: #6d7e92; }
.unread-count { background: #3374c8; }
.avatar.messenger-badge { border: 1px solid #fff9; box-shadow: inset 0 1px 1px #fff5, 0 3px 7px #334d7010; }
.thread { background: radial-gradient(ellipse at 85% 8%, #dbe6f275, transparent 65%), #f4f7fb85; }
.empty-state h2 { color: #344c69; font-weight: 600; letter-spacing: -.5px; }
.empty-state p { color: #65758a; }
.empty-icon { color: #4773ac; background: linear-gradient(145deg, #fff9, #dde7f599); border: 1px solid #fffd; border-radius: 23px; box-shadow: inset 0 2px 0 #fff, 0 12px 28px #45648b12; }
.message { background: #fff; color: #26384e; border: 1px solid #e4eaf2; box-shadow: 0 2px 6px #334d7006; }
.message.out { background: #e1ebfb; border-color: #d4e2f7; }
.message small { color: #61758e; }
.composer { background: #ffffffd9; border: 1px solid #fff; border-radius: 20px; box-shadow: 0 8px 26px #36557810, inset 0 1px 0 #fff; backdrop-filter: blur(18px); }
.composer textarea { background: transparent; border-color: transparent; }
.primary { background: #386fc2; border-radius: 12px; box-shadow: inset 0 1px 0 #ffffff30, 0 3px 7px #3266ad18; }
.primary:hover { background: #2c5fae; }
.secondary { background: #ffffffb8; border-color: #dbe3ee; color: #425f83; border-radius: 12px; box-shadow: 0 2px 4px #334d7005; }
.secondary:hover { background: #fff; }
.channel-card, .user-card { border-color: #fff; background: var(--glass); border-radius: 20px; box-shadow: 0 8px 26px #36557808; }
dialog { background: #f9fbfff2; border: 1px solid #fff; border-radius: 24px; box-shadow: 0 30px 90px #263f6a30, inset 0 1px 0 #fff; backdrop-filter: blur(24px); color: var(--ink); }
dialog::backdrop { background: #31496630; backdrop-filter: blur(7px); }
input, select, textarea { color: var(--ink); border-color: #dce4ee; }
input:focus, textarea:focus, select:focus { border-color: #678dca; outline: 2px solid #4083e31f; }
button:focus-visible, a:focus-visible { outline: 3px solid #3075d8; outline-offset: 3px; }
#toast { background: #304c70ed; border: 1px solid #ffffff50; backdrop-filter: blur(20px); pointer-events: none; }
@media(min-width:761px) {
  body { padding: 14px; }
  .app-shell { height: calc(100dvh - 28px); border: 1px solid #ffffffc9; border-radius: 24px; overflow: hidden; box-shadow: 0 18px 65px #405c7d14, inset 0 1px 0 #fff; grid-template-columns: 96px minmax(0,1fr); }
  .sidebar { padding-top: 25px; }
  .sidebar .wordmark { margin-bottom: 30px; }
  .sidebar .nav-button { padding: 14px 3px; margin-bottom: 8px; }
  .login-screen { min-height: calc(100dvh - 28px); border-radius: 24px; overflow: hidden; }
}
@media(max-width:760px) {
  html, body { width: 100%; height: 100%; overflow: hidden; overscroll-behavior: none; }
  body { position: fixed; inset: 0; }
  .app-shell, .login-screen { height: var(--mobile-height, 100dvh); min-height: 0; overflow: hidden; }
  .app-shell { grid-template-columns: 62px minmax(0,1fr); padding-bottom: env(safe-area-inset-bottom); }
  .login-form-wrap { min-height: 0; height: 100%; overflow-y: auto; overscroll-behavior: contain; padding: max(20px, env(safe-area-inset-top)) 24px max(20px, env(safe-area-inset-bottom)); }
  .login-card input { font-size: 16px; }
  .conversation-list, .messages, .section-body { overscroll-behavior-y: contain; min-height: 0; }
  .sidebar { padding: 18px 5px; }
  .sidebar .nav-button { padding: 13px 10px; }
  .composer { border-radius: 16px; }
}
@media(prefers-reduced-transparency:reduce), (prefers-contrast:more) {
  .sidebar, .page-header, .thread-header, .conversation-pane, .composer, .channel-card, .user-card, dialog { background: #f9fbff; backdrop-filter: none; }
  .thread { background: #edf2f8; }
  :root { --muted: #435873; --border: #768aa5; }
}
@media(prefers-reduced-motion:reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
.sidebar nav { touch-action: none; user-select: none; -webkit-user-select: none; }
.sidebar .nav-button.reordering { box-shadow: 0 0 0 2px #386fc2; background: #dce9ff; transform: scale(1.06); }
#security-dialog { max-height: 85dvh; overflow-y: auto; }
.security-request { padding: 14px 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.security-request p, #security-note { font-size: 12px; margin: 5px 0; }
.security-request button { margin: 8px 6px 0 0; }
.message, .message-media, .message-media > div { min-width: 0; overflow-wrap: anywhere; }
.message-media audio { display: block; width: 260px; max-width: 100%; min-width: 0; margin: 7px 0; }
.message-media span, .message-media a { display: block; font-size: 12px; }
.attachment-choices { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
#inbox-options { display: none; }
.page-header .inbox-sections { display: flex; padding: 0; gap: 4px; overflow: visible; }
#messenger-tabs { grid-template-columns: repeat(auto-fit, minmax(78px, 1fr)); }
@media(max-width:760px) {
  .app-shell { grid-template-columns: 44px minmax(0, 1fr); padding-top: env(safe-area-inset-top); }
  .sidebar { padding: 10px 4px; overflow: hidden; }
  .sidebar .wordmark { margin: 0 auto 14px; }
  .sidebar .logo { width: 30px; height: 30px; font-size: 26px; border-radius: 10px; }
  .sidebar .nav-button { padding: 10px 4px; margin: 0 0 6px; gap: 0; border-radius: 11px; position: relative; min-height: 44px; }
  .sidebar .nav-button span { font-size: 19px; width: 22px; }
  #security-count:not([hidden]) { display: block; position: absolute; top: 0; right: 0; background: #d94545; color: white; padding: 1px 4px; }
  .page-header { height: 38px; padding: 3px 10px; gap: 6px; }
  .page-header .eyebrow, .page-header p { display: none; }
  .page-header h1 { font-size: 19px; letter-spacing: -.4px; }
  .page-header button { padding: 8px; min-height: 34px; }
  .page-header .inbox-sections button { min-height: 32px; padding: 6px 9px; font-size: 12px; }
  #new-chat { font-size: 11px; white-space: nowrap; }
  #messenger-tabs { order: -4; display: grid; grid-template-columns: repeat(auto-fit, minmax(76px, 1fr)); gap: 4px; padding: 3px 8px; overflow: visible; }
  #messenger-tabs button { min-width: 0; display: flex; align-items: center; justify-content: center; gap: 2px; font-size: 10px; border-radius: 8px; padding: 7px 3px; box-shadow: none; }
  #messenger-tabs .tab-unread { position: static; margin-left: 0; flex-shrink: 0; min-width: 15px; height: 15px; font-size: 9px; box-shadow: none; }
  .search-wrap { order: -3; padding: 3px 8px 5px; gap: 5px; flex-wrap: wrap; }
  .search-wrap input { flex: 1; min-width: 0; padding: 5px 8px; font-size: 16px; height: 32px; }
  #inbox-options { display: block; width: 32px; height: 32px; flex-shrink: 0; border-radius: 8px; background: #e8edf3b0; color: #476b9c; font-size: 19px; }
  .search-wrap select { display: none; width: 100%; font-size: 12px; padding: 4px 0; }
  .conversation-pane:not(.controls-open) .folder-tools, .conversation-pane:not(.controls-open) .list-options { display: none; }
  .controls-open .search-wrap select { display: block; }
  #custom-folders { order: -2; }
  .chat-folders { padding: 3px 8px; gap: 3px; }
  .chat-folders button { padding: 6px 8px; font-size: 11px; }
  #custom-folders:empty { display: none; }
  .folder-tools { padding: 0 8px; }
  .folder-tools button { padding: 4px 0; font-size: 10px; }
  .list-options { padding: 2px 8px 5px; }
  .list-options select { padding: 4px; }
  .conversation-list { padding: 2px 4px 8px; }
  .conversation-item { gap: 8px; padding: 9px 7px; margin: 1px 0; border-radius: 10px; }
  .conversation-item .avatar.messenger-badge { width: 30px; height: 30px; border-radius: 9px; font-size: 15px; }
  .conversation-item p { margin: 3px 0; }
  .conversation-meta { min-width: 34px; gap: 6px; }
  .section-body { padding: 10px; }
  .channel-card { padding: 14px; border-radius: 14px; }
  .thread { touch-action: pan-y; }
  .thread, .messages { overflow-x: hidden; overscroll-behavior-x: none; }
  .message { max-width: 100%; }
  .message-media { max-width: 100%; }
  .thread-header { flex-wrap: wrap; height: auto; min-height: 58px; padding: 6px; }
  .thread-header > div:not(.avatar) { flex: 1; min-width: 0; }
  .thread-header h2 { max-width: 100%; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .thread-header small { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .thread-header #pin-chat, .thread-header #archive-chat { font-size: 10px; padding: 5px 6px; }
  .app-shell, .login-screen { position: absolute; top: var(--mobile-top, 0px); left: 0; width: 100%; }
  #thread-content { min-height: 0; min-width: 0; overflow: hidden; }
  .thread-header, .composer { flex-shrink: 0; }
  .composer { display: grid; grid-template-columns: 34px 34px 34px 34px minmax(0,1fr); gap: 3px; margin: 0 6px 5px; padding: 5px; min-width: 0; }
  .composer textarea { grid-column: 1 / -1; grid-row: 1; width: 100%; min-width: 0; min-height: 44px; max-height: 100px; font-size: 16px; overflow-y: auto; }
  .composer #attachment-preview:not([hidden]) { grid-column: 1 / -1; grid-row: 1; max-height: 100px; overflow-y: auto; }
  .composer:has(#attachment-preview:not([hidden])) textarea { grid-row: 2; }
  .composer .icon-button { min-width: 34px; min-height: 34px; padding: 5px; }
  .composer #send { justify-self: end; min-height: 34px; padding: 6px 10px; }
  #toast { top: max(8px, env(safe-area-inset-top)); bottom: auto; font-size: 12px; padding: 10px 14px; }
}
