:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #6d7884;
  --line: #dbe1e7;
  --surface: #ffffff;
  --soft: #f3f6f8;
  --accent: #1769e0;
  --accent-dark: #0e4fac;
}

* { box-sizing: border-box; }
body { margin: 0; background: #eef2f5; color: var(--ink); font: 15px/1.5 Inter, "Segoe UI", sans-serif; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.sr-only { clip: rect(0, 0, 0, 0); clip-path: inset(50%); height: 1px; overflow: hidden; position: absolute; white-space: nowrap; width: 1px; }
.muted { color: var(--muted); }
.eyebrow { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .14em; margin: 0 0 4px; }
.brand-mark { align-items: center; background: var(--accent); border-radius: 8px; color: #fff; display: inline-flex; font-size: 16px; font-weight: 800; height: 42px; justify-content: center; width: 42px; }
.brand-mark.small { font-size: 12px; height: 28px; width: 28px; }
.auth-shell { align-items: center; display: flex; justify-content: center; min-height: 100vh; padding: 24px; }
.auth-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 18px 55px #1c2b3a18; max-width: 430px; padding: 38px; width: 100%; }
.auth-panel h1 { font-size: 28px; line-height: 1.15; margin: 10px 0 8px; }
.stack-form { display: grid; gap: 9px; margin-top: 28px; }
.stack-form label { color: #394650; font-size: 13px; font-weight: 650; margin-top: 7px; }
.stack-form input, .new-conversation-form input, .message-form textarea { background: #fff; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); outline: none; padding: 11px 12px; }
.stack-form input:focus, .new-conversation-form input:focus, .message-form textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #1769e01c; }
.primary-button, .secondary-button, .ghost-button, .icon-button { border: 0; border-radius: 6px; font-weight: 700; }
.primary-button { background: var(--accent); color: #fff; margin-top: 12px; padding: 11px 16px; }
.primary-button:hover { background: var(--accent-dark); }
.secondary-button { background: #e8f0ff; color: var(--accent-dark); padding: 9px 12px; }
.ghost-button { background: transparent; color: var(--muted); padding: 6px 8px; }
.icon-button { background: transparent; color: var(--muted); font-size: 24px; height: 34px; width: 34px; }
.alert, .field-error { color: #a53c36; font-size: 13px; }
.auth-footer { font-size: 13px; margin: 20px 0 0; text-align: center; }
.auth-footer a { color: var(--accent-dark); font-weight: 650; text-decoration: none; }
.app-shell { display: flex; flex-direction: column; min-height: 100vh; }
.topbar { align-items: center; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; min-height: 58px; padding: 0 22px; }
.brand-lockup, .topbar-actions { align-items: center; display: flex; gap: 10px; }
.topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
.brand-lockup { font-weight: 750; }
.user-chip { background: var(--soft); border-radius: 999px; color: #53616e; font-size: 13px; padding: 5px 10px; }
.device-dialog, .wide-dialog { border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 18px 55px #1c2b3a35; max-height: min(760px, calc(100vh - 32px)); min-width: min(420px, calc(100vw - 32px)); padding: 0; }
.wide-dialog { width: min(720px, calc(100vw - 32px)); }
.device-dialog::backdrop, .wide-dialog::backdrop { background: #17212b55; }
.dialog-heading { align-items: center; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; padding: 14px 18px; }
.dialog-heading h2 { font-size: 18px; margin: 0; }
.device-list { display: grid; gap: 4px; padding: 10px 14px 14px; }
.device-row { align-items: center; display: flex; justify-content: space-between; padding: 10px 4px; }
.device-row + .device-row { border-top: 1px solid var(--line); }
.device-row strong, .device-row small { display: block; }
.device-row small { color: var(--muted); font-size: 11px; margin-top: 2px; }
.dialog-content { display: grid; gap: 18px; max-height: calc(100vh - 150px); overflow: auto; padding: 18px; }
.dialog-content h3 { font-size: 14px; margin: 0 0 8px; }
.contacts-layout { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.contacts-layout section:last-child { grid-column: 1 / -1; }
.inline-form { align-items: center; display: flex; gap: 8px; }
.inline-form input, .inline-form select, .compact-form input { background: #fff; border: 1px solid var(--line); border-radius: 6px; min-width: 0; padding: 9px 10px; width: 100%; }
.inline-form select { color: var(--ink); }
.action-list { display: grid; gap: 4px; }
.action-row { align-items: center; border-bottom: 1px solid var(--line); display: flex; gap: 8px; justify-content: space-between; min-height: 48px; padding: 8px 2px; }
.action-row:last-child { border-bottom: 0; }
.action-row strong, .action-row small { display: block; }
.action-row small { color: var(--muted); font-size: 11px; }
.row-actions { align-items: center; display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.danger-button { background: #fff0ef; border: 0; border-radius: 6px; color: #a53c36; font-weight: 700; margin-top: 10px; padding: 9px 12px; }
.compact-form { margin: 0; }
.compact-form fieldset { border: 1px solid var(--line); border-radius: 6px; margin: 10px 0 0; padding: 12px; }
.compact-form legend { color: #394650; font-size: 13px; font-weight: 650; padding: 0 5px; }
.choice-list { display: grid; gap: 4px; max-height: 260px; overflow: auto; }
.choice-row { align-items: center; display: flex; gap: 9px; padding: 7px 3px; }
.choice-row input { width: auto; }
.workspace { display: flex; flex: 1; min-height: 0; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 22px 16px; width: 340px; }
.sidebar-heading, .conversation-header { align-items: center; display: flex; justify-content: space-between; }
.sidebar-heading h1, .conversation-header h2 { font-size: 22px; margin: 0; }
.new-conversation-form { display: flex; gap: 7px; margin: 18px 0 12px; }
.new-conversation-form input { min-width: 0; width: 100%; }
.conversation-list { display: grid; gap: 4px; margin-top: 16px; overflow: auto; }
.conversation-item { background: transparent; border: 0; border-radius: 6px; color: var(--ink); padding: 12px; text-align: left; }
.conversation-item:hover, .conversation-item.active { background: #edf3ff; }
.conversation-item strong { display: block; font-size: 14px; }
.conversation-item small { color: var(--muted); display: block; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-item-heading { align-items: center; display: flex; gap: 8px; justify-content: space-between; }
.unread-badge { align-items: center; background: #c93f37; border-radius: 999px; color: #fff; display: inline-flex; font-size: 11px; font-weight: 750; height: 20px; justify-content: center; min-width: 20px; padding: 0 6px; }
.chat-panel { display: flex; flex: 1; min-width: 0; }
.empty-state { align-self: center; margin: auto; max-width: 360px; text-align: center; }
.empty-icon { color: var(--accent); font-size: 42px; font-weight: 300; }
.empty-state h2 { font-size: 22px; margin: 6px 0; }
.conversation-view { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.conversation-header { background: var(--surface); border-bottom: 1px solid var(--line); padding: 18px 28px; }
.conversation-actions { align-items: center; display: flex; gap: 10px; }
.status-dot { color: var(--muted); font-size: 12px; }
.status-dot.online { color: #21854b; }
.message-list { display: flex; flex: 1; flex-direction: column; gap: 10px; overflow: auto; padding: 26px clamp(18px, 5vw, 70px); }
.message { align-self: flex-start; max-width: min(680px, 82%); }
.message.mine { align-self: flex-end; }
.message-bubble { background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 10px 13px; white-space: pre-wrap; word-break: break-word; }
.message.mine .message-bubble { background: #e8f0ff; border-color: #c7d9ff; }
.message-meta { color: var(--muted); font-size: 11px; margin: 3px 4px 0; }
.attachment-list { display: grid; gap: 6px; margin-top: 9px; }
.attachment-link { background: #f3f6f8; border: 1px solid var(--line); border-radius: 6px; color: var(--accent-dark); display: block; font-size: 13px; padding: 7px 9px; text-decoration: none; }
.attachment-link:hover { border-color: var(--accent); }
.attachment-link span { color: var(--muted); float: right; font-size: 11px; margin-left: 14px; }
.message-form { align-items: flex-end; background: var(--surface); border-top: 1px solid var(--line); display: flex; gap: 10px; padding: 16px 28px 20px; }
.message-form textarea { max-height: 150px; min-height: 44px; resize: vertical; width: 100%; }
.file-button { align-items: center; background: var(--soft); border: 1px solid var(--line); border-radius: 6px; color: var(--muted); cursor: pointer; display: inline-flex; font-size: 22px; height: 44px; justify-content: center; width: 44px; }
.file-button:hover { border-color: var(--accent); color: var(--accent); }
.selected-files { align-items: center; display: flex; flex-wrap: wrap; gap: 4px; max-width: 260px; }
.selected-file { background: #edf3ff; border-radius: 5px; color: var(--accent-dark); font-size: 11px; max-width: 170px; overflow: hidden; padding: 5px 7px; text-overflow: ellipsis; white-space: nowrap; }
.selected-file small { color: var(--muted); }
.send-button { margin: 0; }
@media (max-width: 720px) { .sidebar { width: 100%; } .workspace { flex-direction: column; } .chat-panel { min-height: 62vh; } .conversation-list { max-height: 180px; } .topbar { gap: 8px; min-height: 58px; padding: 8px 14px; } .topbar-actions { gap: 2px; } .topbar-actions .ghost-button { font-size: 12px; padding: 5px; } .user-chip { display: none; } .conversation-header, .message-form { padding-left: 16px; padding-right: 16px; } .contacts-layout { grid-template-columns: 1fr; } .contacts-layout section:last-child { grid-column: auto; } }
