:root {
  --bg: #0a0a0b; --panel: #111113; --raised: #18181b; --hover: #1f1f23;
  --line: #26262b; --text: #ededee; --dim: #9a9aa3; --faint: #6b6b74;
  --accent: #e8e8ea; --accent-ink: #0a0a0b; --blue: #6ea8ff; --green: #4ade80; --amber: #f5b454; --red: #ff6b6b;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}
@media (prefers-color-scheme: light) {
  :root { --bg: #fafafa; --panel: #f3f3f4; --raised: #fff; --hover: #eaeaec; --line: #dedee2; --text: #131316; --dim: #5d5d66; --faint: #8b8b94; --accent: #131316; --accent-ink: #fff; --blue: #1d5fd1; --green: #15803d; --amber: #a86400; --red: #c62828; }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
[hidden] { display: none !important; }

#app { display: grid; grid-template-columns: 272px minmax(0, 1fr) 300px; height: 100vh; }

/* sidebar */
#sidebar { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.brand { display: flex; gap: 10px; align-items: center; padding: 16px 16px 12px; }
.logo { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; }
.brand-name { font-weight: 600; letter-spacing: -0.01em; }
.brand-sub { font-size: 12px; color: var(--dim); }
.brand-sub.ok::before, .brand-sub.bad::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; background: var(--green); }
.brand-sub.bad::before { background: var(--red); }
.views { display: flex; gap: 4px; padding: 0 12px 10px; }
.views button { flex: 1; padding: 6px 4px; border-radius: 8px; color: var(--dim); font-size: 12.5px; }
.views button:hover { background: var(--hover); color: var(--text); }
.views button.on { background: var(--raised); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
#filter { margin: 0 12px 8px; padding: 8px 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; outline: none; }
#filter:focus { border-color: var(--faint); }
#rooms { overflow-y: auto; padding: 0 8px 16px; flex: 1; }
.group-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--faint); padding: 14px 8px 4px; }
.room { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 8px; border-radius: 9px; text-align: left; }
.room:hover { background: var(--hover); }
.room.on { background: var(--raised); box-shadow: inset 0 0 0 1px var(--line); }
.room .label { flex: 1; min-width: 0; }
.room .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room .sub { font-size: 12px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hash { width: 28px; height: 28px; border-radius: 8px; background: var(--raised); border: 1px solid var(--line); display: grid; place-items: center; color: var(--dim); font-family: var(--mono); flex: none; }
.badge { font-size: 11px; padding: 1px 7px; border-radius: 10px; background: var(--hover); color: var(--dim); flex: none; }
.badge.you { background: var(--amber); color: #1a1200; font-weight: 600; }
.badge.new { background: var(--blue); color: #fff; }

/* avatars */
.av { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 600; flex: none; position: relative; color: #fff; }
.av.lg { width: 36px; height: 36px; font-size: 13px; }
.av.xl { width: 64px; height: 64px; font-size: 22px; }
.av.busy::after { content: ""; position: absolute; inset: -3px; border-radius: 50%; border: 2px solid var(--blue); border-top-color: transparent; animation: spin 0.9s linear infinite; }
.av.human { background: var(--accent); color: var(--accent-ink); }
@keyframes spin { to { transform: rotate(360deg); } }

/* main */
#main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.view { display: flex; flex-direction: column; flex: 1; min-height: 0; }
#banner { padding: 10px 20px; background: color-mix(in srgb, var(--amber) 16%, var(--bg)); border-bottom: 1px solid var(--line); font-size: 13px; }
#banner code { font-family: var(--mono); background: var(--raised); padding: 1px 6px; border-radius: 5px; }
#chat-head { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line); min-height: 61px; }
#chat-head .title { font-weight: 600; }
#chat-head .about { font-size: 12.5px; color: var(--dim); }
#chat-head .grow { flex: 1; min-width: 0; }
.chip-btn { padding: 5px 10px; border-radius: 8px; border: 1px solid var(--line); color: var(--dim); font-size: 12.5px; }
.chip-btn:hover { background: var(--hover); color: var(--text); }
.chip-btn.on { background: var(--raised); color: var(--text); border-color: var(--faint); }
.chip-btn.danger { color: var(--red); }

#messages { flex: 1; overflow-y: auto; padding: 20px 20px 8px; }
.empty { margin: 12vh auto 0; max-width: 420px; text-align: center; color: var(--dim); }
.empty h2 { color: var(--text); font-size: 18px; margin: 14px 0 6px; font-weight: 600; }
.empty .av { margin: 0 auto; }
.msg { display: flex; gap: 12px; padding: 8px 0; max-width: 860px; margin: 0 auto; }
.msg .body { min-width: 0; flex: 1; }
.msg .meta { display: flex; gap: 8px; align-items: baseline; }
.msg .who { font-weight: 600; }
.msg .tag { font-size: 11px; color: var(--faint); font-family: var(--mono); }
.msg .when { font-size: 11.5px; color: var(--faint); }
.msg .text { overflow-wrap: anywhere; }
.msg .text p { margin: 2px 0 8px; }
.msg .text ul, .msg .text ol { margin: 2px 0 8px; padding-left: 22px; }
.msg .text pre { background: var(--raised); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; overflow-x: auto; font: 12.5px/1.5 var(--mono); }
.msg .text code { font-family: var(--mono); font-size: 12.5px; background: var(--raised); padding: 1px 5px; border-radius: 5px; }
.msg .text pre code { background: none; padding: 0; }
.msg .text a { color: var(--blue); }
.mention { color: var(--blue); background: color-mix(in srgb, var(--blue) 14%, transparent); padding: 0 4px; border-radius: 5px; font-weight: 500; }
.mention.you { color: var(--amber); background: color-mix(in srgb, var(--amber) 16%, transparent); }
.msg.system { justify-content: center; }
.msg.system .note { font-size: 12.5px; color: var(--dim); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px; max-width: 640px; }
.msg.system.error .note { border-color: color-mix(in srgb, var(--red) 50%, var(--line)); color: var(--text); }
.msg.routine .text { color: var(--dim); border-left: 2px solid var(--line); padding-left: 10px; }

#activity { min-height: 24px; padding: 0 20px; font-size: 12.5px; color: var(--dim); max-width: 900px; width: 100%; margin: 0 auto; }
#activity .dots::after { content: "…"; animation: blink 1.2s steps(3) infinite; }
@keyframes blink { 50% { opacity: 0.3; } }

#composer { position: relative; display: flex; align-items: flex-end; gap: 8px; margin: 4px auto 18px; padding: 8px; width: calc(100% - 40px); max-width: 860px; background: var(--raised); border: 1px solid var(--line); border-radius: 16px; }
#composer:focus-within { border-color: var(--faint); }
#input { flex: 1; resize: none; border: 0; outline: 0; background: none; color: var(--text); font: inherit; padding: 6px 8px; max-height: 180px; }
#send, #mic { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none; }
#send { background: var(--accent); color: var(--accent-ink); }
#send:disabled { opacity: 0.35; cursor: default; }
#mic { color: var(--dim); }
#mic:hover { background: var(--hover); color: var(--text); }
#mic.on { background: var(--red); color: #fff; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--red) 25%, transparent); } }
#mention-pop { position: absolute; bottom: calc(100% + 6px); left: 8px; min-width: 260px; background: var(--raised); border: 1px solid var(--line); border-radius: 12px; padding: 4px; box-shadow: 0 10px 30px rgba(0,0,0,0.35); }
#mention-pop button { display: flex; gap: 10px; align-items: center; width: 100%; padding: 6px 8px; border-radius: 8px; text-align: left; }
#mention-pop button.on, #mention-pop button:hover { background: var(--hover); }
#mention-pop .id { color: var(--faint); font-family: var(--mono); font-size: 12px; }

/* detail */
#detail { background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto; padding: 20px 16px; }
#detail h3 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--faint); margin: 20px 0 8px; font-weight: 500; }
.profile { text-align: center; }
.profile .av { margin: 0 auto 10px; }
.profile .pname { font-weight: 600; font-size: 16px; }
.profile .ptitle { color: var(--dim); }
.kv { display: grid; grid-template-columns: 84px 1fr; gap: 6px 10px; font-size: 13px; }
.kv dt { color: var(--dim); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.member { display: flex; gap: 10px; align-items: center; padding: 6px; border-radius: 9px; width: 100%; text-align: left; }
.member:hover { background: var(--hover); }
.member .sub { font-size: 12px; color: var(--dim); }
.prompt-box { font: 12px/1.55 var(--mono); white-space: pre-wrap; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px; max-height: 300px; overflow: auto; color: var(--dim); }
.row-btns { display: flex; gap: 6px; flex-wrap: wrap; }

/* orb (Jarvis) */
.orb { width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 10px; background: radial-gradient(circle at 35% 30%, #bfe3ff, #3b82f6 45%, #0b1b3a 80%); box-shadow: 0 0 24px rgba(80,150,255,0.45), inset 0 0 14px rgba(255,255,255,0.25); animation: breathe 4s ease-in-out infinite; }
.orb.sm { width: 34px; height: 34px; margin: 0; flex: none; }
.orb.active { animation: think 0.9s ease-in-out infinite; }
.orb.speaking { animation: talk 0.45s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.05); box-shadow: 0 0 34px rgba(80,150,255,0.6), inset 0 0 14px rgba(255,255,255,0.25); } }
@keyframes think { 50% { transform: scale(0.9); filter: hue-rotate(40deg); } }
@keyframes talk { 50% { transform: scale(1.14); box-shadow: 0 0 44px rgba(110,170,255,0.85), inset 0 0 14px rgba(255,255,255,0.35); } }
@media (prefers-reduced-motion: reduce) { .orb, .orb.active, .orb.speaking, .av.busy::after, #mic.on { animation: none; } }

/* org + routines pages */
.page-head { padding: 22px 28px 6px; }
.page-head h1 { margin: 0; font-size: 20px; letter-spacing: -0.01em; }
.page-head p { margin: 4px 0 0; color: var(--dim); }
#org-tree, #routine-list { padding: 14px 28px 40px; overflow-y: auto; flex: 1; }
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { margin-left: 18px; padding-left: 18px; border-left: 1px solid var(--line); }
.tree li { padding: 4px 0; position: relative; }
.tree ul > li::before { content: ""; position: absolute; left: -18px; top: 26px; width: 14px; border-top: 1px solid var(--line); }
.node { display: inline-flex; gap: 10px; align-items: center; padding: 7px 14px 7px 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--raised); text-align: left; min-width: 250px; }
button.node:hover { border-color: var(--faint); }
.node .sub { font-size: 12px; color: var(--dim); }
.routine { display: flex; gap: 14px; align-items: flex-start; border: 1px solid var(--line); background: var(--raised); border-radius: 14px; padding: 14px 16px; margin-bottom: 10px; max-width: 820px; }
.routine .grow { flex: 1; min-width: 0; }
.routine .rname { font-weight: 600; }
.routine .rmeta { font-size: 12.5px; color: var(--dim); }
.routine .rprompt { font-size: 13px; color: var(--dim); margin-top: 6px; }
.switch { width: 38px; height: 22px; border-radius: 11px; background: var(--hover); border: 1px solid var(--line); position: relative; flex: none; margin-top: 2px; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--dim); transition: transform 0.15s; }
.switch.on { background: var(--green); border-color: var(--green); }
.switch.on::after { transform: translateX(16px); background: #fff; }

@media (max-width: 1100px) { #app { grid-template-columns: 240px minmax(0, 1fr); } #detail { display: none; } }
@media (max-width: 700px) { #app { grid-template-columns: 1fr; } #sidebar { display: none; } }

/* ---- accounts, modals, mobile (added with logins) ---- */
.grow { flex: 1; min-width: 0; }
.av img, .av.photo { object-fit: cover; }
img.av { display: block; background: var(--raised); }
#sidebar { position: relative; }
.me-card { display: flex; align-items: center; gap: 10px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); text-align: left; width: 100%; }
.me-card:hover { background: var(--hover); }
.me-card .sub { font-size: 12px; color: var(--dim); }
.views { flex-wrap: wrap; }
.views button { flex: 1 1 auto; }
.side-action { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 8px; border-radius: 9px; color: var(--dim); text-align: left; }
.side-action:hover { background: var(--hover); color: var(--text); }
.side-action .hash { border-style: dashed; }

#auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 28px 24px; }
.auth-card .orb { margin-bottom: 16px; }
.auth-card h1 { font-size: 20px; margin: 0 0 4px; text-align: center; letter-spacing: -0.01em; }
.auth-card p.lead { color: var(--dim); text-align: center; margin: 0 0 20px; }
label.field { display: block; margin-bottom: 12px; font-size: 12.5px; color: var(--dim); }
label.field input, label.field select, label.field textarea { display: block; width: 100%; margin-top: 5px; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; outline: none; }
label.field textarea { min-height: 130px; resize: vertical; font: 12.5px/1.5 var(--mono); }
label.field input:focus, label.field select:focus, label.field textarea:focus { border-color: var(--faint); }
.btn { display: inline-flex; justify-content: center; align-items: center; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--raised); }
.btn:hover { border-color: var(--faint); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.wide { width: 100%; }
.btn.danger { color: var(--red); }
.chip-btn.solid { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.form-error { color: var(--red); font-size: 13px; min-height: 18px; margin: 4px 0 8px; }
.hint { font-size: 12px; color: var(--faint); margin: -6px 0 12px; }

#modal { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: grid; place-items: center; padding: 16px; z-index: 50; }
.sheet { width: 100%; max-width: 480px; max-height: calc(100vh - 32px); overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 20px; }
.sheet h2 { margin: 0 0 14px; font-size: 17px; }
.sheet .foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; flex-wrap: wrap; }
.sheet .foot .left { margin-right: auto; }
.avatar-row { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.checks { border: 1px solid var(--line); border-radius: 12px; max-height: 260px; overflow-y: auto; padding: 6px; background: var(--bg); margin-bottom: 12px; }
.checks .grp { display: flex; justify-content: space-between; align-items: center; font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--faint); padding: 8px 6px 2px; }
.checks .grp button { color: var(--blue); font-size: 12px; text-transform: none; letter-spacing: 0; }
.checks label { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 7px; }
.checks label:hover { background: var(--hover); }
.checks .sub { color: var(--faint); font-size: 12px; }

.page-head { display: flex; align-items: flex-start; gap: 12px; }
.page-head > div { flex: 1; }
.page-body { padding: 14px 28px 40px; overflow-y: auto; flex: 1; }
.back { display: none; font-size: 26px; line-height: 1; padding: 0 8px 4px 0; color: var(--dim); }
.person { display: flex; gap: 14px; align-items: center; border: 1px solid var(--line); background: var(--raised); border-radius: 14px; padding: 12px 16px; margin-bottom: 10px; max-width: 820px; width: 100%; text-align: left; }
button.person:hover { border-color: var(--faint); }
.person .sub { font-size: 12.5px; color: var(--dim); }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: var(--hover); color: var(--dim); white-space: nowrap; }
.pill.admin { background: color-mix(in srgb, var(--amber) 22%, transparent); color: var(--amber); }
.pill.builder { background: color-mix(in srgb, var(--blue) 20%, transparent); color: var(--blue); }
.role-notes { max-width: 820px; color: var(--dim); font-size: 13px; margin: 18px 0 0; }
.role-notes b { color: var(--text); font-weight: 600; }
#chat-head .back, #chat-head .info { display: none; }

@media (max-width: 1100px) {
  #chat-head .info { display: inline-flex; }
  #detail.open { display: block; position: fixed; inset: 0 0 0 auto; width: min(340px, 100vw); z-index: 40; box-shadow: -20px 0 60px rgba(0,0,0,0.5); }
}
@media (max-width: 760px) {
  #app { grid-template-columns: 1fr; height: 100dvh; }
  #sidebar { display: flex; border-right: 0; }
  #main { display: none; }
  body.in-view #sidebar { display: none; }
  body.in-view #main { display: flex; height: 100dvh; }
  .back, #chat-head .back { display: inline-block; }
  #chat-head { padding: 10px 12px; gap: 8px; padding-top: calc(10px + env(safe-area-inset-top)); }
  #chat-head .chip-btn { padding: 5px 8px; }
  #chat-head .hide-sm { display: none; }
  .brand { padding-top: calc(16px + env(safe-area-inset-top)); }
  #messages { padding: 14px 12px 8px; }
  #composer { width: calc(100% - 20px); margin-bottom: calc(10px + env(safe-area-inset-bottom)); }
  #input, label.field input, label.field select, label.field textarea, #filter { font-size: 16px; } /* stops iOS zooming on focus */
  .page-head { padding: calc(14px + env(safe-area-inset-top)) 14px 6px; }
  .page-body { padding: 12px 14px 40px; }
  .node { min-width: 0; }
  .tree ul { margin-left: 8px; padding-left: 12px; }
  .tree ul > li::before { left: -12px; width: 10px; }
  .room { padding: 9px 8px; }
  .msg .tag { display: none; }
}

/* ---- voice calls ---- */
#call { position: fixed; inset: 0; z-index: 45; background: radial-gradient(ellipse at 50% 20%, #101a33 0%, var(--bg) 60%); display: flex; flex-direction: column; align-items: center; padding: calc(20px + env(safe-area-inset-top)) 16px calc(18px + env(safe-area-inset-bottom)); color: #ededee; }
.call-top { text-align: center; }
.call-top .name { font-weight: 600; font-size: 17px; }
.call-top .clock { color: #9a9aa3; font-size: 13px; font-variant-numeric: tabular-nums; }
.call-grid { flex: 1; display: flex; flex-wrap: wrap; gap: 26px 30px; align-items: center; justify-content: center; align-content: center; width: 100%; max-width: 760px; }
.tile { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 150px; text-align: center; font-size: 13px; }
.tile .ring { width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center; position: relative; transition: box-shadow 0.2s, transform 0.2s; }
.tile .ring > * { width: 84px !important; height: 84px !important; font-size: 26px !important; margin: 0 !important; }
.tile .ring img { width: 84px; height: 84px; border-radius: 50%; }
.tile.speaking .ring { box-shadow: 0 0 0 3px #4ade80, 0 0 34px rgba(74,222,128,0.5); animation: talk 0.5s ease-in-out infinite; }
.tile.thinking .ring { box-shadow: 0 0 0 3px #6ea8ff; animation: breathe 1.2s ease-in-out infinite; }
.tile.listening .ring { box-shadow: 0 0 0 3px #f5b454, 0 0 26px rgba(245,180,84,0.4); }
.tile .state { color: #9a9aa3; font-size: 12px; min-height: 16px; }
.call-caption { min-height: 66px; max-width: 640px; text-align: center; color: #c9c9d1; font-size: 15px; line-height: 1.45; margin-bottom: 14px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.call-caption b { color: #fff; font-weight: 600; }
#call-type, #meet-type { display: flex; gap: 8px; width: 100%; max-width: 520px; margin-bottom: 14px; }
#call-type input, #meet-type input { flex: 1; padding: 10px 12px; border-radius: 12px; border: 1px solid #2b2b33; background: rgba(255,255,255,0.05); color: #fff; font: inherit; font-size: 16px; outline: none; }
.call-ctl { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.call-ctl button { padding: 11px 16px; border-radius: 24px; background: rgba(255,255,255,0.09); color: #fff; font-weight: 500; }
.call-ctl button:hover { background: rgba(255,255,255,0.16); }
.call-ctl button.on { background: #f5b454; color: #1a1200; }
.call-ctl button.hang { background: #e5484d; }
.msg .tag.call { color: var(--green); }
@media (prefers-reduced-motion: reduce) { .tile.speaking .ring, .tile.thinking .ring { animation: none; } }

.call-meter { width: 160px; height: 4px; border-radius: 2px; background: rgba(255,255,255,0.12); overflow: hidden; margin: 0 auto 12px; }
#call-level { height: 100%; width: 0; background: #4ade80; transition: width 0.08s linear; }

.new-meeting { margin: 0 12px 8px; }

/* raised hands in meetings */
.tile .ring { position: relative; }
.hand-badge { position: absolute; right: -4px; top: -4px; font-size: 26px; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5)); animation: wave 1.2s ease-in-out infinite; }
@keyframes wave { 50% { transform: rotate(14deg); } }
.tile.hand .ring { box-shadow: 0 0 0 3px #f5b454; }
.hand-reason { font-size: 12px; color: #f5d9a8; max-width: 150px; line-height: 1.35; }
.hand-btns { display: flex; gap: 6px; margin-top: 4px; }
.hand-btns button { padding: 5px 10px; border-radius: 14px; background: rgba(255,255,255,0.12); color: #fff; font-size: 12px; }
.hand-btns button:first-child { background: #f5b454; color: #1a1200; font-weight: 600; }
@media (prefers-reduced-motion: reduce) { .hand-badge { animation: none; } }

.twostep { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 12px; font-size: 13px; }
.twostep b { font-weight: 500; }

/* all bots table */
table.bots { border-collapse: collapse; width: 100%; max-width: 980px; }
table.bots th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--faint); font-weight: 500; padding: 6px 10px; }
table.bots td { padding: 4px 10px; border-top: 1px solid var(--line); vertical-align: middle; }
table.bots tr.grp td { border-top: 0; padding-top: 18px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--faint); }
table.bots select { background: var(--raised); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font: inherit; }
table.bots .tick { display: flex; align-items: center; gap: 8px; color: var(--dim); font-size: 13px; }
table.bots .sub { font-size: 12.5px; color: var(--dim); }
@media (max-width: 760px) { table.bots th:nth-child(5), table.bots td:nth-child(5) { display: none; } table.bots td { padding: 4px 4px; } }

/* a bot's computer */
#desk { position: fixed; inset: 0; z-index: 44; background: var(--bg); display: flex; flex-direction: column; }
.desk-bar, .desk-keys { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
.desk-keys { border-bottom: 0; border-top: 1px solid var(--line); padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
.desk-bar { padding-top: calc(8px + env(safe-area-inset-top)); }
.desk-name { font-weight: 600; margin: 0 6px; white-space: nowrap; }
#desk-url, #desk-type { width: 100%; padding: 7px 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; font-size: 16px; outline: none; }
#desk-type { flex: 1; width: auto; min-width: 160px; }
#desk-tabs { max-width: 200px; background: var(--raised); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font: inherit; }
.desk-screen { flex: 1; min-height: 0; display: grid; place-items: center; background: #000; position: relative; overflow: hidden; }
#desk-img { max-width: 100%; max-height: 100%; cursor: default; user-select: none; -webkit-user-drag: none; touch-action: manipulation; }
#desk-status { position: absolute; bottom: 10px; left: 0; right: 0; text-align: center; color: #c9c9d1; font-size: 13px; pointer-events: none; }
@media (max-width: 760px) { .desk-name { display: none; } #desk-go { order: 9; flex-basis: 100%; } #desk-tabs { max-width: 120px; } }

/* posts made by the editor */
.media { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 4px; }
.media img, .media video { height: 280px; border-radius: 10px; border: 1px solid var(--line); background: #000; display: block; }
.media-links { font-size: 12.5px; color: var(--dim); }
.media-links a { color: var(--blue); }
@media (max-width: 760px) { .media img, .media video { height: 200px; } }

/* publishing accounts */
.pubcard { border: 1px solid var(--line); background: var(--raised); border-radius: 14px; padding: 14px 16px; margin-bottom: 12px; max-width: 760px; }
.pubhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pubgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pubnote { border: 1px solid var(--amber); border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; max-width: 760px; }
.pubcard .sub { font-size: 12.5px; color: var(--dim); }
@media (max-width: 760px) { .pubgrid { grid-template-columns: 1fr; } }

/* ---- handoffs between bots ---- */
.handoff.late { border-color: var(--red); }
.handoff.answered, .handoff.closed { opacity: 0.75; }
.handoff .row-btns { display: flex; flex-direction: column; gap: 6px; }
@media (max-width: 760px) { .handoff { flex-wrap: wrap; } .handoff .row-btns { flex-direction: row; flex-basis: 100%; } }

/* meetings: who is talking, who is muted */
.tile.human-tile.talking .ring { animation: talkring 1s ease-out infinite; }
@keyframes talkring { 0% { box-shadow: 0 0 0 3px #8b8cff, 0 0 0 3px rgba(139,140,255,0.55); } 100% { box-shadow: 0 0 0 3px #8b8cff, 0 0 0 14px rgba(139,140,255,0); } }
.tile .ring > .mute-badge { position: absolute; right: 4px; bottom: 4px; width: 28px !important; height: 28px !important; font-size: 12px !important; border-radius: 50%; background: #26262d; border: 2px solid #0e0e12; display: grid; place-items: center; color: #f87171; }
.mute-badge svg { width: 15px; height: 15px; }
.tile.human-tile.muted .ring img, .tile.human-tile.muted .ring .av { filter: saturate(0.6); }
.tile .ring > .hand-badge { width: auto !important; height: auto !important; font-size: 26px !important; }
@media (prefers-reduced-motion: reduce) { .tile.human-tile.talking .ring { animation: none; box-shadow: 0 0 0 3px #8b8cff; } }

/* meetings: cameras, and bots as cartoons on camera */
.tile.has-video { width: 236px; }
.tile.has-video .ring { width: 224px; height: 168px; border-radius: 18px; overflow: hidden; background: #000; }
.tile.has-video .ring > video, .tile.has-video .ring > svg.cartoon { width: 100% !important; height: 100% !important; border-radius: 18px; object-fit: cover; display: block; }
.tile .ring > video.mirror { transform: scaleX(-1); }
.tile.has-video .ring > .mute-badge { right: 8px; bottom: 8px; }
.tile.bot-tile.speaking .ring { animation: none; box-shadow: 0 0 0 3px #4ade80, 0 0 30px rgba(74,222,128,0.45); }
.tile.bot-tile.thinking .ring { animation: none; box-shadow: 0 0 0 3px #6ea8ff; }
.cartoon .lids rect { transform-box: fill-box; transform-origin: center; transform: scaleY(0); animation: blink 4.3s infinite; }
@keyframes blink { 0%, 93%, 100% { transform: scaleY(0); } 96% { transform: scaleY(1); } }
.cartoon .pupils.up { transform: translateY(-3px); }
.cartoon .think { animation: bob 1.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-3px); } }
@media (max-width: 520px) { .tile.has-video { width: 168px; } .tile.has-video .ring { width: 160px; height: 120px; } }
@media (prefers-reduced-motion: reduce) { .cartoon .lids rect, .cartoon .think { animation: none; } }

/* a bot's own picture as its puppet: the drawn mouth shows only while it talks */
.cartoon.photo [data-mouth] { opacity: 0; transition: opacity 0.12s; }
.bot-tile.speaking .cartoon.photo [data-mouth] { opacity: 1; }
.cartoon.photo .think { transform: translate(14px, 0); }
.mouth-pick { position: relative; display: inline-block; max-width: 220px; cursor: crosshair; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.mouth-pick img { display: block; width: 100%; height: auto; }
.mouth-dot { position: absolute; width: 26px; height: 12px; margin: -6px 0 0 -13px; border-radius: 50%; background: #3a0606; border: 2px solid #fff; box-shadow: 0 0 0 1px #111; pointer-events: none; }

/* drawn puppets in their scene */
.tile.has-video .ring > .stage { width: 100% !important; height: 100% !important; font-size: inherit !important; position: relative; overflow: hidden; border-radius: 18px; background: #2a2a33; }
.stage .scene { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.stage .scene.plain { background: radial-gradient(circle at 50% 35%, #4b4b63, #1d1d26); }
.stage .pup { position: absolute; left: 50%; bottom: -4%; height: 96%; aspect-ratio: auto; transform-origin: 50% 100%; translate: -50% 0; animation: breathe-pup 3.2s ease-in-out infinite; --open: 0; }
.stage .pup img { display: block; height: 100%; width: auto; }
.stage .pup .pup-jaw { position: absolute; left: 0; top: 0; transform: translateY(calc(var(--open) * 5%)); }
.stage .pup .pup-hole { position: absolute; left: var(--mx); top: var(--my); width: 17%; height: calc(var(--open) * 5% + 0.5%); translate: -50% -15%; background: #2a0505; border-radius: 0 0 50% 50% / 0 0 100% 100%; border: 2px solid #111; opacity: min(1, calc(var(--open) * 8)); }
.stage.talking .pup { animation: bob-pup 0.42s ease-in-out infinite; }
.stage.attending:not(.talking) .pup { animation: nod-pup 1.6s ease-in-out infinite; }
.stage.thinking .pup { animation: none; rotate: -4deg; translate: -50% -2%; }
.stage .pup-think { position: absolute; right: 8%; top: 6%; width: 22%; animation: bob 1.4s ease-in-out infinite; }
.stage .pup-wait { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 26px; }
@keyframes breathe-pup { 50% { scale: 1.012 1.02; } }
@keyframes bob-pup { 50% { translate: -50% -1.5%; rotate: 1deg; } }
@keyframes nod-pup { 0%, 100% { rotate: 0deg; } 30% { rotate: 2.5deg; } 60% { rotate: -1deg; } }
@media (prefers-reduced-motion: reduce) { .stage .pup, .stage.talking .pup, .stage.attending .pup, .stage .pup-think { animation: none; } }
.puppet-prev { position: relative; width: 224px; height: 168px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); margin-bottom: 8px; }
.puppet-prev .stage { width: 100%; height: 100%; position: relative; }
/* the round 84px avatar rule must not shrink the scene or the puppet pieces */
.tile .ring .stage img.scene { width: 100%; height: 100%; border-radius: 0; }
.tile .ring .stage .pup img { width: auto; height: 100%; border-radius: 0; }

/* meetings: the side chat */
#call:has(.meet-main) { flex-direction: row; align-items: stretch; padding: 0; }
.meet-main { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; overflow-y: auto; padding: calc(20px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom)); }
.meet-chat { display: none; width: 340px; flex: none; flex-direction: column; border-left: 1px solid #23232b; background: rgba(10,10,16,0.85); }
#call.chat-open .meet-chat { display: flex; }
.meet-chat-head { display: flex; justify-content: space-between; align-items: center; padding: calc(14px + env(safe-area-inset-top)) 14px 10px; font-weight: 600; color: #fff; border-bottom: 1px solid #23232b; }
.meet-chat-head button { color: #9a9aa3; font-size: 22px; line-height: 1; padding: 0 4px; }
.meet-chat-list { flex: 1; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 10px; }
.mc-msg { max-width: 92%; }
.mc-msg .mc-meta { font-size: 12px; color: #9a9aa3; margin-bottom: 2px; }
.mc-msg .mc-meta b { color: #d6d6de; font-weight: 600; }
.mc-msg .mc-text { background: rgba(255,255,255,0.07); color: #ececf1; padding: 8px 10px; border-radius: 12px; font-size: 14px; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.mc-msg.bot .mc-text { background: rgba(110,168,255,0.14); }
.mc-msg.mine { align-self: flex-end; text-align: right; }
.mc-msg.mine .mc-text { background: rgba(74,222,128,0.16); text-align: left; }
.mc-note { align-self: center; font-size: 12px; color: #8a8a93; text-align: center; max-width: 90%; }
.meet-chat #meet-type { margin: 0; padding: 10px 12px calc(12px + env(safe-area-inset-bottom)); max-width: none; border-top: 1px solid #23232b; }
@media (max-width: 899px) {
  #call.chat-open .meet-chat { position: absolute; inset: 0; width: auto; z-index: 2; background: #0b0b10; border-left: 0; }
}
