/* Hide STT provider fields by default (shown via JS) */
#stt-azure-fields,
#stt-vosk-fields {
  display: none;
}
/* ── DaveSoftBot Admin — Design System ──────────────────────────────────────
   Single source of truth for all admin pages (login, qr, menu-builder).
   Import with: <link rel="stylesheet" href="/admin/style.css">
   ───────────────────────────────────────────────────────────────────────── */

/* ── Tokens ────────────────────────────────────────────────────────────── */
:root {
  --brand:       #25D366;
  --brand-dark:  #128C7E;
  --brand-dim:   rgba(37, 211, 102, .12);

  --radius-sm:   6px;
  --radius:      12px;
  --radius-lg:   18px;
  --shadow-sm:   0 1px 4px rgba(0,0,0,.08);
  --shadow:      0 4px 24px rgba(0,0,0,.11);
  --shadow-up:   0 -2px 12px rgba(0,0,0,.07);
  --trans:       .17s ease;

  --font:        -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono:   'Courier New', Courier, monospace;
  --font-size:   15px;
  --line:        1.55;
}

/* ── Light theme (default) ─────────────────────────────────────────────── */
:root {
  --bg:        #f0f4f8;
  --surface:   #ffffff;
  --surface2:  #f5f7fa;
  --border:    #e2e8f0;
  --text:      #1a202c;
  --text2:     #4a5568;
  --muted:     #a0aec0;
  --accent:    var(--brand);
  --accent-h:  var(--brand-dark);
  --danger:    #e53e3e;
  --warn:      #c05621;
  --info:      #2b6cb0;
  --success:   #276749;
}

/* ── Dark theme ────────────────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg:        #0d1117;
  --surface:   #161b22;
  --surface2:  #1c2128;
  --border:    #30363d;
  --text:      #e6edf3;
  --text2:     #8b949e;
  --muted:     #484f58;
  --accent:    #25D366;
  --accent-h:  #1da851;
  --danger:    #f85149;
  --warn:      #d29922;
  --info:      #58a6ff;
  --success:   #25D366;
}

/* ── RTL support ───────────────────────────────────────────────────────── */
[dir="rtl"] { text-align: right; }
[dir="rtl"] .nav { flex-direction: row-reverse; }
[dir="rtl"] .lang-picker { flex-direction: row-reverse; }

/* ── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: var(--font-size);
  line-height: var(--line);
  overflow-x: hidden;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Typography ────────────────────────────────────────────────────────── */
h1 { font-size: 1.7rem;  font-weight: 700; letter-spacing: -.025em; line-height: 1.2; }
h2 { font-size: 1.25rem; font-weight: 700; letter-spacing: -.015em; }
h3 { font-size: 1rem;    font-weight: 600; }
p  { color: var(--text2); font-size: .95rem; }
strong { font-weight: 600; }

/* ── Links ─────────────────────────────────────────────────────────────── */
a { color: var(--accent); text-decoration: none; transition: opacity var(--trans); }
a:hover { opacity: .8; text-decoration: underline; }

/* ── Form elements ─────────────────────────────────────────────────────── */
input, select, textarea {
  font-family: inherit;
  font-size: .9rem;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: .55rem .8rem;
  width: 100%;
  transition: border-color var(--trans), box-shadow var(--trans);
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--brand-dim);
}
input::placeholder { color: var(--muted); }
select option { background: var(--surface); }
textarea { resize: vertical; min-height: 70px; }

label {
  display: block;
  font-size: .75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: .3rem;
}
label:not(:first-child) { margin-top: .9rem; }

.field { margin-bottom: 1rem; }
.field label { font-size: .75rem; margin-top: 0; }

.hint { font-size: .78rem; color: var(--muted); margin-top: .3rem; line-height: 1.35; }

/* ── Checkbox row ──────────────────────────────────────────────────────── */
.check-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-top: .6rem;
}
.check-row input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--accent);
  flex-shrink: 0;
}
.check-row span { font-size: .9rem; color: var(--text); }

/* ── Buttons ───────────────────────────────────────────────────────────── */
button, .btn {
  cursor: pointer;
  font-family: inherit;
  font-size: .875rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  padding: .55rem 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  white-space: nowrap;
  transition: background var(--trans), box-shadow var(--trans), opacity var(--trans), transform var(--trans);
  line-height: 1;
  text-decoration: none;
}
button:active, .btn:active { transform: scale(.97); }
button:disabled, .btn:disabled { opacity: .45; pointer-events: none; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37,211,102,.35);
}
.btn-primary:hover { background: var(--accent-h); box-shadow: 0 4px 14px rgba(37,211,102,.45); text-decoration: none; }

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1.5px solid var(--danger);
}
.btn-danger:hover { background: var(--danger); color: #fff; text-decoration: none; }

.btn-ghost {
  background: transparent;
  color: var(--text2);
  border: none;
  padding: .45rem .75rem;
}
.btn-ghost:hover { background: var(--surface2); color: var(--text); text-decoration: none; }

.btn-full { width: 100%; padding: .75rem; }
.btn-sm   { font-size: .8rem; padding: .38rem .7rem; }
.btn-icon {
  background: var(--surface2);
  border: 1.5px solid var(--border);
  color: var(--text2);
  width: 34px; height: 34px;
  padding: 0;
  border-radius: var(--radius-sm);
}
.btn-icon:hover { border-color: var(--accent); color: var(--accent); }

/* ── Card ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

/* ── Divider ───────────────────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: .9rem 0; }

/* ── Tag / pill ────────────────────────────────────────────────────────── */
.tag-list { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .35rem; }
.tag {
  display: inline-flex; align-items: center; gap: .3rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .2rem .55rem;
  font-size: .78rem;
  line-height: 1.4;
}
.tag button {
  background: none; border: none; color: var(--muted);
  font-size: .85rem; padding: 0; width: 14px; height: 14px;
  border-radius: 2px;
}
.tag button:hover { color: var(--danger); background: none; }

/* ── KV row ────────────────────────────────────────────────────────────── */
.kv-row { display: flex; gap: .4rem; align-items: center; margin-bottom: .4rem; }
.kv-row input { flex: 1; }

/* ── Field row (two columns) ───────────────────────────────────────────── */
.field-row { display: flex; gap: .5rem; }
.field-row > * { flex: 1; min-width: 0; }

/* ── Nav bar ───────────────────────────────────────────────────────────── */
.nav {
  height: 54px;
  background: var(--surface);
  border-bottom: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: 0 1.25rem;
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}
.nav-brand {
  font-weight: 700;
  font-size: .95rem;
  color: var(--brand);
  display: flex; align-items: center; gap: .35rem;
  margin-inline-end: .25rem;
  white-space: nowrap;
}
.nav-brand .bot-name,
.nav-brand #nav-botname {
  display: none;
}
.nav-divider { width: 1px; height: 20px; background: var(--border); margin: 0 .2rem; flex-shrink: 0; }
.nav-spacer  { flex: 1; }

.nav-link {
  font-size: .85rem;
  font-weight: 500;
  color: var(--text2);
  padding: .3rem .65rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--trans), color var(--trans);
  display: flex; align-items: center; gap: .3rem;
  white-space: nowrap;
}
.nav-link:hover  { background: var(--surface2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--brand-dim); color: var(--brand); }
/* PRO-locked nav link — greyed out, pointer forbidden */
.nav-link.nav-pro-locked { opacity: .45; cursor: not-allowed; }
.nav-link.nav-pro-locked::after { content: ' 🔒'; font-size: .75em; }
.nav-link.nav-pro-locked:hover { background: none; color: var(--text2); }
/* Plan badge (FREE / PRO) shown next to bot name in nav */
.plan-badge {
  display: inline-block;
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .06em;
  padding: .1rem .35rem;
  border-radius: .2rem;
  vertical-align: middle;
  line-height: 1.4;
  margin-inline-start: .2rem;
}
.plan-badge-pro  { background: #7c3aed; color: #fff; }
.plan-badge-free { background: var(--surface2); color: var(--muted); border: 1px solid var(--border); }

/* ── Status dot ────────────────────────────────────────────────────────── */
.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}
.status-dot.green  { background: var(--success); box-shadow: 0 0 0 3px rgba(37,211,102,.2); }
.status-dot.yellow { background: var(--warn); }
.status-dot.red    { background: var(--danger); }

/* ── Language picker ───────────────────────────────────────────────────── */
.lang-picker { position: relative; }
.lang-btn {
  background: var(--surface2);
  border: 1.5px solid var(--border);
  color: var(--text2);
  font-size: .75rem;
  font-weight: 600;
  padding: .25rem .55rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--trans);
  line-height: 1.4;
}
.lang-btn:hover { border-color: var(--accent); color: var(--accent); }

.lang-menu {
  position: absolute; top: 100%; right: 0; z-index: 1000;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); margin-top: .3rem;
  min-width: 70px; padding: .4rem;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
  display: none; flex-direction: column; gap: .2rem;
}
.lang-menu.open { display: flex; }
.lang-menu-item {
  background: transparent; border: none;
  color: var(--text2); font-size: .78rem; font-weight: 600;
  padding: .4rem .6rem; cursor: pointer;
  text-align: left; border-radius: var(--radius-sm);
  transition: all var(--trans);
  white-space: nowrap;
}
.lang-menu-item:hover { background: var(--surface2); color: var(--accent); }
.lang-menu-item.active { background: var(--brand-dim); color: var(--brand); }

[dir="rtl"] .lang-menu { right: auto; left: 0; }

/* ── Theme toggle ──────────────────────────────────────────────────────── */
.theme-toggle {
  background: none; border: none;
  color: var(--text2);
  font-size: 1rem;
  cursor: pointer;
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--trans);
  padding: 0;
}
.theme-toggle:hover { background: var(--surface2); }

/* ── Toast ─────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 1.5rem; left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: #1a202c; color: #e6edf3;
  padding: .65rem 1.3rem;
  border-radius: 100px;
  font-size: .85rem; font-weight: 500;
  opacity: 0; pointer-events: none;
  transition: opacity .22s, transform .22s;
  z-index: 999;
  box-shadow: var(--shadow);
  white-space: nowrap;
}
[data-theme="dark"] .toast { background: var(--surface2); border: 1px solid var(--border); }
.toast.show    { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--brand);  color: #fff; }
.toast.error   { background: var(--danger); color: #fff; }

/* ── Modal / dialog overlay ────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.48);
  display: none; align-items: center; justify-content: center;
  z-index: 200;
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  padding: 1rem;
}
.modal-overlay.show {
  display: flex;
  animation: dsOverlayIn .2s ease both;
}

@keyframes dsOverlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-box {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem 1.75rem 1.35rem;
  width: min(420px, 100%);
  box-shadow: 0 12px 40px rgba(0,0,0,.18), 0 2px 8px rgba(0,0,0,.08);
}
.modal-overlay.show .modal-box {
  animation: dsBoxIn .25s cubic-bezier(.22,.61,.36,1) both;
}

@keyframes dsBoxIn {
  from { transform: translateY(12px) scale(.97); opacity: 0; }
  to   { transform: translateY(0) scale(1);      opacity: 1; }
}

.modal-box h3 {
  margin: 0 0 .2rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: .45rem;
}
.modal-box h3::before {
  content: '';
  display: inline-block;
  width: 3.5px;
  height: 1.1em;
  border-radius: 2px;
  background: var(--accent);
  flex-shrink: 0;
}

#ds-dlg-body {
  font-size: .9rem;
  color: var(--text2);
  line-height: 1.55;
  margin: .5rem 0 0;
}
#ds-dlg-body .card-input {
  margin-top: .6rem;
}
#ds-dlg-body .card-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--brand-dim);
}

.modal-footer {
  display: flex;
  gap: .5rem;
  justify-content: flex-end;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.modal-footer .btn {
  min-width: 80px;
  font-size: .85rem;
  padding: .5rem 1rem;
}

/* ── Error message ─────────────────────────────────────────────────────── */
.error-msg {
  background: rgba(229, 62, 62, .09);
  border: 1px solid rgba(229, 62, 62, .3);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: .6rem .85rem;
  font-size: .85rem;
  margin-bottom: .85rem;
}

/* ── Page layouts ──────────────────────────────────────────────────────── */
.page-center {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
}
.page-padded { padding: 1.25rem; }
@media (min-width: 640px) { .page-padded { padding: 1.75rem 2rem; } }

/* ── Login card ────────────────────────────────────────────────────────── */
.login-card { width: 100%; max-width: 400px; padding: 2.25rem 2rem; }
.login-logo {
  display: flex; align-items: center; gap: .5rem;
  margin-bottom: 1.6rem;
}
.login-logo .logo-icon { font-size: 1.8rem; }
.login-logo .logo-text { font-size: 1.15rem; font-weight: 700; color: var(--brand); }
.login-title { font-size: 1.45rem; margin-bottom: .25rem; }
.login-sub   { color: var(--text2); font-size: .9rem; margin-bottom: 1.6rem; }
.login-card .lang-picker { margin-bottom: 1.4rem; }

/* ── Scrollbar (Webkit) ────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── UTILITY: Card panels ────────────────────────────────────────────────── */
.card-panel    { width: 100%; max-width: 440px; padding: 1rem 1.25rem; display: flex; flex-direction: column; }
.card-panel-sm { gap: .6rem;  }
.card-panel-md { gap: .7rem;  }
.card-panel-lg { gap: .75rem; }

/* ── UTILITY: Section headings, labels, hints inside cards ───────────────── */
.section-heading { font-size: .82rem; font-weight: 600; color: var(--text2); margin: 0; }
.field-col       { display: flex; flex-direction: column; gap: .3rem;  }
.field-col-sm    { display: flex; flex-direction: column; gap: .35rem; }
.field-label-sm  { font-size: .78rem; color: var(--muted); }
.field-hint-xs   { font-size: .74rem; color: var(--muted); }
.muted-hint      { font-size: 12px; color: var(--muted); }
.muted-hint-mb   { font-size: 12px; color: var(--muted); margin-bottom: 12px; }

/* ── UTILITY: Row / flex helpers ─────────────────────────────────────────── */
.row-end      { display: flex; justify-content: flex-end; gap: .5rem; }
.row-between  { display: flex; align-items: center; justify-content: space-between; }
.btn-group    { display: flex; gap: .5rem; }
.btn-group-sm { display: flex; gap: .4rem; }
.btn-group-add{ display: flex; gap: .4rem; margin-top: .15rem; }

/* ── UTILITY: Bot control status ─────────────────────────────────────────── */
.bot-status-row { display: flex; align-items: center; gap: .6rem; font-size: .85rem; color: var(--text2); }
.bot-ctrl-dot   { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #888; flex-shrink: 0; }

/* ── UTILITY: Compact card input ─────────────────────────────────────────── */
.card-input { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .45rem .75rem; color: var(--text); font-size: .88rem; width: 100%; box-sizing: border-box; }

/* ── UTILITY: Logs pane ──────────────────────────────────────────────────── */
.logs-pre { font-size: .72rem; line-height: 1.45; max-height: 260px; overflow-y: auto; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .6rem .75rem; margin: 0; white-space: pre-wrap; word-break: break-all; color: var(--text); }

/* ── Nav pages dropdown ──────────────────────────────────────────────── */
.nav-pages { position: relative; margin-inline-start: .25rem; }
.nav-pages-btn {
  background: var(--surface2);
  border: 1.5px solid var(--border);
  color: var(--text);
  font-size: .82rem;
  font-weight: 600;
  padding: .28rem .7rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--trans);
  white-space: nowrap;
  line-height: 1.4;
}
.nav-pages-btn::after { content: ' ▾'; font-size: .7em; opacity: .6; }
.nav-pages-btn:hover { border-color: var(--accent); color: var(--accent); }

.nav-pages-menu {
  position: absolute; top: 100%; left: 0; z-index: 1000;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); margin-top: .3rem;
  min-width: 180px; padding: .4rem;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
  display: none; flex-direction: column; gap: .15rem;
}
.nav-pages-menu.open { display: flex; }
.nav-pages-menu .nav-link {
  display: flex; width: 100%;
  font-size: .82rem; padding: .45rem .7rem;
}
[dir="rtl"] .nav-pages-menu { left: auto; right: 0; }
[dir="rtl"] .nav-pages-menu .nav-link { justify-content: flex-end; }

/* ── Mobile nav: hamburger button ────────────────────────────────────────── */
.nav-hamburger {
  display: none;
  flex-shrink: 0;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px; height: 36px;
  padding: 7px;
  background: none;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--trans);
}
.nav-hamburger:hover { border-color: var(--accent); }
.nav-hamburger span {
  display: block;
  width: 100%; height: 2px;
  background: var(--text2);
  border-radius: 2px;
  transition: transform .22s ease, opacity .15s ease;
  transform-origin: center;
}
.nav-hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-hamburger.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nav-hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Mobile nav: slide-down panel ────────────────────────────────────────── */
.nav-mobile-panel {
  position: absolute;
  top: 100%; left: 0; right: 0;
  display: none;
  flex-direction: column;
  padding: .4rem .75rem .65rem;
  gap: .1rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-bottom: 1.5px solid var(--border);
  box-shadow: 0 8px 24px rgba(0,0,0,.13);
  max-height: calc(100svh - 54px);
  overflow-y: auto;
  z-index: 100;
}
.nav-mobile-panel.open { display: flex; }
.nav-mobile-panel .nav-link {
  display: flex !important;
  width: 100%;
  padding: .65rem .75rem;
  border-radius: var(--radius-sm);
  font-size: .92rem;
  white-space: normal;
  text-decoration: none;
}
[dir="rtl"] .nav-mobile-panel .nav-link { justify-content: flex-end; }

/* ── Responsive breakpoint: hamburger nav ────────────────────────────────── */
@media (max-width: 768px) {
  .nav { overflow: visible; max-width: 100vw; }
  .nav > .nav-divider,
  .nav > .nav-spacer { display: none !important; }
  /* Move all direct nav-links and utilities into the hamburger panel */
  .nav > a.nav-link { display: none !important; }
  .nav > #lang-picker { display: none !important; }
  .nav > #theme-btn  { display: none !important; }
  /* Show hamburger – pinned to the right */
  .nav-hamburger { display: flex; flex-shrink: 0; margin-left: auto; }
  .nav-pages-btn { font-size: .78rem; }
  /* Ensure secondary toolbars wrap */
  #topbar { flex-wrap: wrap; height: auto; min-height: 40px; padding: 6px 12px; gap: 4px; }
  #topbar .btn-action { font-size: 12px; padding: 4px 8px; }
  #topbar input[type="search"] { min-width: 0; flex: 1; }
}

/* ── Mobile panel utility items ─────────────────────────────────────────── */
.panel-sep {
  height: 1px;
  background: var(--border);
  margin: .35rem .75rem;
  flex-shrink: 0;
}
.panel-util-btn {
  display: flex; align-items: center; justify-content: flex-start;
  width: 100%; padding: .6rem .9rem;
  background: none; border: none; cursor: pointer;
  font-size: .9rem; color: var(--text);
  transition: background var(--trans);
  flex-shrink: 0;
}
.panel-util-btn:hover { background: var(--surface2); }
.panel-lang-toggle { display: flex; justify-content: space-between; align-items: center; }
.panel-lang-arrow {
  display: inline-block; font-style: normal;
  transition: transform .2s ease;
  transform: rotate(0deg);
}
.panel-lang-toggle.open .panel-lang-arrow { transform: rotate(90deg); }
.panel-lang-grid {
  display: flex; flex-direction: column;
  gap: 0; overflow: hidden;
  max-height: 400px; transition: max-height .25s ease, padding .25s ease;
  padding: .15rem 0 .4rem;
}
.panel-lang-grid.collapsed { max-height: 0; padding: 0; }
.panel-lang-item {
  padding: .5rem .9rem;
  background: none; border: none;
  border-radius: var(--radius-sm); cursor: pointer;
  font-size: .9rem; color: var(--text);
  text-align: start;
  transition: background var(--trans);
}
.panel-lang-item:hover { background: var(--surface2); }
.panel-lang-item.active { color: var(--primary); font-weight: 600; }

/* ── Page-level mobile tweaks ────────────────────────────────────────────── */
@media (max-width: 479px) {
  .page-padded { padding: .9rem .75rem; }
  .card-panel { max-width: 100%; }
  .modal-box { padding: 1.25rem 1.25rem 1rem; }
  .nav-pages-btn { font-size: .72rem; padding: .2rem .45rem; max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
}

/* ── Onboarding checklist panel ─────────────────────────────────────────── */
.ob-panel {
  position: fixed;
  top: 50%;
  right: 0;
  transform: translate(100%, -50%);
  width: 300px;
  max-height: 80vh;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
  box-shadow: -4px 0 24px rgba(0,0,0,.15);
  display: flex;
  flex-direction: column;
  z-index: 400;
  transition: transform .28s cubic-bezier(.22,.61,.36,1);
  overflow: hidden;
}
.ob-panel.open { transform: translate(0, -50%); }

.ob-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: .85rem 1rem .55rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.ob-title { font-weight: 700; font-size: .92rem; color: var(--text); }
.ob-close {
  background: none; border: none; cursor: pointer;
  font-size: 1.1rem; color: var(--muted); line-height: 1;
  min-width: 36px; min-height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  transition: color var(--trans), background var(--trans);
  flex-shrink: 0;
}
.ob-close:hover { color: var(--danger); background: var(--surface2); }

.ob-subtitle {
  font-size: .75rem; color: var(--muted);
  margin: .4rem 1rem .5rem; flex-shrink: 0;
}

.ob-list {
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column;
  padding: .25rem .5rem;
}

.ob-step {
  display: flex; align-items: flex-start; gap: .5rem;
  padding: .5rem .6rem;
  border-radius: var(--radius-sm);
  text-decoration: none; color: var(--text);
  transition: background var(--trans);
}
.ob-step:hover { background: var(--surface2); text-decoration: none; }
.ob-step.ob-done { opacity: .55; }
.ob-chk  { font-size: .82rem; flex-shrink: 0; margin-top: 2px; }
.ob-icon { font-size: .9rem;  flex-shrink: 0; margin-top: 2px; }
.ob-txt  { display: flex; flex-direction: column; gap: .1rem; }
.ob-txt b    { font-size: .82rem; color: var(--text); font-weight: 600; }
.ob-txt span { font-size: .73rem; color: var(--muted); line-height: 1.35; }

.ob-footer {
  padding: .6rem 1rem;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: flex-end;
  flex-shrink: 0; gap: .5rem;
}
.ob-congrats { font-size: .8rem; font-weight: 600; color: var(--brand); flex: 1; }

/* Floating reopen button */
.ob-fab {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 350;
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--brand); color: #fff;
  border: none; cursor: pointer; font-size: 1.15rem;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(37,211,102,.35);
  transition: transform var(--trans), box-shadow var(--trans);
}
.ob-fab:hover { transform: scale(1.1); box-shadow: 0 6px 20px rgba(37,211,102,.45); }

/* Mobile: slide up from bottom */
@media (max-width: 560px) {
  .ob-panel {
    width: 100vw;
    max-width: 100vw;
    top: auto; bottom: 0; right: 0; left: 0;
    transform: translateY(100%);
    border-radius: var(--radius) var(--radius) 0 0;
    border-right: 1.5px solid var(--border);
    border-bottom: none;
    max-height: 70vh;
  }
  .ob-panel.open { transform: translateY(0); }
  .ob-head { padding: 1rem 1rem .65rem; }
  .ob-close { min-width: 40px; min-height: 40px; font-size: 1.25rem; }
  .ob-fab { bottom: 1rem; right: 1rem; }
}

/* ── AI Chat assistant popup ────────────────────────────────────────────── */
.ai-chat-fab {
  position: fixed; bottom: 5rem; right: 1.5rem; z-index: 450;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--brand); color: #fff;
  border: none; cursor: pointer; font-size: 1.2rem;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(37,211,102,.35);
  transition: transform var(--trans), box-shadow var(--trans);
}
.ai-chat-fab:hover { transform: scale(1.1); box-shadow: 0 6px 20px rgba(37,211,102,.45); }

.ai-chat-panel {
  position: fixed; bottom: 5rem; right: 1.5rem; z-index: 500;
  width: 360px; height: 480px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  display: flex; flex-direction: column;
  transform: scale(0); transform-origin: bottom right;
  opacity: 0;
  transition: transform .22s cubic-bezier(.22,.61,.36,1), opacity .18s ease;
  overflow: hidden;
}
.ai-chat-panel.open { transform: scale(1); opacity: 1; }

.ai-chat-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: .7rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface2);
}
.ai-chat-head-title { font-weight: 700; font-size: .88rem; color: var(--text); }
.ai-chat-head-remaining { font-size: .72rem; color: var(--muted); }
.ai-chat-close {
  background: none; border: none; cursor: pointer;
  font-size: 1rem; color: var(--muted); padding: 0; line-height: 1;
  transition: color var(--trans);
}
.ai-chat-close:hover { color: var(--danger); }

.ai-chat-messages {
  flex: 1; overflow-y: auto;
  padding: .75rem .75rem .25rem;
  display: flex; flex-direction: column; gap: .5rem;
}

.ai-chat-msg {
  max-width: 85%; padding: .55rem .75rem;
  border-radius: var(--radius-sm);
  font-size: .82rem; line-height: 1.45;
  word-wrap: break-word; white-space: pre-wrap;
}
.ai-chat-msg.user {
  align-self: flex-end;
  background: var(--brand); color: #fff;
  border-bottom-right-radius: 2px;
}
.ai-chat-msg.assistant {
  align-self: flex-start;
  background: var(--surface2); color: var(--text);
  border-bottom-left-radius: 2px;
}
.ai-chat-msg.error {
  align-self: center;
  background: transparent; color: var(--danger);
  font-size: .76rem; text-align: center;
}
.ai-chat-typing {
  align-self: flex-start;
  font-size: .78rem; color: var(--muted);
  padding: .3rem .75rem;
}

.ai-chat-input-row {
  display: flex; gap: .4rem;
  padding: .6rem .75rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
}
.ai-chat-input {
  flex: 1; border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .45rem .6rem;
  font-size: .82rem; font-family: inherit;
  background: var(--surface2); color: var(--text);
  outline: none;
  transition: border-color var(--trans);
}
.ai-chat-input:focus { border-color: var(--brand); }
.ai-chat-send {
  background: var(--brand); color: #fff;
  border: none; border-radius: var(--radius-sm);
  padding: .4rem .7rem; cursor: pointer;
  font-size: .85rem; font-weight: 600;
  transition: opacity var(--trans);
}
.ai-chat-send:disabled { opacity: .5; cursor: default; }

/* Mobile: full width */
@media (max-width: 560px) {
  .ai-chat-fab { bottom: 4rem; right: 1rem; }
  .ai-chat-panel {
    width: calc(100% - 1rem); height: 60vh;
    bottom: 4rem; right: .5rem; left: .5rem;
  }
}
