:root {
  --green-950: #09072f;
  --green-900: #0e0b49;
  --green-800: #17125a;
  --green-700: #241e78;
  --green-600: #d8331d;
  --green-500: #f0442c;
  --green-100: #faddd7;
  --green-50: #fff4f2;
  --ink: #18152f;
  --muted: #6d6a82;
  --line: #e1e0ea;
  --surface: #ffffff;
  --canvas: #f4f3f8;
  --danger: #b3261e;
  --shadow: 0 18px 50px rgba(14, 11, 73, .18);
  font-family: Inter, ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: #e7e6ef;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { overflow: hidden; }
button, input, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
.is-hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.workspace { width: min(100%, 1180px); height: 100dvh; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); overflow: hidden; background: var(--surface); box-shadow: 0 0 70px rgba(14,11,73,.14); }
.chat-app { min-width: 0; height: 100%; display: grid; grid-template-rows: auto auto minmax(0,1fr) auto auto auto; position: relative; overflow: hidden; background: var(--canvas); }

.topbar { min-height: 74px; padding: calc(10px + env(safe-area-inset-top)) 14px 10px; display: flex; align-items: center; gap: 10px; color: white; background: linear-gradient(135deg, var(--green-950), var(--green-700)); z-index: 6; box-shadow: 0 3px 18px rgba(14,11,73,.28); }
.group-avatar { position: relative; flex: 0 0 46px; width: 46px; height: 46px; padding: 0; overflow: visible; border: 1px solid rgba(255,255,255,.15); border-radius: 15px; cursor: pointer; background: rgba(255,255,255,.12); }
.group-avatar img { width: 100%; height: 100%; border-radius: 14px; }
.presence-pip { position: absolute; right: -1px; bottom: -1px; width: 13px; height: 13px; border: 3px solid var(--green-900); border-radius: 50%; background: #8da19d; }
.presence-pip.online { background: #5ee6a8; }
.channel-info { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; padding: 0; border: 0; cursor: pointer; color: white; background: transparent; text-align: left; }
.channel-kicker { margin-bottom: 2px; color: #ff8a75; font-size: 8px; font-weight: 900; letter-spacing: 1.35px; }
.channel-info strong { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; letter-spacing: -.15px; }
.channel-info > span:last-child { max-width: 100%; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #d5d2f0; font-size: 11px; }
.top-action, .profile-avatar { flex: 0 0 39px; width: 39px; height: 39px; border: 0; border-radius: 13px; cursor: pointer; display: grid; place-items: center; }
.top-action { color: white; background: transparent; }
.top-action:hover { background: rgba(255,255,255,.1); }
.top-action svg { width: 21px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.profile-avatar { color: var(--green-900); background: #faddd7; font-weight: 850; }

.search-panel { min-height: 52px; display: flex; align-items: center; gap: 8px; padding: 7px 12px; border-bottom: 1px solid var(--line); background: white; z-index: 5; animation: panel-down .16s ease-out; }
.search-panel > svg { width: 19px; fill: none; stroke: var(--muted); stroke-width: 2; }
.search-panel input { flex: 1; min-width: 0; padding: 8px 4px; border: 0; outline: 0; color: var(--ink); background: transparent; }
.search-panel span { color: var(--muted); font-size: 11px; white-space: nowrap; }
.search-panel button { width: 34px; height: 34px; border: 0; border-radius: 50%; cursor: pointer; color: var(--muted); background: #f0eff5; font-size: 21px; }

.messages { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 20px max(13px, calc((100% - 720px)/2)) 16px; scroll-behavior: smooth; background-color: var(--canvas); background-image: radial-gradient(circle at 15px 15px, rgba(14,11,73,.05) 1.5px, transparent 1.6px); background-size: 30px 30px; }
.welcome-card { max-width: 410px; margin: 8px auto 26px; padding: 23px 22px; border: 1px solid #e1e0ea; border-radius: 22px; text-align: center; background: rgba(255,255,255,.88); backdrop-filter: blur(10px); box-shadow: 0 9px 26px rgba(14,11,73,.08); }
.welcome-card img { width: 56px; height: 56px; border-radius: 18px; box-shadow: 0 8px 18px rgba(14,11,73,.2); }
.eyebrow { margin: 13px 0 5px; color: var(--green-600); font-size: 9px; font-weight: 900; letter-spacing: 1.6px; }
.welcome-card h1 { margin: 0 0 7px; font-size: 20px; letter-spacing: -.35px; }
.welcome-card > p:not(.eyebrow) { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.welcome-card > span { display: inline-block; margin-top: 14px; padding: 6px 10px; border-radius: 99px; color: var(--green-800); background: #eeecf8; font-size: 9px; font-weight: 700; }
.day-chip { width: max-content; margin: 10px auto 15px; border-radius: 99px; padding: 6px 11px; color: var(--muted); background: rgba(255,255,255,.92); box-shadow: 0 2px 8px rgba(14,11,73,.08); font-size: 9px; font-weight: 850; letter-spacing: .8px; }
.message-row { position: relative; display: flex; align-items: center; margin: 4px 0; animation: message-in .2s ease-out; }
.message-row.own { justify-content: flex-end; }
.message-row.grouped { margin-top: 1px; }
.message-row.filtered-out { display: none; }
.bubble { max-width: min(82%, 500px); padding: 8px 10px 6px; border: 1px solid rgba(14,11,73,.05); border-radius: 6px 17px 17px 17px; overflow: hidden; background: white; box-shadow: 0 2px 5px rgba(14,11,73,.09); }
.own .bubble { border-radius: 17px 6px 17px 17px; background: #fbe7e3; }
.sender-line { display: flex; align-items: center; gap: 6px; margin: 0 0 4px; }
.sender-avatar { width: 19px; height: 19px; display: grid; place-items: center; border-radius: 7px; color: white; font-size: 8px; font-weight: 900; }
.sender-name { color: var(--green-600); font-size: 11px; font-weight: 850; }
.own .sender-line, .grouped .sender-line { display: none; }
.message-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.4; font-size: 14.5px; }
.media-bubble { padding: 4px 4px 5px; max-width: min(86%, 420px); }
.media-bubble .sender-line { padding: 5px 6px 1px; }
.media-bubble img, .media-bubble video { display: block; width: 100%; max-height: 450px; border-radius: 13px; object-fit: cover; background: #e3e1ec; }
.media-bubble img { cursor: zoom-in; }
.media-bubble video { object-fit: contain; }
.media-bubble > .message-text { padding: 7px 7px 2px; }
.reply-quote { width: 100%; margin: 0 0 7px; padding: 7px 9px; border: 0; border-left: 3px solid var(--green-500); border-radius: 8px; cursor: pointer; text-align: left; color: inherit; background: rgba(216,51,29,.09); }
.reply-quote strong, .reply-quote span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-quote strong { color: var(--green-800); font-size: 10px; }
.reply-quote span { margin-top: 2px; color: var(--muted); font-size: 10px; }
.message-meta { display: flex; justify-content: flex-end; align-items: center; gap: 3px; margin-top: 2px; color: #77748a; font-size: 9px; }
.checkmark { color: var(--green-600); font-size: 11px; font-weight: 800; }
.message-action { width: 31px; height: 31px; margin: 0 6px; border: 0; border-radius: 50%; opacity: 0; cursor: pointer; display: grid; place-items: center; color: var(--muted); background: rgba(255,255,255,.9); box-shadow: 0 2px 8px rgba(14,11,73,.1); transition: opacity .15s, transform .15s; }
.message-action svg { width: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.message-row:hover .message-action, .message-action:focus-visible { opacity: 1; }
.message-action:active { transform: scale(.92); }
.message-row.highlight .bubble { outline: 3px solid rgba(216,51,29,.25); }
.empty-search { margin: 50px auto; padding: 12px 16px; width: max-content; max-width: 90%; border-radius: 13px; color: var(--muted); background: white; font-size: 12px; }

.jump-latest { position: absolute; right: 18px; bottom: 92px; z-index: 5; width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 50%; cursor: pointer; display: grid; place-items: center; color: var(--green-800); background: white; box-shadow: 0 8px 20px rgba(14,11,73,.16); }
.jump-latest svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 2.3; }
.jump-latest span { position: absolute; right: -4px; top: -5px; min-width: 19px; height: 19px; padding: 0 5px; display: grid; place-items: center; border: 2px solid white; border-radius: 99px; color: white; background: var(--green-600); font-size: 9px; font-weight: 800; }
.typing-line { min-height: 20px; padding: 3px 22px 0; color: var(--green-600); background: #f8f7fb; font-size: 10px; font-style: italic; }
.reply-composer { min-height: 54px; display: flex; align-items: center; gap: 9px; padding: 7px 13px; border-top: 1px solid var(--line); background: #f8f7fb; }
.reply-accent { width: 3px; align-self: stretch; border-radius: 99px; background: var(--green-500); }
.reply-composer div { flex: 1; min-width: 0; }
.reply-composer strong, .reply-composer p { display: block; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-composer strong { color: var(--green-700); font-size: 11px; }
.reply-composer p { margin-top: 2px; color: var(--muted); font-size: 10px; }
.reply-composer button { width: 32px; height: 32px; border: 0; border-radius: 50%; cursor: pointer; color: var(--muted); background: #ebe9f2; font-size: 20px; }
.composer { display: flex; align-items: flex-end; gap: 8px; padding: 8px 11px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: #f8f7fb; }
.composer-action, .send-button { flex: 0 0 43px; width: 43px; height: 43px; border: 0; border-radius: 15px; cursor: pointer; display: grid; place-items: center; }
.composer-action { color: var(--green-800); background: #eeecf8; }
.composer-action svg, .send-button svg { width: 21px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.message-field { flex: 1; min-width: 0; display: flex; border: 1px solid #dad8e5; border-radius: 17px; background: white; box-shadow: 0 2px 8px rgba(14,11,73,.04); }
.message-field:focus-within { border-color: #f08a78; box-shadow: 0 0 0 3px rgba(216,51,29,.1); }
.message-field textarea { width: 100%; max-height: 120px; resize: none; overflow-y: auto; border: 0; outline: 0; padding: 11px 13px; background: transparent; color: var(--ink); line-height: 20px; }
.message-field textarea::placeholder { color: #9491a5; }
.send-button { color: white; background: linear-gradient(135deg, var(--green-800), var(--green-600)); box-shadow: 0 5px 15px rgba(216,51,29,.24); transition: transform .15s, opacity .15s; }
.send-button:active { transform: scale(.94); }
.send-button:disabled { opacity: .38; cursor: default; box-shadow: none; }

.details-panel { position: fixed; inset: 0 0 0 auto; z-index: 15; width: min(88%, 350px); padding: calc(30px + env(safe-area-inset-top)) 25px 30px; overflow-y: auto; text-align: center; background: white; box-shadow: -18px 0 50px rgba(14,11,73,.2); transform: translateX(102%); transition: transform .23s ease; }
.details-panel.open { transform: translateX(0); }
.details-panel::before { content: ""; position: fixed; inset: 0; pointer-events: none; }
.mobile-close { position: absolute; top: calc(13px + env(safe-area-inset-top)); right: 14px; width: 37px; height: 37px; border: 0; border-radius: 50%; cursor: pointer; color: var(--muted); background: #efedf5; font-size: 23px; }
.details-logo { width: 76px; height: 76px; margin-top: 10px; border-radius: 24px; box-shadow: 0 10px 24px rgba(14,11,73,.22); }
.details-panel h2 { margin: 14px 0 4px; font-size: 20px; }
.details-status { margin: 0; color: var(--muted); font-size: 11px; }
.details-status span { display: inline-block; width: 7px; height: 7px; margin-right: 4px; border-radius: 50%; background: #53d69b; }
.details-status span.offline { background: #f58b7c; }
.details-stats { margin: 23px 0; display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.details-stats div { padding: 13px 8px; display: flex; flex-direction: column; }
.details-stats div + div { border-left: 1px solid var(--line); }
.details-stats strong { color: var(--green-800); font-size: 15px; }
.details-stats span { margin-top: 3px; color: var(--muted); font-size: 9px; }
.details-section { padding: 17px 0; border-top: 1px solid var(--line); text-align: left; }
.details-section h3 { margin: 0 0 12px; color: #4f4b67; font-size: 10px; letter-spacing: .9px; text-transform: uppercase; }
.details-section ul { margin: 0; padding: 0; list-style: none; }
.details-section li { display: flex; align-items: center; gap: 10px; margin: 12px 0; }
.feature-icon { width: 34px; height: 34px; flex: 0 0 34px; display: grid; place-items: center; border-radius: 11px; color: var(--green-800); background: var(--green-50); }
.details-section li div { display: flex; flex-direction: column; }
.details-section li strong { font-size: 11px; }
.details-section li small { margin-top: 2px; color: var(--muted); font-size: 9px; }
.safety-note p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.55; }
.secondary-button { width: 100%; padding: 11px; border: 1px solid #d6d2ea; border-radius: 13px; cursor: pointer; color: var(--green-800); background: #f1eff9; font-size: 11px; font-weight: 800; }
.admin-button { margin-bottom: 9px; color: white; border-color: var(--green-800); background: var(--green-800); }

.modal-backdrop { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 20px; background: rgba(9,7,47,.68); backdrop-filter: blur(8px); }
.modal-card { width: min(100%, 430px); padding: 28px; border-radius: 26px; background: white; box-shadow: var(--shadow); animation: modal-in .24s ease-out; }
.name-card, .access-card, .admin-login-card { text-align: center; }
.large-logo { width: 74px; height: 74px; margin: -66px auto 18px; overflow: hidden; border-radius: 24px; box-shadow: 0 10px 25px rgba(14,11,73,.25); }
.large-logo img { width: 100%; height: 100%; }
.modal-card h2 { margin: 0 0 8px; font-size: 23px; letter-spacing: -.45px; }
.modal-card > p:not(.eyebrow):not(.file-meta):not(.upload-progress):not(.limit-note) { color: var(--muted); font-size: 12px; line-height: 1.5; }
.text-label { display: block; margin: 17px 0 7px; text-align: left; color: #4a4661; font-size: 11px; font-weight: 750; }
.modal-card input { width: 100%; padding: 12px 13px; border: 1px solid #d8d5e2; outline: 0; border-radius: 13px; background: #fcfbfd; }
.modal-card input:focus { border-color: var(--green-500); box-shadow: 0 0 0 3px rgba(216,51,29,.1); }
.password-field { position: relative; }
.password-field input { padding-right: 58px; }
.password-field button { position: absolute; top: 5px; right: 5px; height: calc(100% - 10px); padding: 0 11px; border: 0; border-radius: 9px; cursor: pointer; color: var(--green-800); background: var(--green-50); font-size: 10px; font-weight: 800; }
.form-error { min-height: 17px; margin: 6px 2px -7px; color: var(--danger); text-align: left; font-size: 10px; }
.primary-button { width: 100%; margin-top: 14px; padding: 13px; border: 0; border-radius: 14px; cursor: pointer; color: white; background: linear-gradient(135deg, var(--green-800), var(--green-600)); box-shadow: 0 7px 18px rgba(216,51,29,.2); font-weight: 800; }
.primary-button:disabled { opacity: .55; cursor: wait; }
.modal-cancel { margin-top: 9px; }
.privacy-note { display: block; margin-top: 20px; color: #88849a; font-size: 9px; }
.logout-button { width: 100%; margin-top: 9px; padding: 10px; border: 0; border-radius: 12px; cursor: pointer; color: #9b2c24; background: #fff1f0; font-size: 10px; font-weight: 750; }
.update-backdrop { z-index: 60; }
.update-card { max-width: 390px; border-top-color: var(--green-600); }
.update-card h2 { color: var(--green-900); }
.version-comparison { margin: 20px 0 4px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.version-comparison span { padding: 10px 7px; border: 1px solid var(--line); border-radius: 12px; color: var(--muted); background: var(--canvas); font-size: 9px; }
.version-comparison strong { display: block; margin-top: 4px; color: var(--green-900); font-size: 15px; }
.update-download { display: block; text-decoration: none; }
.copy-update-link { margin-top: 9px; }
.notification-settings p { margin: 0 0 12px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.notification-button { width: 100%; padding: 10px 12px; border: 0; border-radius: 12px; cursor: pointer; color: white; background: var(--green-700); font-size: 10px; font-weight: 800; }
.notification-button.enabled { color: var(--green-900); background: var(--green-100); }
.notification-button:disabled { cursor: default; opacity: .7; }
.sheet-backdrop { align-items: end; padding: 0; }
.attach-card, .upload-card, .groups-card { width: min(100%, 720px); padding: 10px 19px calc(20px + env(safe-area-inset-bottom)); border-radius: 26px 26px 0 0; }
.sheet-handle { width: 42px; height: 4px; margin: 0 auto 16px; border-radius: 99px; background: #d6d3df; }
.sheet-heading { display: flex; align-items: center; justify-content: space-between; }
.sheet-heading .eyebrow { margin-top: 0; }
.sheet-heading h2 { margin: 0; font-size: 19px; }
.close-button { width: 37px; height: 37px; border: 0; border-radius: 50%; cursor: pointer; color: #5f5b73; background: #efedf5; font-size: 24px; }
.attach-options { margin: 18px 0 10px; display: grid; gap: 9px; }
.groups-list { max-height: min(52vh, 430px); margin: 18px 0 10px; overflow-y: auto; display: grid; gap: 8px; }
.group-option { width: 100%; padding: 12px; display: flex; align-items: center; gap: 11px; border: 1px solid var(--line); border-radius: 16px; cursor: pointer; text-align: left; color: var(--ink); background: #fcfbfd; }
.group-option.active { border-color: var(--green-500); background: var(--green-50); box-shadow: 0 0 0 2px rgba(216,51,29,.08); }
.group-option-icon { width: 42px; height: 42px; flex: 0 0 42px; display: grid; place-items: center; border-radius: 14px; color: white; background: linear-gradient(135deg, var(--green-800), var(--green-600)); font-size: 16px; font-weight: 900; }
.group-option-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.group-option-copy strong, .group-option-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-option-copy strong { font-size: 12px; }
.group-option-copy small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.group-option-check { color: var(--green-600); font-size: 18px; font-weight: 900; }
.create-group-toggle { margin-top: 10px; }
.create-group-form { padding-top: 5px; }
.create-group-form .text-label { margin-top: 12px; }
.attach-options button { width: 100%; padding: 11px; display: flex; align-items: center; gap: 11px; border: 1px solid var(--line); border-radius: 15px; cursor: pointer; text-align: left; color: var(--ink); background: #fcfbfd; }
.attach-options button > span:nth-child(2) { flex: 1; display: flex; flex-direction: column; }
.attach-options strong { font-size: 12px; }
.attach-options small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.attach-options b { color: #9692a6; font-size: 24px; font-weight: 400; }
.option-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; font-weight: 900; }
.gallery-icon { color: #4f46e5; background: #eeecff; }
.camera-icon { color: var(--green-800); background: var(--green-100); }
.limit-note { margin: 12px 0 0; color: var(--muted); text-align: center; font-size: 9px; }
.media-preview { min-height: 150px; max-height: 35vh; margin-top: 14px; display: grid; place-items: center; overflow: hidden; border-radius: 17px; background: #eceaf1; }
.media-preview img, .media-preview video { display: block; width: 100%; max-height: 35vh; object-fit: contain; }
.file-meta { margin: 8px 2px 0; color: var(--muted); font-size: 10px; }
.upload-progress { min-height: 18px; margin: 7px 0 0; color: var(--green-600); text-align: center; font-size: 10px; }
.progress-track { width: 100%; height: 5px; margin-top: 12px; overflow: hidden; border-radius: 99px; background: #e2e0e9; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--green-500), var(--green-800)); transition: width .15s; }
.lightbox { position: fixed; inset: 0; z-index: 40; padding: 60px 18px 25px; display: grid; grid-template-rows: minmax(0,1fr) auto; place-items: center; background: rgba(5,4,28,.95); }
.lightbox button { position: absolute; top: calc(14px + env(safe-area-inset-top)); right: 17px; width: 40px; height: 40px; border: 0; border-radius: 50%; cursor: pointer; color: white; background: rgba(255,255,255,.12); font-size: 28px; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; }
.lightbox p { margin: 12px 0 0; color: white; font-size: 12px; }
.toast { position: fixed; z-index: 50; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom)); max-width: calc(100% - 32px); padding: 10px 15px; border-radius: 12px; opacity: 0; pointer-events: none; transform: translate(-50%,20px); color: white; background: #18152f; box-shadow: var(--shadow); font-size: 11px; transition: .25s; }
.toast.show { opacity: 1; transform: translate(-50%,0); }
.toast.error { background: var(--danger); }

@keyframes message-in { from { opacity: 0; transform: translateY(5px) scale(.985); } }
@keyframes modal-in { from { opacity: 0; transform: translateY(16px) scale(.98); } }
@keyframes panel-down { from { opacity: 0; transform: translateY(-5px); } }

@media (min-width: 820px) {
  body { padding: 18px; }
  .workspace { height: calc(100dvh - 36px); border-radius: 24px; }
  .chat-app { border-radius: 24px; }
  .sheet-backdrop { align-items: center; padding: 20px; }
  .attach-card, .upload-card, .groups-card { max-width: 520px; border-radius: 26px; }
}

@media (min-width: 1020px) {
  .workspace { grid-template-columns: minmax(0,1fr) 320px; }
  .chat-app { border-radius: 24px 0 0 24px; }
  .details-panel { position: relative; inset: auto; z-index: 1; width: auto; height: 100%; padding-top: 30px; border-left: 1px solid var(--line); box-shadow: none; transform: none; }
  .mobile-close { display: none; }
  #detailsButton, #channelInfoButton { cursor: default; }
  .message-action { opacity: 0; }
}

@media (hover: none) { .message-action { opacity: .8; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; } }
