/* ---------- design tokens ---------- */
:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #1a1d23;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #b91c1c;
  --success: #047857;
  --warning: #c2410c;
  --pill-bg: #eef2ff;
  --pill-fg: #3730a3;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --surface: #161a22;
    --border: #2a313d;
    --text: #e6e8ec;
    --muted: #9aa3b2;
    --pill-bg: #1e293b;
    --pill-fg: #c7d2fe;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.4);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

.hidden { display: none !important; }

/* ---------- topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; }
.logo { font-size: 22px; }
.user-area { display: flex; align-items: center; gap: 12px; }
#userBadge { color: var(--muted); font-size: 13px; }
#modeBadge {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--pill-bg);
  color: var(--pill-fg);
  font-weight: 600;
}

/* ---------- buttons & forms ---------- */
button {
  font: inherit;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 9px 16px;
  cursor: pointer;
  transition: background .12s ease, transform .05s ease;
}
button:active { transform: translateY(1px); }
button.primary { background: var(--primary); color: #fff; }
button.primary:hover { background: var(--primary-hover); }
button.primary:disabled { background: #94a3b8; cursor: not-allowed; }
button.ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
button.ghost:hover { background: var(--bg); }
button.block { width: 100%; }

label { display: block; margin-bottom: 12px; font-size: 13px; color: var(--muted); font-weight: 500; }
label.row { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 400; }
label.row input { width: auto; }
input[type=text], input[type=email], input[type=password], textarea {
  width: 100%;
  margin-top: 4px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
input:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
textarea { resize: vertical; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row.gap { display: flex; gap: 10px; align-items: center; }

/* ---------- screens & cards ---------- */
.screen { padding: 24px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

/* ---------- auth ---------- */
.auth-card { max-width: 440px; margin: 50px auto; }
.auth-card h1 { margin: 0 0 4px; }
.muted { color: var(--muted); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 16px 0 18px; }
.tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 14px;
  color: var(--muted);
  font-weight: 600;
}
.tab.active { color: var(--text); border-bottom-color: var(--primary); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }
.error { color: var(--danger); margin-top: 8px; font-size: 13px; }

/* ---------- case layout ---------- */
.case-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 18px;
  max-width: 1200px;
  margin: 0 auto;
}
@media (max-width: 720px) {
  .case-layout { grid-template-columns: 1fr; }
}
.sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  height: fit-content;
}
.sidebar h2 { margin: 0 0 12px; font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.case-list { list-style: none; padding: 0; margin: 12px 0 0; max-height: 480px; overflow: auto; }
.case-list li {
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  margin-bottom: 4px;
  border: 1px solid transparent;
}
.case-list li:hover { background: var(--bg); }
.case-list li.active { background: var(--pill-bg); color: var(--pill-fg); font-weight: 600; }
.case-list .case-status { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }

.case-main .empty { text-align: center; color: var(--muted); }
.case-main .empty h2 { margin-top: 0; }

/* ---------- chat ---------- */
.chat-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.chat-header h2 { margin: 0; font-size: 19px; }
.chat-header .muted { margin: 4px 0 0; font-size: 13px; }
.pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--pill-bg);
  color: var(--pill-fg);
  font-size: 12px;
  font-weight: 600;
}

.messages {
  background: var(--bg);
  border-radius: 10px;
  padding: 14px;
  max-height: 460px;
  overflow-y: auto;
  margin-bottom: 14px;
  border: 1px solid var(--border);
}
.message { margin-bottom: 12px; display: flex; }
.message.user { justify-content: flex-end; }
.message .bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 14px;
  white-space: pre-wrap;
}
.message.user .bubble {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.message.assistant .bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.message .role-label { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.message.assistant .role-label { text-align: left; }
.message.user .role-label { text-align: right; }

.reply { display: flex; gap: 10px; align-items: flex-end; }
.reply textarea { flex: 1; }
.actions { margin-top: 14px; }

/* ---------- report ---------- */
.report {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.report h3 { margin-top: 18px; }
.report .issue {
  padding: 10px 12px;
  border-left: 4px solid var(--border);
  margin-bottom: 8px;
  background: var(--bg);
  border-radius: 0 8px 8px 0;
}
.report .issue.RED { border-left-color: var(--danger); }
.report .issue.YELLOW { border-left-color: var(--warning); }
.report .issue.GREEN { border-left-color: var(--success); }
.report .severity-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .05em;
  padding: 2px 6px;
  border-radius: 4px;
  margin-right: 6px;
  vertical-align: middle;
}
.report .severity-tag.RED { background: #fee2e2; color: #991b1b; }
.report .severity-tag.YELLOW { background: #fef3c7; color: #92400e; }
.report .severity-tag.GREEN { background: #d1fae5; color: #065f46; }
.report ul { padding-left: 22px; }
.report .disclaimer {
  margin-top: 22px;
  padding: 12px;
  background: var(--bg);
  border-radius: 8px;
  font-size: 13px;
  color: var(--muted);
}
/* Sticky action bar — Download/Close stay visible while reading a long report,
   so the user never has to scroll to the bottom to find them. */
.report .download-row {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  align-items: center;
  margin: 24px -4px 0;
  padding: 13px 14px;
  background: rgba(255, 255, 255, 0.95);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
  backdrop-filter: saturate(180%) blur(8px);
  border-top: 1px solid var(--border);
  border-radius: 0 0 12px 12px;
}
.report .download-row button { white-space: nowrap; }
@media (max-width: 640px) {
  .report .download-row { padding: 11px 12px; }
  .report .download-row button { flex: 1 1 auto; }
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: var(--shadow);
  z-index: 999;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

/* ---------- thinking indicator ---------- */
.thinking-bubble {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  opacity: 0.95;
  font-style: italic;
}
.thinking-bubble .dots {
  display: inline-flex;
  gap: 3px;
}
.thinking-bubble .dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.4;
  animation: thinking-bounce 1.2s infinite ease-in-out;
}
.thinking-bubble .dots span:nth-child(2) { animation-delay: 0.15s; }
.thinking-bubble .dots span:nth-child(3) { animation-delay: 0.30s; }
.thinking-elapsed {
  font-size: 11px;
  opacity: 0.6;
  margin-left: 6px;
  font-variant-numeric: tabular-nums;
  font-style: normal;
}
@keyframes thinking-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.3; }
  40% { transform: scale(1); opacity: 1; }
}

.thinking-bubble { flex-direction: column; align-items: flex-start; }
.thinking-line { display: inline-flex; align-items: center; gap: 8px; }
.thinking-note {
  margin-top: 8px;
  font-size: 12px;
  font-style: normal;
  opacity: 0.7;
  line-height: 1.45;
  max-width: 560px;
}

/* ---------- action plan panel ---------- */
.action-plan {
  background: rgba(34, 197, 94, 0.07);
  border: 1.5px solid rgba(34, 197, 94, 0.4);
  border-radius: 10px;
  padding: 18px 22px;
  margin: 22px 0 16px 0;
}
.action-plan h3 { color: #22c55e; margin-top: 0; border-bottom: 2px solid rgba(34, 197, 94, 0.25); padding-bottom: 6px; }
.action-plan h4 { color: #4ade80; margin-top: 14px; margin-bottom: 6px; }
.action-plan h4.ap-warn { color: #f87171; }
.ap-recommended {
  background: rgba(34, 197, 94, 0.12);
  border-radius: 8px;
  padding: 12px 16px;
  margin: 10px 0 16px 0;
}
.ap-alt {
  background: rgba(255, 255, 255, 0.03);
  border-left: 3px solid #94a3b8;
  padding: 10px 14px;
  margin: 10px 0;
  border-radius: 0 6px 6px 0;
}
.ap-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #86efac;
  margin-bottom: 4px;
}
.ap-alt .ap-label { color: #cbd5e1; }
.ap-when { margin: 4px 0 6px 0; font-size: 13px; opacity: 0.85; }
.action-plan ol li { margin-bottom: 6px; line-height: 1.5; }

/* ---------- section switcher (Cases / Contracts tabs in sidebar) ---------- */
.section-switch { display: flex; gap: 6px; margin-bottom: 12px; background: var(--surface-alt, #1e293b); border-radius: 8px; padding: 4px; }
.section-switch .seg {
  flex: 1; padding: 7px 10px; border: 0; background: transparent;
  color: var(--muted, #94a3b8); cursor: pointer; border-radius: 6px;
  font-size: 13px; font-weight: 500;
}
.section-switch .seg.active { background: var(--primary, #2563eb); color: #fff; }
.section-switch .seg:hover:not(.active) { background: rgba(255,255,255,0.05); }

/* ---------- contract template picker ---------- */
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-top: 14px; }
.tpl-card {
  text-align: left; padding: 14px; border: 1px solid var(--border, #334155);
  background: var(--surface-alt, #1e293b); color: var(--text, #e2e8f0);
  border-radius: 10px; cursor: pointer; transition: border-color 0.15s, transform 0.05s;
}
.tpl-card:hover { border-color: var(--primary, #2563eb); }
.tpl-card:active { transform: translateY(1px); }
.tpl-cat { font-size: 10px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--primary, #60a5fa); font-weight: 600; }
.tpl-title { font-size: 15px; font-weight: 600; margin: 4px 0 2px 0; }
.tpl-desc { font-size: 12px; color: var(--muted, #94a3b8); margin-top: 8px; line-height: 1.45; }
.small { font-size: 11px; }

/* ---------- contract form ---------- */
#contractFields label { display: block; margin-bottom: 12px; }
#contractFields label span { display: block; font-size: 12px; color: var(--muted, #94a3b8); margin-bottom: 4px; }
#contractFields input[type=checkbox] { width: auto; margin-right: 6px; }

.danger { color: var(--danger, #dc2626); }

/* ---------- case attachments bar ---------- */
.attachments-bar {
  margin: 10px 0 6px 0;
  padding: 10px 12px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border, #334155);
  border-radius: 8px;
}
.attachment-list { list-style: none; padding: 0; margin: 8px 0 0 0; }
.attachment-item {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; border-radius: 6px;
  background: rgba(255,255,255,0.03);
  margin-bottom: 4px; font-size: 13px;
}
.attachment-name { flex: 1; color: var(--text, #e2e8f0); }
.attachment-item button { padding: 2px 8px; border-radius: 4px; }

/* ---------- language selector in topbar ---------- */
.lang-select {
  background: var(--surface-alt, #1e293b);
  color: var(--text, #e2e8f0);
  border: 1px solid var(--border, #334155);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 13px;
  cursor: pointer;
  margin-right: 8px;
}
.lang-select:hover { border-color: var(--primary, #2563eb); }

/* ============================================================
   MODERN THEME OVERLAY (v9)
   Layered on top of the base tokens so the original design
   keeps working if anything below this is removed.
   ============================================================ */

:root {
  --grad-primary: linear-gradient(135deg, #6366f1 0%, #2563eb 60%, #0ea5e9 100%);
  --grad-accent: linear-gradient(135deg, #a855f7 0%, #6366f1 100%);
  --glass: rgba(255,255,255,0.65);
  --glass-stroke: rgba(255,255,255,0.4);
  --ring: 0 0 0 3px rgba(99,102,241,0.18);
  --easing: cubic-bezier(.2,.7,.2,1);
}
@media (prefers-color-scheme: dark) {
  :root {
    --glass: rgba(22,26,34,0.6);
    --glass-stroke: rgba(255,255,255,0.06);
  }
}

/* ----- typography polish ----- */
body {
  font-family: "Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.005em;
  background:
    radial-gradient(60rem 40rem at -10% -10%, rgba(99,102,241,0.10), transparent 60%),
    radial-gradient(60rem 40rem at 110% 10%, rgba(14,165,233,0.10), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
h1, h2, h3 { letter-spacing: -0.02em; }

/* ----- topbar ----- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  background: var(--glass);
  border-bottom: 1px solid var(--glass-stroke);
  padding: 12px 22px;
}
.brand {
  font-size: 16px; font-weight: 700;
  background: var(--grad-primary);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.brand .logo {
  filter: drop-shadow(0 2px 6px rgba(99,102,241,.4));
}
.lang-select {
  background: rgba(255,255,255,0.04);
  border-radius: 8px;
}
#modeBadge { background: var(--grad-accent); color: #fff; border: none; }

/* ----- connection status dot ----- */
.conn-dot {
  display: inline-block;
  width: 8px; height: 8px; border-radius: 50%;
  background: #16a34a;
  box-shadow: 0 0 0 3px rgba(22,163,74,0.18);
  transition: background .2s var(--easing), box-shadow .2s var(--easing);
  margin-right: 8px;
  cursor: help;
}
.conn-dot.warn { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245,158,11,0.18); }
.conn-dot.down { background: #dc2626; box-shadow: 0 0 0 3px rgba(220,38,38,0.18); animation: pulse-down 1.4s infinite var(--easing); }
@keyframes pulse-down {
  0%,100% { transform: scale(1); }
  50% { transform: scale(1.35); }
}

/* ----- cards ----- */
.card {
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 10px 30px rgba(0,0,0,.06);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: box-shadow .25s var(--easing), border-color .2s var(--easing);
}
.card:hover { box-shadow: 0 1px 2px rgba(0,0,0,.05), 0 16px 40px rgba(0,0,0,.08); }
.auth-card {
  position: relative;
  overflow: hidden;
}
.auth-card::before {
  content: ""; position: absolute; inset: -2px;
  background: var(--grad-primary);
  filter: blur(40px); opacity: 0.18; z-index: -1;
}

/* ----- buttons ----- */
button { transition: background .15s var(--easing), transform .08s var(--easing), box-shadow .15s var(--easing); }
button.primary {
  background: var(--grad-primary);
  border: none;
  box-shadow: 0 6px 16px rgba(37,99,235,0.25), inset 0 -1px 0 rgba(0,0,0,0.15);
  font-weight: 600;
}
button.primary:hover { filter: brightness(1.06); transform: translateY(-1px); }
button.primary:active { transform: translateY(0); }
button.primary:focus-visible { outline: none; box-shadow: 0 6px 16px rgba(37,99,235,0.25), var(--ring); }
button.ghost { border-color: var(--border); }
button.ghost:hover { background: rgba(99,102,241,0.06); }

/* ----- form inputs ----- */
input, textarea, select {
  transition: border-color .15s var(--easing), box-shadow .15s var(--easing), background .15s var(--easing);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--ring);
}

/* ----- sidebar ----- */
.sidebar h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 14px 0 8px;
}
.case-list li {
  position: relative;
  border: 1px solid transparent;
  transition: background .15s var(--easing), border-color .15s var(--easing), transform .12s var(--easing);
  border-radius: 10px;
}
.case-list li:hover { background: rgba(99,102,241,0.06); transform: translateX(2px); }
.case-list li.active {
  background: rgba(99,102,241,0.12);
  border-color: rgba(99,102,241,0.4);
}
.case-list li.active::before {
  content: ""; position: absolute; left: -4px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 2px;
  background: var(--grad-primary);
}

/* ----- template cards ----- */
.tpl-card {
  position: relative; overflow: hidden;
  transition: transform .15s var(--easing), border-color .15s var(--easing), box-shadow .2s var(--easing);
}
.tpl-card::after {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--grad-primary);
  opacity: 0; transition: opacity .2s var(--easing);
}
.tpl-card:hover { transform: translateY(-3px); box-shadow: 0 12px 30px rgba(99,102,241,0.15); }
.tpl-card:hover::after { opacity: 1; }
.tpl-cat {
  background: var(--grad-accent);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  font-weight: 700;
}

/* ----- empty / pick state ----- */
.empty-pick {
  background:
    radial-gradient(20rem 12rem at 50% 0%, rgba(99,102,241,0.08), transparent 60%),
    transparent !important;
  transition: border-color .2s var(--easing);
}
.empty-pick:hover { border-color: rgba(99,102,241,0.4) !important; }
.empty { padding: 28px; }

/* ----- thinking bubble polish ----- */
.thinking-bubble {
  background: linear-gradient(135deg, rgba(99,102,241,0.10), rgba(14,165,233,0.10));
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: 12px;
  padding: 10px 14px;
}
.thinking-bubble .dots span { background: var(--primary); }

/* ----- toast polish ----- */
.toast {
  border-radius: 12px;
  border: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  animation: toast-in .25s var(--easing);
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ============================================================
   CONFIRM MODAL  (replaces native confirm() for destructive ops)
   ============================================================ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  animation: backdrop-in .15s var(--easing);
}
.modal-card {
  width: min(440px, 92vw);
  background: var(--surface);
  border-radius: 14px;
  border: 1px solid var(--border);
  box-shadow: 0 30px 60px rgba(0,0,0,0.4);
  padding: 22px;
  animation: modal-in .2s var(--easing);
}
.modal-card h3 { margin: 0 0 8px; }
.modal-card p { margin: 0 0 16px; color: var(--muted); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============================================================
   FOOTER: brand + link columns + disclaimer bar (monochrome)
   ============================================================ */
.app-footer {
  border-top: 1px solid #e7e7e3;
  background: #ffffff;
  color: #55554e;
  font-size: 13px;
}
.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 36px 24px 18px;
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr;
  gap: 32px;
}
.footer-brand { max-width: 380px; }
.footer-logo { font-size: 17px; font-weight: 700; letter-spacing: -0.2px; color: #141414; }
.footer-tagline { margin: 8px 0 14px; line-height: 1.55; color: #6b6b63; }
.footer-trust { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.footer-trust li { color: #6b6b63; font-size: 12.5px; }
.footer-trust li::before { content: "\2713"; margin-inline-end: 7px; color: #141414; font-weight: 700; }
.footer-col { display: flex; flex-direction: column; gap: 7px; }
.footer-col-title {
  margin: 0 0 4px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em; color: #8a8a82;
}
.footer-col a {
  color: #55554e; text-decoration: none; width: fit-content;
  border-bottom: 1px solid transparent; transition: color .14s ease, border-color .14s ease;
}
.footer-col a:hover { color: #141414; border-bottom-color: #141414; }
.footer-bottom {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-top: 28px; padding-top: 14px; border-top: 1px solid #ececea;
  font-size: 12px; color: #8a8a82;
}
@media (max-width: 760px) {
  .footer-grid { grid-template-columns: 1fr; gap: 24px; }
  .footer-inner { padding: 28px 18px 14px; }
  .footer-bottom { flex-direction: column; align-items: flex-start; gap: 6px; }
}

/* ============================================================
   CONTACT / FEEDBACK: floating button + modal (monochrome)
   ============================================================ */
.contact-fab {
  position: fixed; bottom: 18px; inset-inline-end: 18px; z-index: 950;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border: 1px solid rgba(255,255,255,0.28); border-radius: 999px;
  background: #141414; color: #fff; font: inherit; font-size: 13.5px; font-weight: 700;
  cursor: pointer; box-shadow: 0 8px 24px rgba(0,0,0,0.28);
  transition: transform .16s ease, box-shadow .16s ease;
}
.contact-fab:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(0,0,0,0.34); }
.contact-fab svg { width: 16px; height: 16px; }
@media (max-width: 640px) {
  .contact-fab { bottom: 14px; inset-inline-end: 14px; padding: 9px 13px; font-size: 12.5px; }
}

#contactModal .contact-card {
  position: relative; width: min(480px, 94vw); max-height: 90vh; overflow: auto;
  background: #fff; color: #1a1a18; border: 1px solid #e7e7e3; border-radius: 16px;
  padding: 22px;
}
#contactModal h2 { margin: 0 34px 6px 0; font-size: 19px; color: #141414; }
#contactModal .muted { color: #6b6b63; font-size: 13.5px; margin: 0 0 14px; }
#contactModal label { display: block; margin: 0 0 12px; font-size: 13px; font-weight: 600; color: #444440; }
#contactModal input, #contactModal textarea {
  display: block; width: 100%; box-sizing: border-box; margin-top: 5px;
  padding: 10px 12px; font: inherit; font-size: 14px; color: #1a1a18;
  background: #fff; border: 1px solid #d8d8d2; border-radius: 10px; resize: vertical;
}
#contactModal input:focus, #contactModal textarea:focus { outline: none; border-color: #141414; }
#contactModal button.primary {
  width: 100%; background: #141414; color: #fff; border: 0; border-radius: 10px;
  padding: 11px 18px; font: inherit; font-weight: 700; cursor: pointer;
}
#contactModal button.primary:disabled { opacity: .6; cursor: default; }
.contact-sent { margin: 8px 0 0; font-size: 14.5px; line-height: 1.55; color: #1a1a18; }
.contact-sent::before { content: "\2713"; font-weight: 700; margin-inline-end: 8px; }
.contact-direct { margin: 0 0 16px; font-size: 13px; color: #6b6b63; }
.contact-direct a { color: #141414; font-weight: 700; text-decoration: underline; }

/* ============================================================
   SKELETON loader (for lists while data loads)
   ============================================================ */
.skel {
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.04) 100%);
  background-size: 200% 100%;
  animation: skel-shimmer 1.2s infinite linear;
  border-radius: 6px;
  height: 14px;
}
@keyframes skel-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================================
   MODERN THEME v10 — bolder, glassier, more eye-catching
   ============================================================ */

:root {
  --grad-hero:
    radial-gradient(60rem 40rem at 8% 10%, rgba(168,85,247,0.18), transparent 60%),
    radial-gradient(60rem 40rem at 92% 0%, rgba(14,165,233,0.22), transparent 60%),
    radial-gradient(70rem 50rem at 50% 110%, rgba(34,197,94,0.10), transparent 60%);
  --noise: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 .04 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  --stroke-soft: rgba(255,255,255,0.06);
}

/* ----- animated mesh background ----- */
body {
  background:
    var(--noise),
    var(--grad-hero),
    var(--bg);
  background-attachment: fixed;
  background-size: 200px 200px, auto, auto;
  position: relative;
}
body::before {
  content: "";
  position: fixed; inset: -10vmax;
  background:
    radial-gradient(40rem 30rem at 20% 30%, rgba(99,102,241,0.18), transparent 60%),
    radial-gradient(40rem 30rem at 80% 70%, rgba(236,72,153,0.14), transparent 60%);
  filter: blur(20px);
  z-index: -2;
  animation: mesh-drift 28s ease-in-out infinite alternate;
  pointer-events: none;
}
@keyframes mesh-drift {
  0%   { transform: translate3d(0,0,0) rotate(0deg); }
  50%  { transform: translate3d(-3%,-2%,0) rotate(2deg); }
  100% { transform: translate3d(2%,3%,0) rotate(-2deg); }
}

/* ----- topbar v2: cleaner, brand more prominent ----- */
.topbar {
  border-bottom: 1px solid var(--stroke-soft);
  padding: 14px 26px;
}
.brand {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.brand .logo {
  font-size: 24px;
  filter: drop-shadow(0 4px 10px rgba(99,102,241,.45));
  animation: logo-float 4s ease-in-out infinite;
}
@keyframes logo-float {
  0%,100% { transform: translateY(0) rotate(-2deg); }
  50%     { transform: translateY(-2px) rotate(2deg); }
}
#modeBadge {
  box-shadow: 0 4px 12px rgba(168,85,247,0.35), inset 0 -1px 0 rgba(0,0,0,0.15);
  letter-spacing: 0.02em;
}

/* ----- auth screen hero polish ----- */
.auth-card {
  padding: 32px;
  border: 1px solid var(--stroke-soft);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.01)),
    var(--surface);
}
.auth-card h1 {
  font-size: 32px;
  font-weight: 800;
  background: linear-gradient(135deg, #fff 0%, #c7d2fe 60%, #818cf8 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  margin-bottom: 6px;
}
.auth-card::before {
  background: var(--grad-primary);
  filter: blur(60px);
  opacity: 0.3;
  z-index: -1;
}

/* ----- case-main pane background card ----- */
.case-main .card {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.025), transparent 200px),
    var(--surface);
  animation: pane-fade-in .4s var(--easing);
}
@keyframes pane-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ----- sidebar v2 ----- */
.sidebar {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.005)),
    var(--surface);
  border: 1px solid var(--stroke-soft);
  border-radius: 14px;
  padding: 14px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.section-switch {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--stroke-soft);
  padding: 4px;
  border-radius: 10px;
}
.section-switch .seg {
  font-weight: 600;
  border-radius: 7px;
}
.section-switch .seg.active {
  background: var(--grad-primary);
  box-shadow: 0 6px 16px rgba(99,102,241,0.4);
}
.case-list { display: flex; flex-direction: column; gap: 6px; }
.case-list li {
  padding: 10px 12px;
  list-style: none;
  cursor: pointer;
  font-size: 13.5px;
}
.case-list li .case-status {
  display: block;
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 2px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.case-list li.active .case-status { color: #a5b4fc; }
.case-list li:hover { transform: translateX(3px); }

/* ----- buttons v2: pill-shape primaries with glow ----- */
button.primary {
  border-radius: 10px;
  padding: 10px 18px;
  letter-spacing: 0.01em;
  box-shadow:
    0 8px 20px rgba(99,102,241,0.4),
    0 1px 0 rgba(255,255,255,0.1) inset,
    0 -1px 0 rgba(0,0,0,0.2) inset;
}
button.primary::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255,255,255,0.18), transparent 40%);
  opacity: 0; transition: opacity .15s var(--easing);
}
button.primary:hover::after { opacity: 1; }
button.primary {
  position: relative;
  overflow: hidden;
}
button.block { width: 100%; }

button.ghost {
  border-color: var(--stroke-soft);
  background: rgba(255,255,255,0.03);
  border-radius: 10px;
}

/* ----- inputs / selects v2 ----- */
input, textarea, select {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--stroke-soft);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
  font-size: 14px;
}
input:focus, textarea:focus, select:focus {
  background: rgba(99,102,241,0.04);
  border-color: rgba(99,102,241,0.6);
  box-shadow: 0 0 0 4px rgba(99,102,241,0.18);
}
textarea { resize: vertical; min-height: 80px; }

label { display: block; margin-bottom: 14px; }
label > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }

/* ----- template grid v2: bigger, category icons ----- */
.template-grid { gap: 16px; }
.tpl-card {
  padding: 18px;
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.04), transparent 80px),
    rgba(255,255,255,0.025);
  border: 1px solid var(--stroke-soft);
  display: flex; flex-direction: column; gap: 6px;
  min-height: 140px;
}
.tpl-card .tpl-icon {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  font-size: 20px;
  background: var(--grad-accent);
  box-shadow: 0 4px 12px rgba(168,85,247,0.3);
  margin-bottom: 4px;
}
.tpl-card .tpl-title {
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.tpl-card:hover {
  border-color: rgba(99,102,241,0.5);
  transform: translateY(-4px);
}

/* ----- chat composer polish ----- */
.reply textarea {
  border-radius: 14px;
  font-size: 14px;
  padding: 14px 16px;
}
.messages {
  border-radius: 14px;
  padding: 8px 0;
}
.message .bubble {
  border-radius: 14px;
  padding: 12px 16px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}
.message.user .bubble {
  background: var(--grad-primary);
  color: #fff;
  border: none;
}
.message .role-label { font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 4px; }

/* ----- attachments bar v2 ----- */
.attachments-bar {
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  border: 1px dashed var(--stroke-soft);
}
.attachment-item {
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  transition: background .15s var(--easing);
}
.attachment-item:hover { background: rgba(99,102,241,0.08); }

/* ----- pills v2 ----- */
.pill, #statusPill, #contractStatus {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--stroke-soft);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--muted);
}
#statusPill::before, #contractStatus::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; opacity: 0.7;
}

/* ----- chat-header layout polish ----- */
.chat-header {
  border-bottom: 1px solid var(--stroke-soft);
  padding-bottom: 14px;
  margin-bottom: 14px;
}
.chat-header h2 { font-size: 18px; font-weight: 700; margin: 0; }
.chat-header .muted { font-size: 12.5px; margin-top: 2px; }

/* ----- modal v2 ----- */
.modal-card {
  border: 1px solid var(--stroke-soft);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.05), transparent 60px),
    var(--surface);
}
.modal-card h3 { font-size: 18px; font-weight: 700; }

/* ---------- v10 quick fixes ---------- */

/* Hide the "Claude API" mode badge unless it's in stub/local mode (warning). */
#modeBadge { display: none; }
#modeBadge.stub-warning { display: inline-flex; background: linear-gradient(135deg, #f59e0b, #ea580c); }

/* Pin the footer to the bottom of the viewport on short pages. */
html, body { min-height: 100%; }
body { display: flex; flex-direction: column; }
main#app { flex: 1 0 auto; }
.app-footer { flex: 0 0 auto; margin-top: auto; }

/* The user/email + lang dropdown were squashing — give them breathing room. */
.user-area { gap: 14px; }
.user-area #userBadge { white-space: nowrap; }

/* ---------- v10 fixes round 2 ---------- */

/* 1) Logo emoji was being clipped by the gradient text-fill on .brand.
   Restore its native rendering (emoji), keep the gradient only on the text. */
.brand .logo {
  -webkit-background-clip: initial; background-clip: initial;
  -webkit-text-fill-color: initial; color: initial;
  background: none;
  display: inline-flex; align-items: center;
  /* Slight glow stays via the existing drop-shadow filter rule */
}

/* 2) Log out button was wrapping to two lines. Give it firm sizing. */
#logoutBtn {
  white-space: nowrap;
  padding: 8px 14px;
  font-size: 13px;
  border-radius: 9px;
}

/* 3) <select> option text was black-on-black in dark themes (some
   browsers ignore the parent text color for <option>). Force it. */
select { color: var(--text); }
select option {
  background: var(--surface);
  color: var(--text);
}
@media (prefers-color-scheme: dark) {
  select option {
    background: #1f2937;
    color: #e6e8ec;
  }
}

/* Also make the topbar `.user-area` group don't squish on narrow widths. */
.topbar { gap: 12px; }
.user-area { flex-wrap: nowrap; }

/* ---------- RTL polish (Arabic / Farsi / Hebrew / Urdu) ---------- */
html[dir="rtl"] body { font-family: "Vazirmatn", "IBM Plex Sans Arabic", "Geeza Pro", "Tahoma", sans-serif; }

/* Sidebar active indicator bar flips side. */
html[dir="rtl"] .case-list li.active::before { left: auto; right: -4px; }

/* Sidebar hover translate flips direction. */
html[dir="rtl"] .case-list li:hover { transform: translateX(-3px); }

/* Attachment items & similar rows reverse so the ✕ button stays on the "end". */
html[dir="rtl"] .attachment-item,
html[dir="rtl"] .chat-header,
html[dir="rtl"] .reply,
html[dir="rtl"] .row { direction: rtl; }

/* Markdown body keeps natural reading direction for the content language —
   but since most contracts/output are in their jurisdiction's language, this
   stays LTR by default. */
.md, .messages .bubble { direction: inherit; text-align: start; }

/* ---------- output-language banner ---------- */
.lang-banner {
  margin: 10px 0 14px 0;
  padding: 10px 14px;
  border-radius: 10px;
  background:
    linear-gradient(135deg, rgba(99,102,241,0.10), rgba(14,165,233,0.10));
  border: 1px solid rgba(99,102,241,0.25);
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
}
.lang-banner strong { color: #c7d2fe; }

/* ---------- v10 fixes round 3 ---------- */

/* Inputs were showing browser-default black text on the dark theme. Force
   the theme text colour on every form control. */
input, textarea, select, button {
  color: var(--text);
}
input::placeholder, textarea::placeholder {
  color: var(--muted);
  opacity: 0.7;
}
/* Autofill (Safari/Chrome) was repainting fields white-on-white. Override. */
input:-webkit-autofill, textarea:-webkit-autofill, select:-webkit-autofill {
  -webkit-text-fill-color: var(--text) !important;
  -webkit-box-shadow: 0 0 0 1000px rgba(255,255,255,0.04) inset !important;
  caret-color: var(--text);
}
/* Disabled / readonly fields. */
input:disabled, textarea:disabled, select:disabled {
  color: var(--muted);
  background: rgba(255,255,255,0.02);
  cursor: not-allowed;
}

/* ============================================================
   CLARAVEN brand — logo + hero
   ============================================================ */

/* ---- logo ---- */
.brand { display: flex; align-items: center; height: 36px; text-decoration: none; }
.brand .logo-img { height: 36px; width: auto; display: block; }
.brand:hover .logo-img { filter: drop-shadow(0 4px 14px rgba(99,102,241,0.5)); transition: filter 0.2s var(--easing); }
/* Full wordmark on desktop, compact mark-only on phones (keeps the topbar from
   crowding the nav buttons). */
.brand .logo-mark { display: none; }
@media (max-width: 640px) {
  .brand .logo-full { display: none; }
  .brand .logo-mark { display: block; }
}

/* ---- auth screen: two-column hero + sign-in card ---- */
.auth-screen-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 56px;
  align-items: center;
  max-width: 1180px;
  margin: 32px auto;
  padding: 0 28px;
}
@media (max-width: 900px) {
  .auth-screen-grid { grid-template-columns: 1fr; gap: 24px; }
}
/* Chat-first landing: auth lives in the top nav + a modal, so the grid is a
   single centered column with the chatbox as the hero. */
.auth-screen-grid--solo { grid-template-columns: 1fr; max-width: 720px; }

.hero { padding: 8px 0; }
.hero-eyebrow {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(99,102,241,0.10);
  border: 1px solid rgba(99,102,241,0.25);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #c7d2fe;
  margin-bottom: 18px;
}
.hero-title {
  font-size: 44px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0 0 14px;
}
.hero-title-grad {
  display: block;
  background: linear-gradient(135deg, #818cf8 0%, #60a5fa 50%, #22d3ee 100%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.hero-lede {
  font-size: 17px;
  line-height: 1.55;
  color: var(--text);
  margin: 0 0 24px;
  max-width: 56ch;
}
.hero-lede strong { color: #fff; }

.hero-feats {
  list-style: none;
  padding: 0;
  margin: 0 0 22px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.hero-feats li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--stroke-soft);
  font-size: 14px;
  line-height: 1.45;
}
.hero-feats .ico {
  font-size: 18px;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}
.hero-disclaimer {
  font-size: 12px;
  line-height: 1.5;
  padding-top: 14px;
  border-top: 1px solid var(--stroke-soft);
}

/* On wide screens, the sign-in card stays compact + sticky */
@media (min-width: 901px) {
  .auth-screen-grid .auth-card {
    max-width: 420px;
    width: 100%;
    align-self: start;
    position: sticky;
    top: 80px;
  }
}

/* ============================================================
   PRICING MODAL  (country-aware prices, language-aware copy)
   ============================================================ */
.pricing-modal {
  width: min(1040px, 94vw);
  max-height: 92vh;
  overflow-y: auto;
  padding: 26px 28px 30px;
}
.pricing-head { text-align: center; margin-bottom: 6px; position: relative; }
.pricing-head h2 { margin: 0 0 6px; font-size: 26px; }
.pricing-head p { margin: 0 auto; color: var(--muted); max-width: 620px; }
.pricing-close {
  position: absolute; top: -4px; inset-inline-end: -4px;
  width: 34px; height: 34px; border-radius: 8px;
  border: none; background: transparent;
  color: var(--muted); cursor: pointer; font-size: 20px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s ease, color .15s ease;
}
.pricing-close:hover { background: var(--pill-bg); color: var(--text); }
.pricing-toolbar {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  flex-wrap: wrap; margin: 16px 0 22px;
}
.pricing-toolbar .loc-note { color: var(--muted); font-size: 13px; }
.pricing-toolbar select {
  padding: 6px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.tier-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
}
@media (max-width: 760px) { .tier-grid { grid-template-columns: 1fr; } }
.tier-card {
  border: 1px solid var(--border); border-radius: 14px;
  padding: 22px 20px; background: var(--surface);
  display: flex; flex-direction: column; position: relative;
}
.tier-card.featured {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary), 0 18px 40px rgba(37,99,235,.18);
}
.tier-badge {
  position: absolute; top: -11px; inset-inline-start: 50%; transform: translateX(-50%);
  background: var(--primary); color: #fff; font-size: 11px; font-weight: 700;
  letter-spacing: .3px; padding: 3px 12px; border-radius: 999px; white-space: nowrap;
}
.tier-name { font-size: 18px; font-weight: 700; margin: 2px 0 2px; }
.tier-tagline { color: var(--muted); font-size: 13px; min-height: 34px; margin-bottom: 12px; }
.tier-price { font-size: 34px; font-weight: 800; line-height: 1; }
.tier-price .per { font-size: 14px; font-weight: 500; color: var(--muted); }
.tier-feats { list-style: none; padding: 0; margin: 16px 0 20px; display: grid; gap: 9px; }
.tier-feats li { display: flex; gap: 9px; align-items: flex-start; font-size: 14px; }
.tier-feats li::before { content: "✓"; color: var(--success); font-weight: 800; flex: 0 0 auto; }
.tier-card .tier-cta { margin-top: auto; width: 100%; }
.tier-card.featured .tier-cta { background: var(--primary); color: #fff; border-color: var(--primary); }
.pricing-vat { text-align: center; color: var(--muted); font-size: 12px; margin-top: 18px; }
[dir="rtl"] .tier-feats li { flex-direction: row; }

/* topbar pricing button */
#pricingNavBtn {
  background: transparent; border: 1px solid var(--border); color: var(--text);
  padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600;
}
#pricingNavBtn:hover { border-color: var(--primary); color: var(--primary); }

/* ---- billing badge (topbar) + trial-blocked banner ---- */
.billing-badge {
  font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px;
  background: var(--pill-bg); color: var(--pill-fg); white-space: nowrap;
  border: 1px solid transparent;
}
.billing-badge.warn { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.pricing-blocked {
  display: flex; flex-direction: column; gap: 2px; text-align: center;
  background: #fef3c7; color: #92400e; border: 1px solid #fde68a;
  border-radius: 10px; padding: 12px 16px; margin: 4px auto 18px; max-width: 560px;
}
.pricing-blocked strong { font-size: 15px; }
.pricing-blocked span { font-size: 13px; }
/* Inline "sign in to choose a plan" notice: informative (not warning) + a CTA. */
.pricing-authprompt {
  background: #eef2ff; color: #1e293b; border-color: #c7d2fe;
  gap: 10px; align-items: center;
}
.pricing-authprompt span { font-size: 14px; }
.pricing-authprompt #pricingAuthBtn {
  background: #141414; color: #ffffff; border: none; border-radius: 8px;
  padding: 9px 18px; font-weight: 600; font-size: 14px; cursor: pointer;
}
.pricing-authprompt #pricingAuthBtn:hover { background: #000000; }

/* ---- settings modal ---- */
#settingsBtn {
  background: transparent; border: none; color: var(--muted);
  width: 34px; height: 34px; border-radius: 8px; cursor: pointer; font-size: 17px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s ease, color .15s ease;
}
#settingsBtn:hover { background: var(--pill-bg); color: var(--text); }
.set-section {
  text-align: left; border-top: 1px solid var(--border); padding-top: 16px; margin-top: 18px;
}
.set-section h3 { margin: 0 0 12px; font-size: 15px; }
.set-section label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.set-section input {
  display: block; width: 100%; margin-top: 5px; padding: 9px 11px; box-sizing: border-box;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font-size: 14px;
}
.set-btn { padding: 9px 16px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.set-btn.danger { color: var(--danger); border: 1px solid var(--danger); background: transparent; }
.set-btn.danger:hover { background: var(--danger); color: #fff; }

/* ============================================================
   Auth screen polish — readable link, animated aurora, glass card
   (added 2026-06-15)
   ============================================================ */

/* Readable "Forgot password?" link in both light and dark */
#forgotLink {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 500;
}
#forgotLink:hover { filter: brightness(1.12); }
@media (prefers-color-scheme: dark) {
  #forgotLink { color: #ffffff; opacity: 0.85; }
  #forgotLink:hover { opacity: 1; filter: none; }
}

/* Clean, solid sign-in card — NO full-page gradient. The earlier "aurora"
   rendered as a harsh green wash on Windows/Linux browsers; a solid card looks
   identical on every platform. */
.auth-screen-grid .auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.12);
}
@media (prefers-color-scheme: dark) {
  .auth-screen-grid .auth-card {
    background: #161a22;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  }
}

/* First-run onboarding guide */
.guide-card { width: min(540px, 94vw); }
.guide-steps { list-style: none; padding: 0; margin: 16px 0 18px; display: grid; gap: 14px; }
.guide-steps li { display: flex; gap: 12px; align-items: flex-start; }
.guide-ico {
  font-size: 22px; flex-shrink: 0; width: 34px; height: 34px;
  display: grid; place-items: center; border-radius: 10px;
  background: rgba(99,102,241,0.12); border: 1px solid rgba(99,102,241,0.22);
}
.guide-steps strong { display: block; margin-bottom: 2px; font-size: 15px; }
.guide-steps p { margin: 0; font-size: 13.5px; color: var(--muted); line-height: 1.45; }

/* ============================================================
   FORMAL BLACK & WHITE THEME (Harvey-inspired) — 2026-06-15
   White surfaces, charcoal text, black accents, flat (no color gradients).
   Forces the formal light look regardless of system dark mode.
   Appended last so it overrides everything above.
   ============================================================ */
html { color-scheme: light; }

:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --border: #e7e7e3;
  --text: #1a1a18;
  --muted: #70706a;
  --primary: #141414;
  --primary-hover: #000000;
  --pill-bg: #f4f4f0;
  --pill-fg: #1a1a18;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.07);
  --grad-primary: #141414;
  --grad-accent: #141414;
  --glass: rgba(255,255,255,0.85);
  --glass-stroke: rgba(0,0,0,0.06);
  --ring: 0 0 0 3px rgba(0,0,0,0.12);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #ffffff; --surface: #ffffff; --border: #e7e7e3;
    --text: #1a1a18; --muted: #70706a; --primary: #141414; --primary-hover: #000000;
    --pill-bg: #f4f4f0; --pill-fg: #1a1a18;
    --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.07);
    --grad-primary: #141414; --grad-accent: #141414;
    --glass: rgba(255,255,255,0.85); --glass-stroke: rgba(0,0,0,0.06);
    --ring: 0 0 0 3px rgba(0,0,0,0.12);
  }
}

body { background: #ffffff; color: #1a1a18; }

/* Buttons — solid black, flat */
button.primary { background: #141414; color: #ffffff; box-shadow: none; }
button.primary:hover { background: #000000; filter: none; transform: none; }

/* Topbar — white with a thin rule */
.topbar { background: #ffffff; border-bottom: 1px solid #e7e7e3; }

/* Hero — charcoal text, no blue gradient */
.hero-title { color: #1a1a18; }
.hero-title-grad { background: none; -webkit-text-fill-color: #1a1a18; color: #1a1a18; }
.hero-lede, .hero-lede strong { color: #1a1a18; }
.hero-eyebrow { background: #f4f4f0; border-color: #e2e2dc; color: #3a3a36; }
.hero-feats li { background: #fafafa; border: 1px solid #ececea; }
.hero-disclaimer { border-top-color: #ececea; }

/* Sign-in card — clean white, no colored glow */
.auth-screen-grid { gap: 64px; }
.auth-screen-grid .auth-card { background: #ffffff; border: 1px solid #e7e7e3; box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 10px 30px rgba(0,0,0,.07); }
.auth-card::before { display: none; }

/* Forgot link — charcoal */
#forgotLink { color: #141414; opacity: 1; }
#forgotLink:hover { color: #000000; filter: none; }

/* Inputs — flat, formal */
input, select, textarea { background: #ffffff; border-color: #d9d9d4; color: #1a1a18; }

/* Footer — light */
.app-footer { background: #ffffff; border-top: 1px solid #e7e7e3; }

/* Formal B&W — fixes + graphics (2026-06-15) */
/* Flat white: kill the leftover color mesh + corner glows */
body::before, body::after { display: none !important; }
body { background: #ffffff !important; }
.empty-pick { background: #ffffff !important; }

/* "Welcome" heading was a white→indigo gradient text-fill (invisible on white) */
.auth-card h1 { background: none !important; -webkit-text-fill-color: #1a1a18 !important; color: #1a1a18 !important; }

/* Harvey-style "grounded in official sources" trust strip */
.hero-sources { margin: 24px 0 0; padding-top: 20px; border-top: 1px solid #ececea; }
.hero-sources-label { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: #8a8a82; margin: 0 0 12px; font-weight: 600; }
.hero-sources-row { display: flex; flex-wrap: wrap; gap: 12px 26px; align-items: center; }
.hero-sources-row span { font-size: 15px; font-weight: 600; color: #2a2a26; letter-spacing: -0.01em; }
.hero-sources-row span::after { content: ""; }

/* Clearer hero: plain value prop + "why not ChatGPT" reasoning */
.hero-title-accent { display: inline; color: #8a8a82; font-weight: 700; }
.hero-why { margin: 24px 0 4px; }
.hero-why-title { font-size: 13px; font-weight: 700; color: #1a1a18; margin: 0 0 12px; letter-spacing: -0.01em; }
.hero-why-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.hero-why-list li { font-size: 15px; line-height: 1.5; color: #44443e; padding-left: 28px; position: relative; }
.hero-why-list li::before { content: "✓"; position: absolute; left: 0; top: -1px; color: #141414; font-weight: 800; font-size: 16px; }
.hero-why-list strong { color: #1a1a18; font-weight: 700; }

/* Landing: stats band + "how it works" steps (formal B&W) */
.auth-landing { display: block; }
.landing-sections { max-width: 1180px; margin: 0 auto; padding: 4px 28px 64px; }
.landing-stats { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid #ececea; border-radius: 16px; overflow: hidden; background: #fff; }
.lstat { padding: 26px 20px; text-align: center; border-right: 1px solid #ececea; }
.lstat:last-child { border-right: none; }
.lstat-v { font-size: 30px; font-weight: 800; color: #141414; letter-spacing: -0.02em; line-height: 1.1; }
.lstat-l { font-size: 13px; color: #70706a; margin-top: 6px; line-height: 1.4; }
.landing-band { margin-top: 56px; }
.landing-h2 { font-size: 24px; font-weight: 700; color: #1a1a18; text-align: center; margin: 0 0 28px; letter-spacing: -0.02em; }
.landing-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.lstep { border: 1px solid #ececea; border-radius: 16px; padding: 26px 24px; background: #fff; }
.lstep-ico { width: 40px; height: 40px; color: #141414; display: grid; place-items: center; border: 1px solid #e7e7e3; border-radius: 11px; }
.lstep-ico svg { width: 22px; height: 22px; }
.lstep-n { font-size: 11px; font-weight: 700; color: #b3b3aa; margin: 16px 0 6px; letter-spacing: .12em; }
.lstep h3 { font-size: 17px; font-weight: 700; color: #1a1a18; margin: 0 0 7px; }
.lstep p { font-size: 14px; color: #55554e; line-height: 1.55; margin: 0; }
@media (max-width: 760px) {
  .landing-stats { grid-template-columns: repeat(2, 1fr); }
  .lstat:nth-child(2n) { border-right: none; }
  .lstat:nth-child(1), .lstat:nth-child(2) { border-bottom: 1px solid #ececea; }
  .landing-steps { grid-template-columns: 1fr; }
}

/* ============================================================
   MOBILE RESPONSIVE  — phones & small tablets  (v26)
   Makes the whole app comfortable to read + use on a phone.
   ============================================================ */
@media (max-width: 640px) {
  /* --- base spacing --- */
  .screen { padding: 16px 14px; }

  /* --- topbar: shrink, let it wrap gracefully instead of overflowing --- */
  .topbar { padding: 10px 12px; gap: 8px; flex-wrap: wrap; }
  .brand .logo-img { height: 26px; }
  .user-area { gap: 7px; row-gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
  .lang-select { max-width: 134px; font-size: 12px; padding: 5px 8px; }
  #pricingNavBtn, #logoutBtn, button { padding: 7px 11px; }
  #pricingNavBtn, #logoutBtn { font-size: 12.5px; }
  #userBadge { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* --- hero / landing: scale type + tighten spacing --- */
  .auth-screen-grid { margin: 14px auto; padding: 0 4px; gap: 18px; }
  .hero { padding: 0; }
  .hero-title { font-size: 30px; }
  .hero-lede { font-size: 15px; margin-bottom: 18px; }
  .hero-why { padding: 16px 16px; }
  .hero-sources-row { flex-wrap: wrap; gap: 8px 14px; }
  .landing-sections { padding: 4px 14px 40px; }
  .landing-band { margin-top: 40px; }
  .landing-h2 { font-size: 21px; margin-bottom: 20px; }
  .lstat { padding: 20px 12px; }
  .lstat-v { font-size: 24px; }
  .lstep { padding: 22px 18px; }

  /* --- auth card: full width, less chrome --- */
  .auth-screen-grid .auth-card { max-width: 100%; padding: 20px 18px; }
  .auth-card { margin: 14px auto; }

  /* --- forms: stack two-column rows, allow button rows to wrap --- */
  .grid-2 { grid-template-columns: 1fr; }
  .row.gap { flex-wrap: wrap; }
  .row.gap > button { flex: 1 1 auto; }

  /* --- case workspace --- */
  .case-layout { gap: 14px; }
  .chat-header { flex-wrap: wrap; gap: 8px; }
  .messages { max-height: 56vh; }
  .message .bubble { max-width: 90%; }

  /* --- pricing modal --- */
  .pricing-modal { padding: 18px 16px 22px; }
  .pricing-head h2 { font-size: 22px; }
  .pricing-toolbar { gap: 8px; }

  /* --- any modal that's taller than the screen can scroll --- */
  .modal-card { max-height: 90vh; overflow-y: auto; }
}

/* very small phones */
@media (max-width: 420px) {
  .hero-title { font-size: 26px; }
  .hero-title-accent { display: inline; }
  .lstat { padding: 16px 8px; }
  .lstat-v { font-size: 21px; }
  .lstat-l { font-size: 12px; }
  .lang-select { max-width: 116px; }
  #userBadge { display: none; }  /* free up the cramped topbar */
}

/* ============================================================
   SOCIAL LOGIN BUTTONS  (Google / Apple)
   ============================================================ */
.oauth-block { display: grid; gap: 10px; margin: 2px 0 4px; }
.oauth-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 11px 14px;
  border: 1px solid var(--border); border-radius: 10px;
  background: #fff; color: #1a1a18;
  font: inherit; font-weight: 600; font-size: 14.5px;
  text-decoration: none; cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
}
.oauth-btn:hover { background: #f6f6f4; border-color: #d8d8d2; }
.oauth-btn svg { width: 18px; height: 18px; flex: 0 0 auto; }
/* Apple's brand guidance: solid black button, white logo + text. */
.oauth-btn.oauth-apple { background: #000; color: #fff; border-color: #000; }
.oauth-btn.oauth-apple:hover { background: #1a1a1a; border-color: #1a1a1a; }
.oauth-divider {
  display: flex; align-items: center; gap: 12px;
  color: var(--muted); font-size: 11.5px; letter-spacing: .08em;
  text-transform: uppercase; margin: 8px 0 2px;
}
.oauth-divider::before, .oauth-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}

/* ============================================================
   AUTH CARD HEADING — small "Welcome", big bold value line
   ============================================================ */
.auth-card .auth-h1 { margin: 0 0 8px; line-height: 1.16; }
.auth-h1-pre {
  display: block; font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .12em;
  text-align: center;
  color: #9a9a92 !important; -webkit-text-fill-color: #9a9a92 !important;
  margin-bottom: 7px;
}
.auth-h1-strong {
  display: block; font-size: 28px; font-weight: 800; letter-spacing: -0.02em;
  line-height: 1.12;
  color: #141414 !important; -webkit-text-fill-color: #141414 !important;
}
.auth-sub { font-size: 14.5px; line-height: 1.55; margin: 8px 0 6px; color: #55554e; }

/* ============================================================
   SAMPLE OUTPUTS — "See a real example" CTA + document viewer
   ============================================================ */
.landing-sample-cta { text-align: center; margin-top: 32px; }
.landing-sample-cta button {
  background: #fff; border: 1px solid #141414; color: #141414;
  padding: 11px 22px; border-radius: 10px;
  font-weight: 700; font-size: 14.5px; cursor: pointer;
  transition: background .12s ease, color .12s ease;
}
.landing-sample-cta button:hover { background: #141414; color: #fff; }

.samples-modal {
  position: relative; width: min(720px, 94vw); max-height: 90vh;
  overflow-y: auto; padding: 26px 26px 24px; text-align: left;
}
.samples-close {
  position: absolute; top: 12px; inset-inline-end: 14px;
  width: 32px; height: 32px; border: none; background: transparent;
  font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer;
  border-radius: 8px;
}
.samples-close:hover { background: #f0f0ee; color: #1a1a18; }
.samples-title { font-size: 22px; font-weight: 800; margin: 0 6px 4px 0; color: #141414; }
.samples-sub { color: var(--muted); font-size: 14px; margin: 0 0 18px; }
.sample-sheet {
  position: relative; border: 1px solid #e7e7e3; border-radius: 12px;
  background: #fff; padding: 22px 22px 18px; margin-bottom: 16px;
  box-shadow: 0 8px 24px rgba(20, 20, 20, .05);
}
.sample-badge {
  position: absolute; top: 14px; inset-inline-end: 14px;
  font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: #9a9a92; border: 1px solid #e7e7e3; border-radius: 6px; padding: 3px 7px;
}
.sample-doc-kicker {
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: #b3b3aa; margin-bottom: 6px;
}
.sample-sheet h4 { font-size: 18px; font-weight: 800; color: #141414; margin: 0 0 10px; }
.sample-q {
  font-style: italic; color: #55554e;
  border-inline-start: 3px solid #e7e7e3; padding-inline-start: 12px; margin: 0 0 14px;
}
.sample-h {
  font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: #8a8a82; margin: 14px 0 4px;
}
.sample-sheet p { font-size: 14px; line-height: 1.55; color: #33332f; margin: 0 0 8px; }
.sample-sheet ul, .sample-sheet ol { margin: 4px 0 8px; padding-inline-start: 20px; }
.sample-sheet li { font-size: 14px; line-height: 1.5; color: #33332f; margin-bottom: 4px; }
.sample-sources { font-size: 12.5px !important; color: #5b5b53 !important; margin-top: 14px !important; line-height: 1.7 !important; }
.sample-sources a { color: #2456c7 !important; text-decoration: underline !important; text-underline-offset: 2px; }
.sample-sources a:hover { color: #173a8a !important; }
.samples-foot { font-size: 12px; color: var(--muted); line-height: 1.5; margin: 4px 0 0; }

/* ============================================================
   BUTTON CLARITY — v32  (every secondary control gets a real border)
   ============================================================ */
/* Ghost / secondary buttons — give them an obvious chip-look so they don't
   read as plain text links (this is what made Edit fields / Regenerate /
   Delete / Log out feel invisible against the white page). */
button.ghost,
.ghost {
  background: #fff;
  color: #1a1a18 !important;
  border: 1px solid #d8d8d2 !important;
  border-radius: 9px;
  font-weight: 600;
  padding: 8px 14px;
  transition: background .12s ease, border-color .12s ease;
}
button.ghost:hover,
.ghost:hover {
  background: #f6f6f4;
  border-color: #141414 !important;
}
button.ghost.danger,
.ghost.danger {
  color: #b91c1c !important;
  border-color: #f0c8c8 !important;
}
button.ghost.danger:hover,
.ghost.danger:hover {
  background: #fdf2f2;
  border-color: #b91c1c !important;
}

/* Log out button in the top bar — match the same chip style for clarity. */
#logoutBtn {
  background: #fff !important;
  color: #1a1a18 !important;
  border: 1px solid #d8d8d2 !important;
  font-weight: 600;
}
#logoutBtn:hover { background: #f6f6f4 !important; border-color: #141414 !important; }

/* Pricing in topbar — same clear chip. */
#pricingNavBtn {
  background: #fff;
  color: #1a1a18;
  border: 1px solid #d8d8d2;
  border-radius: 9px;
  font-weight: 600;
}
#pricingNavBtn:hover { background: #f6f6f4; border-color: #141414; color: #141414; }

/* Cases / Contracts switcher — make it an obvious pill toggle. */
.section-switch {
  background: #f3f3f1 !important;
  border: 1px solid #e7e7e3 !important;
  padding: 4px !important;
  border-radius: 11px !important;
  display: flex; gap: 4px;
}
.section-switch .seg {
  flex: 1;
  background: transparent !important;
  color: #55554e !important;
  font-weight: 700;
  padding: 9px 14px;
  border: 0 !important;
  border-radius: 8px !important;
  box-shadow: none !important;
}
.section-switch .seg:hover:not(.active) {
  background: rgba(20,20,20,0.04) !important;
  color: #1a1a18 !important;
}
.section-switch .seg.active {
  background: #141414 !important;
  color: #fff !important;
  box-shadow: 0 2px 6px rgba(20,20,20,0.18) !important;
}

/* Case / contract list rows — clear separators, hover affordance. */
.case-list li {
  border: 1px solid #ececea;
  background: #fff;
}
.case-list li:hover { background: #f7f7f5; border-color: #d8d8d2; }
.case-list li.active {
  background: #141414 !important;
  border-color: #141414 !important;
  color: #fff !important;
}
.case-list li.active .case-status { color: rgba(255,255,255,0.7) !important; }

/* ---------- Home (post-login) choice cards: Cases vs Contracts ---------- */
.home-pane { text-align: left; color: #1a1a18; }
.home-pane h2 { margin: 0 0 4px; font-size: 23px; color: #141414; }
.home-sub { margin: 0 0 20px; font-size: 15px; color: #6b6b63; }
.home-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 620px) { .home-cards { grid-template-columns: 1fr; } }
.home-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 7px;
  text-align: left; width: 100%;
  padding: 20px; border: 1px solid #e7e7e3; border-radius: 16px;
  background: #fff; cursor: pointer; font: inherit;
  transition: border-color .16s ease, transform .16s ease, box-shadow .16s ease;
}
.home-card:hover {
  border-color: #141414; transform: translateY(-2px);
  box-shadow: 0 10px 26px rgba(20,20,20,0.08);
}
.home-card:focus-visible { outline: 2px solid #141414; outline-offset: 2px; }
.home-card-ico {
  width: 42px; height: 42px; border-radius: 12px;
  background: #141414; color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 4px;
}
.home-card-ico svg { width: 22px; height: 22px; }
.home-card-title { font-size: 17px; font-weight: 700; color: #141414; }
.home-card-desc { font-size: 13.5px; line-height: 1.5; color: #55554e; }
.home-card-cta { margin-top: 6px; font-size: 13px; font-weight: 700; color: #141414; }
.home-card-cta::after { content: " \2192"; }
html[dir="rtl"] .home-card-cta::after { content: " \2190"; }
html[dir="rtl"] .home-pane, html[dir="rtl"] .home-card { text-align: right; align-items: flex-end; }

/* "Pick up where you left off": recent cases with a human status pill. */
.home-continue { margin-top: 24px; border-top: 1px solid #ececea; padding-top: 18px; }
.home-continue-title {
  margin: 0 0 10px; font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: #8a8a82;
}
.home-continue-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.home-continue-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; padding: 12px 14px; font: inherit; font-size: 14px; text-align: left;
  background: #fff; border: 1px solid #ececea; border-radius: 12px; cursor: pointer;
  transition: border-color .16s ease, background .16s ease;
}
.home-continue-row:hover { border-color: #141414; background: #fafaf8; }
.home-continue-name {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 600; color: #1a1a18;
}
.home-status-pill {
  flex: 0 0 auto; font-size: 11px; font-weight: 700; letter-spacing: .02em;
  padding: 4px 11px; border-radius: 999px;
  background: #f3f3f1; color: #55554e; border: 1px solid #e7e7e3;
  white-space: nowrap;
}
.home-status-pill.is-action { background: #141414; color: #fff; border-color: #141414; }
html[dir="rtl"] .home-continue-row { text-align: right; }

/* Contract / case header action row — give it breathing room + visible buttons. */
.chat-header { gap: 10px; }
.chat-header button + button { margin-inline-start: 0; }

/* Section toggle on small viewports stays full-width. */
@media (max-width: 640px) {
  .section-switch { width: 100%; }
}

/* ============================================================
   MOBILE AUTO-FIT v33 — kill horizontal scroll, clean topbar wrap
   ============================================================ */

/* Safety net: never let the page itself scroll sideways on phones. */
html, body { overflow-x: hidden; max-width: 100%; }

/* Make every grid/flex child shrinkable below its content width.
   This is the single biggest cause of "horizontal scroll on mobile":
   a child with min-width: auto refuses to shrink and pushes the parent
   wider than the viewport. */
.case-layout, .sidebar, .case-main, .chat-header,
.section-switch, .case-list, .row.gap {
  min-width: 0;
}

/* Long case / contract titles must wrap inside list rows. */
.case-list li,
.case-list li > div,
.chat-header h2,
.chat-header .muted,
#contractViewMeta {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* ---------- TOPBAR on phones ---------- */
@media (max-width: 640px) {
  /* Tighten everything so we don't need a second row in the first place. */
  .topbar { padding: 9px 12px; gap: 6px; }
  .user-area { gap: 6px; row-gap: 6px; }
  .brand .logo-img { height: 24px; }

  /* Compact controls — every saved pixel keeps Log out on the same row. */
  .lang-select { max-width: 110px; font-size: 11.5px; padding: 4px 6px; }
  #pricingNavBtn, #logoutBtn { font-size: 12px; padding: 6px 10px; }
  #settingsBtn { padding: 5px 8px; }
  .billing-badge { font-size: 10.5px; padding: 3px 7px; }
}

/* Very small phones (≤ 380px): hide non-critical chrome to keep one tidy row. */
@media (max-width: 400px) {
  /* User email already hidden at this width — also collapse Pricing to chip-only.
     The full Pricing dialog remains reachable from the settings gear. */
  #pricingNavBtn { display: none; }
  /* Make "Log out" an icon-only button so it never wraps to row 2. */
  #logoutBtn { font-size: 0; padding: 6px 9px; }
  #logoutBtn::after {
    content: "⎋"; font-size: 16px; line-height: 1;
    display: inline-block; transform: translateY(-1px);
  }
  /* Trim the language picker even further on tiny screens. */
  .lang-select { max-width: 86px; padding: 4px 4px; }
}

/* ---------- CASE / CONTRACT WORKSPACE on phones ---------- */
@media (max-width: 720px) {
  .screen { padding: 14px 12px; }

  /* Chat header: stack title block on top of action buttons so a long
     "#1 · Online Shopping & Consumer Protection — Package Marked…" can wrap
     to multiple lines and never overlap with "Close case". */
  .chat-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .chat-header > div:last-child { flex-wrap: wrap; }
  .chat-header h2 { font-size: 17px; line-height: 1.3; }

  /* Section toggle: keep buttons inline but allow them to shrink. */
  .section-switch .seg {
    flex: 1 1 0;
    min-width: 0;
    padding: 9px 6px;
    font-size: 13.5px;
  }
  .section-switch .seg span,
  .section-switch .seg { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* Case-list rows shrink to fit, with multi-line titles allowed. */
  .case-list li {
    padding: 10px 12px;
    line-height: 1.35;
  }
  .case-list li .case-status { display: inline-block; margin-top: 2px; }

  /* Messages bubbles can't push the page wider than the viewport. */
  .messages, .message, .message .bubble { max-width: 100%; }
  .message .bubble { word-break: break-word; }
}

/* Attention pulse on the "Generate report" button for a brand-new user who has
   not generated their first report yet. Runs continuously (set/cleared by
   renderCase) so the next step is never missed, not a fleeting one-time hint. */
@keyframes ctaPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(36, 86, 199, 0); }
  50%      { box-shadow: 0 0 0 6px rgba(36, 86, 199, 0.30); }
}
#generateBtn.cta-pulse {
  animation: ctaPulse 1.4s ease-in-out infinite;
  border-radius: 10px;
}
@media (prefers-reduced-motion: reduce) {
  #generateBtn.cta-pulse { animation: none; box-shadow: 0 0 0 4px rgba(36, 86, 199, 0.28); }
}

/* First-run coachmark above the Generate button: a persistent, unmissable callout
   that guides a brand-new user to generate their first report. Theme-aware. */
.firstrun-guide {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 0 0 12px;
  padding: 12px 14px;
  border: 1px solid var(--primary);
  /* Fallback tint for browsers without color-mix(); modern browsers use the line
     below it. Both read as a subtle primary wash over the surface. */
  background: rgba(37, 99, 235, 0.09);
  background: color-mix(in srgb, var(--primary) 12%, var(--surface));
  border-radius: 10px;
}
.firstrun-guide .firstrun-arrow { font-size: 20px; line-height: 1.3; }
.firstrun-guide p {
  margin: 0;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.45;
}

/* "Ready to generate" heading above the Generate report button, shown once intake
   is complete (the answer composer is hidden then, so this is the clear next step). */
.action-ready {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
#actionBar.actions { display: block; }
