/* 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: .45em;
}

.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 { 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;
  color: rgba(255,255,255,.85);
  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%; }
}

/* ── 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);
}

.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;
  }

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

  .modules-title {
    font-size: 1.35rem;
  }

  .module-card {
    padding: 1rem;
  }

  .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;
}

/* ══════════════════════════════════════════════════════════
   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;
}

/* ===== 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;
}

.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-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 */
.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;
}
