:root {
  --bg: #0f1117;
  --panel: #171a23;
  --panel-2: #1d212c;
  --border: #272c39;
  --text: #e6e8ee;
  --muted: #8a90a2;
  --accent: #6366f1;
  --accent-2: #4f46e5;
  --bubble-me: #4f46e5;
  --bubble-them: #232838;
  --danger: #ef4444;
  --ok: #22c55e;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Login ---------- */
.login-body { display: grid; place-items: center; min-height: 100vh;
  background: radial-gradient(1200px 600px at 50% -10%, #1b2030, var(--bg)); }
.login-card {
  width: min(380px, 92vw); background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; padding: 32px 28px; box-shadow: 0 20px 60px rgba(0,0,0,.45);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-weight: 800; font-size: 22px; color: white;
}
.brand h1 { font-size: 22px; margin: 0; letter-spacing: -.2px; }
.subtitle { color: var(--muted); margin: 14px 0 18px; }
.login-card label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.login-card input {
  width: 100%; margin-top: 6px; padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text); font-size: 15px;
}
.login-card input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.login-card button, .composer button.send {
  width: 100%; padding: 12px; border: 0; border-radius: 10px; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white; font-weight: 600; font-size: 15px;
}
.login-card button:hover { filter: brightness(1.08); }
.demo-hint { margin-top: 16px; font-size: 12.5px; color: var(--muted); text-align: center; }
.error { background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.4);
  color: #fca5a5; padding: 10px 12px; border-radius: 10px; margin-bottom: 14px; font-size: 14px; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-rows: 56px 1fr; height: 100vh; }
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 0 16px;
  border-bottom: 1px solid var(--border); background: var(--panel);
}
.topbar .brand h1 { font-size: 17px; }
.topbar .brand-mark { width: 30px; height: 30px; font-size: 16px; border-radius: 8px; }
.spacer { flex: 1; }
.lang-toggle { display: flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.lang-toggle button { background: var(--panel-2); color: var(--muted); border: 0; padding: 6px 12px;
  cursor: pointer; font-size: 13px; font-weight: 600; }
.lang-toggle button.active { background: var(--accent-2); color: white; }
.whoami { color: var(--muted); font-size: 13px; }
.logout { color: var(--muted); text-decoration: none; font-size: 13px; border: 1px solid var(--border);
  padding: 6px 10px; border-radius: 9px; }
.logout:hover { color: var(--text); }

.body { display: grid; grid-template-columns: 300px 1fr 288px; min-height: 0; }
.body.no-panel { grid-template-columns: 300px 1fr; }
.body.no-panel .rightpanel { display: none; }

.topbtn { background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  padding: 6px 11px; border-radius: 9px; cursor: pointer; font-size: 13px; font-weight: 600; }
.topbtn:hover { background: #2a3040; }

/* ---------- Sidebar ---------- */
.sidebar { border-right: 1px solid var(--border); background: var(--panel); overflow-y: auto; }
.section-title { display: flex; align-items: center; gap: 8px; padding: 14px 16px 6px;
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.section-title .sec-label { flex: 1; }
.section-title .dot { width: 7px; height: 7px; border-radius: 50%; }
.sec-add { background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  width: 22px; height: 22px; border-radius: 6px; cursor: pointer; line-height: 1; font-size: 15px; }
.sec-add:hover { background: var(--accent-2); color: #fff; border-color: transparent; }
.dot.project { background: #f59e0b; } .dot.group { background: #22c55e; } .dot.people { background: #38bdf8; }
.convo {
  display: flex; align-items: center; gap: 11px; padding: 10px 14px; cursor: pointer;
  border-left: 3px solid transparent;
}
.convo:hover { background: var(--panel-2); }
.convo.active { background: var(--panel-2); border-left-color: var(--accent); }
.avatar { width: 36px; height: 36px; border-radius: 10px; flex: none; display: grid; place-items: center;
  font-weight: 700; font-size: 14px; color: white; background: #3b4256; }
.convo .meta { min-width: 0; flex: 1; }
.convo .name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.convo .preview { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { background: var(--accent); color: white; font-size: 11px; font-weight: 700; min-width: 19px;
  height: 19px; border-radius: 10px; display: grid; place-items: center; padding: 0 5px; }

/* presence dots */
.pdot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-left: 6px;
  vertical-align: middle; box-shadow: 0 0 0 2px var(--panel); transition: background .2s; }
.pdot.active { background: var(--ok); }
.pdot.idle { background: #f59e0b; }
.pdot.offline { background: var(--danger); }
.chat-header .sub .pdot, .msg .sender .pdot { box-shadow: none; margin-left: 5px; }

/* ---------- Chat pane ---------- */
.chat { display: grid; grid-template-rows: 56px 1fr auto auto; min-width: 0; }
.chat-header { display: flex; align-items: center; gap: 11px; padding: 0 18px;
  border-bottom: 1px solid var(--border); background: var(--panel); }
.chat-header .name { font-weight: 700; }
.chat-header .sub { color: var(--muted); font-size: 12.5px; }
.messages { overflow-y: auto; padding: 20px 18px; display: flex; flex-direction: column; gap: 12px; }
.empty-state { margin: auto; color: var(--muted); text-align: center; }

.msg { max-width: 70%; display: flex; flex-direction: column; gap: 4px; }
.msg.me { align-self: flex-end; align-items: flex-end; }
.msg .sender { font-size: 12px; color: var(--muted); padding: 0 4px; }
.bubble { padding: 9px 13px; border-radius: 14px; background: var(--bubble-them); font-size: 14.5px;
  line-height: 1.45; word-wrap: break-word; white-space: pre-wrap; }
.msg.me .bubble { background: var(--bubble-me); color: white; }
.bubble img, .bubble video { max-width: 280px; border-radius: 10px; display: block; }
.bubble.media { padding: 5px; }
.loc-link { display: block; margin-top: 5px; font-size: 12.5px; color: #c7d2fe; text-decoration: none; }
.msg .time { font-size: 11px; color: var(--muted); padding: 0 4px; }
.translate-row { display: flex; gap: 8px; align-items: center; padding: 0 4px; }
.translate-btn { background: none; border: 0; color: var(--accent); cursor: pointer; font-size: 12px; padding: 0; }
.translate-btn:hover { text-decoration: underline; }
.translated { font-size: 13.5px; color: #a5b4fc; font-style: italic; padding: 2px 4px; }

/* ---------- Composer ---------- */
.composer { display: flex; align-items: center; gap: 8px; padding: 12px 16px;
  border-top: 1px solid var(--border); background: var(--panel); }
.composer input.text { flex: 1; padding: 11px 14px; border-radius: 22px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text); font-size: 14.5px; }
.composer input.text:focus { outline: 2px solid var(--accent); border-color: transparent; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text); cursor: pointer; font-size: 17px; display: grid; place-items: center; }
.icon-btn:hover { background: #2a3040; }
.composer button.send { width: auto; padding: 10px 18px; border-radius: 22px; }
.composer.disabled { opacity: .5; pointer-events: none; }

/* ---------- Location modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: none;
  place-items: center; z-index: 50; }
.modal-backdrop.show { display: grid; }
.modal { width: min(560px, 94vw); background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; overflow: hidden; }
.modal h3 { margin: 0; padding: 16px 18px; border-bottom: 1px solid var(--border); font-size: 16px; }
#map { height: 360px; width: 100%; }
.modal-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 12px 18px; }
.modal-actions .hint { color: var(--muted); font-size: 12.5px; }
.modal-actions .btns { display: flex; gap: 8px; }
.btn-ghost { background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  padding: 9px 14px; border-radius: 9px; cursor: pointer; }
.btn-primary { background: var(--accent-2); color: white; border: 0; padding: 9px 16px;
  border-radius: 9px; cursor: pointer; font-weight: 600; }

/* typing + receipts */
.typing-row { min-height: 18px; padding: 0 20px 4px; font-size: 12.5px; color: var(--muted);
  font-style: italic; }
.receipt { font-size: 11px; color: var(--muted); padding: 1px 4px 0; }
.receipt.seen { color: #a5b4fc; }

/* right panel: Milestones / To-Do */
.rightpanel { border-left: 1px solid var(--border); background: var(--panel); display: flex;
  flex-direction: column; min-height: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; height: 56px;
  padding: 0 14px 0 18px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 14px; }
.chev { background: none; border: 0; color: var(--muted); font-size: 16px; cursor: pointer;
  transition: transform .2s; }
.chev.rot { transform: rotate(-90deg); }
.panel-body { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.panel-body.collapsed { display: none; }
.task-list { list-style: none; margin: 0; padding: 10px 10px 4px; overflow-y: auto; flex: 1; }
.task-empty { color: var(--muted); font-size: 13px; padding: 6px 8px; }
.task { display: flex; align-items: flex-start; gap: 9px; padding: 7px 8px; border-radius: 8px; }
.task:hover { background: var(--panel-2); }
.task input[type=checkbox] { margin-top: 2px; width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }
.task-text { flex: 1; font-size: 13.5px; line-height: 1.4; word-break: break-word; }
.task.done .task-text { text-decoration: line-through; color: var(--muted); }
.task-del { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 16px;
  line-height: 1; opacity: 0; }
.task:hover .task-del { opacity: 1; }
.task-del:hover { color: var(--danger); }
.task-add { display: flex; gap: 7px; padding: 10px; border-top: 1px solid var(--border); }
.task-add input { flex: 1; padding: 8px 11px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text); font-size: 13.5px; }
.task-add input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.task-add button { width: 36px; border: 0; border-radius: 9px; background: var(--accent-2); color: #fff;
  font-size: 18px; cursor: pointer; }

/* modal form bits */
.modal-form { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.modal-form input[type=text], .modal-form > input { width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text); font-size: 14.5px; }
.modal-form input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.pick-label { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.user-pick { max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.pick-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  cursor: pointer; font-size: 14px; }
.pick-row:hover { background: var(--panel-2); }
.pick-row input { width: 16px; height: 16px; accent-color: var(--accent); }
.pick-row .tag, .tag { font-size: 10px; text-transform: uppercase; letter-spacing: .08em;
  background: var(--bubble-them); color: var(--muted); padding: 2px 6px; border-radius: 6px; margin-left: auto; }
.chk { display: flex; align-items: center; gap: 9px; font-size: 14px; color: var(--text); cursor: pointer; }
.chk input { width: 16px; height: 16px; accent-color: var(--accent); }

@media (max-width: 900px) {
  .body, .body.no-panel { grid-template-columns: 260px 1fr; }
  .rightpanel { display: none; }
}
