:root {
  color-scheme: dark;
  --bg: #101412;
  --panel: #191f1c;
  --aside: #141916;
  --line: #303c36;
  --text: #e7eeea;
  --muted: #97a59d;
  --accent: #aebdb4;
  --on-accent: #141c18;
  --danger: #e0a8a2;
  --chip: #24302b;
  --mine: #1e3330;
  font-family: "Segoe UI", sans-serif;
}
[data-theme="white"] {
  color-scheme: light;
  --bg: #f3f3f2;
  --panel: #ffffff;
  --aside: #e8e8e6;
  --line: #d4d4d1;
  --text: #1a1a1a;
  --muted: #5c5c5a;
  --accent: #24384c;
  --on-accent: #f7f7f6;
  --danger: #9d3434;
  --chip: #e4e8ee;
  --mine: #e4edf6;
}
[data-theme="dusk"] {
  color-scheme: dark;
  --bg: #10131c;
  --panel: #191e2c;
  --aside: #141824;
  --line: #2c3550;
  --text: #e7ecf8;
  --muted: #9aa6c2;
  --accent: #9aabc4;
  --on-accent: #151820;
  --danger: #c99292;
  --chip: #24304a;
  --mine: #243456;
}
[data-theme="sand"] {
  color-scheme: light;
  --bg: #f4ecdf;
  --panel: #fffaf3;
  --aside: #eadcc8;
  --line: #dcc9ae;
  --text: #2a2116;
  --muted: #6a5844;
  --accent: #8a4e24;
  --on-accent: #fff8f1;
  --danger: #9d3434;
  --chip: #f3ddc4;
  --mine: #f8e2c6;
}
[data-theme="moss"] {
  color-scheme: dark;
  --bg: #0c140f;
  --panel: #15261a;
  --aside: #101c14;
  --line: #2d4a36;
  --text: #e5f3e6;
  --muted: #86a88c;
  --accent: #d4c7a2;
  --on-accent: #1a2214;
  --danger: #e0a8a2;
  --chip: #1c3d28;
  --mine: #174a30;
}
[data-theme="mist"] {
  color-scheme: light;
  --bg: #e6eef2;
  --panel: #f7fafb;
  --aside: #d7e3ea;
  --line: #c1d0da;
  --text: #16242c;
  --muted: #4e6270;
  --accent: #1f556c;
  --on-accent: #f4fafb;
  --danger: #9d3434;
  --chip: #d0e4ee;
  --mine: #d4eaf3;
}
[data-theme="haze"] {
  color-scheme: light;
  --bg: #eeeaf2;
  --panel: #f8f6fb;
  --aside: #e0dae8;
  --line: #cdc5d8;
  --text: #241f2c;
  --muted: #61596c;
  --accent: #543e74;
  --on-accent: #f8f6fb;
  --danger: #9d3434;
  --chip: #e3dced;
  --mine: #eadff4;
}
[data-theme="ink"] {
  color-scheme: dark;
  --bg: #14181c;
  --panel: #1c2228;
  --aside: #181d22;
  --line: #313b46;
  --text: #e6eaee;
  --muted: #93a0ab;
  --accent: #8aa0ad;
  --on-accent: #14191d;
  --danger: #c48984;
  --chip: #243038;
  --mine: #1e2a32;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}
button, input, select, textarea {
  font: inherit;
  color: inherit;
}
button {
  background: var(--accent);
  color: var(--on-accent);
  border: 0;
  border-radius: 999px;
  padding: 0.7rem 1.1rem;
  font-weight: 650;
  cursor: pointer;
}
button.ghost, #logout, #back, #tab-join, #tab-in, #passkey-login, #add-passkey, #audio, #video, #status-line, #shield {
  background: transparent;
  color: var(--text);
}
#onboarding, #auth {
  min-height: 100vh;
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 0.8rem;
  max-width: 32rem;
  margin: 0 auto;
  padding: 2rem 1.2rem;
}
a.apk { color: var(--accent); font-size: 0.92rem; }
.step { color: var(--accent); letter-spacing: 0.08em; text-transform: uppercase; font-size: 0.78rem; }
h1 { font-size: 1.8rem; line-height: 1.25; margin: 0; }
.lead, .facts, #auth-error, #chat-note, #dev-code { color: var(--muted); margin: 0; }
.facts { padding-left: 1.15rem; display: grid; gap: 0.35rem; }
#auth-error:empty, #chat-note:empty { display: none; }
form { display: grid; gap: 0.7rem; width: min(100%, 24rem); }
label { display: grid; gap: 0.3rem; color: var(--muted); font-size: 0.92rem; }
.user-line { display: flex; gap: 0.4rem; }
.user-line input { flex: 1; min-width: 0; }
#suggest { background: transparent; color: var(--text); border: 1px solid var(--line); white-space: nowrap; }
input:not([type="checkbox"]), select, textarea {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem 0.8rem;
}
.tabs { display: flex; gap: 0.6rem; }
.tabs .on { color: var(--accent); }
#app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}
aside {
  border-right: 1px solid var(--line);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  background: var(--aside);
}
.brand, .top, .media, .pair { display: flex; align-items: center; gap: 0.6rem; }
.brand { justify-content: space-between; }
.profile { display: grid; gap: 0.15rem; padding: 0.1rem 0.15rem 0.35rem; }
.profile strong { font-size: 0.95rem; }
#profile-email { color: var(--muted); font-size: 0.82rem; overflow-wrap: anywhere; }
#contacts { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35rem; }
#contacts button {
  width: 100%;
  text-align: left;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
}
#contacts .active { background: var(--chip); color: var(--accent); }
main { display: grid; grid-template-rows: auto 1fr auto auto; min-height: 100vh; }
.top {
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
#shield { width: 42px; height: 42px; border-radius: 12px; padding: 0; }
#shield svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.7; }
#shield.handshake { color: var(--muted); }
#shield.verified { color: var(--accent); animation: pulse 1.6s ease-in-out infinite; }
#shield.mismatch { color: var(--danger); }
@keyframes pulse { 50% { filter: drop-shadow(0 0 6px var(--accent)); } }
#status-line {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.82rem;
  padding: 0;
  text-align: left;
}
#words { margin-top: 0.45rem; }
#word-list { font-family: ui-monospace, Consolas, monospace; letter-spacing: 0.04em; margin: 0 0 0.4rem; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--chip); color: var(--accent); font-weight: 700;
}
#circuit { width: 120px; height: 24px; }
#circuit path {
  fill: none; stroke: var(--accent); stroke-width: 1.5;
  stroke-dasharray: 160; stroke-dashoffset: 160;
}
#circuit.live path { animation: draw 1.1s ease forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
#secured { margin: 0; min-height: 1.2rem; color: var(--accent); letter-spacing: 0.04em; }
#secured span { opacity: 0; animation: letter 0.35s ease forwards; }
@keyframes letter { to { opacity: 1; } }
#stage { position: relative; min-height: 0; }
#messages {
  height: 100%;
  overflow: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
#remote-video {
  width: min(240px, 46vw);
  border-radius: 16px;
  position: absolute;
  right: 1rem;
  top: 1rem;
  background: #000;
}
.bubble {
  max-width: min(88%, 42rem);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px 16px 16px 6px;
  padding: 0.55rem 0.7rem 0.4rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.2rem 0.45rem;
}
.bubble.mine { align-self: flex-end; border-radius: 16px 16px 6px 16px; background: var(--mine); }
.bubble p { margin: 0; white-space: pre-wrap; word-break: break-word; }
.lock { width: 14px; height: 14px; }
.lock .body { fill: transparent; stroke: var(--muted); }
.lock .shackle { fill: none; stroke: var(--muted); }
.lock.filled .body { fill: var(--accent); stroke: var(--accent); }
.lock.filled .shackle { stroke: var(--accent); }
.arc { width: 18px; height: 18px; grid-column: 2; }
.arc circle { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; opacity: 0.85; }
.bubble.gone { opacity: 0; transition: opacity 0.7s ease; }
#composer { width: 100%; display: flex; gap: 0.5rem; padding: 0.8rem 1rem 0.2rem; align-items: end; }
#composer select { width: 9.5rem; flex: 0 0 auto; }
#composer input { flex: 1 1 auto; min-width: 0; min-height: 3.1rem; }
#composer button { flex: 0 0 auto; }
#chat-note { padding: 0 1rem 0.8rem; font-size: 0.85rem; }
#add-passkey, #passkey-login, #admin { border: 1px solid var(--line); }
.theme-pick { display: grid; gap: 0.3rem; color: var(--muted); font-size: 0.85rem; width: 11rem; }
#desk {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: var(--bg);
  overflow: auto;
  padding: 1.2rem 1.2rem 3rem;
}
.desk-wrap { max-width: 960px; margin: 0 auto; display: grid; gap: 0.9rem; }
.desk-bar, .row-actions { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; }
.desk-bar { justify-content: space-between; }
#desk-tabs { display: flex; flex-wrap: wrap; gap: 0.35rem; }
#desk-tabs button { background: transparent; color: var(--text); border: 1px solid var(--line); padding: 0.35rem 0.7rem; }
#desk-tabs button.on { color: var(--accent); border-color: var(--accent); }
#desk h2, #desk h3 { margin: 0; }
#desk-note, .hint { margin: 0; color: var(--muted); }
#desk-search { flex: 1; min-width: 12rem; }
.desk-form { display: grid; gap: 0.55rem; max-width: 36rem; }
.desk-form textarea { min-height: 7rem; resize: vertical; }
#desk-stats, .stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr)); gap: 0.45rem; }
.bars { display: grid; gap: 0.35rem; }
.bar-row { display: grid; grid-template-columns: 4.2rem 1fr 2rem; gap: 0.45rem; align-items: center; color: var(--muted); font-size: 0.82rem; }
.bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 800px) { .two { grid-template-columns: 1fr; } }
.stat {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.55rem 0.7rem;
  background: var(--panel);
}
.stat b { display: block; font-size: 1.2rem; }
.stat span { color: var(--muted); font-size: 0.78rem; }
.account-card {
  display: grid;
  gap: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.75rem;
  background: var(--panel);
}
.account-card strong { font-weight: 650; }
.account-card p, #desk-rooms { margin: 0; color: var(--muted); font-size: 0.88rem; }
#desk-rooms { list-style: none; padding: 0; display: grid; gap: 0.3rem; }
.row-actions button, #desk-close, #purge-mail, #purge-log {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  padding: 0.4rem 0.75rem;
}
main.desk-open { grid-template-rows: 1fr; }
main.desk-open .top, main.desk-open #stage, main.desk-open #composer, main.desk-open #chat-note { display: none; }
#back { display: none; }
@media (max-width: 800px) {
  #composer { display: grid; grid-template-columns: 1fr auto; }
  #composer select { width: 100%; grid-column: 1 / -1; }
  #app { grid-template-columns: 1fr; }
  #app.chatting aside { display: none; }
  #app:not(.chatting) main { display: none; }
  #back { display: inline-flex; }
  #circuit { width: 72px; }
}
