/* Handlr UI: shared by the user dashboard (/app) and the admin console (/admin). */
:root {
  --display: 'Plus Jakarta Sans', system-ui, sans-serif;
  --sans: 'Onest', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  --aura: linear-gradient(120deg, #5B4CF0 0%, #B44CF0 52%, #FF6B4A 100%);
  --bg: #F2F1F6; --panel: #FFFFFF; --panel2: #F7F6FB; --panel3: #ECEAF4;
  --line: #E1DFEC; --line2: #EBE9F2; --line-h: #C9C5DA;
  --ink: #17142B; --muted: #55516C; --dim: #6B6784;
  --acc: #5B4CF0; --acc-ink: #FFFFFF; --acc-soft: rgba(91,76,240,.09); --acc-line: rgba(91,76,240,.32);
  --coral: #CF4520; --coral-soft: rgba(255,107,74,.13);
  --ok: #0B7F76; --ok-soft: rgba(14,138,128,.11);
  --warn: #8F5B00; --warn-soft: rgba(214,150,20,.15);
  --glass: rgba(255,255,255,.66); --gline: rgba(255,255,255,.85); --gedge: rgba(40,30,110,.08);
  --gshadow: 0 1px 0 rgba(255,255,255,.9) inset, 0 0 0 1px var(--gedge), 0 14px 40px -22px rgba(60,40,150,.3);
  --scrim: rgba(23,20,43,.34);
  --r-lg: 20px; --r: 14px; --r-sm: 10px;
  color-scheme: light;
}
[data-theme='dark'] {
  --bg: #100E1A; --panel: #17142A; --panel2: #1E1A33; --panel3: #27223F;
  --line: #2F2948; --line2: #231F38; --line-h: #463F66;
  --ink: #F2EFFC; --muted: #ADA7C8; --dim: #8E87AE;
  --acc: #8C80FF; --acc-ink: #120F22; --acc-soft: rgba(140,128,255,.14); --acc-line: rgba(140,128,255,.4);
  --coral: #FF8A6B; --coral-soft: rgba(255,138,107,.14);
  --ok: #4FD1C2; --ok-soft: rgba(79,209,194,.13);
  --warn: #F2B544; --warn-soft: rgba(242,181,68,.14);
  --glass: rgba(30,26,51,.62); --gline: rgba(255,255,255,.06); --gedge: rgba(255,255,255,.06);
  --gshadow: 0 1px 0 rgba(255,255,255,.04) inset, 0 0 0 1px var(--gedge), 0 18px 50px -24px rgba(0,0,0,.6);
  --scrim: rgba(0,0,0,.55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.55 var(--sans); color: var(--ink); background: var(--bg); min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
body::before { /* soft aura behind everything */
  content: ''; position: fixed; inset: -20vh -10vw auto auto; width: 70vw; height: 70vh; z-index: -1; pointer-events: none;
  background: radial-gradient(closest-side, rgba(180,76,240,.18), transparent), radial-gradient(closest-side at 30% 70%, rgba(255,107,74,.12), transparent);
  filter: blur(20px);
}
h1, h2, h3, h4 { font-family: var(--display); letter-spacing: -.02em; margin: 0; line-height: 1.2; }
h1 { font-size: 28px; font-weight: 750; }
h2 { font-size: 19px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 700; }
p { margin: 0; }
a { color: var(--acc); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--muted); }
.dim { color: var(--dim); font-size: 13px; }
.mono { font-family: var(--mono); font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack { display: grid; gap: 16px; }
.stack.tight { gap: 8px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.grow { flex: 1; min-width: 0; }
.hide { display: none !important; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; padding: 22px 14px; display: flex; flex-direction: column; gap: 6px;
  border-right: 1px solid var(--line2); background: color-mix(in oklab, var(--panel) 55%, transparent); backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font: 750 20px/1 var(--display); letter-spacing: -.03em; color: var(--ink); }
.brand .mark { width: 26px; height: 26px; border-radius: 8px; background: var(--aura); box-shadow: 0 6px 18px -6px rgba(180,76,240,.6); }
.brand small { font: 600 11px var(--sans); color: var(--dim); letter-spacing: 0; padding: 3px 7px; border-radius: 99px; background: var(--panel3); }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 12px; color: var(--muted); font-weight: 550;
  text-decoration: none; transition: background .15s, color .15s;
}
.nav a svg { width: 18px; height: 18px; flex: none; }
.nav a:hover { background: var(--panel3); color: var(--ink); }
.nav a.on { background: var(--acc-soft); color: var(--acc); box-shadow: inset 0 0 0 1px var(--acc-line); }
.nav .count { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--coral); color: #fff; font: 700 11px/20px var(--sans); text-align: center; }
.side .foot { margin-top: auto; display: grid; gap: 8px; }
.me { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 14px; background: var(--panel2); border: 1px solid var(--line2); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--aura); color: #fff; display: grid; place-items: center; font: 700 14px var(--display); flex: none; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.main { padding: 28px clamp(16px, 4vw, 44px) 90px; max-width: 1120px; width: 100%; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.head p { margin-top: 6px; }
.topbar { display: none; }
.tabbar { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; position: sticky; top: 0; z-index: 20; background: color-mix(in oklab, var(--bg) 80%, transparent); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line2); }
  .topbar .brand { padding: 0; font-size: 18px; }
  .main { padding: 18px 16px 100px; }
  h1 { font-size: 24px; }
  .tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 10px; right: 10px; bottom: 10px; z-index: 30;
    padding: 6px; border-radius: 20px; background: var(--glass); backdrop-filter: blur(20px) saturate(1.4); box-shadow: var(--gshadow);
  }
  .tabbar a { display: grid; justify-items: center; gap: 2px; padding: 7px 2px; border-radius: 14px; color: var(--dim); font-size: 11px; font-weight: 600; text-decoration: none; position: relative; }
  .tabbar a svg { width: 20px; height: 20px; }
  .tabbar a.on { color: var(--acc); background: var(--acc-soft); }
  .tabbar .count { position: absolute; top: 3px; right: 22%; min-width: 16px; height: 16px; border-radius: 99px; background: var(--coral); color: #fff; font: 700 10px/16px var(--sans); }
}

/* ---------- surfaces ---------- */
.card {
  background: var(--glass); backdrop-filter: blur(18px) saturate(1.3); -webkit-backdrop-filter: blur(18px) saturate(1.3);
  border: 1px solid var(--gline); border-radius: var(--r-lg); box-shadow: var(--gshadow); padding: 20px;
}
.card.flat { background: var(--panel); backdrop-filter: none; }
.card h2 + p, .card h3 + p { margin-top: 4px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 6px 2px 12px; }
.divider { height: 1px; background: var(--line2); margin: 14px 0; border: 0; }
.hero-card { position: relative; overflow: hidden; }
.hero-card::after { content: ''; position: absolute; inset: auto -40px -60px auto; width: 220px; height: 220px; border-radius: 50%; background: var(--aura); opacity: .14; filter: blur(10px); pointer-events: none; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: 600 14px var(--sans); cursor: pointer;
  transition: transform .08s, background .15s, border-color .15s, opacity .15s; white-space: nowrap; text-decoration: none;
}
.btn:hover { border-color: var(--line-h); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--acc); border-color: transparent; color: var(--acc-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.aura { background: var(--aura); border: 0; color: #fff; box-shadow: 0 10px 26px -12px rgba(180,76,240,.7); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--panel3); color: var(--ink); }
.btn.danger { color: var(--coral); }
.btn.danger:hover { border-color: var(--coral); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn.lg { height: 48px; padding: 0 22px; font-size: 15px; border-radius: 14px; }
.btn svg { width: 16px; height: 16px; }

label.field { display: grid; gap: 6px; font-weight: 600; font-size: 13px; color: var(--muted); }
label.field .hint { font-weight: 400; color: var(--dim); font-size: 12.5px; }
.input, select.input, textarea.input {
  width: 100%; height: 42px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel);
  color: var(--ink); font: 15px var(--sans); transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.input:focus { outline: none; border-color: var(--acc); box-shadow: 0 0 0 3px var(--acc-soft); }
.input.code { font-family: var(--mono); letter-spacing: .06em; text-transform: uppercase; }

.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; cursor: pointer; margin: 0; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--panel3); border: 1px solid var(--line); transition: background .15s; pointer-events: none; }
.switch span::after { content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .18s; }
.switch input:checked + span { background: var(--acc); border-color: var(--acc); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--acc); outline-offset: 2px; }

.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--panel3); gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--muted); font: 600 13px var(--sans); padding: 6px 12px; border-radius: 9px; cursor: pointer; }
.seg button.on { background: var(--panel); color: var(--ink); box-shadow: 0 1px 3px rgba(20,10,60,.12); }

.days { display: flex; gap: 6px; flex-wrap: wrap; }
.days button { width: 42px; height: 38px; border-radius: 11px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); font: 600 13px var(--sans); cursor: pointer; }
.days button.on { background: var(--acc-soft); border-color: var(--acc-line); color: var(--acc); }

/* ---------- data ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 99px; font: 600 12px var(--sans); background: var(--panel3); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--coral-soft); color: var(--coral); }
.pill.acc { background: var(--acc-soft); color: var(--acc); }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.list { display: grid; }
.item { display: flex; gap: 12px; align-items: flex-start; padding: 13px 2px; border-bottom: 1px solid var(--line2); }
.item:last-child { border-bottom: 0; }
.item .ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--panel3); color: var(--muted); flex: none; }
.item .ico svg { width: 17px; height: 17px; }
.item .body { flex: 1; min-width: 0; }
.item .title { font-weight: 600; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font: 600 12px var(--sans); color: var(--dim); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 12px; border-bottom: 1px solid var(--line2); vertical-align: middle; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--acc-soft); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; margin: -6px -8px; }

.stat .k { font: 750 30px/1.1 var(--display); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: 13px; font-weight: 600; margin-top: 4px; }
.meter { height: 10px; border-radius: 99px; background: var(--panel3); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 99px; background: var(--aura); transition: width .4s; }
.meter.hot > i { background: var(--coral); }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 90px; }
.bars i { flex: 1; min-width: 3px; border-radius: 4px 4px 2px 2px; background: var(--acc); opacity: .75; }
.bars i:hover { opacity: 1; }

.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty h3 { color: var(--ink); margin-bottom: 4px; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; background: var(--acc-soft); border: 1px solid var(--acc-line); color: var(--ink); font-size: 14px; }
.notice.warn { background: var(--warn-soft); border-color: transparent; }
.notice.bad { background: var(--coral-soft); border-color: transparent; }
.notice.ok { background: var(--ok-soft); border-color: transparent; }

/* ---------- checklist ---------- */
.check { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line2); }
.check:last-child { border-bottom: 0; }
.check .box { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line-h); display: grid; place-items: center; flex: none; }
.check.done .box { border-color: transparent; background: var(--ok); color: #fff; }
.check.done .box svg { width: 14px; height: 14px; }
.check.done .label { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line-h); }

/* ---------- modal + toast ---------- */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 50; display: grid; place-items: center; padding: 16px; animation: fade .15s; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--panel); border-radius: 22px; padding: 22px; box-shadow: 0 30px 90px -20px rgba(20,10,60,.45); border: 1px solid var(--line2); }
.modal.wide { width: min(860px, 100%); }
.modal .spread { margin-bottom: 16px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; padding: 11px 16px; border-radius: 14px; background: var(--ink); color: var(--bg); font-weight: 600; font-size: 14px; box-shadow: 0 14px 40px -10px rgba(0,0,0,.4); animation: rise .2s; max-width: calc(100vw - 32px); }
.toast.bad { background: var(--coral); color: #fff; }
@media (max-width: 860px) { .toast { bottom: 92px; } }
@keyframes fade { from { opacity: 0 } }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px) } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- sign-in ---------- */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.gate .card { width: min(440px, 100%); padding: 34px 30px; text-align: center; }
.gate h1 { font-size: 30px; margin: 18px 0 8px; }
.gate .mark { width: 54px; height: 54px; border-radius: 16px; background: var(--aura); margin: 0 auto; box-shadow: 0 16px 40px -14px rgba(180,76,240,.8); }
.gbtn { width: 100%; height: 50px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: 650 15px var(--sans); display: flex; align-items: center; justify-content: center; gap: 10px; cursor: pointer; margin-top: 24px; text-decoration: none; }
.gbtn:hover { border-color: var(--line-h); text-decoration: none; }
.gbtn svg { width: 20px; height: 20px; }

/* ---------- plans ---------- */
.plan { display: flex; flex-direction: column; gap: 14px; }
.plan.current { box-shadow: 0 0 0 2px var(--acc), var(--gshadow); }
.plan .price { font: 750 34px/1 var(--display); letter-spacing: -.03em; }
.plan .price small { font: 500 14px var(--sans); color: var(--muted); letter-spacing: 0; }
.plan ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 7px; font-size: 14px; }
.plan li { display: flex; gap: 8px; }
.plan li::before { content: ''; width: 16px; height: 16px; flex: none; margin-top: 3px; border-radius: 50%; background: var(--ok-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8.5l2.5 2.5L12 5.5' fill='none' stroke='%230B7F76' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/12px no-repeat; }
.plan .foot { margin-top: auto; }

/* ---------- onboarding ---------- */
.steps { display: flex; gap: 8px; margin-bottom: 22px; }
.steps i { flex: 1; height: 5px; border-radius: 99px; background: var(--panel3); }
.steps i.on { background: var(--aura); }
.welcome { max-width: 560px; margin: 6vh auto 0; }
.big-input { height: 56px; font: 700 22px var(--display); text-align: center; }
.code-box { font: 700 30px var(--mono); letter-spacing: .18em; padding: 14px; border-radius: 16px; background: var(--panel2); border: 1px dashed var(--line-h); text-align: center; }

/* fixes */
.notice > svg { width: 18px; height: 18px; flex: none; margin-top: 2px; }
.spread.wrap { flex-wrap: wrap; }
.chan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
@media (max-width: 420px) { .chan-grid { grid-template-columns: 1fr; } }
.chead { display: flex; align-items: center; gap: 12px; }
.chead .ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--panel3); color: var(--muted); flex: none; }
.chead .ico svg { width: 20px; height: 20px; }
.chead .grow p { margin-top: 2px; }

/* v2.1: character, voice, meetings */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.chips button { padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); font: 600 13px var(--sans); cursor: pointer; text-transform: capitalize; }
.chips button.on { background: var(--acc-soft); border-color: var(--acc-line); color: var(--acc); }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.swatches > button { padding: 3px; border-radius: 14px; border: 2px solid transparent; background: none; cursor: pointer; line-height: 0; }
.swatches > button.on { border-color: var(--acc); }
.swatches > button:focus-visible, .chips button:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
.seg { flex-wrap: wrap; }
.me-link { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; padding: 6px; margin: -6px; border-radius: 12px; color: inherit; text-decoration: none; }
.me-link:hover, .me-link.on { background: var(--acc-soft); }
.me-link:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
.bubble { padding: 10px 12px; border-radius: 12px; background: var(--panel2); border: 1px solid var(--line2); }
.bubble.admin { background: var(--acc-soft); border-color: var(--acc-line); }
.voices { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.voice { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 12px; padding: 4px 6px 4px 4px; background: var(--panel); }
.voice.on { border-color: var(--acc); background: var(--acc-soft); }
.voice .pick { flex: 1; text-align: left; background: none; border: 0; padding: 8px; cursor: pointer; color: inherit; font: inherit; display: grid; gap: 2px; border-radius: 9px; }
.voice .pick:focus-visible { outline: 2px solid var(--acc); }
.voice .pick span { font-size: 12.5px; }
