:root {
  --bg: hsl(232 32% 8%);
  --panel: hsl(228 24% 14% / 0.6);
  --panel-solid: hsl(228 24% 14%);
  --text: hsl(220 15% 85%);
  --muted: hsl(220 10% 65%);
  --accent: hsl(190 95% 60%);
  --accent-2: hsl(270 95% 70%);
  --error: #ff6b6b;
  --radius: 14px;
  --shadow: 0 10px 30px hsl(210 60% 10% / 0.4), inset 0 1px 0 hsl(0 0% 100% / 0.06);
  --kb: 0px;               /* dynamic keyboard inset set by JS */
  --composer-h: 68px;      /* measured by JS for mobile padding */
}

* { box-sizing: border-box; }
html, body, #app { height: 100%; }
body { margin: 0; font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial; background: radial-gradient(1200px 800px at 70% -10%, hsl(265 90% 22% / 0.35), transparent 50%), radial-gradient(900px 700px at -10% 110%, hsl(198 90% 24% / 0.35), transparent 50%), var(--bg); background-attachment: fixed, fixed, fixed; color: var(--text); }

/* Landing */
.landing { position: relative; min-height: 100%; display: grid; grid-template-rows: auto 1fr; }
.landing .bg { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.landing .bg .glow { position: absolute; width: 70vmax; height: 70vmax; background: radial-gradient(circle at 50% 50%, var(--accent), transparent 60%); filter: blur(80px); opacity: 0.12; transform: translate(-30%, -20%); }
.landing .bg .grid { position: absolute; inset: 0; background-image: linear-gradient(hsl(0 0% 100% / 0.05) 1px, transparent 1px), linear-gradient(90deg, hsl(0 0% 100% / 0.05) 1px, transparent 1px); background-size: 40px 40px; mask-image: radial-gradient(1000px 600px at 50% 20%, black, transparent 70%); }
.hero { text-align: center; padding: 64px 20px 24px; }
.brand { font-size: clamp(44px, 7vw, 76px); line-height: 1.05; margin: 0; letter-spacing: -0.02em; background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 6px 30px hsl(190 95% 60% / 0.15)); }
.tag { margin: 12px 0 0; color: var(--muted); font-size: clamp(14px, 2vw, 18px); }

.card { position: relative; max-width: 960px; margin: 24px auto 40px; padding: 20px; border-radius: var(--radius); background: linear-gradient(180deg, hsl(0 0% 100% / 0.06), hsl(0 0% 100% / 0.02)) , var(--panel); backdrop-filter: blur(8px); box-shadow: var(--shadow); border: 1px solid hsl(0 0% 100% / 0.07); }
.card-title { margin: 6px 4px 14px; font-size: 14px; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; }
.form { display: grid; grid-template-columns: 1fr; gap: 16px; justify-items: center; }
.form .field { display: flex; flex-direction: column; gap: 6px; }
.form label { font-size: 13px; color: var(--muted); }
.form .field, .form .row, .inline-error, .below-action { width: min(560px, 100%); }
.form input { width: 100%; padding: 12px 14px; background: hsl(220 20% 10%); color: var(--text); border: 1px solid hsl(220 14% 20%); border-radius: 10px; outline: none; box-shadow: inset 0 1px 0 hsl(0 0% 100% / 0.05); }
.form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px hsl(190 95% 60% / 0.2); }

.adv { grid-column: span 2; display: flex; flex-direction: column; gap: 8px; }
.adv .link { align-self: flex-start; background: none; border: none; color: var(--accent); cursor: pointer; padding: 6px 2px; border-radius: 6px; }
.adv .adv-panel { display: grid; gap: 8px; }

.btn-primary { display: inline-flex; align-items: center; gap: 8px; justify-content: center; padding: 12px 16px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); color: hsl(230 30% 6%); border: none; border-radius: 999px; font-weight: 700; cursor: pointer; box-shadow: 0 8px 30px hsl(200 90% 50% / 0.25); }
.form .btn-primary { grid-column: 1; width: min(560px, 100%); }
.btn-primary:hover { filter: brightness(1.05); }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid hsl(0 0% 100% / 0.1); border-radius: 10px; padding: 8px 12px; cursor: pointer; }

.inline-error { grid-column: 1; color: var(--error); background: hsl(0 80% 50% / 0.1); border: 1px solid hsl(0 80% 60% / 0.35); padding: 8px 12px; border-radius: 10px; }
.below-action { grid-column: 1; display: flex; justify-content: center; margin-top: 4px; text-align: center; }
.link-white { color: #fff; text-decoration: none; font-weight: 600; opacity: 0.9; }
.link-white:hover { opacity: 1; text-decoration: underline; }

/* .link-btn removed (auto location on load) */

/* Chat */
.chat-screen { position: fixed; inset: 0; display: flex; flex-direction: column; overflow: hidden; }
.topbar { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; background: linear-gradient(180deg, var(--panel-solid), transparent); backdrop-filter: blur(8px); border-bottom: 1px solid hsl(0 0% 100% / 0.06); }
.topbar .left { display: flex; align-items: center; gap: 10px; }
.topbar .right { display: flex; align-items: center; gap: 10px; }
.logo-mini { width: 36px; height: 36px; display: grid; place-items: center; background: none; border-radius: 0; filter: none; }
.topbar .meta .title { font-weight: 800; letter-spacing: 0.02em; }
.topbar .meta .sub { color: var(--muted); font-size: 12px; }

.chat-area { padding: 16px; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,0.35); opacity: 0; transition: opacity .15s ease; pointer-events: none; z-index: 70; }
.scrim.open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; left: 0; bottom: 0; width: 320px; max-width: 85vw; background: var(--panel-solid); border-right: 1px solid hsl(0 0% 100% / 0.08); box-shadow: var(--shadow); transform: translateX(-102%); transition: transform .2s ease; z-index: 80; display: flex; flex-direction: column; }
.drawer.open { transform: translateX(0); }
.drawer-header { display: flex; align-items: center; justify-content: space-between; padding: 12px; border-bottom: 1px solid hsl(0 0% 100% / 0.06); }
.drawer-header .title { font-weight: 700; color: var(--text); }
.drawer-list { display: flex; flex-direction: column; padding: 8px; gap: 6px; overflow: auto; }
.drawer-item { position: relative; text-align: left; width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--text); cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.drawer-item:hover { background: hsl(228 24% 18%); }
.drawer-item.active { background: linear-gradient(90deg, var(--accent), var(--accent-2)); color: hsl(230 30% 6%); }
.drawer-item .badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 6px; border-radius: 999px; background: #ff6b6b; color: white; font-size: 11px; font-weight: 700; }

/* Menu button unread dot */
.menu-btn { position: relative; }
.menu-dot { position: absolute; top: -2px; right: -2px; width: 10px; height: 10px; background: #ff6b6b; border-radius: 50%; box-shadow: 0 0 0 2px rgba(0,0,0,.3); }
.messages { flex: 1; min-height: 0; width: 100%; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding-bottom: 0; }
.msg { display: flex; }
.msg.self { justify-content: flex-end; }
.bubble { max-width: min(70ch, 90%); padding: 10px 12px; border-radius: 14px; background: var(--panel-solid); border: 1px solid hsl(0 0% 100% / 0.06); box-shadow: var(--shadow); }
.msg.self .bubble { background: linear-gradient(120deg, hsl(190 95% 40% / 0.25), hsl(270 95% 40% / 0.25)); border-color: hsl(0 0% 100% / 0.1); }
.bubble .from { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.bubble .text { font-size: 15px; line-height: 1.4; }

.composer { position: sticky; bottom: 0; display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(0deg, var(--panel-solid), transparent); backdrop-filter: blur(8px); border-top: 1px solid hsl(0 0% 100% / 0.06); }
.composer input { width: 100%; padding: 12px 14px; background: hsl(220 20% 10%); color: var(--text); border: 1px solid hsl(220 14% 20%); border-radius: 999px; outline: none; }
.composer input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px hsl(190 95% 60% / 0.2); }

@media (max-width: 720px) {
  .drawer { width: 100%; max-width: 100%; border-right: none; }
  .form { grid-template-columns: 1fr; }
  .form .btn-primary, .adv { grid-column: 1; }
  .form input { font-size: 16px; }
  .composer input { font-size: 16px; }
  /* Mobile: make landing feel like an app (no card chrome) */
  .join-card { background: transparent; backdrop-filter: none; border: none; box-shadow: none; border-radius: 0; padding: 0 16px 24px; margin: 8px auto 16px; }
  .hero { padding: 40px 16px 12px; }
  /* Mobile: pin composer above keyboard */
  .composer { position: fixed; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom) + var(--kb)); z-index: 50; }
  /* Mobile: reserve space inside scroller for composer */
  .messages { padding-bottom: calc(var(--composer-h) + env(safe-area-inset-bottom) + 10px); }
}

/* Conversation header */
.conv-header { margin: 0 0 8px; width: 100%; }
.conv-header .conv { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; background: linear-gradient(180deg, hsl(0 0% 100% / 0.06), hsl(0 0% 100% / 0.02)), var(--panel); border: 1px solid hsl(0 0% 100% / 0.07); }
.conv-header .icon { filter: drop-shadow(0 1px 0 rgba(0,0,0,.15)); }
.conv-header .label { color: var(--text); font-weight: 600; }
