/* Signal Messenger — style reference */
:root {
  --color-signal-blue: #2c6bed;
  --color-deep-signal: #2942ff;
  --color-signal-sky: #9dbbf8;
  --color-signal-mist: #a5cad5;
  --color-ink: #1b1b1b;
  --color-slate: #404654;
  --color-twilight: #3c3744;
  --color-fog: #e9e9e9;
  --color-paper: #f6f6f6;
  --color-white: #ffffff;
  --color-danger: #c0392b;

  --font-inter: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  --radius-btn: 8px;
  --radius-panel: 16px;
  --shadow-md: rgba(0, 0, 0, 0.12) 0px 4px 12px 0px, rgba(0, 0, 0, 0.08) 0px 0px 2px 0px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font-inter);
  font-size: 16px;
  line-height: 1.5;
  color: var(--color-ink);
  background: var(--color-paper);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--color-slate); word-break: break-all; }

/* ── Screens ─────────────────────────────────────────── */
.screen { height: 100%; }

#screen-app { display: grid; grid-template-columns: 320px 1fr; }

/* ── Hero / auth ─────────────────────────────────────── */
#screen-login {
  position: relative;
  background: var(--color-signal-sky);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.halftone {
  position: absolute; inset: 0;
  background-image: radial-gradient(var(--color-signal-blue) 1.5px, transparent 1.6px);
  background-size: 22px 22px;
  opacity: 0.16;
  pointer-events: none;
}

.hero { position: relative; width: 100%; max-width: 1200px; padding: 64px 32px; }

.hero-inner { max-width: 560px; }

.brand-lockup { display: flex; align-items: center; gap: 12px; margin-bottom: 48px; }

.brand-mark { width: 28px; height: 28px; color: var(--color-deep-signal); }

.brand-word { font-weight: 600; font-size: 20px; line-height: 1.4; color: var(--color-ink); }

.brand-lockup-sm .brand-mark { width: 22px; height: 22px; }
.brand-lockup-sm { margin-bottom: 0; }

.display {
  font-weight: 800;
  font-size: 60px;
  line-height: 1.07;
  color: var(--color-ink);
  letter-spacing: -0.02em;
}

.hero-body {
  margin-top: 24px;
  font-weight: 400;
  font-size: 16px;
  line-height: 1.5;
  color: var(--color-slate);
  max-width: 480px;
}

.auth-form { margin-top: 40px; display: flex; flex-direction: column; gap: 16px; max-width: 360px; }

.hero-note { margin-top: 20px; font-size: 14px; color: var(--color-slate); }

/* ── Inputs / buttons ────────────────────────────────── */
.input {
  font: inherit;
  font-size: 16px;
  color: var(--color-ink);
  background: var(--color-white);
  border: 1px solid var(--color-fog);
  border-radius: var(--radius-btn);
  padding: 12px 16px;
  outline: none;
  width: 100%;
  transition: border-color 0.15s ease;
}

.input:focus { border-color: var(--color-signal-blue); }

textarea.input { resize: vertical; }

.btn {
  font: inherit;
  font-weight: 600;
  font-size: 16px;
  border-radius: var(--radius-btn);
  padding: 12px 24px;
  cursor: pointer;
  border: 1.5px solid transparent;
  background: transparent;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-outline { border-color: var(--color-signal-blue); color: var(--color-signal-blue); background: var(--color-white); }
.btn-outline:hover { background: rgba(44, 107, 237, 0.06); }

.btn-lg { padding: 14px 32px; font-size: 16px; }

.btn-sm { padding: 8px 16px; font-size: 14px; }
.btn-xs { padding: 5px 12px; font-size: 13px; }

.btn-ghost { color: var(--color-slate); }
.btn-ghost:hover { color: var(--color-ink); }

.btn-danger { background: var(--color-danger); border-color: var(--color-danger); color: var(--color-white); }
.danger-text { color: var(--color-danger) !important; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border-radius: var(--radius-btn);
  border: 1.5px solid transparent;
  background: transparent; color: var(--color-deep-signal);
  cursor: pointer;
  transition: background 0.15s ease;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background: var(--color-paper); }

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--color-white);
  border-right: 1px solid var(--color-fog);
  min-height: 0;
}

.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--color-fog);
}

.sidebar-actions { display: flex; gap: 6px; }

.sidebar-foot { border-top: 1px solid var(--color-fog); padding: 10px 14px; }

.device-chip { display: flex; align-items: center; gap: 10px; }
.device-chip-name { flex: 1; font-size: 14px; color: var(--color-slate); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.presence-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--color-fog); flex: none; }
.presence-dot.online { background: #2ecc71; }
.presence-dot.away { background: var(--color-signal-blue); }

.room-list { list-style: none; overflow-y: auto; flex: 1; padding: 8px; }

.room-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-panel);
  cursor: pointer;
  transition: background 0.12s ease;
}
.room-item:hover { background: var(--color-paper); }
.room-item.active { background: rgba(44, 107, 237, 0.08); }

.avatar {
  width: 42px; height: 42px; flex: none;
  border-radius: 50%;
  background: var(--color-signal-sky);
  color: var(--color-deep-signal);
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}

.room-item-body { flex: 1; min-width: 0; }
.room-item-name { font-weight: 600; font-size: 15px; color: var(--color-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-item-meta { font-size: 13px; color: var(--color-slate); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.room-item-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.room-item-time { font-size: 11px; color: var(--color-slate); }
.unread-badge {
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px;
  background: var(--color-signal-blue); color: var(--color-white);
  font-size: 12px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}

.empty-rooms { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 32px; text-align: center; }
.empty-title { font-weight: 800; font-size: 20px; line-height: 1.38; color: var(--color-ink); }
.empty-sub { font-size: 14px; color: var(--color-slate); }

/* ── Thread ──────────────────────────────────────────── */
.thread { display: flex; flex-direction: column; min-height: 0; background: var(--color-paper); position: relative; }

.thread-head {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--color-white);
  border-bottom: 1px solid var(--color-fog);
  padding: 12px 20px;
}

.thread-identity { display: flex; align-items: center; gap: 12px; }
.thread-title { font-weight: 600; font-size: 18px; line-height: 1.3; color: var(--color-ink); }
.thread-meta { font-size: 13px; color: var(--color-slate); }

.typing-bar {
  font-size: 13px; color: var(--color-deep-signal);
  padding: 6px 24px;
  background: var(--color-white);
  border-bottom: 1px solid var(--color-fog);
}

.key-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-size: 14px; color: var(--color-ink);
  background: rgba(165, 202, 213, 0.35);
  padding: 10px 24px;
  border-bottom: 1px solid var(--color-fog);
}

/* ── Messages ────────────────────────────────────────── */
.message-list {
  flex: 1; overflow-y: auto;
  padding: 24px;
  display: flex; flex-direction: column; gap: 4px;
  scroll-behavior: smooth;
}

.thread-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; }

.msg-row { display: flex; align-items: flex-end; gap: 8px; }
.msg-row.own { flex-direction: row-reverse; }

.msg-avatar { width: 30px; height: 30px; flex: none; border-radius: 50%; background: var(--color-signal-sky); color: var(--color-deep-signal); font-weight: 800; font-size: 13px; display: flex; align-items: center; justify-content: center; }

.msg {
  max-width: 62%;
  background: var(--color-white);
  border: 1px solid var(--color-fog);
  border-radius: var(--radius-panel);
  padding: 10px 14px;
  box-shadow: var(--shadow-md);
  margin-top: 4px;
}

.msg-row.own .msg { background: rgba(44, 107, 237, 0.07); border-color: rgba(44, 107, 237, 0.22); }

.msg-group { display: flex; flex-direction: column; max-width: 100%; }

.msg-sender { font-size: 13px; font-weight: 600; color: var(--color-deep-signal); margin-bottom: 2px; }
.msg-row.own .msg-sender { color: var(--color-signal-blue); }

.msg-text { font-size: 15px; color: var(--color-ink); white-space: pre-wrap; word-break: break-word; }

.msg-media img { max-width: 100%; max-height: 320px; border-radius: 10px; display: block; }
.msg-file { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--color-deep-signal); font-weight: 600; }
.msg-file svg { width: 22px; height: 22px; }

.msg-locked { font-size: 14px; color: var(--color-slate); font-style: italic; }

.msg-foot { display: flex; align-items: center; justify-content: flex-end; gap: 4px; margin-top: 4px; }
.msg-time { font-size: 11px; color: var(--color-slate); }
.tick { color: var(--color-signal-blue); font-weight: 700; font-size: 12px; }
.tick.read { color: var(--color-signal-blue); }

.msg-del-btn { opacity: 0; border: none; background: transparent; color: var(--color-slate); cursor: pointer; font-size: 12px; padding: 2px; }
.msg-row:hover .msg-del-btn { opacity: 1; }
.msg-del-btn:hover { color: var(--color-danger); }

.date-sep { text-align: center; font-size: 12px; color: var(--color-slate); padding: 16px 0 8px; }

/* ── Composer ────────────────────────────────────────── */
.composer {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--color-white);
  border-top: 1px solid var(--color-fog);
  padding: 12px 16px;
}

.msg-input {
  flex: 1;
  font: inherit; font-size: 15px; color: var(--color-ink);
  background: var(--color-paper);
  border: 1px solid var(--color-fog);
  border-radius: var(--radius-btn);
  padding: 11px 14px;
  outline: none;
  resize: none;
  max-height: 140px;
}
.msg-input:focus { border-color: var(--color-signal-blue); background: var(--color-white); }

.btn-send { display: inline-flex; align-items: center; justify-content: center; padding: 10px 14px; }
.btn-send svg { width: 20px; height: 20px; }

.attach { flex: none; }

.attach-preview {
  display: flex; align-items: center; gap: 10px;
  background: var(--color-paper);
  border: 1px solid var(--color-fog);
  border-radius: var(--radius-btn);
  padding: 8px 12px;
  font-size: 13px; color: var(--color-slate);
}
.attach-preview img { max-height: 60px; border-radius: 6px; }

/* ── Modals ──────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(59, 55, 68, 0.35);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}

.modal-card {
  width: 100%; max-width: 460px;
  background: var(--color-white);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-md);
  padding: 30px 32px;
  max-height: 90vh; overflow-y: auto;
}

.modal-title { font-weight: 800; font-size: 28px; line-height: 1.14; color: var(--color-ink); }
.modal-sub { font-size: 14px; color: var(--color-slate); margin: 6px 0 20px; }
.modal-sub.mono { margin-bottom: 20px; }

.modal-card form { display: flex; flex-direction: column; gap: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

.info-sub { font-weight: 600; font-size: 16px; margin: 24px 0 8px; }
.info-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

.participant-list { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.participant-item { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-radius: var(--radius-btn); }
.participant-item .name { flex: 1; font-size: 14px; color: var(--color-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.participant-item .role { font-size: 11px; color: var(--color-slate); text-transform: uppercase; letter-spacing: 0.04em; }

/* ── Toast ───────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--color-twilight); color: var(--color-white);
  border-radius: var(--radius-panel);
  padding: 12px 20px;
  font-size: 14px;
  box-shadow: var(--shadow-md);
  z-index: 100;
  max-width: 80%;
}

/* ── Scrollbar ───────────────────────────────────────── */
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-thumb { background: #d8d8d8; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #c8c8c8; }

@media (max-width: 720px) {
  #screen-app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}
