* { box-sizing: border-box; }
:root {
  --bg: #f6f7f9; --panel: #fff; --line: #e4e7ec; --text: #111827; --muted: #6b7280;
  --accent: #0f766e; --accent-soft: #ccfbf1; --here: #15803d; --nearby: #b45309; --remote: #6b7280;
}
html, body { margin: 0; height: 100%; font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--accent); }
button { font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 6px 12px; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
input, textarea { font: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* landing */
.landing { max-width: 720px; margin: 48px auto; padding: 0 20px; }
.landing h1 { font-size: 30px; margin-bottom: 4px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-top: 24px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; text-decoration: none; color: inherit; }
.card b { display: block; margin-bottom: 4px; color: var(--accent); }

/* simulator */
.sim { display: flex; gap: 28px; justify-content: center; padding: 24px; align-items: flex-start; }
.sim-side { width: 260px; }
.sim-side h2 { margin-top: 0; }
.persona { display: block; width: 100%; text-align: left; margin-bottom: 6px; }
.persona.on { border-color: var(--accent); background: var(--accent-soft); }
.phone { width: 380px; height: 760px; border-radius: 44px; border: 12px solid #111; background: #efeae2; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.18); }
.phone.imessage { background: #fff; }
.phone-top { background: #075e54; color: #fff; padding: 14px 16px 10px; display: flex; align-items: center; gap: 10px; }
.phone.imessage .phone-top { background: #f7f7f7; color: #111; border-bottom: 1px solid #ddd; justify-content: center; flex-direction: column; gap: 2px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; }
.thread { flex: 1; overflow-y: auto; padding: 12px 10px; display: flex; flex-direction: column; gap: 6px; }
.bubble { max-width: 82%; padding: 7px 10px; border-radius: 10px; white-space: pre-wrap; word-wrap: break-word; box-shadow: 0 1px 1px rgba(0,0,0,.08); }
.bubble.in { align-self: flex-end; background: #d9fdd3; }
.bubble.out { align-self: flex-start; background: #fff; }
.phone.imessage .bubble { border-radius: 18px; box-shadow: none; }
.phone.imessage .bubble.in { background: #0a84ff; color: #fff; }
.phone.imessage .bubble.out { background: #e9e9eb; }
.choices { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.choices button { width: 100%; color: #027eb5; background: #fff; border-radius: 8px; }
.linkcard { display: block; margin-top: 6px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); text-decoration: none; background: #f7f7f7; }
.linkcard div { padding: 8px 10px; color: var(--text); }
.linkcard small { display: block; color: var(--muted); }
.linkcard .bar { background: var(--accent); color: #fff; font-weight: 600; }
.composer { display: flex; gap: 6px; padding: 8px; background: #f0f0f0; }
.composer input { flex: 1; border-radius: 20px; }
.sheet { position: absolute; inset: auto 0 0 0; background: #fff; border-radius: 16px 16px 0 0; box-shadow: 0 -8px 30px rgba(0,0,0,.2); max-height: 70%; overflow-y: auto; }
.sheet .row { padding: 10px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.sheet .row:hover { background: var(--bg); }
.sheet .row small { display: block; color: var(--muted); }
.phone-wrap { position: relative; }
.phone-wrap .sheet { left: 12px; right: 12px; bottom: 12px; border-radius: 16px 16px 32px 32px; }
.typing { align-self: flex-start; color: var(--muted); font-style: italic; padding: 2px 8px; }

/* room app */
.room { display: grid; grid-template-columns: 220px 1fr 280px; height: 100vh; }
.room > aside, .room > main { min-height: 0; }
.col { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.col.right { border-right: 0; border-left: 1px solid var(--line); }
.place-head { padding: 14px; border-bottom: 1px solid var(--line); }
.place-head h1 { font-size: 16px; margin: 0 0 2px; }
.place-head .muted { font-size: 12px; }
.section { padding: 10px 14px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
.section button { padding: 0 6px; border: 0; color: var(--accent); }
.chan { padding: 6px 14px; cursor: pointer; color: #374151; }
.chan.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.feed { display: flex; flex-direction: column; min-height: 0; background: var(--panel); }
.feed-head { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.messages { flex: 1; overflow-y: auto; padding: 12px 16px; }
.msg { padding: 6px 0; }
.msg .who { font-weight: 600; }
.msg .when { color: var(--muted); font-size: 11px; margin-left: 6px; }
.msg .body { white-space: pre-wrap; word-wrap: break-word; }
.msg .thread-link { font-size: 12px; color: var(--accent); cursor: pointer; }
.msg:hover .reply-btn { visibility: visible; }
.reply-btn { visibility: hidden; font-size: 12px; padding: 0 6px; margin-left: 6px; }
.send { display: flex; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--line); }
.send textarea { flex: 1; resize: none; height: 42px; }
.member { padding: 6px 14px; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.badge { font-size: 11px; border-radius: 999px; padding: 1px 8px; white-space: nowrap; background: #f3f4f6; color: var(--remote); }
.badge.here { background: #dcfce7; color: var(--here); }
.badge.nearby { background: #fef3c7; color: var(--nearby); }
#minimap { height: 180px; border-bottom: 1px solid var(--line); }
.thread-panel { z-index: 1000; position: fixed; top: 0; right: 0; width: 380px; height: 100vh; background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; box-shadow: -10px 0 30px rgba(0,0,0,.08); }
.center-box { max-width: 420px; margin: 15vh auto; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 24px; text-align: center; }
.modal { z-index: 1100; position: fixed; inset: 0; background: rgba(0,0,0,.35); display: grid; place-items: center; }
.modal > div { background: #fff; padding: 22px; border-radius: 14px; width: 340px; }
.modal input { width: 100%; margin: 10px 0; }
#worldmap { height: 100vh; }
