/* DQ Rule Engine — v3.0 UI redesign */

:root {
  --teal:       #0F766E;
  --teal-dk:    #0D5C56;
  --teal-lt:    #CCFBF1;
  --teal-xlt:   #F0FDFA;
  --amber:      #D97706;
  --amber-lt:   #FEF3C7;
  --blue:       #2563EB;
  --blue-lt:    #DBEAFE;
  --green:      #059669;
  --green-lt:   #D1FAE5;
  --coral:      #F76C5E;
  --ink:        #111827;
  --ink-mid:    #4B5568;
  --ink-lt:     #9CA3AF;
  --ink-xlt:    #D1D5DB;
  --border:     #E5E7EB;
  --border-lt:  #F3F4F6;
  --bg:         #F9F8F6;
  --card:       #FFFFFF;
  --panel-dark: #111827;
  --r:          12px;
  --r-sm:       8px;
  --r-xs:       6px;
  --shadow-sm:  0 1px 2px rgba(0,0,0,.05);
  --shadow:     0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.07);
  --shadow-lg:  0 8px 32px rgba(0,0,0,.14);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100dvh;
  overflow-x: hidden;
}

/* ── Screens ─────────────────────────────────────────────── */
.screen {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  min-height: 100svh;
  animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }

/* ══════════════════════════════════════════════════════════
   AUTH — split layout
══════════════════════════════════════════════════════════ */
.auth-split {
  display: flex;
  flex: 1;
  min-height: 100dvh;
}

/* Left: brand + value prop */
.auth-left {
  flex: 0 0 420px;
  background: var(--panel-dark);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 2.75rem 2.75rem 2.25rem;
  position: relative;
  overflow: hidden;
}

.auth-left::before {
  content: 'DQ';
  position: absolute;
  right: -1.5rem;
  bottom: -2rem;
  font-family: 'Fraunces', serif;
  font-size: 14rem;
  font-weight: 600;
  color: rgba(255,255,255,.04);
  line-height: 1;
  pointer-events: none;
  user-select: none;
}

.auth-left-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: auto;
}

.brand-mark-lg {
  width: 40px;
  height: 40px;
  background: var(--teal);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Fraunces', serif;
  font-size: .95rem;
  font-weight: 600;
  color: #fff;
  letter-spacing: .04em;
  flex-shrink: 0;
}

.auth-left-brand-name {
  font-family: 'Fraunces', serif;
  font-size: 1rem;
  font-weight: 600;
  color: rgba(255,255,255,.9);
  line-height: 1.2;
}

.auth-left-brand-sub {
  font-size: .72rem;
  color: rgba(255,255,255,.4);
  display: block;
}

.auth-left-hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 3rem 0 2rem;
}

.auth-left-headline {
  font-family: 'Fraunces', serif;
  font-size: 2rem;
  font-weight: 300;
  line-height: 1.25;
  color: #fff;
  margin-bottom: 1rem;
}

.auth-left-headline em {
  font-style: italic;
  color: var(--teal-lt);
}

.auth-left-desc {
  font-size: .875rem;
  color: rgba(255,255,255,.55);
  line-height: 1.7;
  margin-bottom: 2rem;
}

.auth-features {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: .875rem;
}

.auth-features li {
  display: flex;
  align-items: flex-start;
  gap: .625rem;
  font-size: .825rem;
  color: rgba(255,255,255,.7);
  line-height: 1.5;
}

.auth-features li::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--teal-lt);
  flex-shrink: 0;
  margin-top: .5em;
}

.auth-feature-body {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  flex: 1;
}

.auth-feature-head {
  color: rgba(255, 255, 255, .95);
  font-weight: 500;
  line-height: 1.4;
}

.auth-feature-sub {
  color: rgba(255, 255, 255, .6);
  font-size: .78rem;
  line-height: 1.45;
}

.auth-features-tag {
  margin: 1.25rem 0 0;
  padding-top: .9rem;
  border-top: 1px solid rgba(255, 255, 255, .12);
  font-size: .78rem;
  color: rgba(255, 255, 255, .55);
  font-style: italic;
}

.auth-left-foot {
  font-size: .72rem;
  color: rgba(255,255,255,.25);
  letter-spacing: .06em;
  text-transform: uppercase;
}

/* Right: form */
.auth-right {
  flex: 1;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 2rem;
  overflow-y: auto;
}

.auth-form-wrap {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
}

.auth-form-title {
  font-family: 'Fraunces', serif;
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--ink);
  margin-bottom: .375rem;
}

.auth-form-sub {
  font-size: .825rem;
  color: var(--ink-lt);
  margin-bottom: 1.75rem;
}

.auth-foot-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  margin-top: 1.25rem;
  font-size: .8rem;
  color: var(--ink-lt);
}

/* ── Auth wrap (signup screen still uses this) */
.auth-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 2rem 1.5rem 3rem;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

.brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 2.5rem;
}

.brand-mark {
  width: 40px;
  height: 40px;
  background: var(--teal);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: 'Fraunces', serif;
  font-size: .9rem;
  font-weight: 600;
  letter-spacing: .04em;
}

.brand-text { display: flex; flex-direction: column; }

.brand-name {
  font-family: 'Fraunces', serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
}

.brand-sub {
  font-size: .72rem;
  color: var(--ink-lt);
}

.auth-body { flex: 1; }

.auth-headline {
  font-family: 'Fraunces', serif;
  font-size: clamp(1.75rem, 6vw, 2.25rem);
  font-weight: 300;
  line-height: 1.2;
  color: var(--ink);
  margin-bottom: 1rem;
}

.auth-headline em { font-style: italic; color: var(--teal); }

.auth-desc {
  font-size: .875rem;
  color: var(--ink-mid);
  line-height: 1.6;
  margin-bottom: 2rem;
}

.auth-form {
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
}

/* ── Form fields */
.field-label {
  display: block;
  font-size: .75rem;
  font-weight: 600;
  color: var(--ink-mid);
  margin-bottom: .35rem;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.field-input {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  padding: .75rem 1rem;
  font-family: 'DM Sans', sans-serif;
  font-size: .9rem;
  color: var(--ink);
  background: var(--card);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  margin-bottom: .875rem;
}

.field-input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-lt);
}

.auth-msg {
  font-size: .825rem;
  margin-top: .5rem;
  line-height: 1.5;
  padding: .625rem .875rem;
  border-radius: var(--r-sm);
}
.auth-msg.ok  { background: var(--teal-lt); color: var(--teal-dk); }
.auth-msg.err { background: #FEE2E2; color: #991B1B; }

.auth-note {
  font-size: .78rem;
  color: var(--ink-lt);
  margin-top: 1rem;
  line-height: 1.5;
  text-align: center;
}

/* ══════════════════════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════════════════════ */
.btn-primary,
.btn-secondary {
  border: none;
  border-radius: var(--r-sm);
  padding: .75rem 1.5rem;
  font-family: 'DM Sans', sans-serif;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s, border-color .15s, color .15s, box-shadow .15s;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-dk); box-shadow: 0 2px 8px rgba(15,118,110,.3); }
.btn-primary:active { transform: scale(.99); }
.btn-primary:disabled { background: var(--border); color: var(--ink-lt); cursor: not-allowed; }
.btn-primary.full { width: 100%; }

.btn-secondary {
  background: var(--card);
  color: var(--teal);
  border: 1.5px solid var(--teal);
  margin-top: .5rem;
}
.btn-secondary:hover { background: var(--teal-lt); }
.btn-secondary:active { transform: scale(.99); }
.btn-secondary:disabled { background: var(--bg); border-color: var(--border); color: var(--ink-lt); cursor: not-allowed; }
.btn-secondary.full { width: 100%; }

.btn-google {
  background: var(--card);
  color: var(--ink);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  padding: .75rem 1.5rem;
  font-family: 'DM Sans', sans-serif;
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  transition: border-color .15s, box-shadow .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn-google:hover { border-color: #4285F4; box-shadow: var(--shadow-sm); }
.btn-google.full { width: 100%; }

.or-divider {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin: 1.125rem 0;
  color: var(--ink-lt);
  font-size: .75rem;
}
.or-divider::before,
.or-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.btn-ghost {
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: .875rem;
  color: var(--ink-lt);
  padding: .5rem .625rem;
  border-radius: var(--r-xs);
  -webkit-tap-highlight-color: transparent;
  transition: color .15s, background .15s;
}
.btn-ghost:hover { color: var(--ink-mid); background: var(--border-lt); }

.icon-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-mid);
  -webkit-tap-highlight-color: transparent;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--border); color: var(--ink); }

.btn-back-menu {
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: .3rem;
  padding: .3rem .65rem;
  font-size: .78rem;
  font-weight: 600;
  color: var(--ink-mid);
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: background .15s, color .15s, border-color .15s;
}
.btn-back-menu:hover { background: var(--border); color: var(--ink); }

/* ══════════════════════════════════════════════════════════
   LOADING
══════════════════════════════════════════════════════════ */
.loading-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.5rem;
  text-align: center;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 2.5px solid var(--border);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-text { font-size: .875rem; color: var(--ink-lt); }

/* ══════════════════════════════════════════════════════════
   SESSIONS
══════════════════════════════════════════════════════════ */
.page-wrap {
  flex: 1;
  max-width: 620px;
  margin: 0 auto;
  width: 100%;
  padding: 0 1.5rem 2rem;
  display: flex;
  flex-direction: column;
}

.sessions-header {
  padding: 2rem 0 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
}

.sessions-header-left { flex: 1; min-width: 0; }

.sessions-title {
  font-family: 'Fraunces', serif;
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--ink);
  line-height: 1.2;
}

.sessions-user {
  font-size: .78rem;
  color: var(--ink-lt);
  margin-top: .25rem;
  display: flex;
  align-items: center;
  gap: .375rem;
}

.sessions-user-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}

/* Keep legacy selectors working */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-top: 1.75rem;
  padding-bottom: 1.25rem;
}
.page-title {
  font-family: 'Fraunces', serif;
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--ink);
}
.page-sub { font-size: .78rem; color: var(--ink-lt); margin-top: .2rem; }

/* New session CTA card */
.new-session-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--teal);
  border-radius: var(--r);
  color: #fff;
  cursor: pointer;
  border: none;
  width: 100%;
  font-family: 'DM Sans', sans-serif;
  text-align: left;
  transition: background .15s, box-shadow .15s;
  -webkit-tap-highlight-color: transparent;
  margin-bottom: .875rem;
  box-shadow: 0 2px 10px rgba(15,118,110,.2);
}
.new-session-card:hover {
  background: var(--teal-dk);
  box-shadow: 0 4px 16px rgba(15,118,110,.28);
}
.new-session-card:active { transform: scale(.99); }

.new-session-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: rgba(255,255,255,.15);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.new-session-text-main {
  font-size: .9rem;
  font-weight: 600;
  line-height: 1.2;
}

.new-session-text-sub {
  font-size: .75rem;
  opacity: .7;
  margin-top: .125rem;
}

.session-list {
  display: flex;
  flex-direction: column;
  gap: .625rem;
  flex: 1;
}

/* Session card */
.session-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1rem 1.25rem .875rem;
  transition: border-color .15s, box-shadow .15s;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.session-card:hover {
  border-color: var(--teal);
  box-shadow: var(--shadow);
}

.session-card-top {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
}

.session-card-body {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.session-delete-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink-xlt);
  padding: .25rem;
  border-radius: var(--r-xs);
  display: flex;
  align-items: center;
  transition: color .15s, background .15s;
  -webkit-tap-highlight-color: transparent;
}
.session-delete-btn:hover { color: #DC2626; background: #FEE2E2; }

.session-confirm {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  font-size: .825rem;
  color: var(--ink-mid);
}
.session-confirm-btns { display: flex; gap: .4rem; }

.session-confirm-yes {
  background: #DC2626; color: #fff; border: none; border-radius: var(--r-xs);
  padding: .3rem .7rem; font-family: 'DM Sans', sans-serif; font-size: .78rem; font-weight: 600; cursor: pointer;
}
.session-confirm-yes:hover { background: #B91C1C; }

.session-confirm-no {
  background: none; color: var(--ink-mid); border: 1px solid var(--border); border-radius: var(--r-xs);
  padding: .3rem .7rem; font-family: 'DM Sans', sans-serif; font-size: .78rem; cursor: pointer;
}
.session-confirm-no:hover { background: var(--bg); }

.session-rule {
  font-size: .875rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: .3rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-meta {
  font-size: .72rem;
  color: var(--ink-lt);
  display: flex;
  align-items: center;
  gap: .375rem;
  flex-wrap: wrap;
}

/* Progress bar on session cards */
.session-prog {
  height: 3px;
  background: var(--border);
  border-radius: 100px;
  margin-top: .75rem;
  overflow: hidden;
}

.session-prog-fill {
  height: 100%;
  background: var(--teal);
  border-radius: 100px;
  transition: width .4s ease;
}

.session-prog-fill.complete { background: var(--green); }

.badge {
  font-size: .65rem;
  font-weight: 600;
  padding: .15em .55em;
  border-radius: 100px;
  font-family: 'DM Mono', monospace;
  letter-spacing: .02em;
}
.badge-progress  { background: var(--amber-lt); color: var(--amber); }
.badge-complete  { background: var(--green-lt); color: var(--green); }
.badge-abandoned { background: var(--border-lt); color: var(--ink-lt); }

/* Empty state */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 1rem;
  gap: .875rem;
  color: var(--ink-lt);
}

.empty-state-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--border-lt);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: .25rem;
}

.empty-state-title {
  font-size: .9rem;
  font-weight: 600;
  color: var(--ink-mid);
}

.empty-state-desc {
  font-size: .8rem;
  color: var(--ink-lt);
  line-height: 1.55;
  max-width: 280px;
}

.empty { color: var(--ink-lt); font-size: .875rem; padding: 2.5rem 0; text-align: center; }

.sessions-footer {
  display: flex;
  align-items: center;
  gap: .375rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

/* ══════════════════════════════════════════════════════════
   CHAT SCREEN
══════════════════════════════════════════════════════════ */
.chat-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
  height: 100dvh;
  height: 100svh; /* iOS Safari: excludes browser chrome */
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .625rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-shrink: 0;
}

.chat-meta { flex: 1; min-width: 0; }

.chat-title-text {
  font-size: .8rem;
  font-weight: 600;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink);
}

/* Progress bar in header */
.chat-progress-bar {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-top: 5px;
}

.phase-bar {
  display: flex;
  gap: 4px;
  margin-top: 5px;
}

.phase-pill {
  font-size: .65rem;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--border);
  color: var(--ink-lt);
  transition: background .25s, color .25s;
  letter-spacing: .01em;
}
.phase-pill.done {
  background: var(--teal);
  color: #fff;
  opacity: .55;
}
.phase-pill.active {
  background: var(--teal);
  color: #fff;
}

/* Chat feed */
.chat-feed {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  -webkit-overflow-scrolling: touch;
}

/* ── Messages */
.msg {
  display: flex;
  flex-direction: column;
  animation: msgIn .18s ease;
}

@keyframes msgIn {
  from { opacity:0; transform:translateY(5px); }
  to   { opacity:1; transform:translateY(0); }
}

/* Engine: full width, left border accent */
.msg.engine {
  align-self: stretch;
  max-width: 100%;
}

/* User: right-aligned, constrained width */
.msg.user {
  align-self: flex-end;
  max-width: 80%;
}

.msg-label {
  font-size: .62rem;
  font-weight: 600;
  color: var(--ink-lt);
  margin-bottom: .25rem;
  padding: 0 .125rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.msg.user .msg-label { text-align: right; }

/* Engine bubble: card with left teal border */
.msg.engine .msg-bubble {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--teal);
  border-radius: 0 var(--r) var(--r) 0;
  padding: 1rem 1.125rem;
  font-size: .875rem;
  line-height: 1.7;
  color: var(--ink);
}

/* User bubble: teal pill */
.msg.user .msg-bubble {
  background: var(--teal);
  color: #fff;
  border-radius: var(--r) var(--r) 4px var(--r);
  padding: .7rem 1rem;
  font-size: .875rem;
  line-height: 1.55;
}

/* Message content */
.msg-bubble { box-shadow: var(--shadow-sm); }
.msg-bubble p  { margin-bottom: .5em; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble strong { font-weight: 600; }
.msg-bubble ul,
.msg-bubble ol  { padding-left: 1.35rem; margin: .4em 0; }
.msg-bubble li  { margin-bottom: .3em; }
.msg-bubble h2  { font-size: .95rem; font-weight: 700; margin: .75em 0 .35em; color: var(--ink); }
.msg-bubble h3  { font-size: .875rem; font-weight: 600; margin: .6em 0 .25em; color: var(--ink); }

/* ── Collapsible detail block */
.msg-detail {
  margin-top: .75rem;
  border-top: 1px solid var(--border);
  padding-top: .5rem;
}
.msg-detail summary {
  font-size: .75rem;
  font-weight: 600;
  color: var(--teal);
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: .3rem;
}
.msg-detail summary::-webkit-details-marker { display: none; }
.msg-detail summary::before {
  content: '▸';
  font-size: .65rem;
  transition: transform .15s;
}
.msg-detail[open] summary::before { transform: rotate(90deg); }
.msg-detail summary:hover { color: var(--teal-dk); }
.msg-detail-body {
  margin-top: .5rem;
  font-size: .82rem;
  color: var(--ink-mid);
  line-height: 1.6;
}

/* ── Step milestone divider */
.step-marker {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .25rem 0;
  opacity: .6;
  animation: fadeIn .3s ease;
}
.step-marker::before,
.step-marker::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.step-marker-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 2px solid var(--teal);
  background: var(--teal-lt);
  flex-shrink: 0;
}

/* ── Typing indicator */
.typing-bubble {
  display: flex;
  gap: 4px;
  align-items: center;
  height: 20px;
  padding: 1rem 1.125rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--teal);
  border-radius: 0 var(--r) var(--r) 0;
  box-shadow: var(--shadow-sm);
}
.typing-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ink-lt);
  animation: typeBounce 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: .2s; }
.typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes typeBounce {
  0%,60%,100% { transform:translateY(0); opacity:.5; }
  30% { transform:translateY(-5px); opacity:1; }
}

/* ══════════════════════════════════════════════════════════
   CHAT INPUT AREA
══════════════════════════════════════════════════════════ */
.chat-foot {
  border-top: 1px solid var(--border);
  background: var(--card);
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
  flex-shrink: 0;
}

/* ── Chip row (short pill options) */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  padding: .625rem 1rem 0;
}

.chip {
  background: var(--card);
  border: 1.5px solid var(--teal);
  color: var(--teal);
  border-radius: 100px;
  padding: .35rem .875rem;
  font-family: 'DM Sans', sans-serif;
  font-size: .8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
  -webkit-tap-highlight-color: transparent;
}
.chip:hover, .chip:active { background: var(--teal); color: #fff; }

/* ── YES / NO split buttons */
.yesno-row {
  display: flex;
  gap: .5rem;
  padding: .75rem 1rem 0;
}

.yesno-btn {
  flex: 1;
  padding: .75rem 1rem;
  border-radius: var(--r-sm);
  border: 2px solid var(--border);
  background: var(--card);
  font-family: 'DM Sans', sans-serif;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .15s;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: .04em;
}

.yesno-btn.yesno-yes {
  border-color: var(--teal);
  color: var(--teal);
}
.yesno-btn.yesno-yes:hover {
  background: var(--teal);
  color: #fff;
  box-shadow: 0 2px 10px rgba(15,118,110,.25);
}

.yesno-btn.yesno-no {
  border-color: var(--border);
  color: var(--ink-mid);
}
.yesno-btn.yesno-no:hover {
  border-color: #DC2626;
  background: #DC2626;
  color: #fff;
}

/* ── Numbered option cards */
.chip-row-cards {
  flex-direction: column;
  padding: .75rem 1rem 0;
  gap: .375rem;
}

.option-card {
  width: 100%;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  padding: .75rem 1rem;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  text-align: left;
  transition: border-color .15s, box-shadow .15s, background .15s;
  font-family: 'DM Sans', sans-serif;
  -webkit-tap-highlight-color: transparent;
  box-shadow: var(--shadow-sm);
}
.option-card:hover {
  border-color: var(--teal);
  background: var(--teal-xlt);
  box-shadow: var(--shadow);
}
.option-card:active { transform: scale(.995); }

.option-card-num {
  font-family: 'DM Mono', monospace;
  font-size: .7rem;
  font-weight: 600;
  color: var(--teal);
  width: 18px;
  flex-shrink: 0;
  padding-top: .15em;
  opacity: .8;
}

.option-card-text {
  flex: 1;
  font-size: .85rem;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.5;
}

/* ── Legacy chip option (keep for backwards compat) */
.chip-row-options {
  flex-direction: column;
  padding: .75rem 1rem;
  gap: .4rem;
}

.chip-option {
  width: 100%;
  background: var(--card);
  border: 1.5px solid var(--teal);
  color: var(--teal);
  border-radius: var(--r);
  padding: .75rem 1rem;
  font-family: 'DM Sans', sans-serif;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: background .15s, color .15s;
  -webkit-tap-highlight-color: transparent;
}
.chip-option:hover, .chip-option:active { background: var(--teal); color: #fff; }

.chip-row-2col { flex-direction: row; }
.chip-row-2col .chip-option { flex: 1; }

/* ── Input row */
.input-row {
  display: flex;
  align-items: flex-end;
  gap: .5rem;
  padding: .625rem 1rem .875rem;
}

.chat-input {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  padding: .625rem .875rem;
  font-family: 'DM Sans', sans-serif;
  font-size: .875rem;
  color: var(--ink);
  background: var(--bg);
  resize: none;
  outline: none;
  line-height: 1.55;
  max-height: 140px;
  overflow-y: auto;
  transition: border-color .15s, box-shadow .15s;
}
.chat-input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-lt);
  background: var(--card);
}

.send-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--teal);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s, box-shadow .15s;
  -webkit-tap-highlight-color: transparent;
}
.send-btn:hover { background: var(--teal-dk); box-shadow: 0 2px 8px rgba(15,118,110,.3); }
.send-btn:disabled { background: var(--border); cursor: not-allowed; box-shadow: none; }

/* ══════════════════════════════════════════════════════════
   FINAL OUTPUT — Step 12 rule cards
══════════════════════════════════════════════════════════ */
.output-panel {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  animation: msgIn .25s ease;
  box-shadow: var(--shadow);
}

.output-panel-header {
  background: var(--ink);
  color: #fff;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.output-panel-title {
  font-family: 'Fraunces', serif;
  font-size: .95rem;
  font-weight: 300;
  color: rgba(255,255,255,.9);
}

.output-panel-count {
  font-family: 'DM Mono', monospace;
  font-size: .7rem;
  color: rgba(255,255,255,.45);
}

.output-copy-btn {
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.15);
  color: rgba(255,255,255,.8);
  border-radius: var(--r-xs);
  padding: .3rem .7rem;
  font-family: 'DM Sans', sans-serif;
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.output-copy-btn:hover { background: rgba(255,255,255,.18); }

.output-rule-card {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  border-left: 4px solid var(--border);
  transition: background .15s;
}
.output-rule-card:last-child { border-bottom: none; }
.output-rule-card:hover { background: var(--bg); }

.output-rule-card.type-blocking  { border-left-color: var(--amber); }
.output-rule-card.type-flagging  { border-left-color: var(--blue); }
.output-rule-card.type-monitoring { border-left-color: var(--green); }

.output-rule-head {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .5rem;
  flex-wrap: wrap;
}

.output-rule-num {
  font-family: 'DM Mono', monospace;
  font-size: .68rem;
  color: var(--ink-lt);
}

.output-rule-type {
  font-family: 'DM Mono', monospace;
  font-size: .65rem;
  font-weight: 600;
  padding: .15em .55em;
  border-radius: 100px;
  letter-spacing: .03em;
}
.output-rule-type.type-blocking  { background: var(--amber-lt); color: var(--amber); }
.output-rule-type.type-flagging  { background: var(--blue-lt); color: var(--blue); }
.output-rule-type.type-monitoring { background: var(--green-lt); color: var(--green); }

.output-rule-dim {
  font-family: 'DM Mono', monospace;
  font-size: .65rem;
  color: var(--ink-lt);
  background: var(--border-lt);
  padding: .15em .5em;
  border-radius: 100px;
}

.output-rule-text {
  font-size: .875rem;
  font-weight: 500;
  line-height: 1.5;
  color: var(--ink);
  margin-bottom: .5rem;
}

.output-rule-explain {
  font-size: .78rem;
  color: var(--ink-mid);
  line-height: 1.6;
  padding-top: .5rem;
  border-top: 1px solid var(--border-lt);
}

/* ══════════════════════════════════════════════════════════
   BACK FAB
══════════════════════════════════════════════════════════ */
.back-fab {
  position: fixed;
  bottom: calc(5.5rem + env(safe-area-inset-bottom));
  left: 1rem;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(17,24,39,.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0,0,0,.22);
  z-index: 100;
  opacity: 0;
  transform: scale(0.8);
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  -webkit-tap-highlight-color: transparent;
}
.back-fab.visible {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}
.back-fab:active { background: rgba(17,24,39,.9); }

/* ══════════════════════════════════════════════════════════
   SUMMARY FAB (fixed, right side, above feedback)
══════════════════════════════════════════════════════════ */
.summary-fab {
  position: fixed;
  bottom: calc(4.75rem + env(safe-area-inset-bottom));
  right: 1.25rem;
  height: 36px;
  padding: 0 .875rem 0 .625rem;
  border-radius: 18px;
  background: var(--teal);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: .35rem;
  font-size: .8rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  z-index: 100;
  transition: background .15s, box-shadow .15s;
  -webkit-tap-highlight-color: transparent;
}
.summary-fab:hover { background: var(--teal-dk); box-shadow: var(--shadow-lg); }

/* ══════════════════════════════════════════════════════════
   DATA ELEMENTS SHEET
══════════════════════════════════════════════════════════ */
.data-sheet {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: flex-end;
  background: rgba(0,0,0,.35);
}
.data-sheet-inner {
  background: var(--card);
  border-radius: var(--r) var(--r) 0 0;
  width: 100%;
  max-height: 75vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.data-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .875rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.data-sheet-title {
  font-size: .9rem;
  font-weight: 600;
  color: var(--ink);
}
.data-sheet-body {
  overflow-y: auto;
  padding: 1rem 1.25rem 1.5rem;
  flex: 1;
}

.summary-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.summary-tab {
  flex: 1;
  padding: .625rem 1rem;
  font-size: .825rem;
  font-weight: 500;
  background: none;
  border: none;
  color: var(--ink-lt);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.summary-tab.active {
  color: var(--teal);
  border-bottom-color: var(--teal);
}
.summary-panel { display: block; }
.data-group { margin-bottom: 1.25rem; }
.data-group:last-child { margin-bottom: 0; }
.data-group-title {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--ink-lt);
  margin-bottom: .5rem;
}
.data-item {
  font-size: .875rem;
  color: var(--ink);
  padding: .4rem .625rem;
  background: var(--bg);
  border-radius: var(--r-xs);
  margin-bottom: .35rem;
  line-height: 1.4;
}
.data-empty {
  font-size: .85rem;
  color: var(--ink-lt);
  font-style: italic;
}

/* ── Rule cards (in rules sheet) */
.rule-card {
  background: var(--bg);
  border-radius: var(--r-sm);
  padding: .75rem .875rem;
  margin-bottom: .625rem;
  border: 1px solid var(--border);
}
.rule-card:last-child { margin-bottom: 0; }
.rule-card-head {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .4rem;
}
.rule-number {
  font-size: .72rem;
  font-weight: 700;
  color: var(--ink-lt);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.rule-type-badge {
  font-size: .7rem;
  font-weight: 600;
  padding: .15rem .45rem;
  border-radius: 99px;
  text-transform: capitalize;
}
.rule-text {
  font-size: .875rem;
  color: var(--ink);
  line-height: 1.5;
  margin: 0 0 .35rem;
}
.rule-meta {
  font-size: .78rem;
  color: var(--ink-mid);
  margin: .2rem 0 0;
}

/* ══════════════════════════════════════════════════════════
   FEEDBACK FAB + DRAWER
══════════════════════════════════════════════════════════ */
.fab {
  position: fixed;
  bottom: calc(1.25rem + env(safe-area-inset-bottom));
  right: 1.25rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--card);
  border: 1.5px solid var(--border);
  color: var(--ink-mid);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  z-index: 100;
  transition: border-color .15s, color .15s, box-shadow .15s;
  -webkit-tap-highlight-color: transparent;
}
.fab:hover { border-color: var(--teal); color: var(--teal); box-shadow: var(--shadow-lg); }

.drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  animation: slideUp .2s ease;
}
@keyframes slideUp {
  from { transform:translateY(100%); }
  to   { transform:translateY(0); }
}

.drawer-inner {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r) var(--r) 0 0;
  padding: 1.25rem;
  box-shadow: var(--shadow-lg);
  max-width: 680px;
  margin: 0 auto;
  padding-bottom: calc(1.25rem + env(safe-area-inset-bottom));
}

.drawer-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .875rem;
}

.drawer-title { font-size: .875rem; font-weight: 600; color: var(--ink); }

.textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  padding: .65rem .875rem;
  font-family: 'DM Sans', sans-serif;
  font-size: .875rem;
  color: var(--ink);
  resize: none;
  outline: none;
  margin-bottom: .75rem;
  line-height: 1.5;
  background: var(--bg);
  transition: border-color .15s;
}
.textarea:focus { border-color: var(--teal); }

.feedback-done { font-size: .875rem; color: var(--teal); text-align: center; margin-top: .5rem; }

/* ══════════════════════════════════════════════════════════
   RULE OUTPUT CARDS (legacy, used by step 12 text rendering)
══════════════════════════════════════════════════════════ */
.rule-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--teal);
  border-radius: var(--r);
  padding: .875rem 1rem;
  margin-bottom: .6rem;
}

.rule-num { font-family: 'DM Mono', monospace; font-size: .7rem; color: var(--teal); margin-bottom: .3rem; }
.rule-text { font-size: .875rem; font-weight: 500; line-height: 1.45; margin-bottom: .5rem; }
.rule-tags { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: .4rem; }

.tag { font-family: 'DM Mono', monospace; font-size: .65rem; font-weight: 500; padding: .15em .55em; border-radius: 100px; }
.tag-prev  { background: var(--amber-lt); color: var(--amber); }
.tag-det   { background: var(--blue-lt); color: var(--blue); }
.tag-comp  { background: var(--green-lt); color: var(--green); }
.tag-valid { background: #FDF4FF; color: #7E22CE; }
.tag-time  { background: #FFF7ED; color: #C2410C; }
.tag-other { background: var(--teal-lt); color: var(--teal-dk); }

.rule-explain { font-size: .78rem; color: var(--ink-mid); line-height: 1.55; border-top: 1px solid var(--border); padding-top: .4rem; margin-top: .1rem; }

/* ══════════════════════════════════════════════════════════
   ADMIN
══════════════════════════════════════════════════════════ */
.admin-wrap {
  flex: 1;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.admin-header { display: flex; align-items: center; gap: .75rem; padding-top: .5rem; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .75rem; }

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1rem 1.25rem;
}

.stat-value { font-family: 'Fraunces', serif; font-size: 2rem; font-weight: 400; color: var(--teal); line-height: 1; margin-bottom: .25rem; }
.stat-label { font-size: .72rem; color: var(--ink-lt); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }

.admin-tabs-wrap { position: relative; }
.admin-tabs-toggle {
  display: none;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .65rem .85rem;
  background: var(--card, #fff);
  border: 1px solid var(--border, #e3e8ea);
  border-radius: 10px;
  font: inherit;
  font-size: .9rem;
  font-weight: 600;
  color: var(--ink-dark, #1a2332);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.admin-tabs-toggle svg { transition: transform .15s; flex-shrink: 0; }
.admin-tabs-wrap.open .admin-tabs-toggle svg { transform: rotate(180deg); }

.admin-tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); }

.admin-tab {
  background: none; border: none; cursor: pointer;
  font-family: 'DM Sans', sans-serif; font-size: .875rem; font-weight: 500; color: var(--ink-lt);
  padding: .6rem 1rem; border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .15s, border-color .15s; -webkit-tap-highlight-color: transparent;
}
.admin-tab.active { color: var(--teal); border-bottom-color: var(--teal); }
.admin-tab:hover:not(.active) { color: var(--ink-mid); }

.admin-panel { overflow-x: auto; }
.admin-table-wrap { min-width: 0; }

.admin-table { width: 100%; border-collapse: collapse; font-size: .825rem; }
.admin-table th { text-align: left; font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-lt); padding: .5rem .75rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.admin-table td { padding: .65rem .75rem; border-bottom: 1px solid var(--border); color: var(--ink); max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--bg); }
.admin-empty { color: var(--ink-lt); font-size: .875rem; padding: 2rem 0; text-align: center; }

/* ══════════════════════════════════════════════════════════
   SIGNUP
══════════════════════════════════════════════════════════ */
.signup-form { display: flex; flex-direction: column; }

.back-link {
  background: none; border: none; cursor: pointer;
  font-family: 'DM Sans', sans-serif; font-size: .825rem; color: var(--ink-lt);
  padding: 0; margin-bottom: 1.25rem; display: block; text-align: left;
  -webkit-tap-highlight-color: transparent; transition: color .15s;
}
.back-link:hover { color: var(--ink-mid); }

.field-row { display: flex; gap: .75rem; }
.field-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.opt-label { font-size: .7rem; font-weight: 400; color: var(--ink-lt); text-transform: none; letter-spacing: 0; margin-left: .2em; }

.username-wrap { position: relative; display: flex; align-items: center; }
.username-input { margin-bottom: 0 !important; padding-right: 8rem; }

#usernameStatus { position: absolute; right: .875rem; font-size: .72rem; font-weight: 600; pointer-events: none; white-space: nowrap; }
#usernameStatus.ok       { color: var(--teal); }
#usernameStatus.err      { color: #DC2626; }
#usernameStatus.checking { color: var(--ink-lt); }

.field-hint { font-size: .72rem; color: var(--ink-lt); margin-top: .3rem; margin-bottom: .75rem; line-height: 1.4; }

.pw-wrap { position: relative; display: flex; align-items: center; margin-bottom: .875rem; }
.pw-input { margin-bottom: 0 !important; padding-right: 2.75rem; flex: 1; }
.pw-toggle { position: absolute; right: .5rem; background: none; border: none; cursor: pointer; color: var(--ink-lt); display: flex; align-items: center; justify-content: center; padding: .25rem; border-radius: 4px; -webkit-tap-highlight-color: transparent; }
.pw-toggle:hover { color: var(--ink-mid); }

.form-divider { display: flex; align-items: center; gap: .75rem; margin: 1rem 0 1.25rem; color: var(--ink-lt); font-size: .72rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.form-divider::before,
.form-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.inline-link { background: none; border: none; cursor: pointer; font-family: 'DM Sans', sans-serif; font-size: inherit; color: var(--teal); padding: 0; font-weight: 500; transition: text-decoration .1s; }
.inline-link:hover { text-decoration: underline; }

/* ══════════════════════════════════════════════════════════
   STEP 1 INTRO
══════════════════════════════════════════════════════════ */
.step1-intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 2.5rem 1rem 1.5rem;
  gap: .875rem;
  animation: fadeIn .25s ease;
}

.step1-intro-mark {
  width: 52px;
  height: 52px;
  background: var(--teal);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: 'Fraunces', serif;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: .04em;
  margin-bottom: .125rem;
  box-shadow: 0 4px 16px rgba(15,118,110,.25);
}

.step1-intro-title {
  font-family: 'Fraunces', serif;
  font-size: 1.3rem;
  font-weight: 300;
  color: var(--ink);
  line-height: 1.3;
}

.step1-intro-desc {
  font-size: .85rem;
  color: var(--ink-mid);
  line-height: 1.65;
  max-width: 340px;
}

.step1-options {
  display: flex;
  flex-direction: column;
  gap: .4rem;
  width: 100%;
  max-width: 400px;
  margin-top: .375rem;
}

.step1-option {
  width: 100%;
  background: var(--card);
  border: 1.5px solid var(--border);
  color: var(--ink);
  border-radius: var(--r);
  padding: .875rem 1.125rem;
  font-family: 'DM Sans', sans-serif;
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: border-color .15s, box-shadow .15s, background .15s;
  -webkit-tap-highlight-color: transparent;
  box-shadow: var(--shadow-sm);
}
.step1-option:hover {
  border-color: var(--teal);
  background: var(--teal-xlt);
  box-shadow: var(--shadow);
}
.step1-option::after {
  content: '→';
  font-size: .875rem;
  color: var(--teal);
  opacity: 0;
  transition: opacity .15s;
}
.step1-option:hover::after { opacity: 1; }

/* ══════════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════════ */
/* ══════════════════════════════════════════════════════════
   FLOATING TOP BAR (all screen sizes)
══════════════════════════════════════════════════════════ */
.mobile-top-bar {
  display: flex;
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 760px;
  z-index: 200;
  align-items: center;
  gap: .5rem;
  padding: calc(env(safe-area-inset-top) + .5rem) 1rem .5rem;
  background: rgba(15, 20, 30, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255,255,255,.07);
  min-height: calc(52px + env(safe-area-inset-top));
}

.mob-top-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,.08);
  border: none;
  /* Full white on the dark top bar — the previous .85 alpha made
     the SVG glyph look faint enough to read as "icon not drawn". */
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  transition: background .15s;
}
.mob-top-btn:hover { background: rgba(255,255,255,.15); }
.mob-top-btn:active { background: rgba(255,255,255,.22); }

.mob-top-mid {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.mob-top-title {
  font-size: .85rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mob-top-phase {
  font-size: .7rem;
  font-weight: 500;
  color: var(--teal);
  letter-spacing: .02em;
}

.mob-top-actions {
  display: flex;
  gap: .35rem;
  flex-shrink: 0;
}

/* Hide old header and floating action buttons — replaced by top bar */
.chat-header { display: none; }
#backFab { display: none !important; }
#summaryFab { display: none !important; }
#feedbackBtn { display: none !important; }

/* Push feed below the fixed top bar */
.chat-feed {
  padding-top: calc(52px + env(safe-area-inset-top) + 1rem) !important;
}

@media (max-width: 767px) {
  .auth-split {
    flex-direction: column;
  }

  .auth-left {
    flex: none;
    padding: 1.5rem 1.5rem 1.75rem;
  }

  .auth-left-brand { margin-bottom: 1.25rem; }

  .auth-left-hero { padding: 0; }

  .auth-left-headline { font-size: 1.5rem; }

  .auth-left-desc { display: none; }

  .auth-features { display: none; }

  .auth-left-foot { display: none; }

  .auth-right {
    flex: 1;
    align-items: flex-start;
    padding: 1.75rem 1.25rem;
  }

  .auth-form-wrap { max-width: 100%; }

  .page-wrap { padding: 0 1rem 1.5rem; }

  .sessions-header { padding-top: 1.25rem; }

  .chat-input { font-size: .9rem; }

  .input-row { padding: .5rem .875rem .875rem; }

  .chip-row { padding: .5rem .875rem 0; }

  .yesno-row { padding: .625rem .875rem 0; }

  .chip-row-cards { padding: .625rem .875rem 0; }
}

@media (max-width: 480px) {
  .auth-left-headline { font-size: 1.35rem; }

  .msg.user { max-width: 90%; }

  /* Stack first/last name on the smallest phones so the two columns
     read as obviously full-width fields rather than a slightly-uneven
     split. The field-row stays for ≥481px viewports. */
  .signup-form .field-row { flex-direction: column; gap: 0; }
}

/* ── Review cards */
.review-card {
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 1rem;
  margin-bottom: .75rem;
  background: var(--card);
}
.review-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem;
}
.review-score {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
}
.review-meta {
  font-size: .78rem;
  color: var(--ink-mid);
  margin-top: .2rem;
}
.review-narrative {
  font-size: .85rem;
  color: var(--ink-mid);
  margin-top: .5rem;
  line-height: 1.5;
}
.review-details {
  margin-top: .75rem;
  border-top: 1px solid var(--border);
  padding-top: .75rem;
  display: none;
}
.review-details.open { display: block; }
.review-toggle {
  font-size: .78rem;
  color: var(--teal);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  margin-top: .5rem;
}
.standard-row {
  display: flex;
  gap: .5rem;
  font-size: .8rem;
  padding: .3rem 0;
  border-bottom: 1px solid var(--border);
  line-height: 1.4;
}
.standard-pass { color: #16a34a; font-weight: 600; flex-shrink: 0; }
.standard-fail { color: #dc2626; font-weight: 600; flex-shrink: 0; }
.improvement-item {
  font-size: .82rem;
  padding: .4rem 0;
  border-bottom: 1px solid var(--border);
  line-height: 1.5;
}
.suggested-standard-card {
  border: 1.5px solid var(--teal);
  border-radius: var(--r-sm);
  padding: 1rem;
  margin-bottom: .75rem;
  background: var(--card);
}
.suggested-standard-name {
  font-size: .88rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: .25rem;
}
.suggested-standard-desc {
  font-size: .82rem;
  color: var(--ink-mid);
  margin-bottom: .75rem;
}
.admin-section-title {
  font-size: .88rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 .75rem;
}

/* ══════════════════════════════════════════════════════════
   MODULE SELECTION SCREEN
══════════════════════════════════════════════════════════ */
.modules-wrap {
  max-width: 840px;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
  min-height: 100svh;
}

.modules-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border);
  position: relative;
}

/* Hamburger toggle — hidden on desktop, shown on small viewports.
   When active, the inline action group becomes a dropdown anchored
   to the top-right of the header. */
.menu-toggle {
  display: none;
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
  padding: .35rem;
  border-radius: 8px;
  color: var(--ink-dark, #1a2332);
  -webkit-tap-highlight-color: transparent;
}
.menu-toggle:hover { background: var(--bg-soft, #f1f4f5); }
.menu-toggle:active { transform: scale(.96); }
.menu-toggle-badge {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: #c53030;
  color: #fff;
  font-size: .65rem;
  font-weight: 600;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.modules-brand {
  display: flex;
  gap: .5rem;
  align-items: center;
}

.brand-mark-sm {
  width: 28px;
  height: 28px;
  background: var(--teal);
  color: #fff;
  font-weight: 700;
  font-size: .85rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modules-brand-name {
  font-size: .8rem;
  color: var(--ink-mid);
}

.modules-header-actions {
  display: flex;
  gap: .5rem;
}

.modules-hero {
  padding: 2.5rem 0 2rem;
}

.modules-title {
  font-family: 'Fraunces', serif;
  font-size: 1.75rem;
  font-weight: 400;
  margin: 0 0 .5rem;
  color: var(--ink);
}

.modules-sub {
  font-size: .9rem;
  color: var(--ink-mid);
  margin: 0;
}

.module-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 2.5rem;
}

@media (max-width: 640px) {
  .module-cards {
    grid-template-columns: 1fr;
  }

  .modules-wrap {
    padding: 0 1rem 2rem;
  }

  .modules-header {
    padding: 1rem 0;
  }

  /* Collapse the four-button cluster (Where should I start? / Admin /
     Settings / Sign out) into a hamburger menu. The inline group becomes
     a dropdown anchored to the top-right when the toggle is active. */
  .menu-toggle { display: inline-flex; align-items: center; }
  .modules-header-actions {
    display: none;
    position: absolute;
    top: calc(100% + .35rem);
    right: 0;
    z-index: 80;
    flex-direction: column;
    align-items: stretch;
    min-width: 200px;
    padding: .4rem;
    background: var(--card, #fff);
    border: 1px solid var(--border, #e3e8ea);
    border-radius: 12px;
    box-shadow: 0 10px 28px rgba(15, 23, 42, .14);
  }
  .modules-header.menu-open .modules-header-actions { display: flex; }
  .modules-header-actions .btn-ghost {
    justify-content: flex-start;
    text-align: left;
    padding: .55rem .75rem;
    font-size: .9rem;
    border-radius: 8px;
  }
  .modules-header-actions .btn-ghost:hover { background: var(--bg-soft, #f1f4f5); }
  /* Admin button keeps its inline badge readable inside the dropdown. */
  .modules-header-actions .admin-with-badge { display: flex; align-items: center; gap: .35rem; }

  .modules-hero {
    padding: 1.5rem 0 1.25rem;
    text-align: center;
  }

  .modules-title {
    font-size: 1.35rem;
  }
  .modules-sub { margin: 0 auto; }

  .module-card {
    padding: 1rem;
    align-items: center;
    text-align: center;
  }
  .module-card-icon { margin: 0 auto; }
  .module-card-body { width: 100%; }

  .recent-card {
    padding: .75rem 1rem;
  }
}


.module-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: border-color .15s;
  cursor: pointer;
}

.module-card:hover {
  border-color: var(--teal);
}

.module-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.module-icon-cde {
  color: #6ee7b7;
}

.module-icon-rule {
  color: var(--teal);
}

.module-card-body {
  flex: 1;
}

.module-card-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 .35rem;
}

.module-card-desc {
  font-size: .85rem;
  color: var(--ink-mid);
  margin: 0;
  line-height: 1.5;
}

.modules-empty {
  text-align: center;
  color: var(--ink-mid);
  font-size: .875rem;
  padding-top: 1rem;
}

/* No-access empty state — shown when the profile has zero module
   access flags set. Replaces the module cards. */
.modules-noaccess {
  margin: 2rem auto;
  max-width: 520px;
  padding: 2rem 1.5rem;
  text-align: center;
  background: var(--card, #fff);
  border: 1px solid var(--border, #e3e8ea);
  border-radius: 12px;
}
.modules-noaccess-title {
  font-family: 'Fraunces', serif;
  font-size: 1.15rem;
  font-weight: 500;
  margin: 0 0 .65rem;
  color: var(--ink-dark, #1a2332);
}
.modules-noaccess-body {
  margin: 0 0 1.25rem;
  font-size: .92rem;
  color: var(--ink-mid, #4b5568);
  line-height: 1.55;
}
.modules-noaccess-cta {
  display: inline-block;
  padding: .65rem 1.4rem;
  text-decoration: none;
}
.modules-noaccess-confirm {
  margin: 1rem 0 0;
  font-size: .9rem;
  color: var(--ink-dark, #1a2332);
  background: var(--bg-soft, #f8fafb);
  border: 1px solid var(--border, #e3e8ea);
  border-radius: 8px;
  padding: .75rem 1rem;
}

/* Access requests banner on the admin page */
.access-requests-banner {
  margin: 1rem 0 1.5rem;
  padding: 1rem 1.25rem;
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: 10px;
}
.access-requests-head {
  display: flex; flex-direction: column; gap: .25rem;
  margin-bottom: .65rem;
}
.access-requests-hint {
  font-size: .8rem;
  color: var(--ink-mid, #4b5568);
}
.access-requests-list {
  display: flex; flex-direction: column; gap: .35rem;
}
.access-request-row {
  display: flex; align-items: center; gap: .65rem;
  background: var(--card, #fff);
  border: 1px solid var(--border, #e3e8ea);
  border-radius: 8px;
  padding: .5rem .75rem;
  transition: opacity .2s ease;
}
.access-request-email {
  flex: 1;
  font-size: .9rem;
  color: var(--ink-dark, #1a2332);
  word-break: break-all;
}
.access-request-when {
  font-size: .78rem;
  color: var(--ink-mid, #4b5568);
  flex-shrink: 0;
}
.access-request-dismiss {
  background: transparent;
  border: 1px solid var(--border, #e3e8ea);
  border-radius: 6px;
  font-size: .78rem;
  padding: .25rem .65rem;
  cursor: pointer;
  color: var(--ink-dark, #1a2332);
  flex-shrink: 0;
}
.access-request-dismiss:hover { background: var(--border-lt, #f3f4f6); }

/* Unverified users panel (above the main users table) */
.unverified-panel {
  margin: 0 0 1.25rem;
  padding: .85rem 1rem;
  background: var(--bg-soft, #f8fafb);
  border: 1px solid var(--border, #e3e8ea);
  border-radius: 10px;
}
.unverified-head {
  display: flex; flex-direction: column; gap: .15rem;
  margin-bottom: .55rem;
}
.unverified-hint {
  font-size: .78rem;
  color: var(--ink-mid, #4b5568);
}
.unverified-row {
  display: flex; align-items: center; gap: .65rem;
  padding: .45rem .65rem;
  background: var(--card, #fff);
  border: 1px solid var(--border, #e3e8ea);
  border-radius: 6px;
  margin-bottom: .35rem;
}
.unverified-email {
  font-size: .88rem;
  flex: 1; min-width: 0;
  word-break: break-all;
  color: var(--ink-dark, #1a2332);
}
.unverified-status {
  font-size: .76rem;
  color: var(--ink-mid, #4b5568);
  flex: 1; min-width: 0;
}
.unverified-delete {
  background: transparent;
  border: 1px solid var(--border, #e3e8ea);
  border-radius: 6px;
  font-size: .76rem;
  padding: .25rem .65rem;
  cursor: pointer;
  color: #c53030;
  flex-shrink: 0;
}
.unverified-delete:hover { background: #fef2f2; border-color: #fca5a5; }

/* Bulk-action toolbar above the users table */
.user-bulk-actions {
  display: flex; align-items: center; gap: .65rem;
  padding: .65rem .85rem;
  background: var(--bg-soft, #f8fafb);
  border: 1px solid var(--border, #e3e8ea);
  border-radius: 8px;
  margin-bottom: .85rem;
}
.user-bulk-count {
  font-weight: 600;
  font-size: .88rem;
  color: var(--ink-dark, #1a2332);
}
.user-bulk-select {
  padding: .35rem .6rem;
  border-radius: 6px;
  border: 1px solid var(--border, #e3e8ea);
  font-size: .85rem;
  background: var(--card, #fff);
}
.user-bulk-apply {
  padding: .4rem 1rem;
  font-size: .85rem;
  margin-left: auto;
}
.user-row-check {
  cursor: pointer;
}

/* User action modal — opened by "Delete selected…" on the Users tab */
.user-action-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 1300;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.user-action-inner {
  background: var(--card, #fff);
  border-radius: 14px;
  width: 100%; max-width: 580px;
  max-height: 92vh;
  padding: 1.5rem 1.75rem;
  box-shadow: 0 16px 48px rgba(0,0,0,.22);
  overflow-y: auto;
}
.user-action-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: .35rem;
}
.user-action-title {
  font-family: 'Fraunces', serif;
  font-size: 1.1rem;
  font-weight: 500;
  margin: 0;
  color: var(--ink-dark, #1a2332);
}
.user-action-sub {
  font-size: .88rem;
  color: var(--ink-mid, #4b5568);
  margin: 0 0 1rem;
}
.user-action-opt {
  display: flex; gap: .8rem;
  padding: .9rem 1rem;
  border: 1.5px solid var(--border, #e5e7eb);
  border-radius: 10px;
  margin-bottom: .65rem;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.user-action-opt:hover {
  border-color: var(--ink-dark, #1a2332);
  background: var(--bg-soft, #f8fafb);
}
.user-action-opt input[type="radio"] {
  margin-top: .25rem;
  flex-shrink: 0;
  cursor: pointer;
}
.user-action-opt-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .25rem; }
.user-action-opt-title {
  font-weight: 600;
  font-size: .92rem;
  color: var(--ink-dark, #1a2332);
}
.user-action-opt-desc {
  font-size: .82rem;
  color: var(--ink-mid, #4b5568);
  line-height: 1.5;
}
.user-action-foot {
  display: flex; gap: .65rem; justify-content: flex-end;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-lt, #f3f4f6);
}
.user-action-foot .btn-primary, .user-action-foot .btn-secondary {
  padding: .55rem 1.2rem;
  font-size: .9rem;
}

/* Activate user modal-specific bits (re-uses .user-action-modal shell) */
.activate-section-label {
  margin: 1rem 0 .45rem;
  font-size: .82rem;
  font-weight: 600;
  color: var(--ink-dark, #1a2332);
}
.activate-checkboxes {
  display: flex; flex-direction: column;
  gap: .4rem;
  margin-bottom: .25rem;
}
.activate-check {
  display: flex; align-items: center;
  gap: .55rem;
  padding: .55rem .85rem;
  background: var(--bg-soft, #f8fafb);
  border: 1px solid var(--border, #e3e8ea);
  border-radius: 8px;
  cursor: pointer;
  font-size: .9rem;
  color: var(--ink-dark, #1a2332);
}
.activate-check input[type="checkbox"] { cursor: pointer; flex-shrink: 0; }
.activate-message {
  width: 100%;
  min-height: 96px;
  padding: .6rem .8rem;
  border: 1px solid var(--border, #e3e8ea);
  border-radius: 8px;
  font: inherit;
  font-size: .88rem;
  color: var(--ink-dark, #1a2332);
  background: var(--card, #fff);
  resize: vertical;
  box-sizing: border-box;
}
.activate-message:focus {
  outline: none;
  border-color: var(--ink-dark, #1a2332);
}

/* Activate button on access request rows — primary green vs the
   subdued Dismiss */
.access-request-activate {
  background: #00838c;
  color: #fff;
  border: 1px solid #00838c;
  border-radius: 6px;
  font-size: .78rem;
  padding: .3rem .75rem;
  cursor: pointer;
  flex-shrink: 0;
}
.access-request-activate:hover { background: #006970; border-color: #006970; }
.access-request-activate:disabled { opacity: .5; cursor: not-allowed; }

.signup-captcha {
  margin: 1rem 0 .5rem;
  display: flex;
  justify-content: center;
}

/* Admin button — small red badge with a count for items needing attention */
.admin-with-badge {
  position: relative;
}
.admin-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: .45rem;
  background: #c53030;
  color: #fff;
  font-size: .72rem;
  font-weight: 600;
  line-height: 1;
  border-radius: 9px;
  vertical-align: middle;
}

/* ══════════════════════════════════════════════════════════
   RECENT SESSIONS BLOCK
══════════════════════════════════════════════════════════ */
.recent-block {
  margin-top: 1rem;
}

.recent-block-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .75rem;
}

.recent-block-label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--ink-mid);
  letter-spacing: .04em;
  text-transform: uppercase;
}

.recent-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.recent-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: .875rem 1rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  transition: border-color .15s;
}
.recent-card-body {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  flex: 1;
  cursor: pointer;
  min-width: 0;
}
.recent-delete-btn {
  background: none;
  border: none;
  padding: .375rem;
  cursor: pointer;
  color: var(--ink-mid);
  border-radius: 6px;
  flex-shrink: 0;
  transition: color .15s, background .15s;
}
.recent-delete-btn:hover { color: var(--coral); background: rgba(239,68,68,.08); }
.pending-start-btn {
  background: var(--teal, #00838c);
  color: #fff;
  border: none;
  padding: .35rem .75rem;
  cursor: pointer;
  border-radius: 6px;
  font-size: .78rem;
  font-weight: 500;
  flex-shrink: 0;
  transition: filter .15s;
}
.pending-start-btn:hover { filter: brightness(0.92); }

.recent-card:hover {
  border-color: var(--teal);
}

.recent-card-module {
  font-size: .7rem;
  font-weight: 600;
  color: var(--teal);
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.recent-card-rule {
  flex: 1;
  font-size: .875rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.recent-card-meta {
  font-size: .75rem;
  color: var(--ink-mid);
  white-space: nowrap;
}

/* ══════════════════════════════════════════════════════════
   SESSION PROGRESS BAR
══════════════════════════════════════════════════════════ */
.session-progress-bar {
  position: fixed;
  top: calc(52px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 760px;
  height: 3px;
  background: rgba(255, 255, 255, .06);
  z-index: 199;
}

.session-progress-fill {
  height: 100%;
  background: var(--teal);
  transition: width .4s ease;
  width: 0%;
}

/* ══════════════════════════════════════════════════════════
   RULE STRIP
══════════════════════════════════════════════════════════ */
.rule-strip {
  position: fixed;
  top: calc(55px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 760px;
  z-index: 198;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: .3rem 1rem;
}

.rule-strip-text {
  font-size: .72rem;
  color: var(--ink-mid);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

/* ══════════════════════════════════════════════════════════
   FEEDBACK OVERLAY
══════════════════════════════════════════════════════════ */
.feedback-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  z-index: 500;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.feedback-overlay-inner {
  background: var(--card);
  border-radius: var(--r) var(--r) 0 0;
  padding: 1.25rem;
  padding-bottom: calc(1.25rem + env(safe-area-inset-bottom));
  width: 100%;
  max-width: 760px;
}

.feedback-overlay-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.feedback-overlay-title {
  font-size: .95rem;
  font-weight: 600;
  color: var(--ink);
}

.feedback-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: .875rem;
}

.feedback-chip {
  padding: .4rem .875rem;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--ink-mid);
  font-size: .8rem;
  cursor: pointer;
  transition: all .15s;
}

.feedback-chip:hover,
.feedback-chip.selected {
  border-color: var(--teal);
  color: var(--teal);
  background: rgba(15, 118, 110, .08);
}

.feedback-overlay-textarea {
  width: 100%;
  resize: none;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--ink);
  font-size: .85rem;
  padding: .625rem .75rem;
  margin-bottom: .75rem;
  font-family: inherit;
  box-sizing: border-box;
}

/* ══════════════════════════════════════════════════════════
   CDE OUTPUT SCREEN
══════════════════════════════════════════════════════════ */
.output-wrap {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}

.output-body {
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
  padding: calc(52px + env(safe-area-inset-top) + 1.5rem) 1.25rem 3rem;
  flex: 1;
}

.output-intro {
  margin-bottom: 1.75rem;
}

.output-title {
  font-family: 'Fraunces', serif;
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--ink);
  margin: 0 0 .4rem;
}

.output-subtitle {
  font-size: .875rem;
  color: var(--ink-mid);
  margin: 0;
}

.cde-element-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
}

.cde-element-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1.25rem;
}

.cde-element-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 .5rem;
}

.cde-element-status {
  display: inline-block;
  font-size: .7rem;
  font-weight: 600;
  padding: .2rem .6rem;
  border-radius: 999px;
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-bottom: .75rem;
}

.cde-element-status.confirmed {
  background: rgba(16, 185, 129, .12);
  color: #10b981;
}

.cde-element-status.uncertain {
  background: rgba(245, 158, 11, .12);
  color: #f59e0b;
}

.cde-element-status.missing {
  background: rgba(239, 68, 68, .12);
  color: #ef4444;
}

.cde-element-field {
  margin-bottom: .625rem;
}

.cde-element-label {
  font-size: .7rem;
  font-weight: 600;
  color: var(--ink-mid);
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-bottom: .2rem;
}

.cde-element-value {
  font-size: .875rem;
  color: var(--ink);
  line-height: 1.5;
}

.output-actions {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

/* ══════════════════════════════════════════════════════════
   CHAT FEED — updated padding to clear rule strip
══════════════════════════════════════════════════════════ */
.chat-feed {
  padding-top: calc(52px + env(safe-area-inset-top) + 3px + 28px + 1rem) !important;
}

/* ══════════════════════════════════════════════════════════
   I'M NOT SURE — chip and YES/NO variants
══════════════════════════════════════════════════════════ */
.chip-unsure {
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--ink-mid);
  font-style: italic;
}
.chip-unsure:hover { border-color: var(--teal); color: var(--teal); background: var(--teal-lt); }

.yesno-unsure {
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--ink-mid);
  font-size: .8rem;
  padding: .5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: border-color .15s, color .15s;
}
.yesno-unsure:hover { border-color: var(--teal); color: var(--teal); }

.option-card-unsure {
  background: transparent;
  border: 1px dashed var(--border) !important;
  color: var(--ink-mid);
}
.option-card-unsure .option-card-num { background: transparent; border: 1px dashed var(--border); color: var(--ink-mid); }
.option-card-unsure:hover { border-color: var(--teal) !important; color: var(--teal); }

/* ══════════════════════════════════════════════════════════
   EXPANDABLE RULE CARDS — final output panel
══════════════════════════════════════════════════════════ */
.output-panel-actions {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  padding: 1rem;
}

.output-rule-card {
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.output-rule-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.06); }

.output-rule-summary { display: block; }

.output-rule-top {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .375rem;
}

.output-rule-expand-hint {
  font-size: .72rem;
  color: var(--ink-mid);
  margin-top: .375rem;
}
.expand-arrow { display: inline-block; transition: transform .2s; }

.output-rule-detail {
  border-top: 1px solid var(--border);
  margin-top: .75rem;
  padding-top: .75rem;
}

.rule-detail-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: .25rem .75rem;
  margin-bottom: .5rem;
  font-size: .825rem;
  line-height: 1.45;
}
.rule-detail-label {
  font-size: .7rem;
  font-weight: 600;
  color: var(--ink-mid);
  text-transform: uppercase;
  letter-spacing: .04em;
  padding-top: .1rem;
}
.rule-detail-val { color: var(--ink); }

@media (max-width: 480px) {
  .rule-detail-row { grid-template-columns: 1fr; gap: .1rem; }
}

/* Summary sheet expandable cards */
.rule-card { cursor: pointer; transition: border-color .15s; }
.rule-card:hover { border-color: var(--teal); }
.rule-expand-hint {
  font-size: .72rem;
  color: var(--ink-mid);
  margin-top: .375rem;
}
.rule-card-detail {
  border-top: 1px solid var(--border);
  margin-top: .625rem;
  padding-top: .625rem;
}

/* ══════════════════════════════════════════════════════════
   SWEEP PANEL (scope notes overlay)
══════════════════════════════════════════════════════════ */
.sweep-panel {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 500;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 0 env(safe-area-inset-bottom);
}
.sweep-panel-inner {
  background: var(--card);
  border-radius: var(--r) var(--r) 0 0;
  width: 100%;
  max-width: 760px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sweep-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sweep-panel-title { font-weight: 600; font-size: .95rem; }
.sweep-panel-desc {
  font-size: .8rem;
  color: var(--ink-mid);
  padding: .75rem 1.25rem 0;
  flex-shrink: 0;
  line-height: 1.5;
}
.sweep-panel-body {
  overflow-y: auto;
  padding: .75rem 1.25rem 1.25rem;
  flex: 1;
}
.sweep-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .75rem 1rem;
  font-size: .875rem;
  line-height: 1.5;
  margin-bottom: .625rem;
  color: var(--ink);
}
.sweep-empty { font-size: .875rem; color: var(--ink-mid); text-align: center; padding: 1.5rem 0; }

/* ══════════════════════════════════════════════════════════
   FEEDBACK FOOT LINK
══════════════════════════════════════════════════════════ */
.chat-foot-meta {
  text-align: center;
  padding: .375rem 0 .25rem;
}
.feedback-foot-link {
  background: none;
  border: none;
  font-family: 'DM Sans', sans-serif;
  font-size: .75rem;
  color: var(--ink-mid);
  cursor: pointer;
  padding: 0;
  transition: color .15s;
}
.feedback-foot-link:hover { color: var(--teal); }

/* ══════════════════════════════════════════════════════════
   ADMIN — SOFT DELETE
══════════════════════════════════════════════════════════ */
.admin-session-deleted { opacity: .45; }
.admin-badge-deleted {
  display: inline-block;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .04em;
  color: #fff;
  background: #e53e3e;
  border-radius: 4px;
  padding: .1rem .45rem;
  margin-left: .5rem;
  vertical-align: middle;
}
.admin-delete-btn {
  background: none;
  border: 1px solid #e53e3e;
  color: #e53e3e;
  border-radius: 6px;
  padding: .25rem .6rem;
  font-size: .75rem;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.admin-delete-btn:hover { background: #e53e3e; color: #fff; }

/* ===== Stage 1: consent, settings, data-handling, re-consent modal ===== */

.consent-bullets {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem 0;
  font-size: .9rem;
  color: var(--ink-mid);
}
.consent-bullets li {
  padding: .45rem 0 .45rem 1.4rem;
  position: relative;
  line-height: 1.45;
}
.consent-bullets li::before {
  content: "✓";
  position: absolute;
  left: 0;
  top: .45rem;
  color: var(--teal, #0F766E);
  font-weight: 600;
}
.consent-link-line {
  margin: 0 0 1.25rem 0;
  font-size: .85rem;
}
.consent-required {
  padding: .85rem 1rem;
  background: #fff5f0;
  border: 1px solid #ffd6c2;
  border-radius: 8px;
  margin-bottom: 1rem;
}
.consent-optional {
  padding: .85rem 1rem;
  background: #f8fafb;
  border: 1px solid #e3e8ea;
  border-radius: 8px;
  margin-bottom: 1.25rem;
}
.consent-optional-label {
  font-size: .8rem;
  color: var(--ink-mid);
  margin: 0 0 .6rem 0;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.consent-check {
  display: flex;
  gap: .65rem;
  align-items: flex-start;
  padding: .45rem 0;
  font-size: .88rem;
  line-height: 1.45;
  cursor: pointer;
}
.consent-check input[type="checkbox"] {
  margin-top: .15rem;
  flex-shrink: 0;
  cursor: pointer;
}

.legal-doc {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1rem 3rem 1rem;
  font-size: .95rem;
  line-height: 1.65;
  color: var(--ink-dark, #1a2332);
}
.legal-doc h3 {
  font-family: 'Fraunces', serif;
  font-size: 1.15rem;
  font-weight: 500;
  margin: 1.75rem 0 .6rem 0;
  color: var(--ink-dark, #1a2332);
}
.legal-doc p, .legal-doc li {
  color: var(--ink-mid);
}
.legal-doc ul {
  padding-left: 1.35rem;
  margin: .5rem 0;
}
.legal-doc li {
  padding: .15rem 0;
}

.settings-section {
  max-width: 640px;
  margin: 0 auto 1.5rem auto;
  padding: 1.25rem;
  background: var(--card, #fff);
  border: 1px solid var(--border, #e3e8ea);
  border-radius: 12px;
}
.settings-section-title {
  font-family: 'Fraunces', serif;
  font-size: 1.1rem;
  font-weight: 500;
  margin: 0 0 .35rem 0;
}
.settings-section-desc {
  font-size: .85rem;
  color: var(--ink-mid);
  margin: 0 0 .85rem 0;
}
.settings-row {
  display: flex;
  justify-content: space-between;
  padding: .5rem 0;
  border-bottom: 1px solid #f1f4f5;
  font-size: .9rem;
}
.settings-row:last-child { border-bottom: none; }
.settings-label {
  color: var(--ink-mid);
}
.settings-value {
  color: var(--ink-dark, #1a2332);
  font-weight: 500;
  text-align: right;
  word-break: break-word;
  max-width: 60%;
}
.settings-danger {
  border-color: #ffd6c2;
  background: #fff9f6;
}
.btn-danger {
  background: #e53e3e;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: .55rem 1rem;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
}
.btn-danger:hover:not(:disabled) { background: #c53030; }
.btn-danger:disabled { opacity: .6; cursor: not-allowed; }

.modules-footer {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid #e3e8ea;
  text-align: center;
  font-size: .82rem;
  color: var(--ink-mid);
}

.reconsent-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 1200;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.reconsent-inner {
  background: #fff;
  border-radius: 12px;
  padding: 1.75rem;
  max-width: 440px;
  width: 100%;
}
.reconsent-inner h3 {
  font-family: 'Fraunces', serif;
  font-size: 1.35rem;
  font-weight: 500;
  margin: 0 0 .75rem 0;
}
.reconsent-inner p {
  font-size: .92rem;
  color: var(--ink-mid);
  margin: 0 0 .75rem 0;
  line-height: 1.5;
}
.reconsent-actions {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  margin-top: 1.25rem;
}

/* ===== Next steps panel (cross-module follow-up surfacing) ===== */

.next-steps-panel {
  margin: 1.5rem auto;
  max-width: min(720px, 100%);
  padding: 1.25rem;
  background: var(--card, #fff);
  border: 1px solid var(--border, #e3e8ea);
  border-radius: 12px;
}
.next-steps-title {
  font-family: 'Fraunces', serif;
  font-size: 1.05rem;
  font-weight: 500;
  margin: 0 0 .35rem;
  color: var(--ink-dark, #1a2332);
}
.next-steps-desc {
  font-size: .85rem;
  color: var(--ink-mid, #4b5568);
  margin: 0 0 1rem;
}
.next-steps-list {
  display: flex; flex-direction: column;
  gap: .55rem;
}
.next-step-row {
  padding: .8rem .95rem;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px;
  background: var(--bg-soft, #f8fafb);
  transition: opacity .2s ease;
}
.next-step-row.actioned { opacity: .55; }
.next-step-row.dismissed { display: none; }
.next-step-row-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: .65rem;
  margin-bottom: .4rem;
}
.next-step-title {
  font-weight: 600;
  font-size: .92rem;
  color: var(--ink-dark, #1a2332);
  flex: 1; min-width: 0;
  word-break: break-word;
  line-height: 1.35;
}
.next-step-kind {
  flex-shrink: 0;
  font-size: .72rem;
  padding: .2rem .55rem;
  border-radius: 999px;
  background: #ede9fe;
  color: #5b21b6;
  white-space: nowrap;
}
.next-step-kind-rule_design  { background: #d1fae5; color: #065f46; }
.next-step-kind-definition   { background: #fef3c7; color: #92400e; }
.next-step-kind-procedure    { background: #ede9fe; color: #5b21b6; }
.next-step-kind-priorities_continuation { background: #dbeafe; color: #1e40af; }
.next-step-reason {
  font-size: .82rem;
  color: var(--ink-mid, #4b5568);
  margin: 0 0 .6rem;
  line-height: 1.45;
}
.next-step-actions {
  display: flex; gap: .4rem; flex-wrap: wrap;
}
.next-step-btn {
  font-size: .8rem;
  padding: .35rem .7rem;
  border-radius: 6px;
  border: 1px solid var(--border, #e5e7eb);
  background: var(--card, #fff);
  color: var(--ink-dark, #1a2332);
  cursor: pointer;
  font-family: inherit;
}
.next-step-btn:hover {
  border-color: var(--ink-dark, #1a2332);
}
.next-step-btn-primary {
  background: var(--ink-dark, #1a2332);
  color: #fff;
  border-color: var(--ink-dark, #1a2332);
}
.next-step-btn-primary:hover { background: #000; }
.next-step-btn:disabled {
  opacity: .5; cursor: not-allowed;
}
.next-step-state {
  font-size: .78rem;
  color: var(--ink-mid, #4b5568);
  font-style: italic;
}

@media (max-width: 480px) {
  .next-steps-panel { padding: 1rem; }
  .next-step-row { padding: .7rem .8rem; }
  .next-step-row-head { flex-wrap: wrap; }
  .next-step-actions { flex-direction: column; align-items: stretch; }
  .next-step-actions .next-step-btn { width: 100%; text-align: center; }
}

/* Transient toast — short status messages from auto-save and similar */
.transient-toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  background: var(--ink-dark, #1a2332);
  color: #fff;
  padding: .7rem 1.1rem;
  border-radius: 8px;
  font-size: .85rem;
  z-index: 1500;
  max-width: calc(100% - 2rem);
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
  animation: toast-in .2s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ===== Stage 2: priority matrix output ===== */

.priority-quadrant {
  margin: 0 auto 1.5rem auto;
  max-width: min(720px, 100%);
  padding: 1.25rem;
  background: var(--card, #fff);
  border: 1px solid var(--border, #e3e8ea);
  border-radius: 12px;
  overflow: hidden;
}
.priority-critical-high {
  border-left: 4px solid #e53e3e;
}
.priority-critical-medium {
  border-left: 4px solid #dd6b20;
}
.priority-critical-low {
  border-left: 4px solid #d69e2e;
}
.priority-critical-norisk {
  border-left: 4px solid #718096;
  opacity: .85;
}
.priority-quadrant-title {
  font-family: 'Fraunces', serif;
  font-size: 1.15rem;
  font-weight: 500;
  margin: 0 0 .25rem 0;
}
.priority-quadrant-note {
  font-size: .82rem;
  color: var(--ink-mid);
  margin: 0 0 1rem 0;
}
/* Generic expandable card — used by the priority matrix and (future)
   step 4/5 element cards in the chat feed. Built on <details>/<summary>. */
.expandable-card {
  background: #fafbfc;
  border: 1px solid #e3e8ea;
  border-radius: 8px;
  margin-bottom: .75rem;
  overflow: hidden;
  max-width: 100%;
  min-width: 0;
}
.expandable-card:last-child { margin-bottom: 0; }
.expandable-card-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  padding: .85rem 1rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.expandable-card-summary::-webkit-details-marker { display: none; }
.expandable-card-summary:hover { background: #f3f5f7; }
.expandable-card-headline {
  font-weight: 600;
  font-size: .98rem;
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: break-word;
  word-break: break-word;
}
.expandable-card-badges {
  flex: 0 0 auto;
  display: flex;
  gap: .4rem;
  align-items: center;
}
.expandable-card-chevron {
  flex: 0 0 auto;
  font-size: .8rem;
  color: var(--ink-mid);
  transition: transform 180ms ease;
  margin-left: .25rem;
}
.expandable-card[open] > .expandable-card-summary .expandable-card-chevron {
  transform: rotate(180deg);
}
.expandable-card-body {
  padding: 0 1rem .95rem 1rem;
  border-top: 1px solid #eef1f3;
  padding-top: .75rem;
  overflow-wrap: break-word;
  word-break: break-word;
}
.expandable-card-body > *:first-child { margin-top: 0; }
.expandable-card-body > *:last-child  { margin-bottom: 0; }

/* In-conversation element card (Phase B): used for step 4 element lists
   and step 5 risk lists in the chat feed. Slightly tighter than the
   matrix card since several may sit inside a single chat bubble. */
.element-card {
  margin-bottom: .5rem;
  background: #fff;
}
.element-card .expandable-card-summary {
  padding: .65rem .85rem;
}
.element-card .expandable-card-body {
  padding: 0 .85rem .75rem .85rem;
  padding-top: .55rem;
}
.element-card .element-desc {
  font-size: .88rem;
  color: var(--ink-mid);
  margin: 0 0 .55rem 0;
  line-height: 1.45;
}
.element-card .element-meta {
  font-size: .82rem;
  color: var(--ink-mid);
  margin: .15rem 0;
  line-height: 1.4;
}
.element-card .element-meta strong {
  color: var(--ink-dark);
  font-weight: 500;
}

/* Priority matrix card — decorative variant of the expandable card. */
.priority-card-has-blocker {
  border-color: #ffd6c2;
  background: #fffaf6;
}
.priority-card-has-blocker .expandable-card-summary:hover {
  background: #fff3eb;
}
.priority-card-name {
  font-weight: 600;
  font-size: .98rem;
}
.priority-card-reason,
.priority-card-risk,
.priority-card-block {
  font-size: .85rem;
  color: var(--ink-mid);
  margin: .25rem 0;
  line-height: 1.45;
}
.priority-card-block {
  color: #c53030;
  font-weight: 500;
}
.priority-card-status {
  font-size: .82rem;
  color: var(--ink-mid);
  margin: .55rem 0 0 0;
  line-height: 1.45;
}
.priority-card-blocked {
  color: #9b2c2c;
  font-weight: 500;
}
.priority-card-noaction {
  color: #4a5568;
  font-style: italic;
}

/* Mobile tightening: drop the cumulative padding so the matrix fits a
   360px viewport without horizontal scroll. Also tightens the chat-feed
   element cards in the same vein. */
@media (max-width: 480px) {
  .output-body {
    padding-left: .75rem;
    padding-right: .75rem;
  }
  .priority-quadrant,
  .priority-blockers {
    padding: .875rem;
    margin-bottom: 1rem;
  }
  .expandable-card-summary {
    padding: .75rem .8rem;
    gap: .5rem;
  }
  .expandable-card-body {
    padding-left: .8rem;
    padding-right: .8rem;
  }
  .priority-blocker-item {
    gap: .5rem;
  }
}

.risk-chip {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 4px;
  font-size: .72rem;
  font-weight: 500;
  font-family: 'DM Mono', monospace;
  text-transform: lowercase;
  letter-spacing: .02em;
  white-space: nowrap;
}
.risk-chip.risk-data_quality   { background: #fed7d7; color: #9b2c2c; }
.risk-chip.risk-metadata       { background: #fef3c7; color: #92400e; }
.risk-chip.risk-none           { background: #e2e8f0; color: #4a5568; }
.risk-chip.risk-level-high     { background: #fed7d7; color: #9b2c2c; }
.risk-chip.risk-level-medium   { background: #fef3c7; color: #92400e; }
.risk-chip.risk-level-low      { background: #d1fae5; color: #065f46; }
.risk-chip.risk-level-unknown  { background: #e2e8f0; color: #4a5568; }
.risk-chip.anchor-chip         { background: #e0e7ff; color: #3730a3; margin-left: .35rem; }

.priority-blockers {
  max-width: min(720px, 100%);
  margin: 0 auto 1.5rem auto;
  padding: 1.25rem;
  background: #fff5f0;
  border: 1px solid #ffd6c2;
  border-radius: 12px;
  overflow-wrap: break-word;
  word-break: break-word;
}
.priority-blockers-head {
  font-family: 'Fraunces', serif;
  font-size: 1.05rem;
  font-weight: 500;
  color: #9b2c2c;
  margin-bottom: .75rem;
}
.priority-blocker-item {
  padding: .6rem 0;
  border-top: 1px solid #ffe3d4;
  display: flex;
  gap: .75rem;
  align-items: baseline;
  flex-wrap: wrap;
}
.priority-blocker-item:first-of-type { border-top: none; }
.priority-blocker-term {
  font-weight: 600;
}
.priority-blocker-status {
  font-size: .72rem;
  padding: .15rem .5rem;
  background: #fff;
  border: 1px solid #ffd6c2;
  border-radius: 4px;
  color: #9b2c2c;
  text-transform: lowercase;
}
.priority-blocker-note {
  width: 100%;
  font-size: .85rem;
  color: var(--ink-mid);
  margin-top: .15rem;
}

/* ===== Stage 2b: scroll-to-accept consent doc ===== */

.consent-doc-wrap {
  margin: 0 0 1rem 0;
}
.consent-doc {
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid #e3e8ea;
  border-radius: 8px;
  padding: 1rem 1.1rem;
  background: #fafbfc;
  font-size: .86rem;
  line-height: 1.55;
  color: var(--ink-mid);
}
.consent-doc h3 {
  font-family: 'Fraunces', serif;
  font-size: 1rem;
  font-weight: 500;
  margin: 1rem 0 .4rem 0;
  color: var(--ink-dark, #1a2332);
}
.consent-doc h3:first-child { margin-top: 0; }
.consent-doc ul {
  padding-left: 1.2rem;
  margin: .35rem 0;
}
.consent-doc li {
  padding: .1rem 0;
}
.consent-scroll-hint {
  margin: .4rem 0 0 0;
  font-size: .78rem;
  color: var(--ink-mid);
  font-style: italic;
  text-align: center;
}
.consent-scroll-hint.is-read {
  color: var(--teal, #0F766E);
  font-style: normal;
}

/* ===== Stage 3: Glossary Builder ===== */

.module-icon-glossary {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #92400e;
}

.module-icon-procedure {
  background: linear-gradient(135deg, #ede9fe, #ddd6fe);
  color: #5b21b6;
}

.glossary-record {
  max-width: 720px;
  margin: 0 auto;
}
.glossary-section {
  margin: 0 auto 1.25rem auto;
  padding: 1rem 1.1rem;
  background: var(--card, #fff);
  border: 1px solid var(--border, #e3e8ea);
  border-radius: 10px;
}
.glossary-section-title {
  font-family: 'Fraunces', serif;
  font-size: .98rem;
  font-weight: 500;
  margin-bottom: .55rem;
  color: var(--ink-dark, #1a2332);
}
.glossary-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: .88rem;
  color: var(--ink-mid);
}
.glossary-list li {
  padding: .35rem 0;
  border-top: 1px solid #f1f4f5;
  line-height: 1.45;
}
.glossary-list li:first-child { border-top: none; }
.glossary-meta {
  color: var(--ink-mid);
  font-size: .8rem;
}
.glossary-empty {
  color: var(--ink-mid);
  font-style: italic;
  font-size: .85rem;
  margin: 0;
}
.glossary-inline {
  margin: 0;
  font-size: .9rem;
  color: var(--ink-dark, #1a2332);
}
.glossary-markdown {
  margin: 0;
  padding: .8rem 1rem;
  background: var(--bg-soft, #f8fafb);
  border: 1px solid var(--border, #e3e8ea);
  border-radius: 8px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .82rem;
  line-height: 1.55;
  color: var(--ink-dark, #1a2332);
  white-space: pre-wrap;
  overflow-x: auto;
}
.glossary-status-agreed     { color: #047857; font-weight: 500; }
.glossary-status-proposed   { color: #92400e; font-weight: 500; }
.glossary-status-contested  { color: #c53030; font-weight: 500; }
.glossary-status-undefined  { color: #4a5568; font-weight: 500; }

.astrakan-credit {
  text-align: center;
  font-size: .78rem;
  color: var(--ink-mid);
  margin: 1.5rem auto 0 auto;
  max-width: 720px;
  padding: 0 1rem;
}
.astrakan-credit em {
  font-style: italic;
  color: var(--ink-dark, #1a2332);
}

/* ===== Admin: knowledge layer browser ===== */

.admin-knowledge-toolbar {
  display: flex;
  gap: .5rem;
  align-items: center;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border, #e3e8ea);
  padding-bottom: .5rem;
  flex-wrap: wrap;
}
.admin-subtab {
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: .35rem .85rem;
  font-size: .82rem;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  color: var(--ink-mid);
}
.admin-subtab.active {
  background: var(--card, #fff);
  border-color: var(--border, #e3e8ea);
  color: var(--ink-dark, #1a2332);
  font-weight: 500;
}

.admin-section-desc {
  font-size: .82rem;
  color: var(--ink-mid);
  margin: 0 0 1rem 0;
}

.knowledge-group {
  margin-bottom: 1.25rem;
  background: var(--card, #fff);
  border: 1px solid var(--border, #e3e8ea);
  border-radius: 8px;
  overflow: hidden;
}
.knowledge-group summary {
  padding: .75rem 1rem;
  font-family: 'Fraunces', serif;
  font-size: .95rem;
  font-weight: 500;
  cursor: pointer;
  background: #fafbfc;
  border-bottom: 1px solid var(--border, #e3e8ea);
  user-select: none;
}
.knowledge-group[open] summary { border-bottom-color: var(--border, #e3e8ea); }
.knowledge-group summary::-webkit-details-marker { color: var(--ink-mid); }
.knowledge-count {
  color: var(--ink-mid);
  font-weight: 400;
  font-size: .85rem;
  font-family: 'DM Sans', sans-serif;
}
.knowledge-group .admin-table {
  border: none;
  margin: 0;
}

/* Per-user access toggles in admin Users table */
.access-toggle-cell {
  display: flex;
  gap: .25rem;
  flex-wrap: wrap;
}
.access-toggle {
  font-family: 'DM Mono', monospace;
  font-size: .68rem;
  font-weight: 500;
  letter-spacing: .03em;
  padding: .2rem .5rem;
  border-radius: 4px;
  border: 1px solid;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
  white-space: nowrap;
  min-width: 32px;
}
.access-toggle.access-on {
  background: #d1fae5;
  border-color: #6ee7b7;
  color: #047857;
}
.access-toggle.access-off {
  background: #f1f4f5;
  border-color: #cbd5e0;
  color: #718096;
  text-decoration: line-through;
  text-decoration-color: #cbd5e0;
}
.access-toggle.access-warn {
  background: #fef3c7;
  border-color: #fcd34d;
  color: #92400e;
}
.conversation-toggle {
  margin-top: 1.5rem;
  border-top: 1px solid var(--line, #e3e8ea);
  padding-top: 1rem;
}
.conversation-toggle > summary {
  cursor: pointer;
  font-size: .85rem;
  color: var(--ink-mid);
  font-weight: 500;
  padding: .35rem 0;
  list-style: none;
}
.conversation-toggle > summary::-webkit-details-marker { display: none; }
.conversation-toggle > summary::before {
  content: '▸ ';
  display: inline-block;
  transition: transform .15s;
}
.conversation-toggle[open] > summary::before {
  transform: rotate(90deg);
}
.conversation-feed {
  margin-top: .75rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  max-height: 60vh;
  overflow-y: auto;
  padding: .5rem .25rem;
}
.conversation-feed .msg {
  padding: .65rem .85rem;
  border-radius: 10px;
  font-size: .85rem;
  line-height: 1.45;
  white-space: pre-wrap;
}
.conversation-feed .msg.engine {
  background: #f1f4f5;
  color: var(--ink-dark, #1a2332);
  align-self: flex-start;
  max-width: 88%;
}
.conversation-feed .msg.user {
  background: #00838c;
  color: #fff;
  align-self: flex-end;
  max-width: 88%;
}

/* Credit editor modal */
/* ── Onboarding modal ────────────────────────────────── */
.onb-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 1200;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.onb-card {
  position: relative;
  background: var(--card, #fff);
  border-radius: 14px;
  width: 100%; max-width: 520px;
  max-height: 92vh;
  box-shadow: 0 16px 48px rgba(0,0,0,.22);
  overflow: hidden;
  display: flex; flex-direction: column;
}
.onb-close {
  position: absolute; top: .75rem; right: .75rem;
  background: var(--border-lt, #f3f4f6);
  border: 1px solid var(--border, #e5e7eb);
  color: var(--ink-dark, #1a2332);
  width: 34px; height: 34px;
  padding: 0;
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s ease, color .15s ease, transform .1s ease;
  z-index: 2;
}
.onb-close:hover {
  background: var(--ink-dark, #1a2332);
  border-color: var(--ink-dark, #1a2332);
  color: #fff;
}
.onb-close:active { transform: scale(.94); }
.onb-body {
  padding: 2.25rem 1.75rem 1.25rem;
  overflow-y: auto;
}
.onb-slide-title {
  font-family: 'Fraunces', serif;
  font-size: 1.25rem;
  font-weight: 500;
  margin: 0 0 .85rem;
  color: var(--ink-dark, #1a2332);
}
.onb-slide-body {
  font-size: .92rem;
  line-height: 1.55;
  color: var(--ink-dark, #1a2332);
}
.onb-slide-body p { margin: 0 0 .75rem; }
.onb-slide-body p:last-child { margin-bottom: 0; }
.onb-slide-body ul {
  list-style: none;
  padding: 0;
  margin: .25rem 0 .75rem;
}
.onb-slide-body li {
  padding: .55rem 0 .55rem 1.1rem;
  border-top: 1px solid var(--border-lt, #f3f4f6);
  position: relative;
}
.onb-slide-body li:first-child { border-top: none; }
.onb-slide-body li::before {
  content: '';
  position: absolute; left: 0; top: 1.05rem;
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--ink-mid, #4b5568);
}
.onb-slide-body strong {
  font-weight: 600;
  color: var(--ink-dark, #1a2332);
}
.onb-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.5rem 1rem;
  border-top: 1px solid var(--border-lt, #f3f4f6);
  gap: 1rem;
}
.onb-actions { display: flex; gap: .5rem; align-items: center; margin-left: auto; }
.onb-actions .btn-primary {
  padding: .55rem 1.2rem;
  font-size: .9rem;
}
.onb-hint-btn { font-size: .82rem; }

/* Option cards (used on whereAreYou and knowsWhat steps) */
.onb-options {
  display: flex; flex-direction: column;
  gap: .55rem;
  margin-top: 1rem;
}
.onb-option {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--card, #fff);
  border: 1.5px solid var(--border, #e5e7eb);
  border-radius: 10px;
  padding: .85rem 1rem;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, transform .1s ease;
  font: inherit;
  color: inherit;
}
.onb-option:hover {
  border-color: var(--ink-dark, #1a2332);
  background: var(--bg-soft, #f8fafb);
}
.onb-option:active { transform: scale(.99); }
.onb-option-label {
  display: block;
  font-weight: 600;
  font-size: .92rem;
  color: var(--ink-dark, #1a2332);
  margin-bottom: .2rem;
}
.onb-option-sub {
  display: block;
  font-size: .82rem;
  color: var(--ink-mid, #4b5568);
  line-height: 1.5;
}

/* Primer link below the Start button on orientation */
.onb-primer-link {
  display: block;
  margin: 1rem auto 0;
  background: transparent;
  border: none;
  color: var(--ink-mid, #4b5568);
  font-size: .82rem;
  cursor: pointer;
  padding: .35rem .25rem;
  text-decoration: underline;
}
.onb-primer-link:hover { color: var(--ink-dark, #1a2332); }

/* Primer body uses h3 subheads to make sections scannable */
.onb-primer-body h3 {
  font-family: inherit;
  font-size: .88rem;
  font-weight: 600;
  color: var(--ink-dark, #1a2332);
  margin: .9rem 0 .25rem;
}
.onb-primer-body h3:first-child { margin-top: 0; }
.onb-primer-body p { margin: 0 0 .55rem; }

/* "About this" link in the chat header */
.chat-about-btn {
  background: transparent;
  border: none;
  color: var(--ink-mid, #4b5568);
  font-size: .82rem;
  cursor: pointer;
  padding: .35rem .55rem;
  border-radius: 6px;
  white-space: nowrap;
}
.chat-about-btn:hover {
  background: var(--border-lt, #f3f4f6);
  color: var(--ink-dark, #1a2332);
}

/* Skip link sits below the footer when present */
.onb-skip-wrap {
  text-align: center;
  padding: 0 1.5rem 1.1rem;
}
.onb-skip-wrap:empty { display: none; }
.onb-skip-link {
  background: transparent;
  border: none;
  color: var(--ink-mid, #4b5568);
  font-size: .85rem;
  cursor: pointer;
  padding: .35rem .5rem;
  text-decoration: underline;
}
.onb-skip-link:hover { color: var(--ink-dark, #1a2332); }

@media (max-width: 540px) {
  .onb-body { padding: 1.75rem 1.25rem 1rem; }
  .onb-foot { padding: .85rem 1.25rem 1rem; }
  .onb-slide-title { font-size: 1.1rem; }
  .onb-skip-wrap { padding: 0 1.25rem 1rem; }
}

.credit-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1100;
  display: flex; align-items: center; justify-content: center;
}
.credit-modal {
  background: var(--card, #fff);
  border-radius: var(--r, 12px);
  width: 90%; max-width: 440px;
  padding: 0;
  box-shadow: 0 12px 32px rgba(0,0,0,.18);
  overflow: hidden;
}
.credit-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line, #e3e8ea);
}
.credit-modal-title { font-weight: 600; font-size: 1rem; }
.credit-modal-body { padding: 1.25rem; display: flex; flex-direction: column; gap: 1rem; }
.credit-modal-sub { font-size: .82rem; color: var(--ink-mid); margin: 0; }
.credit-input-row {
  display: flex; align-items: center; gap: .5rem;
  border: 1px solid var(--line, #e3e8ea);
  border-radius: 10px;
  padding: .35rem .5rem;
  background: var(--bg, #f8fafb);
}
.credit-prefix {
  font-weight: 600; color: var(--ink-mid);
  padding: 0 .25rem;
}
.credit-input-row input[type="number"] {
  flex: 1;
  border: none; background: transparent;
  font-size: 1.6rem; font-weight: 600;
  text-align: center;
  -moz-appearance: textfield;
  color: var(--ink-dark, #1a2332);
  padding: .25rem 0;
  outline: none;
}
.credit-input-row input[type="number"]::-webkit-inner-spin-button,
.credit-input-row input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none; margin: 0;
}
.credit-step {
  width: 36px; height: 36px;
  border-radius: 8px;
  border: 1px solid var(--line, #e3e8ea);
  background: var(--card, #fff);
  font-size: 1.2rem; font-weight: 600;
  cursor: pointer;
  color: var(--ink-mid);
}
.credit-step:hover:not(:disabled) { background: #f1f4f5; }
.credit-slider { width: 100%; accent-color: #00838c; }
.credit-slider-ticks {
  display: flex; justify-content: space-between;
  font-size: .7rem; color: var(--ink-mid);
  margin-top: -.5rem;
}
.credit-presets { display: flex; gap: .4rem; flex-wrap: wrap; }
.credit-preset {
  flex: 1; min-width: 60px;
  padding: .4rem .5rem;
  border: 1px solid var(--line, #e3e8ea);
  background: var(--card, #fff);
  border-radius: 8px;
  font-size: .8rem; font-weight: 500;
  cursor: pointer; color: var(--ink-mid);
}
.credit-preset:hover { background: #f1f4f5; color: var(--ink-dark, #1a2332); }
.credit-preset.active {
  background: #00838c; color: #fff; border-color: #00838c;
}
.credit-modal-foot {
  display: flex; align-items: center; gap: .5rem;
  padding: .85rem 1.25rem 1.1rem;
  border-top: 1px solid var(--line, #e3e8ea);
}
.access-toggle:hover:not(:disabled) {
  filter: brightness(0.96);
}
.access-toggle:disabled {
  opacity: .5;
  cursor: wait;
}

/* Scheduled-deletion banner — shown at the top of modules-home when
   profile.scheduled_deletion_at is non-null and in the future.
   Sits above the hero so it's unmissable but doesn't block content. */
.scheduled-deletion-banner {
  margin-top: .75rem;
  padding: .85rem 1rem;
  background: #fff5f0;
  border: 1px solid #ffd6c2;
  border-left: 4px solid #c25a2a;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.scheduled-deletion-text {
  flex: 1;
  min-width: 220px;
  font-size: .85rem;
  color: var(--ink-dark, #1a2332);
  line-height: 1.5;
}
.scheduled-deletion-text strong { display: block; margin-bottom: .15rem; }
.scheduled-deletion-banner .btn-primary {
  flex-shrink: 0;
  padding: .45rem .9rem;
  font-size: .85rem;
}
@media (max-width: 480px) {
  .scheduled-deletion-banner { flex-direction: column; align-items: stretch; }
  .scheduled-deletion-banner .btn-primary { width: 100%; text-align: center; }
}

/* ── Behavior Guide tab ── */
.guide-panel {
  max-width: 780px;
  color: var(--ink, #2a3544);
  line-height: 1.55;
}
.guide-title {
  font-family: 'Fraunces', serif;
  font-size: 1.4rem;
  font-weight: 400;
  margin: 0 0 .5rem;
  color: var(--ink-dark, #1a2332);
}
.guide-lede {
  font-size: .92rem;
  color: var(--ink-mid, #4b5568);
  margin: 0 0 1.5rem;
}
.guide-h3 {
  font-size: .92rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-dark, #1a2332);
  margin: 1.75rem 0 .85rem;
  padding-bottom: .4rem;
  border-bottom: 1px solid var(--border, #e3e8ea);
}
.guide-h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink-dark, #1a2332);
  margin: 0 0 .35rem;
}
.guide-trig {
  display: inline-block;
  margin-left: .4rem;
  font-family: 'DM Mono', monospace;
  font-size: .72rem;
  font-weight: 400;
  color: var(--ink-mid, #5b6770);
  text-transform: none;
  letter-spacing: 0;
}
.guide-p { font-size: .88rem; margin: .35rem 0 .55rem; color: var(--ink-mid, #4b5568); }
.guide-p strong { color: var(--ink-dark, #1a2332); }
.guide-signal {
  padding: 1rem 1.1rem;
  background: var(--bg-soft, #f8fafb);
  border-left: 3px solid var(--teal, #00838c);
  border-radius: 6px;
  margin-bottom: .85rem;
}
.guide-tiers { display: flex; flex-direction: column; gap: .55rem; margin-bottom: .5rem; }
.guide-tier {
  display: flex;
  align-items: flex-start;
  gap: .85rem;
  padding: .7rem .9rem;
  background: var(--bg-soft, #f8fafb);
  border: 1px solid var(--border, #e3e8ea);
  border-radius: 8px;
  font-size: .88rem;
  color: var(--ink-mid, #4b5568);
  line-height: 1.5;
}
.guide-tier strong { color: var(--ink-dark, #1a2332); }
.guide-tier-chip {
  flex-shrink: 0;
  min-width: 36px;
  padding: .2rem .55rem;
  border-radius: 6px;
  font-weight: 700;
  font-size: .82rem;
  text-align: center;
}
.guide-ol, .guide-ul { margin: .35rem 0 1rem; padding-left: 1.4rem; font-size: .88rem; color: var(--ink-mid, #4b5568); }
.guide-ol li, .guide-ul li { margin-bottom: .55rem; line-height: 1.55; }
.guide-ol li strong, .guide-ul li strong { color: var(--ink-dark, #1a2332); }
.guide-foot {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border, #e3e8ea);
  font-size: .75rem;
  color: var(--ink-lt, #7d8893);
}
.guide-foot code {
  font-family: 'DM Mono', monospace;
  font-size: .72rem;
  background: var(--bg-soft, #f8fafb);
  padding: .1rem .35rem;
  border-radius: 3px;
}

@media (max-width: 640px) {
  .guide-panel { font-size: .88rem; }
  .guide-title { font-size: 1.2rem; }
  .guide-h3 { font-size: .82rem; }
  .guide-signal { padding: .85rem .9rem; }
}

/* ══════════════════════════════════════════════════════════
   MOBILE FIXES — recent UI (admin tabs, modals, analytics)
   Earlier breakpoints in this file cover chat/sessions/auth/
   onboarding/priority output. This block fills the gaps left
   by features added since (admin tab row grew to six tabs,
   bulk-actions bar, user/activate modals, analytics charts).
══════════════════════════════════════════════════════════ */
@media (max-width: 767px) {
  /* Admin shell */
  .admin-wrap { padding: 1rem .75rem 1.5rem; gap: 1rem; }
  .admin-header { flex-wrap: wrap; gap: .5rem; padding-top: .25rem; }
  .admin-header h1 { font-size: 1.35rem; }

  /* Six tabs no longer fit on a phone. Collapse the strip into a
     dropdown ("Users ▾") that opens a vertical list of all sections
     on tap. The toggle button shows the active tab name so the user
     always knows where they are without opening the menu. */
  .admin-tabs-toggle { display: flex; }
  .admin-tabs {
    display: none;
    position: absolute;
    top: calc(100% + .35rem);
    left: 0;
    right: 0;
    z-index: 80;
    flex-direction: column;
    gap: 0;
    padding: .35rem;
    background: var(--card, #fff);
    border: 1px solid var(--border, #e3e8ea);
    border-radius: 12px;
    box-shadow: 0 10px 28px rgba(15, 23, 42, .14);
  }
  .admin-tabs-wrap.open .admin-tabs { display: flex; }
  .admin-tab {
    width: 100%;
    text-align: left;
    border-bottom: none;
    margin-bottom: 0;
    padding: .65rem .8rem;
    font-size: .9rem;
    border-radius: 8px;
  }
  .admin-tab.active {
    background: rgba(0, 131, 140, .08);
    border-bottom-color: transparent;
  }
  .admin-tab:hover:not(.active) { background: var(--bg-soft, #f1f4f5); }
  .admin-subtab { padding: .45rem .65rem; font-size: .78rem; }

  /* Stat cards — pack tighter so two fit per row on narrow phones. */
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(115px, 1fr)); gap: .5rem; }
  .stat-card { padding: .75rem .85rem; }
  .stat-value { font-size: 1.5rem; }

  /* Section titles tighter */
  .admin-section-title { font-size: .8rem; margin-bottom: .55rem; }

  /* Tables — keep the horizontal-scroll panel, but bleed the table to
     the panel edges so the viewport's right edge isn't wasted on padding. */
  .admin-panel { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .admin-table { font-size: .78rem; }
  .admin-table th { padding: .4rem .5rem; font-size: .62rem; }
  .admin-table td { padding: .5rem .55rem; max-width: 180px; }

  /* Bulk-actions bar — stack count above the button on cramped widths. */
  .user-bulk-actions {
    flex-wrap: wrap;
    padding: .55rem .7rem;
    gap: .5rem;
  }
  .user-bulk-apply {
    margin-left: 0;
    width: 100%;
    text-align: center;
  }

  /* User action + activate-user modals */
  .user-action-modal { padding: .5rem; align-items: flex-end; }
  .user-action-inner {
    padding: 1.1rem 1.1rem 1.25rem;
    max-height: 88vh;
    border-radius: 14px 14px 0 0;
  }
  .user-action-title { font-size: 1rem; }
  .user-action-opt {
    padding: .7rem .8rem;
    gap: .6rem;
  }
  .user-action-opt-title { font-size: .88rem; }
  .user-action-opt-desc { font-size: .78rem; line-height: 1.45; }
  .user-action-foot {
    flex-direction: column-reverse;
    gap: .5rem;
    padding-top: .85rem;
    margin-top: .85rem;
  }
  .user-action-foot .btn-primary,
  .user-action-foot .btn-secondary {
    width: 100%;
    padding: .65rem 1rem;
  }
  .activate-section-label { margin-top: .85rem; }
  .activate-check { padding: .5rem .7rem; font-size: .85rem; }
  .activate-message { font-size: .85rem; }

  /* Knowledge subtab toolbar wraps if needed */
  .admin-knowledge-toolbar { flex-wrap: wrap; gap: .35rem; }
}

@media (max-width: 480px) {
  /* Squeeze admin chrome further on the smallest phones (≤375 CSS px) */
  .admin-wrap { padding: .75rem .5rem 1.25rem; }
  .admin-tab { padding: .5rem .6rem; font-size: .78rem; }
  .admin-tab[data-tab="analytics"]::after,
  .admin-tab[data-tab="knowledge"]::after { content: none; }

  /* Stat-grid keeps two columns even on 360px viewports by lowering the
     min track width below the gap-aware halving threshold. */
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-value { font-size: 1.35rem; }

  /* Admin tables — even tighter cell padding so wider tables (cost-by-
     user has 9 columns) don't force a long horizontal scroll. */
  .admin-table th, .admin-table td { padding: .4rem .45rem; }
  .admin-table td { max-width: 140px; }

  /* Action modals: full-bleed bottom sheet on narrow phones */
  .user-action-modal { padding: 0; }
  .user-action-inner {
    border-radius: 14px 14px 0 0;
    max-height: 92vh;
    padding: 1rem 1rem 1.15rem;
  }
  .activate-checkboxes { gap: .3rem; }

  /* Analytics: the per-module step-funnel SVG renders at a fixed pixel
     width. Make sure the cell hosting it can scroll independently rather
     than forcing the whole table to scale. */
  #analyticsModules .admin-table td:last-child {
    max-width: 220px;
    overflow-x: auto;
  }
  #analyticsModules .admin-table td:last-child svg {
    max-width: none;
  }

  /* Cohort retention + funnel tables: drop the right-aligned padding a
     bit so percentage cells don't get cut off behind the panel edge. */
  #analyticsFunnel .admin-table td:nth-child(n+2),
  #analyticsCohort .admin-table td:nth-child(n+2) { padding-right: .35rem; }
}

/* iOS Safari sometimes ignores fixed-overlay safe-area insets. Make sure
   the bottom-sheet modals don't render content under the home indicator. */
@supports (padding: env(safe-area-inset-bottom)) {
  .user-action-inner,
  .onb-card {
    padding-bottom: max(1.15rem, env(safe-area-inset-bottom));
  }
}

/* ── Language toggle (globe button) ───────────────────────────────
   Two surfaces:
   1. `.lang-toggle-floating` — fixed top-right on auth-side screens
      (auth / signup / consent / reset / data-handling). app.js shows
      it on those screens and hides it elsewhere by setting display.
   2. Inline `.lang-toggle-btn` inside modules-header — same visual.
   Both call cycleLang() which flips locale and updates URL. */
.lang-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  background: transparent;
  border: 1px solid rgba(0, 131, 140, 0.25);
  color: var(--ink-mid, #4b5568);
  padding: .35rem .55rem;
  border-radius: 999px;
  font-family: inherit;
  font-size: .78rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.lang-toggle-btn:hover {
  background: rgba(0, 131, 140, 0.08);
  color: var(--teal, #00838c);
  border-color: rgba(0, 131, 140, 0.5);
}
.lang-toggle-btn svg {
  flex-shrink: 0;
  opacity: .85;
}
.lang-toggle-code {
  font-family: 'DM Mono', ui-monospace, monospace;
  font-size: .72rem;
  letter-spacing: .05em;
}
.lang-toggle-floating {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 50;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 1px 2px rgba(20, 30, 50, 0.05);
}
@media (max-width: 640px) {
  .lang-toggle-floating {
    top: .75rem;
    right: .75rem;
  }
}

/* Settings-page language section: two side-by-side choice buttons.
   Active language is highlighted via .is-active. */
.lang-choice {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin-top: .35rem;
}
.lang-choice-btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  background: var(--bg-soft, #f8fafb);
  border: 1px solid rgba(20, 30, 50, 0.1);
  color: var(--ink, #1a2332);
  padding: .55rem .85rem;
  border-radius: 8px;
  font-family: inherit;
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.lang-choice-btn:hover {
  background: rgba(0, 131, 140, 0.06);
  border-color: rgba(0, 131, 140, 0.35);
}
.lang-choice-btn.is-active {
  background: rgba(0, 131, 140, 0.1);
  border-color: var(--teal, #00838c);
  color: var(--teal, #00838c);
}
.lang-choice-flag {
  font-family: 'DM Mono', ui-monospace, monospace;
  font-size: .72rem;
  letter-spacing: .05em;
  padding: .15rem .4rem;
  border-radius: 4px;
  background: rgba(20, 30, 50, 0.05);
  color: var(--ink-mid, #4b5568);
}
.lang-choice-btn.is-active .lang-choice-flag {
  background: rgba(0, 131, 140, 0.15);
  color: var(--teal, #00838c);
}
