:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --surface-2: #f0ece5;
  --text: #1d2422;
  --muted: #66706c;
  --line: #e2ddd4;
  --brand: #2f7d6d;
  --brand-ink: #ffffff;
  --brand-soft: #e1efeb;
  --accent: #f2b84b;
  --danger: #c2412d;
  --ok: #2e9a5b;
  --shadow: 0 1px 2px rgb(20 30 25 / 6%), 0 8px 24px rgb(20 30 25 / 8%);
  --radius: 14px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121615;
    --surface: #1a201e;
    --surface-2: #222a27;
    --text: #e9eeec;
    --muted: #97a29e;
    --line: #2c3532;
    --brand: #5cbfa8;
    --brand-ink: #0d1412;
    --brand-soft: #1e3530;
    --danger: #ef7a66;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px rgb(0 0 0 / 30%);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 26px; letter-spacing: -0.01em; }
h2 { font-size: 18px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; letter-spacing: 0.02em; }
.hidden { display: none !important; }

.boot { display: grid; place-items: center; height: 100%; }
.boot-mark { width: 44px; height: 44px; border-radius: 50%; border: 4px solid var(--brand-soft); border-top-color: var(--brand); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* buttons & inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px;
  padding: 10px 16px; cursor: pointer; font-weight: 550; min-height: 44px;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 38px; padding: 6px 12px; font-size: 14px; border-radius: 9px; }
.btn.block { width: 100%; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); }
.input {
  width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 10px;
  padding: 10px 12px; min-height: 42px; outline: none;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.error { color: var(--danger); font-size: 14px; margin: 8px 0 0; min-height: 1em; }

/* onboarding */
.onboard { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  box-shadow: var(--shadow); padding: 28px; width: 100%; max-width: 420px;
}
.brand-row { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; font-weight: 700; font-size: 17px; }
.brand-row img { width: 34px; height: 34px; }
.card p { margin: 8px 0 18px; }
.loadtest-bar {
  position: fixed; left: 12px; bottom: 12px; z-index: 2000; max-width: calc(100% - 24px);
  background: var(--danger); color: #fff; border-radius: 999px; padding: 6px 14px;
  font-size: 13px; font-weight: 600; box-shadow: var(--shadow);
}
.rejoin-card { border: 1px solid var(--brand); background: var(--brand-soft); border-radius: 14px; padding: 12px 14px; margin-bottom: 14px; }
.rejoin-card p { margin: 6px 0; }
.lock-note { display: flex; gap: 8px; align-items: flex-start; background: var(--brand-soft); border-radius: 12px; padding: 10px 12px; font-size: 13px; margin-top: 16px; }

/* app shell */
.shell { display: grid; grid-template-columns: 380px 1fr; height: 100%; }
.side { display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--line); min-height: 0; }
.side-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.side-head img { width: 30px; height: 30px; }
.side-head .title-wrap { flex: 1; min-width: 0; display: flex; }
.side-head .title { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.circle-picker { font: inherit; font-weight: 700; color: var(--text); background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 4px 6px; margin-left: -7px; cursor: pointer; max-width: 100%; }
.circle-picker:hover, .circle-picker:focus-visible { border-color: var(--line); background: var(--bg); }
.new-circle { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.new-circle h4 { margin: 0 0 8px; font-size: 14px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.online { background: var(--ok); }
.dot.connecting { background: var(--accent); }
.tabs { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--line); }
.tab { background: none; border: 0; padding: 11px 4px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 14px; border-bottom: 2px solid transparent; position: relative; }
.tab[aria-selected="true"] { color: var(--brand); border-bottom-color: var(--brand); }
.tab .badge { position: absolute; top: 6px; margin-left: 2px; background: var(--danger); color: #fff; font-size: 11px; border-radius: 9px; padding: 0 5px; }
.panel { flex: 1; overflow-y: auto; padding: 14px 16px 24px; min-height: 0; }
.panel-actions { display: flex; gap: 8px; margin-bottom: 12px; }
.map { position: relative; min-height: 0; }
#map { position: absolute; inset: 0; background: var(--surface-2); }
.map-hint { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 500; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; box-shadow: var(--shadow); font-size: 14px; }

/* people */
.person { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 12px; cursor: pointer; }
.person:hover { background: var(--surface-2); }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; flex: none; font-size: 15px; }
.person .info { flex: 1; min-width: 0; }
.person .name { font-weight: 650; display: flex; align-items: center; gap: 6px; }
.person .meta { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag { font-size: 11px; font-weight: 650; padding: 1px 6px; border-radius: 6px; background: var(--surface-2); color: var(--muted); }
.tag.warn { background: #fbe6d9; color: #9a3d16; }

/* chat */
.chat { display: flex; flex-direction: column; height: 100%; }
.chat-log { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.bubble-row { display: flex; flex-direction: column; align-items: flex-start; max-width: 85%; }
.bubble-row.mine { align-self: flex-end; align-items: flex-end; }
.bubble-from { font-size: 12px; font-weight: 650; margin: 0 4px 2px; }
.bubble { background: var(--surface-2); padding: 8px 12px; border-radius: 16px; white-space: pre-wrap; word-break: break-word; }
.bubble-row.mine .bubble { background: var(--brand); color: var(--brand-ink); }
.bubble-time { font-size: 11px; color: var(--muted); margin: 2px 6px 0; }
.bubble-line { display: flex; align-items: center; gap: 4px; }
.bubble-row.mine .bubble-line { flex-direction: row-reverse; }
.bubble.big { background: none !important; font-size: 44px; line-height: 1.15; padding: 0 2px; }
.react-btn { border: 0; background: none; cursor: pointer; font-size: 18px; color: var(--muted); opacity: 0; width: 30px; height: 30px; border-radius: 50%; transition: opacity 0.15s; }
.bubble-row:hover .react-btn, .react-btn:focus-visible { opacity: 1; }
.react-btn:hover { background: var(--surface-2); }
@media (hover: none) { .react-btn { opacity: 0.6; } }
.react-bar { display: flex; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px; box-shadow: var(--shadow); margin-top: 4px; }
.react-bar button { border: 0; background: none; font-size: 22px; width: 38px; height: 38px; border-radius: 50%; cursor: pointer; }
.react-bar button:hover, .react-bar button.on { background: var(--brand-soft); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.chip { display: inline-flex; align-items: center; gap: 3px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 1px 8px; font-size: 14px; cursor: pointer; color: var(--muted); }
.chip span { font-size: 12px; font-weight: 600; }
.chip.mine { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.chat-form { position: relative; }
.emoji-toggle { padding: 0 10px; font-size: 20px; }
.emoji-picker { position: absolute; bottom: calc(100% + 6px); left: 8px; right: 8px; max-height: 280px; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 4px 10px 10px; z-index: 5; }
.emoji-group { font-size: 12px; font-weight: 700; color: var(--muted); margin: 8px 2px 4px; }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); }
.emoji-grid button { border: 0; background: none; font-size: 22px; height: 38px; border-radius: 8px; cursor: pointer; }
.emoji-grid button:hover { background: var(--surface-2); }
.event-line { align-self: center; font-size: 13px; color: var(--muted); background: var(--surface-2); padding: 4px 10px; border-radius: 999px; }
.chat-form { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); }
.chat-form .input { flex: 1; }

/* settings */
.section { margin-bottom: 22px; }
.section h3 { margin-bottom: 10px; }
.row { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.row .grow { flex: 1; min-width: 0; }
.qr { background: #fff; border-radius: 12px; padding: 10px; width: max-content; margin: 10px 0; }
.qr img { display: block; width: 200px; height: 200px; image-rendering: pixelated; }
.link-box { display: flex; gap: 6px; }
.link-box .input { font-size: 12px; }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { width: 18px; height: 18px; accent-color: var(--brand); }

/* map markers */
.marker { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; border: 3px solid #fff; box-shadow: 0 2px 8px rgb(0 0 0 / 30%); font-family: var(--font); font-size: 15px; }
.marker.stale { filter: grayscale(0.6); opacity: 0.85; }
.place-label { background: var(--surface); color: var(--text); border-radius: 8px; padding: 2px 8px; font: 600 12px var(--font); border: 1px solid var(--line); white-space: nowrap; }
.leaflet-container { font-family: var(--font); }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; box-shadow: var(--shadow); z-index: 2000; font-size: 14px; max-width: calc(100% - 32px); }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: 42vh 1fr; }
  .map { order: -1; }
  .side { border-right: 0; border-top: 1px solid var(--line); }
  .card { padding: 22px; }
}

.conversation-picker { margin: 0 0 10px; font-weight: 600; }
.consent { display: flex; gap: 10px; align-items: flex-start; padding: 12px; margin: 4px 0 14px; border: 1px solid var(--line); border-radius: 12px; font-size: 14px; line-height: 1.45; cursor: pointer; }
.consent input { width: 20px; height: 20px; margin-top: 1px; flex: none; accent-color: var(--brand); }
.input.inline { display: inline-block; width: auto; margin-left: 6px; }

.person-actions { display: flex; flex: none; gap: 6px; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); display: inline-flex; align-items: center; justify-content: center; font-size: 17px; cursor: pointer; color: var(--brand); text-decoration: none; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:disabled { opacity: 0.45; cursor: default; }
.chat-top { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.chat-top .conversation-picker { margin: 0; flex: 1; }
.checked-in { color: var(--brand); font-size: 13px; font-weight: 600; margin-top: 4px; }
.bubble-row .btn.small.primary { margin-top: 6px; }
