:root {
  --navy: #161727; --n80: #444552; --n60: #73747D; --n40: #A2A2A9; --n20: #D0D1D4; --light: #F1F1F1;
  --card: rgba(241, 241, 241, 0.94); --shadow: 0 6px 24px rgba(22, 23, 39, 0.16), 0 1px 3px rgba(22, 23, 39, 0.12);
  --person: #6fa8dc; --biz: #e0644f; --gutter: 16px; --r: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #cfe4ee; color: var(--navy); font-family: Inter, system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
#scene { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; touch-action: none; outline: none; }
#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }

.card { position: fixed; background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }

/* header */
.head { top: var(--gutter); left: var(--gutter); max-width: 440px; padding: 14px 16px 12px; }
.brand { display: flex; align-items: center; gap: 10px; }
.logo { width: 26px; height: 26px; border-radius: 9px 9px 11px 11px; background: var(--navy); position: relative; flex: none; display: inline-block; }
.logo::before, .logo::after { content: ''; position: absolute; top: 9px; width: 4px; height: 5px; border-radius: 2px; background: var(--light); }
.logo::before { left: 7px; } .logo::after { right: 7px; }
h1 { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.2; }
h1 .sub { font-weight: 500; color: var(--n60); letter-spacing: -0.02em; font-size: 15px; }
.explain { margin: 8px 0 10px; font-size: 13px; line-height: 1.5; color: var(--n80); letter-spacing: -0.01em; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; font-weight: 600; color: var(--n80); align-items: center; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 11px; height: 13px; border-radius: 6px; display: inline-block; }
.dot.person { background: linear-gradient(135deg, #6fa8dc, #5fb3b3); }
.dot.biz { background: linear-gradient(135deg, #e0644f, #e8a33d); }
.badge { background: var(--navy); color: var(--light); padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; }

/* controls */
.controls { top: var(--gutter); right: var(--gutter); display: flex; align-items: center; gap: 8px; padding: 8px; }
.clock { padding: 0 8px 0 6px; font-size: 13px; color: var(--n60); white-space: nowrap; font-variant-numeric: tabular-nums; }
.clock strong { color: var(--navy); font-weight: 800; font-size: 15px; margin-left: 4px; display: inline-block; min-width: 64px; }
.btn { border: 0; border-radius: 999px; height: 36px; padding: 0 14px; background: var(--n20); color: var(--navy); font-weight: 600; font-size: 13px; display: inline-flex; align-items: center; gap: 8px; letter-spacing: -0.01em; }
.btn:hover { background: #c3c4c9; }
.btn.icon { width: 36px; padding: 0; justify-content: center; }
.btn.primary { background: var(--navy); color: var(--light); }
.btn.primary:hover { background: var(--n80); }
.btn .ic, .ri .ic { width: 17px; height: 17px; }
.seg { display: inline-flex; background: var(--n20); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: transparent; height: 30px; min-width: 36px; border-radius: 999px; font-weight: 700; font-size: 12px; color: var(--n80); }
.seg button.on { background: var(--navy); color: var(--light); }

.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; display: block; }

/* feed */
.feed { left: var(--gutter); bottom: var(--gutter); width: 420px; max-height: 300px; display: flex; flex-direction: column; overflow: hidden; }
.feed-head { border: 0; background: none; text-align: left; padding: 12px 16px 6px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--n60); display: flex; align-items: center; gap: 8px; }
.feed-head .count { font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--n40); }
.feed-head .chev { margin-left: auto; width: 8px; height: 8px; border-right: 2px solid var(--n60); border-bottom: 2px solid var(--n60); transform: rotate(45deg); transition: transform .2s; }
.feed.collapsed .chev { transform: rotate(-135deg); }
.live { width: 8px; height: 8px; border-radius: 50%; background: #3fa66b; box-shadow: 0 0 0 3px rgba(63, 166, 107, .2); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(63, 166, 107, 0); } }
#feedList { list-style: none; margin: 0; padding: 0 8px 10px; overflow-y: auto; }
#feedList li { display: grid; grid-template-columns: 58px 1fr; gap: 6px; padding: 6px 8px; border-radius: 10px; font-size: 12.5px; line-height: 1.4; letter-spacing: -0.01em; cursor: pointer; animation: feedIn .35s ease-out; }
#feedList li:hover { background: rgba(22, 23, 39, 0.06); }
#feedList time { color: var(--n60); font-variant-numeric: tabular-nums; font-size: 11.5px; padding-top: 1px; }
#feedList .who { font-weight: 700; }
#feedList .tag { display: inline-block; margin-left: 4px; font-size: 11px; font-weight: 600; padding: 0 6px; border-radius: 999px; background: var(--n20); color: var(--n80); }
#feedList .tag.ok { background: #d9eedf; color: #24603d; }
#feedList .tag.no { background: #f3dcd6; color: #8e2f1f; }
@keyframes feedIn { from { opacity: 0; transform: translateY(-4px); } }
.feed.collapsed #feedList { display: none; }

/* side panel */
.panel { top: 84px; right: var(--gutter); width: 380px; max-height: calc(100% - 100px); overflow-y: auto; padding: 18px 18px 16px; }
.panel[hidden] { display: none; }
.close { position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; border: 0; border-radius: 50%; background: var(--n20); display: grid; place-items: center; }
.close::before, .close::after { content: ''; position: absolute; width: 14px; height: 2px; background: var(--navy); border-radius: 1px; transform: rotate(45deg); }
.close::after { transform: rotate(-45deg); }
.p-eyebrow { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--n60); margin-bottom: 6px; }
.p-title { display: flex; align-items: center; gap: 10px; padding-right: 36px; }
.p-title h2 { margin: 0; font-size: 19px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.2; }
.avatar { width: 34px; height: 38px; border-radius: 17px 17px 15px 15px; flex: none; position: relative; box-shadow: inset 0 -4px 0 rgba(22, 23, 39, .08); }
.avatar::before, .avatar::after { content: ''; position: absolute; top: 12px; width: 4px; height: 6px; border-radius: 2px; background: var(--navy); }
.avatar::before { left: 11px; } .avatar::after { right: 11px; }
.sicon { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; color: var(--light); flex: none; }
.sicon .ic { width: 22px; height: 22px; }
.p-sub { margin: 8px 0 0; font-size: 13px; color: var(--n80); line-height: 1.5; }
.p-sub b { color: var(--navy); }
.p-sec { margin-top: 16px; }
.p-sec h3 { margin: 0 0 8px; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--n60); }
.rules { margin: 0; padding: 10px 12px; background: rgba(22, 23, 39, 0.05); border-radius: 12px; font-size: 12.5px; line-height: 1.55; color: var(--n80); list-style: none; }
.rules li::before { content: '•'; margin-right: 6px; color: var(--n40); }
.now { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 12px; background: var(--navy); color: var(--light); font-size: 13px; line-height: 1.4; }
.now .ic { width: 20px; height: 20px; flex: none; }
.now small { display: block; color: var(--n40); font-size: 11.5px; }
.steps { list-style: none; margin: 0; padding: 0 0 0 4px; position: relative; }
.steps li { position: relative; padding: 0 0 10px 20px; font-size: 12.5px; line-height: 1.45; color: var(--n80); }
.steps li::before { content: ''; position: absolute; left: 3px; top: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--n40); }
.steps li::after { content: ''; position: absolute; left: 6.5px; top: 15px; bottom: -3px; width: 1px; background: var(--n20); }
.steps li:last-child::after { display: none; }
.steps li.k-ask::before { background: #e8a33d; }
.steps li.k-ok::before { background: #3fa66b; }
.steps li.k-no::before { background: #d65050; }
.steps li.k-quote { color: var(--navy); font-style: italic; }
.steps time { display: block; font-size: 11px; color: var(--n60); font-variant-numeric: tabular-nums; font-style: normal; }
.hist { list-style: none; margin: 0; padding: 0; }
.hist li { display: grid; grid-template-columns: 56px 1fr; gap: 8px; padding: 6px 0; border-top: 1px solid var(--n20); font-size: 12.5px; line-height: 1.4; color: var(--n80); }
.hist li:first-child { border-top: 0; }
.hist time { color: var(--n60); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.hist b { color: var(--navy); font-weight: 600; }
.menu { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.menu td { padding: 5px 0; border-top: 1px solid var(--n20); color: var(--n80); }
.menu tr:first-child td { border-top: 0; }
.menu td:last-child { text-align: right; font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; background: var(--n20); color: var(--n80); }
.pill.open { background: #d9eedf; color: #24603d; }
.pill.closed { background: #e6e1e8; color: var(--n80); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: rgba(22, 23, 39, 0.05); border-radius: 12px; padding: 8px 10px; }
.stat b { display: block; font-size: 17px; font-weight: 800; letter-spacing: -0.02em; }
.stat span { font-size: 11px; color: var(--n60); font-weight: 600; }
.link { border: 0; background: none; padding: 0; color: var(--navy); font-weight: 700; text-decoration: underline; text-decoration-color: var(--n40); text-underline-offset: 2px; }
.people { display: flex; flex-wrap: wrap; gap: 6px; }
.people button { border: 0; border-radius: 999px; background: var(--n20); padding: 5px 10px 5px 6px; font-size: 12px; font-weight: 600; display: inline-flex; gap: 6px; align-items: center; }
.people i { width: 12px; height: 14px; border-radius: 6px; display: inline-block; }
.empty { font-size: 12.5px; color: var(--n60); }

/* overlay chips and bubbles */
.chip { position: absolute; left: 0; top: 0; width: 30px; height: 30px; border-radius: 50%; background: var(--light); border: 2px solid var(--tint, var(--n80)); color: var(--tint, var(--n80)); display: grid; place-items: center; box-shadow: 0 3px 8px rgba(22, 23, 39, 0.2); will-change: transform; transform-origin: 50% 100%; }
.chip .ic { width: 16px; height: 16px; stroke-width: 2.2; }
.chip::after { content: ''; position: absolute; bottom: -6px; left: 50%; margin-left: -4px; border: 4px solid transparent; border-top-color: var(--tint, var(--n80)); border-bottom: 0; }
.chip[data-kind="phone"] { background: #fbe7c0; animation: wiggle .9s ease-in-out infinite; }
.chip[data-kind="check"] { background: #d9eedf; }
@keyframes wiggle { 50% { box-shadow: 0 0 0 5px rgba(232, 163, 61, 0.25), 0 3px 8px rgba(22, 23, 39, 0.2); } }
.bubble { position: absolute; left: 0; top: 0; max-width: 210px; width: max-content; padding: 7px 11px; border-radius: 12px; background: var(--light); color: var(--navy); font-size: 12px; font-weight: 500; line-height: 1.35; letter-spacing: -0.01em; box-shadow: 0 4px 14px rgba(22, 23, 39, 0.2); will-change: transform; }
.bubble::after { content: ''; position: absolute; bottom: -5px; left: 50%; margin-left: -5px; border: 5px solid transparent; border-top-color: var(--light); border-bottom: 0; }
.bubble.biz { background: var(--navy); color: var(--light); }
.bubble.biz::after { border-top-color: var(--navy); }

.hint { position: fixed; bottom: var(--gutter); left: 50%; transform: translateX(-50%); background: rgba(22, 23, 39, 0.78); color: var(--light); font-size: 12px; font-weight: 500; padding: 7px 14px; border-radius: 999px; pointer-events: none; transition: opacity .6s; white-space: nowrap; }
.hint.gone { opacity: 0; }
.loading { position: fixed; inset: 0; display: grid; place-items: center; background: #cfe4ee; font-weight: 700; color: var(--navy); transition: opacity .5s; }
.loading > div { display: flex; gap: 10px; align-items: center; }
.loading.done { opacity: 0; pointer-events: none; }

@media (max-width: 1100px) { .feed { width: 360px; } .head { max-width: 380px; } }
@media (max-width: 900px) and (min-width: 721px) { .panel { width: 340px; } }

/* phones */
@media (max-width: 720px) {
  .head { left: var(--gutter); right: var(--gutter); max-width: none; padding: 10px 12px; top: calc(var(--gutter) + env(safe-area-inset-top)); }
  h1 { font-size: 17px; } h1 .sub { font-size: 13px; }
  .explain { font-size: 12px; margin: 6px 0 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .legend { font-size: 11px; gap: 4px 10px; }
  .badge { font-size: 10.5px; }
  .controls { top: auto; bottom: calc(var(--gutter) + env(safe-area-inset-bottom)); left: var(--gutter); right: var(--gutter); justify-content: space-between; gap: 6px; padding: 6px; }
  .clock { padding: 0 4px; font-size: 12px; } .clock strong { font-size: 14px; min-width: 58px; }
  #day { display: none; }
  #random .lbl { display: none; } #random { width: 36px; padding: 0; justify-content: center; }
  .feed { left: var(--gutter); right: var(--gutter); width: auto; bottom: calc(var(--gutter) + 58px + env(safe-area-inset-bottom)); max-height: 150px; }
  .feed-head { padding: 9px 12px 4px; }
  #feedList li { grid-template-columns: 50px 1fr; font-size: 12px; padding: 4px 6px; }
  .panel { top: auto; left: var(--gutter); right: var(--gutter); width: auto; bottom: calc(var(--gutter) + 58px + env(safe-area-inset-bottom)); max-height: 56vh; max-height: 56dvh; padding: 14px; z-index: 5; }
  .hint { display: none; }
  body.panel-open .explain, body.panel-open .legend span:not(.badge) { display: none; }
  body.panel-open .head { padding: 8px 12px; }
  body.panel-open .legend { margin-top: 6px; }
  body.panel-open .panel { max-height: 48vh; max-height: 48dvh; }
  .bubble { max-width: 170px; font-size: 11px; padding: 6px 9px; }
}
