:root {
  color-scheme: dark;
  --background: #0d0d0d;
  --surface: #171717;
  --surface-strong: #222;
  --text: #f7f7f7;
  --muted: #9c9c9c;
  --line: #303030;
  --accent: #f3a9c7;
  --accent-contrast: #161014;
}

body[data-user="ANEXA"] { --accent: #6de4ed; --accent-contrast: #061416; }
body[data-theme="light"] {
  color-scheme: light;
  --background: #f1dcb7;
  --surface: #fff;
  --surface-strong: #ededed;
  --text: #111;
  --muted: #656565;
  --line: #dedede;
}
body[data-theme="light"][data-user="IRIS"] { --accent: #b64f79; --accent-contrast: #fff; }
body[data-theme="light"][data-user="ANEXA"] { --accent: #087f8b; --accent-contrast: #fff; }

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--background); }
body { color: var(--text); font: 15px/1.45 Arial, Helvetica, sans-serif; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.app-shell { min-height: 100dvh; }
.screen { min-height: 100dvh; }
.login-screen { display: grid; place-items: center; padding: 24px; }
.login-card { width: min(100%, 370px); text-align: center; }
.eyebrow { color: var(--muted); font-size: 10px; letter-spacing: .18em; margin: 0 0 14px; }
h1 { font-size: 22px; letter-spacing: .16em; margin: 0; }
.login-prompt { color: var(--muted); margin: 54px 0 18px; }
.user-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.user-option, .primary-button, .send-button {
  border: 1px solid var(--accent); background: transparent; color: var(--text);
  min-height: 48px; font-weight: 700; letter-spacing: .08em; transition: background .15s, color .15s;
}
.user-option:hover, .user-option.selected, .primary-button:hover, .send-button:hover {
  background: var(--accent); color: var(--accent-contrast);
}
#login-form { margin-top: 28px; text-align: left; }
label { color: var(--muted); display: block; font-size: 12px; margin-bottom: 8px; }
input, textarea { background: var(--surface); border: 1px solid var(--line); border-radius: 0; color: var(--text); outline: 0; }
input:focus, textarea:focus { border-color: var(--accent); }
input { min-height: 48px; padding: 0 14px; width: 100%; }
.password-field { position: relative; }
.password-field input { padding-right: 52px; }
.password-toggle {
  align-items: center; background: none; border: 0; color: var(--muted); display: flex;
  height: 48px; justify-content: center; position: absolute; right: 0; top: 0; width: 48px;
}
.password-toggle:hover, .password-toggle:focus-visible { color: var(--accent); }
.primary-button { margin-top: 18px; width: 100%; }
.form-error { color: var(--accent); min-height: 21px; margin: 8px 0 0; font-size: 12px; }
.chat-screen { display: flex; flex-direction: column; max-width: 860px; margin: 0 auto; height: 100dvh; }
.chat-header { align-items: center; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; padding: 18px 18px 14px; }
.chat-header .eyebrow { margin-bottom: 4px; }
.header-actions { align-items: center; display: flex; gap: 8px; }
.icon-button, .text-button { background: none; border: 0; color: var(--text); min-height: 40px; padding: 8px; }
.icon-button { border: 1px solid var(--line); font-size: 19px; width: 40px; }
.icon-button:hover, .text-button:hover { color: var(--accent); }
.text-button { color: var(--muted); font-size: 10px; letter-spacing: .08em; }
.call-panel { background: var(--surface); border-bottom: 1px solid var(--line); padding: 10px 18px; text-align: center; }
.call-panel p { margin: 0 0 8px; color: var(--muted); font-size: 12px; }
.call-actions { display: flex; justify-content: center; gap: 8px; }
.call-action { background: none; border: 1px solid var(--line); color: var(--text); min-height: 34px; padding: 6px 12px; font-size: 10px; letter-spacing: .08em; }
.call-action:hover, .call-action.accept { border-color: var(--accent); color: var(--accent); }
.call-action.reject:hover { border-color: #e77; color: #e77; }
.connection-status { color: var(--muted); font-size: 11px; min-height: 18px; padding: 8px 18px 0; }
.messages { display: flex; flex: 1; flex-direction: column; gap: 12px; min-height: 0; overflow-y: auto; padding: 20px 18px; }
.empty-state { color: var(--muted); margin: auto; text-align: center; }
.message { align-self: flex-start; max-width: min(82%, 560px); }
.message.focused .message-bubble { outline: 2px solid var(--accent); outline-offset: 3px; }
.message.mine { align-self: flex-end; }
.message-bubble { background: var(--surface); border-left: 2px solid var(--accent); padding: 10px 12px; overflow-wrap: anywhere; }
.mine .message-bubble { background: var(--accent); border-left: 0; color: var(--accent-contrast); }
.message-meta { align-items: baseline; color: var(--muted); display: flex; font-size: 10px; gap: 8px; margin-bottom: 5px; }
.mine .message-meta { justify-content: flex-end; }
.mine .message-meta, .mine .reply-action { color: color-mix(in srgb, var(--accent) 55%, var(--text)); }
.message-meta strong {
  background: var(--accent);
  color: #000;
  padding: 2px 5px;
}
.message-content { white-space: pre-wrap; }
.message-time { color: var(--muted); display: block; font-size: 10px; font-weight: 400; line-height: 1.2; margin-top: 8px; text-align: right; }
.mine .message-time { color: color-mix(in srgb, var(--accent-contrast) 65%, var(--accent)); }
.message-seen { color: inherit; display: block; font-size: 10px; margin-top: 3px; opacity: .8; text-align: right; }
.reply-quote { border-left: 2px solid currentColor; color: var(--muted); display: block; font-size: 12px; margin-bottom: 8px; padding-left: 8px; text-decoration: none; }
.reply-quote:hover { color: var(--accent); }
.mine .reply-quote { color: color-mix(in srgb, var(--accent-contrast) 65%, var(--accent)); }
.reply-action { background: none; border: 0; color: var(--muted); font-size: 11px; margin-top: 4px; padding: 5px 0; }
.reply-action:hover { color: var(--accent); }
.delete-action { background: none; border: 0; color: var(--muted); font-size: 11px; margin: 4px 0 0 8px; padding: 5px 0; }
.delete-action:hover { color: #d35f6f; }
.delete-dialog { align-items: center; background: rgba(0, 0, 0, .72); display: flex; inset: 0; justify-content: center; padding: 24px; position: fixed; z-index: 20; }
.delete-dialog-card { background: var(--surface); border: 1px solid var(--line); max-width: 300px; padding: 22px; text-align: center; width: 100%; }
.delete-dialog-card p { margin: 0 0 18px; }
.delete-dialog-actions { display: flex; gap: 10px; justify-content: center; }
.delete-dialog-actions button { min-width: 72px; text-transform: uppercase; }
.composer-wrap { background: var(--background); border-top: 1px solid var(--line); flex-shrink: 0; padding: 10px 18px calc(10px + env(safe-area-inset-bottom)); position: sticky; bottom: 0; }
.reply-preview { border-left: 2px solid var(--accent); color: var(--muted); font-size: 12px; margin-bottom: 8px; padding: 7px 10px; }
.reply-preview a { color: var(--text); text-decoration: none; }
.reply-preview a:hover { color: var(--accent); }
.cancel-reply { background: none; border: 0; color: var(--accent); float: right; padding: 0; }
.composer { align-items: flex-end; display: flex; gap: 8px; }
textarea { flex: 1; max-height: 140px; min-height: 46px; padding: 12px; resize: none; }
.emoji-button { background: none; border: 1px solid var(--line); color: var(--text); flex: 0 0 46px; min-height: 46px; padding: 0; }
.emoji-button:hover, .emoji-button[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }
.send-button { flex: 0 0 72px; min-height: 46px; }
.emoji-picker { background: var(--surface); border: 1px solid var(--line); margin-bottom: 8px; max-height: 240px; overflow-y: auto; padding: 8px; }
.emoji-search { box-sizing: border-box; margin-bottom: 8px; min-height: 36px; width: 100%; }
.emoji-grid, .recent-emojis { display: grid; gap: 4px; grid-template-columns: repeat(8, 1fr); }
.recent-emojis { border-bottom: 1px solid var(--line); margin-bottom: 8px; padding-bottom: 8px; }
.emoji-choice { background: none; border: 0; border-radius: 4px; color: var(--text); font-size: 22px; min-height: 38px; padding: 2px; }
.emoji-choice:hover, .emoji-choice:focus-visible { background: var(--surface-strong); }
.sr-only { height: 1px; margin: -1px; overflow: hidden; position: absolute; width: 1px; clip: rect(0, 0, 0, 0); }
[hidden] { display: none !important; }
@media (min-width: 700px) {
  .chat-header { padding-left: 28px; padding-right: 28px; }
  .messages, .composer-wrap, .connection-status { padding-left: 28px; padding-right: 28px; }
  .call-panel { padding-left: 28px; padding-right: 28px; }
}
