:root {
  color-scheme: dark;
  --bg: #09110f;
  --panel: #111c19;
  --panel-2: #172420;
  --line: rgba(255, 255, 255, .09);
  --text: #eff8f4;
  --muted: #90a29a;
  --accent: #38d996;
  --accent-2: #1fa974;
  --own: #176448;
  --other: #1b2a26;
  --danger: #ff7777;
  --shadow: 0 28px 80px rgba(0, 0, 0, .38);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
button, input, textarea { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

.login-page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 10%, rgba(56, 217, 150, .17), transparent 32%),
    radial-gradient(circle at 90% 90%, rgba(34, 117, 87, .18), transparent 34%),
    var(--bg);
}

.login-card {
  width: min(100%, 420px);
  padding: 36px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(17, 28, 25, .92);
  box-shadow: var(--shadow);
}

.brand-mark, .room-avatar {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: var(--accent);
  color: #07130e;
  font-weight: 900;
}

.eyebrow { margin: 28px 0 8px; color: var(--accent); font-size: 12px; font-weight: 800; letter-spacing: .15em; }
h1 { margin: 0; font-size: clamp(25px, 6vw, 34px); letter-spacing: -.04em; }
.muted, .privacy-note { color: var(--muted); line-height: 1.55; }
.privacy-note { margin: 22px 0 0; font-size: 12px; }
.login-card form { display: grid; gap: 10px; margin-top: 28px; }
label { margin-top: 8px; color: #c6d5ce; font-size: 13px; font-weight: 700; }
input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 13px;
  outline: none;
  background: #0b1512;
  color: var(--text);
}
input { height: 48px; padding: 0 14px; }
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(56, 217, 150, .12); }
.primary-button, .send-button {
  border: 0;
  border-radius: 13px;
  background: var(--accent);
  color: #06120d;
  font-weight: 850;
  cursor: pointer;
}
.primary-button { height: 50px; margin-top: 14px; }
button:disabled { cursor: wait; opacity: .55; }
.form-error { margin: 4px 0 0; color: var(--danger); font-size: 13px; }

.chat-page { height: 100dvh; overflow: hidden; }
.chat-shell {
  position: relative;
  width: min(100%, 1040px);
  height: 100dvh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto auto;
  overflow: hidden;
  background:
    linear-gradient(rgba(9, 17, 15, .91), rgba(9, 17, 15, .91)),
    radial-gradient(circle at 20px 20px, rgba(255,255,255,.07) 1px, transparent 1px);
  background-size: auto, 40px 40px;
  border-inline: 1px solid var(--line);
}

.chat-header {
  min-height: 72px;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(17, 28, 25, .97);
  z-index: 3;
}
.room-avatar { width: 44px; height: 44px; border-radius: 14px; }
.room-heading { min-width: 0; flex: 1; }
.room-heading h1 { font-size: 17px; letter-spacing: -.01em; }
.room-heading p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.icon-button, .mini-button, .composer-button {
  border: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
}
.icon-button { padding: 8px 11px; border-radius: 10px; color: var(--muted); font-size: 12px; }
.connection-banner { padding: 7px 12px; text-align: center; background: #7b5a19; font-size: 12px; }
.message-list { min-height: 0; overflow: auto; padding: 18px 14px 12px; scroll-behavior: smooth; }
.load-older { display: block; margin: 0 auto 15px; padding: 8px 13px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); cursor: pointer; color: var(--muted); font-size: 12px; }
.day-separator { display: flex; align-items: center; gap: 10px; margin: 18px auto; color: var(--muted); font-size: 11px; }
.day-separator::before, .day-separator::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.message-row { display: flex; margin: 5px 0; }
.message-row.own { justify-content: flex-end; }
.message-bubble { position: relative; width: fit-content; max-width: min(78%, 620px); padding: 8px 10px 6px; border-radius: 5px 16px 16px 16px; background: var(--other); box-shadow: 0 4px 12px rgba(0,0,0,.12); }
.message-row.own .message-bubble { border-radius: 16px 5px 16px 16px; background: var(--own); }
.sender { display: block; margin-bottom: 3px; color: #67e6ae; font-size: 12px; font-weight: 750; }
.reply-preview { margin-bottom: 6px; padding: 6px 8px; border-left: 3px solid var(--accent); border-radius: 7px; background: rgba(0,0,0,.18); color: #c9d8d1; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.42; }
.message-meta { display: flex; justify-content: flex-end; align-items: center; gap: 5px; margin-top: 4px; color: rgba(238,248,243,.58); font-size: 10px; }
.pending .message-meta::after { content: " ◷"; }
.failed { outline: 1px solid var(--danger); }
.message-actions { display: flex; gap: 8px; margin-top: 6px; opacity: .72; }
.message-actions button { padding: 0; border: 0; background: none; color: #d2e2da; font-size: 10px; cursor: pointer; }
.attachment { display: block; min-width: 210px; color: inherit; text-decoration: none; }
.attachment img, .attachment video { display: block; max-width: 100%; max-height: 360px; border-radius: 10px; background: #08100e; }
.attachment audio { width: min(100%, 340px); }
.file-card { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px; background: rgba(0,0,0,.2); }
.file-icon { font-size: 24px; }
.file-meta { min-width: 0; }
.file-meta strong, .file-meta span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta span { color: var(--muted); font-size: 11px; }

.typing-line { min-height: 24px; margin: 0; padding: 4px 18px; color: var(--accent); background: rgba(17,28,25,.96); font-size: 12px; }
.draft-panel { padding: 8px 10px 0; background: var(--panel); }
.reply-draft, .file-draft { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 12px; background: #0c1714; }
.reply-draft > div, .file-draft-info { min-width: 0; flex: 1; }
.reply-draft strong, .reply-draft span, .file-draft strong, .file-draft span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.reply-draft strong { color: var(--accent); }
.mini-button { width: 28px; height: 28px; border-radius: 50%; }
.progress-track { height: 4px; margin: 7px 0 4px; overflow: hidden; border-radius: 4px; background: #26352f; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--accent); transition: width .15s; }
.composer { display: flex; align-items: flex-end; gap: 8px; padding: 9px 10px max(9px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--panel); }
.composer-button { flex: 0 0 42px; height: 42px; border-radius: 13px; font-size: 24px; }
.composer textarea { min-height: 42px; max-height: 140px; resize: none; padding: 10px 13px; line-height: 20px; }
.send-button { flex: 0 0 62px; height: 42px; }
.new-message-pill { position: absolute; right: 18px; bottom: 105px; z-index: 4; padding: 9px 13px; border: 0; border-radius: 999px; background: var(--accent); color: #07130e; font-weight: 800; cursor: pointer; box-shadow: var(--shadow); }
.drop-overlay { position: absolute; inset: 76px 12px 82px; z-index: 8; display: grid; place-items: center; border: 2px dashed var(--accent); border-radius: 18px; background: rgba(7,19,14,.9); color: var(--accent); font-size: 18px; font-weight: 800; }

@media (min-width: 760px) {
  .chat-page { padding: 18px; background: #07100d; }
  .chat-shell { height: calc(100dvh - 36px); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); }
  .message-list { padding-inline: 32px; }
}

@media (max-width: 480px) {
  .login-card { padding: 26px 20px; border-radius: 20px; }
  .message-bubble { max-width: 87%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
