:root {
  color-scheme: light;
  --ink: #102a35;
  --muted: #69808a;
  --line: #d8e5e9;
  --canvas: #eef6f8;
  --surface: #ffffff;
  --surface-soft: #f5fafb;
  --accent: #087b9d;
  --accent-dark: #075f7b;
  --accent-soft: #d9f2f7;
  --mine: #d6f2ed;
  --danger: #b73b45;
  --shadow: 0 24px 70px rgba(9, 50, 64, .18);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { color: var(--ink); background: radial-gradient(circle at 12% 18%, #d1eef4 0, transparent 28%), linear-gradient(145deg, #f4fafb, #e5f1f4); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.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; }
.eyebrow { margin: 0 0 4px; color: var(--accent); font-size: .78rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }

.login-view { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(430px, 100%); padding: 42px; background: rgba(255,255,255,.93); border: 1px solid rgba(255,255,255,.8); border-radius: 28px; box-shadow: var(--shadow); backdrop-filter: blur(16px); }
.login-card h1 { margin: 0 0 28px; font-size: clamp(1.8rem, 6vw, 2.5rem); line-height: 1.05; }
.login-brand { width: 96px; margin: 0 0 4px; }
.login-logo { display: block; width: 96px; height: 96px; margin: 0 0 8px; border-radius: 22px; object-fit: contain; }
.login-brand-name { width: 96px; text-transform: none; letter-spacing: 0; }
.login-brand-letters { display: flex; width: 100%; align-items: baseline; justify-content: space-between; }
.login-form { display: grid; gap: 17px; }
.login-form label, .new-chat-panel label { display: grid; gap: 7px; font-size: .9rem; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 13px; color: var(--ink); background: var(--surface); outline: none; }
input, select { min-height: 48px; padding: 0 14px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(8,123,157,.13); }
.primary-button { min-height: 50px; border: 0; border-radius: 13px; color: white; background: linear-gradient(135deg, var(--accent), var(--accent-dark)); font-weight: 800; box-shadow: 0 8px 22px rgba(8,123,157,.22); }
.primary-button:hover { filter: brightness(.96); }.primary-button:disabled { opacity: .55; cursor: wait; }
.primary-button.small { min-height: 40px; padding: 0 18px; }
.form-error { min-height: 22px; margin: 0; color: var(--danger); font-size: .9rem; }

.app-shell { width: 100%; height: 100%; display: grid; grid-template-columns: minmax(300px, 370px) 1fr; background: var(--surface); }
.conversation-pane { min-width: 0; display: grid; grid-template-rows: auto auto auto auto 1fr; border-right: 1px solid var(--line); background: var(--surface); }
.app-header, .chat-header { min-height: 74px; display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.app-header { justify-content: space-between; }.app-header h1 { margin: 0; font-size: 1.7rem; }.header-actions { display: flex; align-items: center; gap: 9px; }
.icon-button { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 13px; color: var(--ink); background: var(--surface-soft); font-size: 1.3rem; }
.connection-state { padding: 6px 9px; border-radius: 99px; color: #14724f; background: #e0f6e9; font-size: .75rem; font-weight: 800; }
.connection-state.offline { color: #9b4047; background: #fde7e8; }
.account-line { display: flex; align-items: center; gap: 11px; padding: 15px 20px 8px; }.account-line div { min-width: 0; display: grid; }.account-line strong, .account-line small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }.account-line small { color: var(--muted); }
.avatar { flex: 0 0 auto; width: 43px; height: 43px; display: grid; place-items: center; border-radius: 15px; color: #fff; background: linear-gradient(145deg, #0a89aa, #0b617c); font-size: .86rem; font-weight: 900; letter-spacing: .02em; }
.conversation-tools { display: grid; grid-template-columns: 1fr auto; gap: 9px; padding: 12px 20px; }
.search-box { position: relative; }.search-box span { position: absolute; left: 13px; top: 9px; color: var(--muted); font-size: 1.35rem; }.search-box input { min-height: 43px; padding-left: 38px; background: var(--surface-soft); }
.new-chat-button, .text-button { border: 0; color: var(--accent-dark); background: transparent; font-weight: 800; }.new-chat-button { padding: 0 5px; }
.new-chat-panel { margin: 0 20px 10px; padding: 15px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-soft); }.new-chat-panel > div { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.conversation-list { min-height: 0; overflow-y: auto; padding: 3px 10px 18px; }
.chat-empty-copy { padding: 28px 16px; color: var(--muted); text-align: center; }
.conversation-item { width: 100%; display: grid; grid-template-columns: auto 1fr auto; gap: 11px; align-items: center; padding: 12px 10px; border: 0; border-radius: 17px; color: inherit; text-align: left; background: transparent; }
.conversation-item:hover { background: var(--surface-soft); }.conversation-item.active { background: var(--accent-soft); }
.conversation-copy { min-width: 0; display: grid; gap: 4px; }.conversation-row { display: flex; gap: 8px; justify-content: space-between; }.conversation-row strong, .conversation-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }.conversation-time, .conversation-preview { color: var(--muted); font-size: .78rem; }.unread-badge { min-width: 23px; height: 23px; display: grid; place-items: center; padding: 0 7px; border-radius: 99px; color: #fff; background: var(--accent); font-size: .72rem; font-weight: 900; }

.message-pane { min-width: 0; min-height: 0; background: linear-gradient(rgba(240,248,249,.9), rgba(240,248,249,.9)), radial-gradient(circle at 25% 25%, #a5dce8 1px, transparent 1.5px); background-size: auto, 22px 22px; }
.chat-empty { height: 100%; display: grid; place-content: center; justify-items: center; padding: 30px; text-align: center; }.chat-empty h2 { margin: 16px 0 4px; }.chat-empty p { margin: 0; color: var(--muted); }.empty-bubble { width: 78px; height: 78px; display: grid; place-items: center; border-radius: 28px; background: var(--surface); box-shadow: 0 14px 40px rgba(20,68,83,.12); font-size: 2rem; }
.active-chat { height: 100%; display: grid; grid-template-rows: auto 1fr auto auto auto; }
.chat-header { background: rgba(255,255,255,.94); backdrop-filter: blur(12px); }.chat-header div { min-width: 0; }.chat-header h2 { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1.08rem; }.chat-header small { color: var(--muted); }.refresh-button { margin-left: auto; }.mobile-back { display: none; font-size: 2rem; }
.message-list { min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 7px; padding: 22px clamp(14px, 4vw, 48px); }
.date-separator { align-self: center; margin: 8px 0; padding: 5px 10px; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); background: rgba(255,255,255,.86); font-size: .74rem; font-weight: 700; }
.message { align-self: flex-start; width: fit-content; max-width: min(75%, 680px); padding: 9px 11px 7px; border: 1px solid rgba(207,224,229,.9); border-radius: 6px 18px 18px 18px; background: var(--surface); box-shadow: 0 3px 10px rgba(26,67,79,.06); }
.message.mine { align-self: flex-end; border-color: #b9ded7; border-radius: 18px 6px 18px 18px; background: var(--mine); }.message.deleted { color: var(--muted); font-style: italic; }
.message-sender { margin-bottom: 4px; color: var(--accent-dark); font-size: .78rem; font-weight: 800; }.message.mine .message-sender { display: none; }
.message-body { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; line-height: 1.38; }
.message-meta { display: flex; justify-content: flex-end; align-items: center; gap: 6px; margin-top: 4px; color: var(--muted); font-size: .7rem; }.read-mark { color: var(--accent); font-weight: 900; }
.quoted-message { margin: 0 0 7px; padding: 6px 8px; border-left: 3px solid var(--accent); border-radius: 6px; color: var(--muted); background: rgba(255,255,255,.6); font-size: .78rem; }.quoted-message strong, .quoted-message span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-list { display: grid; gap: 6px; margin-top: 8px; }.attachment-card { max-width: 330px; display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: center; padding: 8px; border: 1px solid rgba(8,123,157,.2); border-radius: 12px; color: var(--accent-dark); background: rgba(255,255,255,.55); text-decoration: none; }.attachment-card img { grid-column: 1/-1; max-width: 100%; max-height: 260px; border-radius: 9px; object-fit: contain; }.attachment-card small { display: block; color: var(--muted); }
.reaction-row { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; }.reaction-button { padding: 3px 7px; border: 1px solid var(--line); border-radius: 99px; background: rgba(255,255,255,.8); font-size: .78rem; }.reaction-button.mine { border-color: var(--accent); background: var(--accent-soft); }
.message-actions { display: flex; gap: 4px; margin: 6px -3px -3px; opacity: .22; transition: opacity .15s; }.message:hover .message-actions, .message:focus-within .message-actions { opacity: 1; }.message-actions button { padding: 4px 6px; border: 0; border-radius: 7px; color: var(--muted); background: transparent; font-size: .72rem; }.message-actions button:hover { color: var(--accent-dark); background: rgba(255,255,255,.7); }
.composer-mode { display: flex; align-items: center; gap: 12px; margin: 0 clamp(12px, 3vw, 34px); padding: 8px 12px; border-left: 3px solid var(--accent); background: rgba(255,255,255,.94); }.composer-mode div { min-width: 0; display: grid; flex: 1; }.composer-mode strong { color: var(--accent-dark); font-size: .8rem; }.composer-mode span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: .78rem; }.composer-mode button { border: 0; background: transparent; font-size: 1.2rem; }
.attachment-tray { display: flex; gap: 7px; overflow-x: auto; padding: 8px clamp(12px, 3vw, 34px); background: rgba(255,255,255,.88); }.pending-attachment { flex: 0 0 auto; max-width: 230px; display: flex; align-items: center; gap: 7px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: .78rem; }.pending-attachment span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }.pending-attachment button { border: 0; background: transparent; }
.composer { display: grid; grid-template-columns: auto 1fr auto; gap: 9px; align-items: end; padding: 12px clamp(12px, 3vw, 34px) max(12px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgba(255,255,255,.96); }.composer textarea { min-height: 46px; max-height: 132px; resize: none; padding: 12px 14px; line-height: 1.35; }.attach-button, .send-button { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 15px; }.attach-button { position: relative; color: var(--accent-dark); background: var(--surface-soft); font-size: 1.7rem; font-weight: 300; cursor: pointer; }.attach-button input { position: absolute; width: 1px; height: 1px; opacity: 0; }.send-button { border: 0; color: #fff; background: linear-gradient(145deg, var(--accent), var(--accent-dark)); font-size: 1.15rem; }.send-button:disabled { opacity: .45; }
.toast { position: fixed; left: 50%; bottom: 28px; z-index: 20; transform: translateX(-50%); max-width: min(90vw, 520px); padding: 11px 16px; border-radius: 12px; color: white; background: #163844; box-shadow: var(--shadow); }

@media (max-width: 760px) {
  .app-shell { display: block; }.conversation-pane, .message-pane { width: 100%; height: 100%; }.message-pane { display: none; }.app-shell.chat-open .conversation-pane { display: none; }.app-shell.chat-open .message-pane { display: block; }.mobile-back { display: grid; }.message { max-width: 88%; }.message-actions { opacity: .7; }.account-line { padding-top: 10px; }.login-card { padding: 30px 24px; border-radius: 23px; }.app-header, .chat-header { padding-left: 14px; padding-right: 14px; }.conversation-tools { padding-left: 14px; padding-right: 14px; }.conversation-list { padding-left: 5px; padding-right: 5px; }
}

@media (prefers-color-scheme: dark) {
  :root { color-scheme: dark; --ink: #e8f4f6; --muted: #91aab2; --line: #29444c; --canvas: #10272e; --surface: #142f37; --surface-soft: #193a43; --accent: #2db4d4; --accent-dark: #62cbe2; --accent-soft: #183f49; --mine: #155046; --danger: #ff8c94; --shadow: 0 24px 70px rgba(0,0,0,.35); }
  body { background: radial-gradient(circle at 12% 18%, #164653 0, transparent 28%), linear-gradient(145deg, #10272e, #0c2026); }.login-card { background: rgba(20,47,55,.94); border-color: #31515a; }.message-pane { background: linear-gradient(rgba(14,36,43,.92), rgba(14,36,43,.92)), radial-gradient(circle at 25% 25%, #29505b 1px, transparent 1.5px); background-size: auto, 22px 22px; }.chat-header, .composer, .composer-mode, .attachment-tray { background: rgba(20,47,55,.96); }.message { border-color: #294850; }.quoted-message, .attachment-card { background: rgba(15,37,43,.65); }.connection-state { color: #82ddb7; background: #173f34; }.connection-state.offline { color: #ff9da3; background: #4b252a; }
}
