:root {
  color-scheme: dark;
  --bg: #07100e;
  --panel: rgba(14, 29, 25, 0.9);
  --panel-2: #10251f;
  --ink: #ecf8f1;
  --muted: #91aca1;
  --line: rgba(167, 219, 194, 0.17);
  --mint: #6af0b4;
  --mint-dark: #123d2e;
  --amber: #f2bd6b;
  --danger: #ff9f91;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 5%, rgba(36, 125, 91, 0.28), transparent 32rem),
    radial-gradient(circle at 95% 90%, rgba(101, 78, 30, 0.2), transparent 30rem),
    var(--bg);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.12;
  background-image: linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px);
  background-size: 40px 40px;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .6; }

.shell {
  width: min(100% - 28px, 920px);
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  place-items: center;
  padding: 28px 0;
}

.panel {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: 0 24px 90px rgba(0, 0, 0, .34);
  backdrop-filter: blur(18px);
}

.lobby { max-width: 630px; padding: clamp(28px, 6vw, 58px); }

.brand { display: flex; gap: 12px; align-items: center; color: var(--mint); font-weight: 800; letter-spacing: .08em; }
.brand-mark { display: grid; place-items: center; width: 44px; height: 34px; border: 1px solid rgba(106,240,180,.5); border-radius: 10px; font-size: .67rem; letter-spacing: .03em; }

h1 { margin: 32px 0 16px; font-size: clamp(2.5rem, 8vw, 4.6rem); line-height: .98; letter-spacing: -.06em; }
h2 { margin: 4px 0; letter-spacing: -.025em; }
.lead { max-width: 510px; color: var(--muted); line-height: 1.75; }
.actions { margin-top: 34px; }

button {
  border: 0;
  border-radius: 13px;
  padding: 13px 18px;
  color: var(--ink);
  transition: transform .15s ease, background .15s ease;
}
button:hover { transform: translateY(-1px); }
.primary { width: 100%; background: var(--mint); color: #062118; font-weight: 800; }
.secondary { width: 100%; margin-top: 10px; background: var(--mint-dark); color: var(--mint); font-weight: 750; border: 1px solid rgba(106,240,180,.22); }
.ghost { padding: 8px 12px; background: transparent; border: 1px solid var(--line); color: var(--muted); }

.divider { display: flex; align-items: center; gap: 14px; margin: 26px 0 20px; color: var(--muted); font-size: .78rem; }
.divider::before, .divider::after { content: ""; height: 1px; background: var(--line); flex: 1; }

label { display: block; margin: 14px 0 7px; color: var(--muted); font-size: .86rem; }
label small { color: #6f8d81; }
input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  background: rgba(3, 12, 9, .55);
  color: var(--ink);
  outline: none;
}
input:focus, textarea:focus { border-color: rgba(106,240,180,.62); box-shadow: 0 0 0 3px rgba(106,240,180,.09); }

.privacy-note { display: flex; gap: 13px; margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--line); color: var(--muted); font-size: .82rem; line-height: 1.55; }
.privacy-note p { margin: 0; }
.privacy-note strong { color: #cfe5da; }
.lock { color: var(--mint); }

.credentials { max-width: 630px; padding: clamp(26px, 6vw, 50px); }
.eyebrow { margin: 0; color: var(--mint); font-size: .72rem; text-transform: uppercase; letter-spacing: .16em; font-weight: 800; }
.credential-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; margin-top: 18px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: rgba(2,9,7,.35); }
.credential-row div { min-width: 0; }
.credential-row span { display: block; color: var(--muted); font-size: .75rem; margin-bottom: 5px; }
.credential-row code { display: block; overflow-wrap: anywhere; color: var(--mint); font-size: 1rem; }
.credential-row button { background: var(--mint-dark); color: var(--mint); padding: 9px 12px; }
.warning { margin: 18px 0 24px; color: var(--amber); font-size: .84rem; line-height: 1.55; }

.chat { height: min(850px, calc(100vh - 32px)); display: grid; grid-template-rows: auto auto 1fr auto; overflow: hidden; }
.chat-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 22px 24px; border-bottom: 1px solid var(--line); }
.chat-header h2 { font-size: 1.06rem; }
.chat-header h2 span { color: #bad4c8; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.status { color: var(--muted); font-size: .75rem; }
.status::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--amber); }
.status.online::before { background: var(--mint); box-shadow: 0 0 10px rgba(106,240,180,.7); }
.status.offline::before { background: var(--danger); }
.retention-banner { padding: 10px 24px; color: var(--muted); background: rgba(6,17,14,.65); font-size: .74rem; border-bottom: 1px solid var(--line); }

.messages { list-style: none; margin: 0; padding: 24px; overflow-y: auto; }
.message { max-width: 78%; margin: 0 0 18px; padding: 14px 16px 11px; border-radius: 6px 17px 17px 17px; background: var(--panel-2); border: 1px solid rgba(167,219,194,.1); }
.message.flagged { border-color: rgba(242,189,107,.32); }
.message-top, .message-footer { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.message-top strong { color: var(--mint); font-size: .8rem; }
.message-top time { color: #69857a; font-size: .68rem; }
.message > p { margin: 10px 0 12px; color: #e5f2ec; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.message-media { margin: 11px 0 12px; }
.message-media img { display: block; width: auto; max-width: 100%; max-height: 420px; border-radius: 12px; background: #06100d; object-fit: contain; }
.image-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; color: var(--muted); font-size: .7rem; }
.image-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.image-download { flex: none; color: var(--mint); text-decoration: none; }
.image-download:hover { text-decoration: underline; }
.message-footer { justify-content: flex-end; }
.retention { margin-right: auto; color: #668176; font-size: .66rem; }
.flag { padding: 4px 7px; color: #7f9a8e; background: transparent; font-size: .68rem; }
.flag:hover { color: var(--amber); }
.flagged .flag, .flagged .retention { color: var(--amber); }

.composer { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: end; padding: 16px; border-top: 1px solid var(--line); background: rgba(5,15,12,.8); }
.composer textarea { resize: none; max-height: 160px; min-height: 48px; }
.image-picker input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.image-picker span { display: grid; place-items: center; min-height: 48px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; color: var(--mint); background: var(--mint-dark); cursor: pointer; font-weight: 750; }
.image-picker:focus-within span { border-color: rgba(106,240,180,.62); box-shadow: 0 0 0 3px rgba(106,240,180,.09); }
.image-picker input:disabled + span { cursor: wait; opacity: .6; }
.send { min-height: 48px; background: var(--mint); color: #062118; font-weight: 800; }
.upload-state { grid-column: 1 / -1; margin: 0; color: var(--muted); font-size: .72rem; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 10; margin: 0; padding: 11px 16px; border: 1px solid var(--line); border-radius: 999px; background: #162a24; box-shadow: 0 12px 38px rgba(0,0,0,.38); font-size: .82rem; }
.hidden { display: none !important; }

@media (max-width: 640px) {
  .shell { width: 100%; padding: 0; }
  .panel { border-radius: 0; border-left: 0; border-right: 0; }
  .lobby, .credentials { min-height: 100vh; }
  .chat { height: 100vh; }
  .chat-header { padding: 16px; }
  .header-actions { align-items: flex-end; flex-direction: column-reverse; }
  .retention-banner { padding: 9px 16px; }
  .messages { padding: 16px; }
  .message { max-width: 92%; }
  .composer { padding: 10px; }
}
