/* Night majlis: deep teal ground, a kraft box wrapped in a Sadu band, white note paper written in clear blue marker.
   Cards stay quiet; the box and the paper carry the identity. One committed dark look. */
:root {
  --night: #0d2321;
  --night-2: #132e2b;
  --night-3: #1b3f3a;
  --line: #2a524c;
  --line-soft: #1e403b;
  --text: #ecf2ee;
  --muted: #98b3ac;
  --kraft: #c8975c;
  --kraft-top: #ddb27c;
  --kraft-edge: #8a6131;
  --slot: #2a1707;
  --sadu: #ad2a2c;
  --sadu-cream: #f3e6cf;
  --sadu-black: #1b1414;
  --ochre: #e7ab3f;
  --ochre-ink: #2b1c04;
  --paper: #fdfbf5;
  --paper-back: #f1ebdc;
  --rule: #d3deec;
  --margin: #eab0ad;
  --pen: #1f3a86;
  --ok: #5cc28f;
  --warn: #f08a7c;
  --warn-ink: #2a0b07;
  --rec: #e5484d;
  --shadow: #020d0c;
  --r-card: 18px;
  --r-ctl: 12px;
  --f-display: "Reem Kufi", "Readex Pro", "Segoe UI", Tahoma, sans-serif;
  --f-ui: "Readex Pro", "Segoe UI", Tahoma, system-ui, sans-serif;
  --f-paper: "Marhey", "Readex Pro", "Segoe UI", Tahoma, sans-serif;
  --f-code: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }
html.locked, html.locked body { overflow: hidden; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--night);
  background-image: radial-gradient(90% 46% at 50% 0%, var(--night-3) 0%, transparent 72%);
  background-repeat: no-repeat;
  color: var(--text);
  font: 400 15px/1.6 var(--f-ui);
}
button, input, textarea, select { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
h1, h2 { text-wrap: balance; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.center { text-align: center; }

/* ---------- boot ---------- */
.boot { position: fixed; inset: 0; display: grid; place-items: center; }
.spinner { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--ochre); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  padding-top: env(safe-area-inset-top, 0px);
  background: color-mix(in srgb, var(--night) 86%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto; height: 62px;
  display: flex; align-items: center; gap: 10px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font: 700 19px/1 var(--f-display); min-width: 0; }
.brand span { white-space: nowrap; }
.spacer { flex: 1; }
.user-chip { display: inline-flex; align-items: center; gap: 8px; padding: 4px 4px 4px 6px; border: 1px solid var(--line); border-radius: 999px; background: var(--night-2); min-width: 0; }
.me-name { font-weight: 500; font-size: 14px; max-width: 12ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-btn { border: 0; background: var(--night-3); color: var(--muted); border-radius: 999px; padding: 6px 12px; font-size: 13px; cursor: pointer; }
.chip-btn:hover { color: var(--text); }
.chip-btn:focus-visible { outline: 2px solid var(--ochre); outline-offset: 2px; }
@media (max-width: 420px) {
  .brand span { display: none; }
}

/* ---------- avatars ---------- */
.avatar {
  --c: var(--ochre);
  width: 30px; height: 30px; flex: none;
  display: inline-grid; place-items: center;
  border-radius: 50%;
  background: var(--c);
  color: #fff;
  font: 700 14px/1 var(--f-ui);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .14);
}
.avatar.lg { width: 38px; height: 38px; font-size: 16px; }

/* ---------- layout ---------- */
.view {
  max-width: 1080px; margin: 0 auto;
  padding-block: 26px 56px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.card { background: var(--night-2); border: 1px solid var(--line-soft); border-radius: var(--r-card); padding: 20px; min-width: 0; }
.card h2 { margin: 0; font: 600 17px/1.35 var(--f-ui); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.h-display { margin: 0; font: 700 clamp(28px, 6vw, 38px)/1.2 var(--f-display); }
.h-display span { color: var(--ochre); }
.empty { margin: 6px 0 0; color: var(--muted); }
.badge {
  min-width: 22px; padding: 3px 8px; border-radius: 999px;
  background: var(--ochre); color: var(--ochre-ink);
  font: 700 12px/1 var(--f-ui); text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 15px/1.2 var(--f-ui);
  color: var(--text);
  background: transparent;
  border: 1.5px solid transparent;
  border-radius: 999px;
  padding: 13px 20px;
  cursor: pointer;
  text-decoration: none;
  transition: transform .12s ease, opacity .2s ease, background-color .2s ease, border-color .2s ease;
}
.btn:focus-visible { outline: 2px solid var(--ochre); outline-offset: 3px; }
.btn:active:not(:disabled) { transform: translateY(2px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--ochre); color: var(--ochre-ink); box-shadow: 0 4px 0 var(--kraft-edge); }
.btn.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--ochre) 88%, white); }
.btn.primary:active:not(:disabled) { box-shadow: 0 2px 0 var(--kraft-edge); }
.btn.ghost { background: var(--night-3); border-color: var(--line); }
.btn.ghost:hover:not(:disabled) { border-color: color-mix(in srgb, var(--ochre) 50%, var(--line)); }
.btn.danger { background: transparent; color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.btn.danger.armed { background: var(--warn); color: var(--warn-ink); }
.btn.link { padding: 6px 2px; color: var(--ochre); font-weight: 500; text-decoration: underline; text-underline-offset: 5px; text-decoration-color: color-mix(in srgb, var(--ochre) 40%, transparent); border-radius: 6px; }
.btn.block { width: 100%; }
.btn.big { padding: 17px 22px; font: 700 18px/1.2 var(--f-display); }
.btn.sm { padding: 8px 14px; font-size: 14px; }
.btn.grow { flex: 1; }
.btn[aria-busy="true"] { position: relative; color: transparent !important; pointer-events: none; }
.btn[aria-busy="true"]::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid color-mix(in srgb, var(--ochre-ink) 25%, transparent);
  border-top-color: var(--ochre-ink);
  animation: spin .7s linear infinite;
}
.btn.ghost[aria-busy="true"]::after { border-color: var(--line); border-top-color: var(--text); }

.input, .field input, .select {
  width: 100%; height: 50px; padding: 0 14px;
  border-radius: var(--r-ctl);
  border: 1px solid var(--line);
  background: var(--night);
  color: var(--text);
  font-size: 16px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus-visible, .field input:focus-visible, .select:focus-visible {
  border-color: var(--ochre);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ochre) 22%, transparent);
}
.input::placeholder, .field input::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }
[aria-invalid="true"] { border-color: var(--warn) !important; }
.select { height: 40px; width: auto; padding: 0 12px; font-size: 14px; border-radius: 999px; background: var(--night-3); }

.field { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; border: 0; min-width: 0; }
.field label, .field legend { color: var(--muted); font-size: 13.5px; font-weight: 500; padding: 0; }
.field legend { margin-bottom: 8px; }
.help { color: var(--muted); font-size: 12.5px; }
.form-error { margin: 0; padding: 10px 14px; border-radius: 12px; background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); font-size: 14px; }

.pass-wrap { position: relative; }
.pass-wrap input { padding-left: 76px; }
.pass-toggle { position: absolute; left: 6px; top: 50%; transform: translateY(-50%); border: 0; background: var(--night-3); color: var(--muted); border-radius: 8px; padding: 6px 10px; font-size: 12.5px; cursor: pointer; }
.pass-toggle:focus-visible { outline: 2px solid var(--ochre); }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; background: var(--night); border: 1px solid var(--line); border-radius: 999px; }
.seg button { border: 0; background: transparent; color: var(--muted); border-radius: 999px; padding: 10px 12px; font-weight: 600; cursor: pointer; }
.seg button[aria-selected="true"], .seg button[aria-checked="true"] { background: var(--night-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.seg button:focus-visible { outline: 2px solid var(--ochre); outline-offset: 1px; }
.seg.mini button { padding: 8px 14px; font-variant-numeric: tabular-nums; }

/* ---------- auth ---------- */
.view-auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding-block: max(28px, env(safe-area-inset-top, 0px)) 40px; }
.auth-wrap { width: min(100%, 430px); display: flex; flex-direction: column; gap: 22px; }
.auth-hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; }
.auth-hero img { width: 170px; height: auto; margin-bottom: 4px; }
.auth-hero h1 { margin: 0; font: 700 clamp(34px, 9vw, 42px)/1.15 var(--f-display); }
.auth-hero h1 span { color: var(--ochre); }
.auth-hero p { margin: 0; color: var(--muted); max-width: 38ch; }
.auth-card { padding: 18px; }
.auth-card form { display: flex; flex-direction: column; gap: 16px; margin-top: 18px; }
.invite-note { margin: 14px 0 0; padding: 10px 14px; border-radius: 12px; background: color-mix(in srgb, var(--ochre) 12%, transparent); font-size: 14px; }
.invite-note b { color: var(--ochre); font-family: var(--f-code); letter-spacing: .12em; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { position: relative; }
.swatch input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.swatch span {
  display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--c); color: #fff; font-weight: 700;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .12);
  transition: transform .15s ease;
}
.swatch input:checked + span { box-shadow: 0 0 0 3px var(--night-2), 0 0 0 5px var(--c); transform: scale(1.05); }
.swatch input:focus-visible + span { outline: 2px solid var(--ochre); outline-offset: 6px; }

/* ---------- lobby ---------- */
.lobby-head { display: flex; flex-direction: column; gap: 6px; margin-bottom: 22px; }
.lobby-head p { margin: 0; }
.lobby-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 16px; margin-bottom: 16px; }
.action-card { display: flex; flex-direction: column; gap: 12px; }
.action-card p { margin: -6px 0 2px; }
.code-input { font: 700 24px/1 var(--f-code); letter-spacing: .4em; text-align: center; text-transform: uppercase; }
.rooms { list-style: none; margin: 0; padding: 0; }
.room-item { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; padding: 14px 0; border-top: 1px solid var(--line-soft); }
.room-item:first-child { border-top: 0; padding-top: 2px; }
.room-item .info { flex: 1 1 200px; min-width: 0; }
.room-item .name { font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-item .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; color: var(--muted); font-size: 13px; margin-top: 2px; }
.room-item .acts { display: flex; align-items: center; gap: 6px; }
.role { font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.role.host { color: var(--ochre); border-color: color-mix(in srgb, var(--ochre) 45%, transparent); }
.code-tag { font: 600 12.5px/1 var(--f-code); letter-spacing: .14em; direction: ltr; }

/* ---------- room ---------- */
.room-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.room-title { min-width: 0; }
.eyebrow { font-size: 12.5px; font-weight: 600; color: var(--ochre); }
.room-head h1 { margin: 2px 0 0; font: 700 clamp(26px, 6vw, 34px)/1.2 var(--f-display); overflow-wrap: anywhere; }
.room-tools { display: flex; align-items: center; gap: 8px; }
.code-chip {
  display: inline-flex; align-items: center; gap: 10px; height: 46px; padding: 0 16px;
  border-radius: 999px; cursor: pointer; color: var(--text);
  border: 1.5px dashed color-mix(in srgb, var(--ochre) 55%, transparent);
  background: color-mix(in srgb, var(--ochre) 8%, transparent);
}
.code-chip:focus-visible { outline: 2px solid var(--ochre); outline-offset: 3px; }
.code-chip .code { font: 700 18px/1 var(--f-code); letter-spacing: .22em; color: var(--ochre); }
.code-label { font-size: 13.5px; font-weight: 500; }
.icon-btn { width: 46px; height: 46px; flex: none; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line); background: var(--night-2); color: var(--text); cursor: pointer; }
.icon-btn.quiet { border-color: transparent; background: transparent; width: 40px; height: 40px; }
.icon-btn svg { width: 21px; height: 21px; }
.icon-btn:focus-visible { outline: 2px solid var(--ochre); outline-offset: 2px; }

.room-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); grid-template-areas: "majlis" "box" "write" "mine" "players"; align-items: start; }
.box-card { grid-area: box; }
.write-card { grid-area: write; }
.mine-card { grid-area: mine; }
.players-card { grid-area: players; }
@media (min-width: 900px) {
  .room-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "majlis majlis" "box write" "players mine"; }
}

.box-card {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  padding-block: 26px 22px;
  background-image: radial-gradient(70% 50% at 50% 26%, var(--night-3), transparent 75%);
}
.box-wrap { position: relative; width: min(270px, 70vw); }
.box-art { display: block; width: 100%; height: auto; transform-origin: 50% 92%; overflow: visible; }
.st-kraft { stop-color: var(--kraft); }
.st-edge { stop-color: var(--kraft-edge); }
.st-top { stop-color: var(--kraft-top); }
.s-red { fill: var(--sadu); }
.s-cream { fill: var(--sadu-cream); }
.s-black { fill: var(--sadu-black); }
.s-ochre { fill: var(--ochre); }
.b-shadow { fill: var(--shadow); opacity: .55; }
.b-slot { fill: var(--slot); }
.b-lip { stroke: var(--kraft-top); stroke-width: 2; stroke-linecap: round; fill: none; }
.b-crease { stroke: var(--kraft-edge); stroke-width: 1.2; opacity: .6; fill: none; }
.count {
  position: absolute; left: 50%; top: 80.5%;
  transform: translate(-50%, -50%) rotate(-1.5deg);
  background: var(--sadu-cream); color: var(--sadu-black);
  font: 600 14px/1 var(--f-ui);
  font-variant-numeric: tabular-nums;
  padding: 7px 12px; border-radius: 2px;
  box-shadow: 0 2px 0 var(--kraft-edge);
  white-space: nowrap;
}
.host-controls { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 10px; }
.host-controls > p { margin: 0; }
.waiting { margin: 0; text-align: center; color: var(--muted); font-size: 14px; max-width: 36ch; }

.gen { margin-top: 6px; padding: 14px; border-radius: 14px; border: 1px solid var(--line-soft); background: var(--night); display: flex; flex-direction: column; gap: 12px; }
.gen-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.gen-title { font-weight: 600; }
.gen-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line); background: var(--night-2); color: var(--muted);
  border-radius: 999px; padding: 6px 12px; font-size: 13.5px; font-weight: 500; cursor: pointer;
}
.chip[aria-checked="true"] { background: var(--ochre); border-color: var(--ochre); color: var(--ochre-ink); font-weight: 600; }
.chip.spicy { border-color: color-mix(in srgb, var(--sadu) 55%, var(--line)); }
.chip.spicy[aria-checked="true"] { background: var(--sadu); border-color: var(--sadu); color: #fff; }
.chip:focus-visible { outline: 2px solid var(--ochre); outline-offset: 2px; }

.write-card { display: flex; flex-direction: column; gap: 12px; }
.write-card .card-head { margin-bottom: 2px; }
.chars { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.hint { margin: 0; color: var(--muted); font-size: 13.5px; }
.hint.warn { color: var(--warn); }
.suggest-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.mine-card summary { list-style: none; display: flex; align-items: center; gap: 10px; cursor: pointer; }
.mine-card summary::-webkit-details-marker { display: none; }
.mine-card summary::after {
  content: ""; margin-inline-start: auto;
  width: 9px; height: 9px;
  border-left: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg); transition: transform .2s ease;
}
.mine-card[open] summary::after { transform: rotate(135deg); }
.mine-card summary:focus-visible { outline: 2px solid var(--ochre); outline-offset: 6px; border-radius: 6px; }
.mine { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.mine li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--paper); color: var(--pen); }
.mine .t { flex: 1; min-width: 0; font: 500 16px/1.6 var(--f-paper); overflow-wrap: anywhere; }
.mine .st { flex: none; font: 600 11.5px/1 var(--f-ui); padding: 5px 9px; border-radius: 999px; background: var(--rule); color: var(--pen); }
.mine li.state-drawn .st { background: var(--ochre); color: var(--ochre-ink); }
.mine li.state-used { opacity: .65; }
.mine .del { flex: none; border: 0; background: transparent; color: var(--sadu); font: 600 13px/1 var(--f-ui); padding: 6px 4px; cursor: pointer; text-decoration: underline; text-underline-offset: 4px; }
.mine .del.armed { color: #fff; background: var(--sadu); border-radius: 6px; padding: 6px 8px; text-decoration: none; }
.mine-card .empty { margin-top: 12px; }

.players { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.player { display: flex; align-items: center; gap: 12px; }
.player .avatar { position: relative; }
.player .avatar::after { content: ""; position: absolute; bottom: -1px; left: -1px; width: 11px; height: 11px; border-radius: 50%; background: var(--line); border: 2px solid var(--night-2); }
.player.online .avatar::after { background: var(--ok); }
.player .pname { flex: 1; min-width: 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player .tag { font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.player .tag.host { color: var(--ochre); border-color: color-mix(in srgb, var(--ochre) 45%, transparent); }
.player .papers { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; min-width: 6ch; text-align: left; }

/* ---------- paper ---------- */
.paper {
  position: relative;
  display: flex; flex-direction: column;
  background: var(--paper);
  color: var(--pen);
  font-family: var(--f-paper);
  padding: 12px 46px 14px 18px;
  border-radius: 3px;
}
.paper::before { content: ""; position: absolute; top: 0; bottom: 0; right: 34px; width: 1.5px; background: var(--margin); }
.paper-head { display: flex; align-items: center; gap: 8px; height: 38px; flex: none; border-bottom: 1.5px solid var(--rule); font: 500 17px/1 var(--f-paper); }
.paper-head .lab { opacity: .55; flex: none; }
.paper-head .who { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 36px; }
.paper-head .who i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--c); margin-inline-end: 6px; vertical-align: middle; }
.paper-body {
  flex: none; display: block;
  width: 100%; height: 136px;
  margin: 0; padding: 0; border: 0; outline: none; resize: none;
  background: transparent repeating-linear-gradient(to bottom, transparent 0 33px, var(--rule) 33px 34px);
  background-attachment: local;
  color: var(--pen);
  font: 500 20px/34px var(--f-paper);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow: hidden;
}
textarea.paper-body { overflow-y: auto; }
.paper-body::placeholder { color: var(--pen); opacity: .35; }
.sheet { box-shadow: 0 2px 0 var(--kraft-edge), 0 22px 30px -18px var(--shadow); }
.sheet:focus-within { outline: 2px solid var(--ochre); outline-offset: 4px; }

.paper.reveal { width: 100%; height: 100%; padding: 14px 46px 16px 22px; box-shadow: 0 26px 40px -20px var(--shadow); }
.paper.reveal .paper-head { font-size: 18px; }
.paper.reveal .paper-body {
  flex: 1; min-height: 0; height: auto;
  text-align: center;
  font-weight: 600;
  background: linear-gradient(to bottom, transparent calc(100% - 1.5px), var(--rule) calc(100% - 1.5px));
  background-size: 100% 48px;
  background-attachment: scroll;
  text-wrap: balance;
}
.paper.reveal .qt { display: block; }
.stamp {
  margin-inline-start: auto; flex: none;
  font: 600 12px/1 var(--f-ui);
  color: var(--sadu);
  border: 1.5px solid currentColor; border-radius: 4px;
  padding: 5px 8px;
  transform: rotate(-4deg);
  opacity: .85;
}

/* ---------- modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 48;
  display: grid; place-items: end center;
  padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, var(--shadow) 62%, transparent);
}
@media (min-width: 600px) { .modal { place-items: center; } }
.modal-card { width: min(100%, 460px); max-height: 100%; overflow-y: auto; background: var(--night-2); border: 1px solid var(--line); border-radius: 22px; padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 4px; box-shadow: 0 30px 60px -20px var(--shadow); }
.modal-card .card-head { margin-bottom: 4px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line-soft); cursor: pointer; }
.switch-row b { font-weight: 600; }
.switch-row small { display: block; color: var(--muted); font-size: 12.5px; }
.switch { appearance: none; -webkit-appearance: none; margin: 0; width: 48px; height: 28px; flex: none; border-radius: 999px; background: var(--line); position: relative; cursor: pointer; transition: background-color .2s ease; }
.switch::after { content: ""; position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--text); transition: transform .2s ease; }
.switch:checked { background: var(--ochre); }
.switch:checked::after { transform: translateX(-20px); }
.switch:focus-visible { outline: 2px solid var(--ochre); outline-offset: 2px; }
.settings-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }

/* ---------- stage ---------- */
.stage {
  position: fixed; inset: 0; z-index: 40;
  display: flex; overflow-y: auto; overscroll-behavior: contain;
  padding-block: max(20px, env(safe-area-inset-top, 0px)) max(20px, env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: color-mix(in srgb, var(--night) 86%, transparent);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.stage-inner { margin: auto; width: 100%; max-width: 480px; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.reveal-slot { width: min(100%, 460px); aspect-ratio: 3 / 2; max-width: 100%; }
.stage-extra {
  width: 100%; display: flex; flex-direction: column; align-items: center; gap: 14px;
  visibility: hidden; opacity: 0; transform: translateY(8px);
  transition: opacity .3s ease, transform .3s ease, visibility 0s .3s;
}
.stage-extra.on { visibility: visible; opacity: 1; transform: none; transition: opacity .3s ease, transform .3s ease; }
.stage-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

.answer { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; }
.answer-text {
  margin: 0; width: min(100%, 420px);
  padding: 12px 16px; border-radius: 4px;
  background: var(--sadu-cream); color: var(--sadu-black);
  font: 600 19px/1.5 var(--f-paper); text-align: center;
  transform: rotate(-1deg);
  box-shadow: 0 10px 20px -12px var(--shadow);
}
.answer-text b { display: block; font: 600 12px/1.4 var(--f-ui); color: var(--sadu); margin-bottom: 2px; }

.voices { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.voice-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.voice {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px 8px 12px;
  border-radius: 999px;
  background: var(--night-2);
  border: 1px solid var(--line);
}
.voice.fresh { border-color: var(--ochre); }
.voice .vname { font-weight: 500; font-size: 14px; max-width: 9ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voice .play { width: 38px; height: 38px; flex: none; border-radius: 50%; border: 0; background: var(--ochre); color: var(--ochre-ink); display: grid; place-items: center; cursor: pointer; }
.voice .play svg { width: 16px; height: 16px; }
.voice .play:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.voice .bar { flex: 1; height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; min-width: 40px; }
.voice .bar i { display: block; height: 100%; width: 0; background: var(--ochre); border-radius: inherit; }
.voice .dur { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; min-width: 4ch; text-align: left; }

.note { display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px 10px 12px; border-radius: 16px; background: var(--paper); color: var(--pen); border: 1px solid transparent; }
.note.fresh { border-color: var(--ochre); }
.note .ntext { flex: 1; min-width: 0; font: 500 16px/1.6 var(--f-paper); overflow-wrap: anywhere; }
.note .vname { color: color-mix(in srgb, var(--pen) 70%, transparent); font: 600 12.5px/1.4 var(--f-ui); display: block; }
.note-form { display: flex; gap: 8px; }
.note-form .input { flex: 1; min-width: 0; height: 46px; border-radius: 999px; }
.recorder { display: flex; justify-content: center; }
.rec-start {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 12px 22px; border-radius: 999px;
  border: 1.5px solid color-mix(in srgb, var(--rec) 55%, transparent);
  background: color-mix(in srgb, var(--rec) 14%, transparent);
  color: var(--text); font-weight: 600; cursor: pointer;
}
.rec-start svg { width: 20px; height: 20px; color: var(--rec); }
.rec-start:focus-visible { outline: 2px solid var(--ochre); outline-offset: 3px; }
.rec-start:disabled { opacity: .5; cursor: not-allowed; }
.rec-live { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; border-radius: 999px; background: var(--night-2); border: 1px solid color-mix(in srgb, var(--rec) 50%, transparent); flex-wrap: wrap; justify-content: center; }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--rec); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 4ch; }
.rec-meter { display: inline-flex; align-items: center; gap: 3px; height: 22px; }
.rec-meter i { width: 4px; height: 4px; border-radius: 2px; background: var(--rec); transition: height .08s linear; }

/* ---------- characters and the majlis ---------- */
.majlis-svg { display: block; height: 250px; width: auto; max-width: none; margin-inline: auto; }
.majlis-svg .seat-name { font: 600 15px var(--f-ui); fill: var(--text); }
.majlis-svg .seat-name.me { fill: var(--ochre); }
.majlis-svg .host-star { fill: var(--ochre); }
.majlis-svg .person.offline { opacity: .45; }
.majlis-svg .halo { opacity: 0; transition: opacity .3s ease; }
.majlis-svg .person.speaking .halo { animation: halo 1.2s ease-in-out infinite; }
.majlis-svg .person.turn .halo { opacity: .55; }
@keyframes halo { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
.majlis-svg .turn-tag { animation: nod 1.6s ease-in-out infinite; }
.majlis-svg .turn-tag rect, .majlis-svg .turn-tag path { fill: var(--ochre); }
.majlis-svg .turn-tag text { font: 700 13px var(--f-ui); fill: var(--ochre-ink); }
@keyframes nod { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }

.turn-pill {
  margin: 0; align-self: center;
  padding: 7px 16px; border-radius: 999px;
  background: var(--night-3); border: 1px solid var(--line);
  color: var(--text); font-weight: 600; font-size: 14px;
}
.turn-pill.mine { background: var(--ochre); border-color: var(--ochre); color: var(--ochre-ink); animation: nod 1.6s ease-in-out infinite; }
.setting-block { display: flex; flex-direction: column; gap: 10px; padding: 14px 0; border-bottom: 1px solid var(--line-soft); }
.setting-block b { font-weight: 600; }
.setting-block small { display: block; color: var(--muted); font-size: 12.5px; }
@media (prefers-reduced-motion: reduce) {
  .majlis-svg .turn-tag, .turn-pill.mine { animation: none; }
}
.portrait { display: block; width: 100%; height: 100%; clip-path: circle(50%); }
.avatar.pic { background: var(--night-3); padding: 0; box-shadow: inset 0 0 0 1.5px var(--line); }
.lab-grid svg { background: var(--night-2); margin: 4px; border-radius: 12px; }

.majlis-card { grid-area: majlis; padding-bottom: 12px; overflow: hidden; }
.majlis-card .card-head { margin-bottom: 6px; }
.majlis-scroll {
  overflow-x: auto; overscroll-behavior-x: contain;
  margin-inline: -20px; padding-inline: 12px;
  background: radial-gradient(60% 80% at 50% 30%, var(--night-3), transparent 75%);
  scrollbar-width: thin;
}
.majlis-scroll .majlis-svg { height: 210px; }
@media (min-width: 900px) { .majlis-scroll .majlis-svg { height: 250px; } }

.me-btn { display: inline-flex; align-items: center; gap: 8px; border: 0; background: transparent; color: inherit; padding: 0; cursor: pointer; border-radius: 999px; }
.me-btn:focus-visible { outline: 2px solid var(--ochre); outline-offset: 2px; }

.look-card { width: min(100%, 860px); max-height: calc(100dvh - 32px); gap: 12px; padding-bottom: 0; }
.look-card > * { flex-shrink: 0; }
.look-intro { margin: 0; color: var(--muted); }
.look-body { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); min-height: 0; }
@media (min-width: 760px) { .look-body { grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); align-items: start; } }
.look-stage {
  border-radius: 16px; background: radial-gradient(70% 70% at 50% 35%, var(--night-3), var(--night) 80%);
  border: 1px solid var(--line-soft);
  display: grid; place-items: center; padding: 8px 0 4px;
  position: sticky; top: 0; z-index: 1;
}
.look-stage .majlis-svg, .look-zoom { height: 210px; }
.look-zoom { display: block; width: auto; max-width: 100%; margin: 0 auto; }
@media (min-width: 760px) { .look-stage .majlis-svg, .look-zoom { height: 340px; } }
.look-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
.look-tile {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 6px 4px 8px; border-radius: 14px;
  border: 1.5px solid var(--line); background: var(--night); color: var(--muted);
  font: 600 12.5px/1.2 var(--f-ui); cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease;
}
.look-tile[aria-checked="true"] { border-color: var(--ochre); color: var(--text); background: color-mix(in srgb, var(--ochre) 12%, var(--night)); }
.look-tile:focus-visible { outline: 2px solid var(--ochre); outline-offset: 2px; }
.tile-pic { display: block; width: 64px; height: 64px; border-radius: 10px; overflow: hidden; background: radial-gradient(circle at 50% 35%, var(--night-3), var(--night-2)); }
.look-tiles.tall .tile-pic { height: 112px; }
.tile-svg { display: block; width: 100%; height: 100%; }
.tile-label { text-align: center; }
.look-controls { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.look-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.look-tabs .chip { flex: none; }
.look-panel { display: flex; flex-direction: column; gap: 14px; }
.look-group { display: flex; flex-direction: column; gap: 8px; }
.look-label { color: var(--muted); font-size: 13px; font-weight: 600; }
.look-note { margin: 0; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--ochre) 12%, transparent); font-size: 13.5px; }
.look-swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.look-swatch {
  width: 36px; height: 36px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--c); box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .18);
}
.look-swatch[aria-checked="true"] { box-shadow: 0 0 0 3px var(--night-2), 0 0 0 5px var(--ochre); }
.look-swatch:focus-visible { outline: 2px solid var(--ochre); outline-offset: 4px; }
.look-actions {
  display: flex; gap: 10px;
  position: sticky; bottom: 0; z-index: 2;
  margin-inline: -20px; padding: 12px 20px 18px;
  background: var(--night-2);
  border-top: 1px solid var(--line-soft);
}

.majlis-svg .mic-badge circle { fill: var(--ok); }
.majlis-svg .mic-badge rect { fill: #fff; }
.majlis-svg .mic-badge path { stroke: #fff; }

/* ---------- AI portrait card ---------- */
.ai-card {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px 12px; align-items: center;
  padding: 12px; border-radius: 16px;
  border: 1px solid color-mix(in srgb, var(--ochre) 40%, var(--line));
  background: color-mix(in srgb, var(--ochre) 8%, var(--night));
}
.ai-pic { width: 56px; height: 56px; border-radius: 50%; overflow: hidden; background: var(--night-3); }
.ai-pic .portrait { width: 100%; height: 100%; }
.ai-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ai-text small { color: var(--muted); font-size: 12.5px; }
.ai-actions { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ai-card.busy .ai-pic { animation: pulse 1.2s ease-in-out infinite; }

/* ---------- room chat ---------- */
.chat-fab {
  position: fixed; z-index: 47;
  bottom: max(18px, env(safe-area-inset-bottom, 0px));
  inset-inline-end: max(16px, env(safe-area-inset-left, 0px));
  width: 58px; height: 58px; border-radius: 50%; border: 0;
  display: grid; place-items: center;
  background: var(--ochre); color: var(--ochre-ink);
  box-shadow: 0 4px 0 var(--kraft-edge), 0 18px 30px -12px var(--shadow);
  cursor: pointer;
  transition: transform .15s ease;
}
.chat-fab:hover { transform: translateY(-2px); }
.chat-fab svg { width: 26px; height: 26px; }
.chat-fab:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
.chat-fab .badge { position: absolute; top: -4px; inset-inline-start: -4px; background: var(--sadu); color: #fff; min-width: 22px; box-shadow: 0 0 0 2px var(--night); }
.chat-fab .live-dot { position: absolute; bottom: 2px; inset-inline-start: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--ok); border: 2px solid var(--ochre); animation: pulse 1.4s ease-in-out infinite; }
html.chat-open .chat-fab { display: none; }

.chat-panel {
  position: fixed; z-index: 46;
  inset: auto 0 0 0;
  height: min(82dvh, 680px);
  display: flex; flex-direction: column;
  background:
    radial-gradient(120% 60% at 50% 0%, color-mix(in srgb, var(--night-3) 70%, transparent), transparent 70%),
    var(--night-2);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -24px 60px -24px var(--shadow);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  overflow: hidden;
}
@media (min-width: 900px) {
  .chat-panel {
    inset: 76px auto 16px 16px;
    width: 400px; height: auto;
    border-bottom: 1px solid var(--line);
    border-radius: 22px;
  }
}

.chat-head { display: flex; align-items: center; gap: 12px; padding: 16px 16px 12px; }
.chat-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-title h2 { margin: 0; font: 700 18px/1.3 var(--f-display); }
.chat-sub { color: var(--muted); font-size: 12.5px; display: inline-flex; align-items: center; gap: 6px; }
.chat-sub::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.chat-faces, .call-faces { display: flex; flex-direction: row-reverse; }
.chat-faces .avatar, .call-faces .avatar { width: 30px; height: 30px; box-shadow: 0 0 0 2px var(--night-2); }
.chat-faces .avatar + .avatar, .call-faces .avatar + .avatar { margin-inline-end: -10px; }
.faces-more { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--night-3); color: var(--muted); font-size: 11px; font-weight: 700; box-shadow: 0 0 0 2px var(--night-2); margin-inline-end: -10px; }

.call-card {
  display: flex; align-items: center; gap: 10px;
  margin: 0 12px 10px; padding: 10px 10px 10px 12px;
  border-radius: 18px;
  background: var(--night);
  border: 1px solid var(--line-soft);
  transition: background-color .25s ease, border-color .25s ease;
}
.call-card.others { border-color: color-mix(in srgb, var(--ok) 35%, var(--line-soft)); }
.call-card.live { background: color-mix(in srgb, var(--ok) 16%, var(--night)); border-color: color-mix(in srgb, var(--ok) 55%, transparent); }
.call-icon {
  width: 38px; height: 38px; flex: none; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--night-3); color: var(--muted);
}
.call-icon svg { width: 19px; height: 19px; }
.call-card.others .call-icon, .call-card.live .call-icon { background: var(--ok); color: #06210f; }
.call-card.live .call-icon { animation: pulse 1.6s ease-in-out infinite; }
.call-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.call-info b { font-weight: 700; font-size: 14px; }
.call-info small { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.call-actions { display: flex; gap: 6px; align-items: center; }
.call-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 14px; border-radius: 999px; border: 0; cursor: pointer;
  font: 700 14px/1 var(--f-ui);
  transition: transform .12s ease, background-color .2s ease;
}
.call-btn svg { width: 17px; height: 17px; }
.call-btn:active:not(:disabled) { transform: scale(.96); }
.call-btn:focus-visible { outline: 2px solid var(--ochre); outline-offset: 2px; }
.call-btn:disabled { opacity: .55; cursor: progress; }
.call-btn.join { background: var(--ok); color: #06210f; }
.call-btn.round { width: 38px; padding: 0; }
.call-btn.mute { background: var(--night-3); color: var(--text); }
.call-btn.mute .off { display: none; }
.call-btn.mute[aria-pressed="true"] { background: var(--text); color: var(--night); }
.call-btn.mute[aria-pressed="true"] .on { display: none; }
.call-btn.mute[aria-pressed="true"] .off { display: block; }
.call-btn.leave { background: var(--rec); color: #fff; }

.chat-body { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; border-top: 1px solid var(--line-soft); }
.chat-list { list-style: none; margin: 0; padding: 14px 14px 8px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; overscroll-behavior: contain; scrollbar-width: thin; }
.chat-empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 24px; text-align: center;
}
.chat-empty .empty-icon { width: 72px; height: 72px; border-radius: 22px; display: grid; place-items: center; background: color-mix(in srgb, var(--ochre) 14%, var(--night)); color: var(--ochre); margin-bottom: 4px; }
.chat-empty .empty-icon svg { width: 40px; height: 40px; }
.chat-empty b { font: 700 18px/1.3 var(--f-display); }
.chat-empty p { margin: 0; color: var(--muted); font-size: 14px; max-width: 30ch; }
.quick { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 10px; }
.quick-btn {
  border: 1px solid var(--line); background: var(--night); color: var(--text);
  border-radius: 999px; padding: 8px 14px; font-size: 14px; cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease;
}
.quick-btn:hover { border-color: var(--ochre); }
.quick-btn:focus-visible { outline: 2px solid var(--ochre); outline-offset: 2px; }

.msg { display: flex; align-items: flex-end; gap: 8px; max-width: 86%; margin-top: 8px; }
.msg.grouped { margin-top: 0; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg .avatar { width: 30px; height: 30px; flex: none; }
.msg.grouped .avatar { visibility: hidden; }
.msg.mine .avatar { display: none; }
.bubble { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px 6px; border-radius: 18px; background: var(--night-3); min-width: 0; box-shadow: 0 1px 0 rgba(0, 0, 0, .18); }
.msg:not(.mine) .bubble { border-start-start-radius: 6px; }
.msg.grouped:not(.mine) .bubble { border-start-start-radius: 18px; }
.msg.mine .bubble { background: linear-gradient(160deg, var(--ochre), color-mix(in srgb, var(--ochre) 80%, var(--kraft-edge))); color: var(--ochre-ink); border-start-end-radius: 6px; }
.msg.mine.grouped .bubble { border-start-end-radius: 18px; }
.msg-name { font-size: 12px; font-weight: 700; color: var(--ochre); }
.msg-text { margin: 0; font-size: 15px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-time { font-size: 10.5px; opacity: .65; align-self: flex-end; font-variant-numeric: tabular-nums; }
.msg-voice { display: flex; align-items: center; gap: 8px; min-width: 190px; padding: 2px 0; }
.msg-voice .play { width: 36px; height: 36px; flex: none; border-radius: 50%; border: 0; background: var(--ochre); color: var(--ochre-ink); display: grid; place-items: center; cursor: pointer; }
.msg.mine .msg-voice .play { background: var(--ochre-ink); color: var(--ochre); }
.msg-voice .play svg { width: 14px; height: 14px; }
.wave { flex: 1; display: flex; align-items: center; gap: 2px; height: 28px; }
.wave i { flex: 1; min-width: 2px; border-radius: 2px; background: currentColor; opacity: .3; transition: opacity .1s linear; }
.wave i.on { opacity: 1; }
.msg:not(.mine) .wave { color: var(--ochre); }
.msg-voice .dur { flex: none; min-width: 3.4em; font-size: 12px; opacity: .75; font-variant-numeric: tabular-nums; }

.chat-compose, .chat-rec { display: flex; align-items: center; gap: 8px; padding: 10px 12px 12px; border-top: 1px solid var(--line-soft); background: color-mix(in srgb, var(--night) 55%, transparent); }
.compose-box { flex: 1; min-width: 0; display: flex; align-items: center; height: 46px; padding: 0 16px; border-radius: 999px; background: var(--night); border: 1px solid var(--line); transition: border-color .15s ease; }
.compose-box:focus-within { border-color: var(--ochre); }
.chat-input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; color: var(--text); font-size: 16px; }
.chat-input::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
.round-btn { width: 46px; height: 46px; flex: none; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer; transition: transform .12s ease; }
.round-btn svg { width: 21px; height: 21px; }
.round-btn:active:not(:disabled) { transform: scale(.94); }
.round-btn:focus-visible { outline: 2px solid var(--ochre); outline-offset: 2px; }
.round-btn.mic { background: var(--night-3); color: var(--ochre); }
.round-btn.send { background: var(--ochre); color: var(--ochre-ink); box-shadow: 0 3px 0 var(--kraft-edge); }
.round-btn.send svg { transform: scaleX(-1); }
.round-btn.ghost { background: transparent; color: var(--muted); }
.round-btn[aria-busy="true"] { color: transparent; position: relative; pointer-events: none; }
.round-btn[aria-busy="true"]::after { content: ""; position: absolute; inset: 0; margin: auto; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid color-mix(in srgb, var(--ochre-ink) 25%, transparent); border-top-color: var(--ochre-ink); animation: spin .7s linear infinite; }
.rec-live-box { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 16px; border-radius: 999px; background: color-mix(in srgb, var(--rec) 14%, var(--night)); border: 1px solid color-mix(in srgb, var(--rec) 45%, transparent); }
.rec-wave { display: inline-flex; align-items: center; gap: 3px; height: 22px; flex: 1; }
.rec-wave i { width: 4px; height: 4px; border-radius: 2px; background: var(--rec); transition: height .08s linear; }
.rec-hint { color: var(--muted); font-size: 12.5px; }
.call-audio { display: none; }
/* On a phone the open chat takes the bottom of the screen: lift notifications above it. */
@media (max-width: 899px) {
  html.chat-open .toasts { bottom: calc(min(82dvh, 680px) + 12px); }
}

/* ---------- floating bits ---------- */
.reopen {
  position: fixed; z-index: 35; left: 50%; transform: translateX(-50%);
  bottom: max(18px, env(safe-area-inset-bottom, 0px));
  padding: 12px 20px; border-radius: 999px; border: 0;
  background: var(--ochre); color: var(--ochre-ink); font-weight: 700;
  box-shadow: 0 4px 0 var(--kraft-edge), 0 18px 30px -12px var(--shadow);
  cursor: pointer;
}
.conn {
  position: fixed; z-index: 36; left: 50%; transform: translateX(-50%);
  top: calc(env(safe-area-inset-top, 0px) + 72px);
  padding: 7px 16px; border-radius: 999px;
  background: var(--warn); color: var(--warn-ink); font-size: 13.5px; font-weight: 600;
}
.toasts {
  position: fixed; z-index: 70; left: 50%; transform: translateX(-50%);
  bottom: max(20px, env(safe-area-inset-bottom, 0px));
  width: min(calc(100vw - 32px), 420px);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}
.toast { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 14px; background: var(--sadu-cream); color: var(--sadu-black); font-size: 14px; font-weight: 500; box-shadow: 0 14px 28px -12px var(--shadow); }
.toast.error { background: var(--warn); color: var(--warn-ink); }
.toast .avatar { width: 24px; height: 24px; font-size: 12px; }

/* ---------- flying paper ---------- */
.fly-layer { position: fixed; inset: 0; z-index: 50; pointer-events: none; overflow: hidden; }
.fly { position: absolute; perspective: 1200px; filter: drop-shadow(0 14px 14px rgba(3, 17, 16, .45)); }
.f1-top { position: absolute; left: 0; top: 0; width: 100%; height: 50%; overflow: hidden; }
.f1-bot { position: absolute; left: 0; top: 50%; width: 100%; height: 50%; transform-origin: 50% 0; transform-style: preserve-3d; }
.f2-left { position: absolute; left: 0; top: 0; width: 50%; height: 100%; }
.f2-right { position: absolute; left: 50%; top: 0; width: 50%; height: 100%; transform-origin: 0 50%; transform-style: preserve-3d; }
.face { position: absolute; inset: 0; overflow: hidden; -webkit-backface-visibility: hidden; backface-visibility: hidden; }
.f1-bot > .back { transform: rotateX(180deg); }
.f2-right > .back { transform: rotateY(180deg); }
.fly .paper { position: absolute; left: 0; top: 0; width: 100%; height: 200%; border-radius: 0; box-shadow: none; }
.fly .paper.lower { top: -100%; }
.pback { background: var(--paper-back); }
.shade { position: absolute; inset: 0; opacity: 0; background: linear-gradient(to bottom, rgba(70, 48, 12, .12), rgba(70, 48, 12, .5)); }
.packet {
  position: absolute; transform-origin: 0 0;
  background: var(--paper-back); border-radius: 2px;
  box-shadow: inset 3px 0 0 rgba(120, 90, 40, .14), inset 0 3px 0 rgba(120, 90, 40, .1), 0 8px 14px -6px rgba(3, 17, 16, .6);
}
.plus { position: absolute; font: 700 24px/1 var(--f-display); color: var(--ochre); text-shadow: 0 2px 0 var(--shadow); }
.fx { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 60; pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
  .spinner, .btn[aria-busy="true"]::after { animation-duration: 2s; }
  .rec-dot { animation: none; }
}
