/* ============================================================================
   LexDraft AI — clean light UI with a ChatGPT-style arrangement
   (sidebar + chat-first main). No dashboard.
   ========================================================================== */
:root {
  --bg: #ffffff;
  --bg-sidebar: #f7f7f8;
  --bg-elev: #f3f3f5;
  --bg-hover: #ececee;
  --bg-active: #e7e7ea;
  --border: #e4e4e7;
  --border-soft: #efeff1;
  --text: #1d1f23;
  --text-dim: #4b5058;
  --text-mute: #8a8f98;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0ff;
  --accent-2: #059669;
  --accent-grad: linear-gradient(135deg, #6366f1 0%, #4f46e5 50%, #7c3aed 100%);
  --danger: #dc2626;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.06);
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }

/* ---- Inline SVG icons (no emojis) ---- */
.ico { display: inline-grid; place-items: center; line-height: 0; }
.ico svg { width: 18px; height: 18px; display: block; }
.brand .ico { color: var(--accent); } .brand .ico svg { width: 20px; height: 20px; }
.auth-brand .ico { color: var(--accent); } .auth-brand .ico svg { width: 22px; height: 22px; }
.icon-btn .ico svg { width: 20px; height: 20px; }
.send-btn .ico svg { width: 18px; height: 18px; }
.quick-actions .ico svg { width: 16px; height: 16px; }
.lp-brand .logo { color: var(--accent); display: inline-grid; place-items: center; }
.lp-brand .logo svg { width: 22px; height: 22px; }
.lp-card .ico { color: var(--accent); } .lp-card .ico svg { width: 24px; height: 24px; }
.ok svg, .bad svg { width: 15px; height: 15px; vertical-align: -3px; }
.recent-list li .del svg { width: 15px; height: 15px; display: block; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #d4d4d8; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #b8b8bd; }
::-webkit-scrollbar-track { background: transparent; }

/* ============================ LANDING PAGE ============================ */
.landing { min-height: 100%; background:
  radial-gradient(1100px 520px at 50% -8%, rgba(99,102,241,.12), transparent 62%),
  linear-gradient(#ffffff, #fbfbfd); }

/* Nav */
.lp-nav { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; max-width: 1140px; margin: 0 auto; padding: 16px 24px; backdrop-filter: saturate(180%) blur(8px); }
.lp-brand { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 700; letter-spacing: .2px; }
.lp-brand .logo { font-size: 22px; }
.lp-brand span { background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lp-nav-mid { display: flex; gap: 28px; }
.lp-nav-mid a { font-size: 14px; color: var(--text-dim); font-weight: 500; }
.lp-nav-mid a:hover { color: var(--text); }
.lp-nav-links { display: flex; align-items: center; gap: 8px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: 999px; font-weight: 600; transition: .15s; }
.btn-ghost { color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); background: var(--bg-hover); }
.btn-primary { background: var(--text); color: #fff; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-grad { background: var(--accent-grad); color: #fff; }
.btn-grad:hover { transform: translateY(-1px); box-shadow: 0 10px 30px rgba(79,70,229,.28); }
.btn-light { background: #fff; color: var(--accent); }
.btn-light:hover { transform: translateY(-1px); box-shadow: 0 10px 30px rgba(0,0,0,.18); }
.btn-lg { padding: 14px 26px; font-size: 16px; }

/* Hero */
.lp-hero { max-width: 900px; margin: 0 auto; padding: 56px 24px 28px; text-align: center; }
.lp-eyebrow { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; margin-bottom: 24px; border: 1px solid var(--border); border-radius: 999px; font-size: 13px; color: var(--text-dim); background: #fff; box-shadow: var(--shadow); }
.lp-eyebrow .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent-2); box-shadow: 0 0 8px var(--accent-2); }
.lp-hero h1 { font-size: 60px; line-height: 1.04; margin: 0 0 20px; font-weight: 800; letter-spacing: -1.8px; }
.lp-hero h1 .grad { background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lp-hero p { font-size: 20px; color: var(--text-dim); margin: 0 auto 32px; max-width: 620px; line-height: 1.5; }
.lp-cta { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.lp-note { margin-top: 18px; font-size: 13px; color: var(--text-mute); }

/* Trust strip */
.lp-trust { max-width: 960px; margin: 16px auto 0; padding: 0 24px; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 14px; color: var(--text-mute); font-size: 13px; font-weight: 500; }
.lp-trust i { width: 4px; height: 4px; border-radius: 50%; background: var(--border); }

/* Product preview */
.lp-preview { max-width: 860px; margin: 40px auto 0; padding: 0 24px; }
.lp-window { border: 1px solid var(--border); border-radius: 18px; overflow: hidden; background: #fff; box-shadow: 0 30px 80px rgba(30,30,60,.12); }
.lp-window-bar { display: flex; align-items: center; gap: 7px; padding: 13px 16px; border-bottom: 1px solid var(--border-soft); }
.lp-window-bar i { width: 12px; height: 12px; border-radius: 50%; background: #e0e0e4; }
.lp-window-title { margin-left: 10px; font-size: 12px; color: var(--text-mute); }
.lp-window-body { padding: 26px; display: flex; flex-direction: column; gap: 14px; background: linear-gradient(#fff, #fafafb); }
.lp-msg { max-width: 80%; padding: 12px 16px; border-radius: 16px; line-height: 1.5; font-size: 14px; }
.lp-msg.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 5px; }
.lp-msg.ai { align-self: flex-start; background: var(--bg-elev); color: var(--text); border-bottom-left-radius: 5px; }

/* Generic section + heading */
.lp-section { max-width: 1140px; margin: 0 auto; padding: 76px 24px; }
.lp-tint { max-width: none; background: linear-gradient(180deg, #fafaff, #f4f5fb); border-top: 1px solid var(--border-soft); border-bottom: 1px solid var(--border-soft); }
.lp-tint > * { max-width: 1140px; margin-left: auto; margin-right: auto; }
.lp-head { text-align: center; max-width: 660px; margin: 0 auto 44px; }
.lp-kicker { display: inline-block; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--accent); margin-bottom: 12px; }
.lp-kicker.light { color: #c7d2fe; }
.lp-head h2 { font-size: 34px; margin: 0 0 12px; letter-spacing: -.6px; line-height: 1.15; }
.lp-head .sub { color: var(--text-dim); margin: 0; font-size: 17px; line-height: 1.5; }

/* How it works */
.lp-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.lp-step { background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.lp-step-n { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: var(--accent-grad); color: #fff; font-weight: 700; font-size: 17px; margin-bottom: 16px; }
.lp-step h3 { margin: 0 0 8px; font-size: 18px; }
.lp-step p { margin: 0; color: var(--text-dim); font-size: 14px; line-height: 1.6; }

/* Features grid */
.lp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }
.lp-card { background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 26px; transition: .2s; box-shadow: var(--shadow); }
.lp-card:hover { transform: translateY(-3px); box-shadow: 0 14px 40px rgba(30,30,60,.10); }
.lp-card .ico { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 13px; background: var(--accent-soft); margin-bottom: 16px; }
.lp-card h3 { margin: 0 0 8px; font-size: 18px; }
.lp-card p { margin: 0; color: var(--text-dim); font-size: 14px; line-height: 1.55; }

/* Use cases */
.lp-uc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.lp-uc { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 20px; transition: .15s; }
.lp-uc:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.lp-uc h4 { margin: 0 0 6px; font-size: 15px; }
.lp-uc p { margin: 0; font-size: 13px; color: var(--text-dim); }
.lp-uc-cta { background: var(--accent-soft); border-color: transparent; }
.lp-uc-cta h4 { color: var(--accent); }

/* Security band */
.lp-band { background: linear-gradient(135deg, #4f46e5, #6d28d9); color: #fff; }
.lp-band-inner { max-width: 1140px; margin: 0 auto; padding: 72px 24px; display: grid; grid-template-columns: 1.3fr 1fr; gap: 48px; align-items: center; }
.lp-band-text h2 { font-size: 34px; margin: 0 0 16px; letter-spacing: -.6px; }
.lp-band-text p { color: #e3e1ff; font-size: 16px; line-height: 1.6; margin: 0 0 26px; }
.lp-band-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.lp-bstat { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18); border-radius: 14px; padding: 20px; }
.lp-bstat strong { display: block; font-size: 26px; font-weight: 800; }
.lp-bstat span { font-size: 13px; color: #d6d8ff; }

/* Testimonials */
.lp-quotes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.lp-quote { margin: 0; background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 26px; box-shadow: var(--shadow); }
.lp-quote blockquote { margin: 0 0 18px; font-size: 15px; line-height: 1.6; color: var(--text); }
.lp-quote figcaption { display: flex; align-items: center; gap: 12px; }
.lp-avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-grad); color: #fff; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.lp-quote figcaption b { display: block; font-size: 14px; }
.lp-quote figcaption small { color: var(--text-mute); font-size: 12px; }

/* FAQ */
.lp-faq { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.lp-faq details { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 2px 20px; box-shadow: var(--shadow); }
.lp-faq summary { cursor: pointer; list-style: none; padding: 16px 0; font-weight: 600; font-size: 15px; display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.lp-faq summary::-webkit-details-marker { display: none; }
.lp-faq summary::after { content: '+'; color: var(--accent); font-size: 22px; font-weight: 400; line-height: 1; }
.lp-faq details[open] summary::after { content: '\2212'; }
.lp-faq p { margin: 0 0 18px; color: var(--text-dim); font-size: 14px; line-height: 1.6; }

/* Final CTA */
.lp-final { max-width: 1140px; margin: 0 auto; padding: 76px 24px; }
.lp-final-card { background: linear-gradient(135deg, #1e1b4b, #4338ca); border-radius: 22px; padding: 60px 32px; text-align: center; color: #fff; }
.lp-final-card h2 { font-size: 38px; margin: 0 0 14px; letter-spacing: -1px; }
.lp-final-card p { color: #cdd0ff; font-size: 18px; margin: 0 0 28px; }
.lp-final-card .btn-grad { background: #fff; color: var(--accent); }
.lp-final-card .btn-primary { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.4); }

@media (max-width: 900px) {
  .lp-nav-mid { display: none; }
  .lp-steps, .lp-quotes { grid-template-columns: 1fr; }
  .lp-uc-grid { grid-template-columns: repeat(2, 1fr); }
  .lp-band-inner { grid-template-columns: 1fr; gap: 28px; }
}
@media (max-width: 640px) {
  .lp-hero h1 { font-size: 42px; }
  .lp-hero p { font-size: 17px; }
  .lp-head h2, .lp-band-text h2, .lp-final-card h2 { font-size: 28px; }
  .lp-section { padding: 56px 20px; }
}

/* ============================ AUTH SCREEN ============================ */
.auth-screen { min-height: 100%; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(900px 460px at 50% -10%, rgba(99,102,241,.12), transparent 60%), linear-gradient(#fff, #fbfbfd); }
.auth-error { display: none; color: var(--danger); font-size: 13px; min-height: 18px; margin: 12px -4px 0; padding: 10px 14px; background: #fef2f2; border: 1px solid #fecaca; border-radius: 10px; line-height: 1.4; }
.auth-error.visible { display: block; }
.auth-card { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--border); border-radius: 18px; padding: 30px; box-shadow: var(--shadow); }
.auth-brand { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.auth-brand span { background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-sub { color: var(--text-mute); font-size: 14px; margin: 0 0 22px; }
.auth-tabs { display: flex; background: var(--bg-elev); border-radius: 10px; padding: 4px; margin-bottom: 18px; }
.auth-tab { flex: 1; padding: 9px; border-radius: 8px; color: var(--text-dim); font-weight: 600; font-size: 14px; }
.auth-tab.active { background: #fff; color: var(--text); box-shadow: var(--shadow); }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-mute); }
input, textarea, select {
  font: inherit; width: 100%; padding: 11px 13px; border-radius: 10px;
  background: #fff; border: 1px solid var(--border); color: var(--text);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.auth-form button[type=submit] { margin-top: 6px; padding: 12px; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 700; }
.auth-form button[type=submit]:hover { background: var(--accent-hover); }
.pw-wrap { display: flex; align-items: center; position: relative; }
.pw-wrap input { padding-right: 40px; }
.pw-toggle { position: absolute; right: 6px; width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center; color: var(--text-mute); }
.pw-toggle:hover { background: var(--bg-hover); color: var(--text); }
.pw-toggle svg { width: 16px; height: 16px; }
.pw-toggle.visible svg { display: none; }
.pw-toggle.visible::after { content: ''; position: absolute; width: 18px; height: 2px; background: currentColor; transform: rotate(45deg); }
.auth-back { display: inline-flex; align-items: center; gap: 6px; margin-top: 16px; color: var(--text-mute); font-size: 13px; }
.auth-back .ico svg { width: 14px; height: 14px; }
.auth-back:hover { color: var(--text); }

/* ============================ APP SHELL ============================ */
.shell { display: grid; grid-template-columns: 264px 1fr; height: 100vh; }
/* Collapsed = a slim icon rail: labels hidden (font-size:0), icons centered.
   The icons are fixed-px SVGs so they stay visible when the text collapses. */
.shell.collapsed { grid-template-columns: 64px 1fr; }
.shell.collapsed .sidebar { padding: 10px 8px; }
.shell.collapsed .sidebar-top { justify-content: center; }
.shell.collapsed #collapseBtn { display: none; }
.shell.collapsed .brand { gap: 0; font-size: 0; justify-content: center; }
.shell.collapsed .new-chat,
.shell.collapsed .side-item { justify-content: center; gap: 0; padding-left: 0; padding-right: 0; font-size: 0; }
.shell.collapsed .side-item .ico,
.shell.collapsed .new-chat .ico { opacity: 1; }
.shell.collapsed .side-section,
.shell.collapsed .recent-search,
.shell.collapsed .recent-list { display: none; }
.shell.collapsed .sidebar-bottom { margin-top: auto; }
.shell.collapsed .user-chip { justify-content: center; gap: 0; padding-left: 0; padding-right: 0; }
.shell.collapsed .user-meta { display: none; }

.sidebar { background: var(--bg-sidebar); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 10px; gap: 4px; min-width: 0; }
.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 12px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; }
.brand .logo { font-size: 18px; }
.brand span { background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.icon-btn { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; color: var(--text-dim); }
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }

.new-chat, .side-item {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  padding: 10px 11px; border-radius: 10px; color: var(--text); font-size: 14px; transition: .12s;
}
.new-chat { font-weight: 600; border: 1px solid var(--border); background: #fff; }
.new-chat:hover { background: var(--bg-hover); }
.side-item:hover { background: var(--bg-hover); }
.side-item.active { background: var(--accent-soft); color: var(--accent); }
.side-item .ico, .new-chat .ico { width: 18px; height: 18px; flex-shrink: 0; opacity: .85; }
.side-nav { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }

.side-section { padding: 16px 11px 6px; font-size: 12px; color: var(--text-mute); font-weight: 600; letter-spacing: .3px; }
.recent-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 1px; }
.recent-list li { display: flex; align-items: center; gap: 6px; padding: 9px 11px; border-radius: 9px; cursor: pointer; color: var(--text-dim); font-size: 14px; }
.recent-list li:hover { background: var(--bg-hover); color: var(--text); }
.recent-list li.active { background: var(--bg-active); color: var(--text); }
.recent-list li .ttl { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-list li .del { opacity: 0; color: var(--text-mute); font-size: 16px; padding: 0 4px; border-radius: 6px; }
.recent-list li:hover .del { opacity: 1; }
.recent-list li .del:hover { color: var(--danger); }
.recent-empty { padding: 10px 11px; color: var(--text-mute); font-size: 13px; }
.recent-search { margin: 2px 0 6px; }
.recent-search input { padding: 9px 12px; font-size: 13px; }

.sidebar-bottom { border-top: 1px solid var(--border); padding-top: 8px; margin-top: 4px; position: relative; }
.user-chip { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px; border-radius: 10px; }
.user-chip:hover { background: var(--bg-hover); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff; background: var(--accent-grad); flex-shrink: 0; }
.user-meta { display: flex; flex-direction: column; line-height: 1.2; text-align: left; overflow: hidden; }
.user-meta b { font-size: 14px; }
.user-meta small { font-size: 12px; color: var(--text-mute); }
.user-menu { position: absolute; bottom: 56px; left: 8px; right: 8px; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 6px; box-shadow: var(--shadow); }
.user-menu button { display: block; width: 100%; text-align: left; padding: 10px 12px; border-radius: 8px; font-size: 14px; }
.user-menu button:hover { background: var(--bg-hover); }

/* ============================ MAIN ============================ */
.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; border-bottom: 1px solid var(--border-soft); }
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-title { font-weight: 600; font-size: 15px; }
.ai-pill { font-size: 12px; color: var(--text-mute); border: 1px solid var(--border); padding: 4px 10px; border-radius: 999px; }

.view { flex: 1; min-height: 0; }
.panel { flex: 1; overflow-y: auto; padding: 28px 32px; }
.panel-wrap { max-width: 920px; margin: 0 auto; }
.panel h1 { font-size: 24px; margin: 0 0 6px; }
.panel .lead { color: var(--text-dim); margin: 0 0 22px; }

/* ---------- Chat view ---------- */
.chatview { display: flex; flex-direction: column; height: 100%; }
.chatview .chat-thread { flex: 1; overflow-y: auto; padding: 24px 0; }
.chat-thread-inner { max-width: 760px; margin: 0 auto; padding: 0 20px; display: flex; flex-direction: column; gap: 22px; }
.chatview.empty .chat-thread { display: none; }
.chatview.empty { justify-content: center; }
.chat-hero { text-align: center; padding: 0 20px 26px; }
.chat-hero h1 { font-size: 30px; font-weight: 600; margin: 0; }
.chatview.active .chat-hero { display: none; }

.composer-area { padding: 8px 20px 22px; }
.composer-area .inner { max-width: 760px; margin: 0 auto; }
.composer { display: flex; align-items: flex-end; gap: 8px; background: #fff; border: 1px solid var(--border); border-radius: 26px; padding: 8px 8px 8px 18px; box-shadow: var(--shadow); }
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer textarea { flex: 1; border: none; background: none; resize: none; padding: 8px 0; max-height: 200px; color: var(--text); font-size: 15px; line-height: 1.5; }
.composer textarea:focus { outline: none; box-shadow: none; }
.send-btn { width: 36px; height: 36px; border-radius: 50%; background: var(--text); color: #fff; display: grid; place-items: center; font-size: 17px; flex-shrink: 0; transition: .12s; }
.send-btn:hover { background: #000; }
.send-btn:disabled { background: #d4d4d8; color: #fff; cursor: default; }
.quick-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.chatview.active .quick-actions { display: none; }
.quick-actions button { display: inline-flex; align-items: center; gap: 8px; padding: 9px 15px; border: 1px solid var(--border); border-radius: 999px; color: var(--text-dim); font-size: 13px; background: #fff; }
.quick-actions button:hover { background: var(--bg-hover); color: var(--text); }
.composer-hint { text-align: center; color: var(--text-mute); font-size: 12px; margin-top: 10px; }

/* ---- New chat: centered hero + composer, document tiles below ---- */
/* Empty state centers the hero + composer as a group; the document tiles sit
   just below (first row visible, scroll for the rest). Once a chat is active the
   composer returns to the bottom and the tiles/hero hide. */
.new-hero { display: none; text-align: center; padding: 0 20px 2px; }
.chatview.empty .new-hero { display: block; order: -2; }
.new-hero h1 { font-size: 30px; font-weight: 600; margin: 0 0 6px; }
.new-hero p { color: var(--text-dim); margin: 0; font-size: 14px; }

.chatview.empty { justify-content: center; gap: 8px; }
.chatview.empty .composer-area { order: -1; }
.chatview.empty .draft-picker { order: 0; max-height: 46vh; overflow-y: auto; }
.chatview.active .draft-picker { display: none; }

.draft-picker { width: 100%; }

/* Category filter tabs */
.dp-tabs { position: sticky; top: 0; z-index: 2; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 820px; margin: 0 auto; padding: 4px 20px 14px; background: var(--bg); }
.dp-tab { padding: 8px 16px; border: 1px solid var(--border); border-radius: 999px; background: #fff; color: var(--text-dim); font-size: 13px; font-weight: 600; cursor: pointer; transition: .15s; }
.dp-tab:hover { background: var(--bg-hover); color: var(--text); }
.dp-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Grouped document grid */
.dp-doc-grid { max-width: 820px; margin: 0 auto; padding: 0 20px 28px; display: flex; flex-direction: column; gap: 16px; }
.dp-group-h { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-mute); margin: 0 0 8px 2px; }
.dp-doc-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.dp-doc { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: #fff; cursor: pointer; transition: border-color .12s ease, transform .12s ease, background .12s ease; }
.dp-doc:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow); }
.dp-doc.sel { border-color: var(--accent); background: var(--accent-soft); }
.dp-doc-t { font-size: 13px; font-weight: 500; color: var(--text); line-height: 1.3; }
.dp-doc-pill { max-width: 100%; font-size: 9.5px; font-weight: 700; letter-spacing: .2px; text-transform: uppercase; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 2px 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dp-error { margin-top: 12px; padding: 10px 12px; background: #fdeaea; color: var(--danger); border: 1px solid #f4c7c7; border-radius: 8px; font-size: 13px; }
.inline-err { margin-bottom: 10px; padding: 8px 12px; background: #fdeaea; color: var(--danger); border: 1px solid #f4c7c7; border-radius: 8px; font-size: 13px; }

/* ---- Draft rendering inside the thread ---- */
.msg.assistant .doc { max-width: 100%; width: 100%; background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 26px 30px; box-shadow: var(--shadow); line-height: 1.65; color: var(--text); }
.msg.assistant .doc h1 { font-size: 1.4rem; margin: 1.1em 0 .4em; font-weight: 600; }
.msg.assistant .doc h2 { font-size: 1.15rem; margin: 1em 0 .4em; font-weight: 600; }
.msg.assistant .doc h3 { font-size: 1rem; margin: .9em 0 .3em; font-weight: 600; }
.msg.assistant .doc > h1:first-child, .msg.assistant .doc > h2:first-child { margin-top: 0; }
.msg.assistant .doc p, .msg.assistant .doc li { margin: .5em 0; }
.msg.assistant .doc ul { margin: .4em 0 .4em 1.2em; }

/* ---- Draft action bar ---- */
.draft-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; padding: 10px 12px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px; }
.da-label { font-size: 13px; color: var(--text-dim); margin-right: auto; }
.da-btn { padding: 7px 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff; font-size: 13px; cursor: pointer; color: var(--text); }
.da-btn:hover { background: var(--bg-hover); }
.da-result { font-size: 12px; color: var(--text-dim); }
.draft-now { display: block; margin: 10px auto 0; background: none; border: none; color: var(--accent); text-decoration: underline; font-size: 13px; cursor: pointer; }

.msg { display: flex; flex-direction: column; gap: 6px; }
.msg.user { align-items: flex-end; }
.msg.assistant { align-items: flex-start; }
.msg .bubble { max-width: 80%; padding: 12px 16px; border-radius: 18px; line-height: 1.6; white-space: pre-wrap; word-wrap: break-word; font-size: 15px; }
.msg.user .bubble { background: var(--accent); color: #fff; border-bottom-right-radius: 5px; }
.msg.assistant .bubble { background: var(--bg-elev); color: var(--text); border-bottom-left-radius: 5px; }
.msg.pending .bubble { color: var(--text-mute); }
.msg .bubble.err { background: #fdeaea; color: var(--danger); }

/* ---------- Per-message actions (Copy / Edit) ---------- */
.msg-actions { display: flex; gap: 4px; opacity: 0; transition: opacity .12s ease; }
.msg:hover .msg-actions, .msg.editing .msg-actions { opacity: 1; }
.msg-act { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; font-size: 12px; color: var(--text-mute); background: transparent; border: 1px solid transparent; border-radius: 7px; cursor: pointer; line-height: 1; }
.msg-act:hover { background: var(--bg-elev); color: var(--text); }
.msg-act svg { width: 13px; height: 13px; }
.msg-act.copied { color: var(--accent); }
@media (hover: none) { .msg-actions { opacity: 1; } }

/* ---------- Inline message editor (Claude-style edit & resend) ---------- */
.msg-edit { width: 100%; max-width: 80%; display: flex; flex-direction: column; gap: 8px; }
.msg-edit-input { width: 100%; min-height: 60px; resize: none; padding: 12px 14px; border: 1px solid var(--border); border-radius: 14px; font: inherit; font-size: 15px; line-height: 1.6; background: #fff; color: var(--text); }
.msg-edit-input:focus { outline: none; border-color: var(--accent); }
.msg-edit-actions { display: flex; gap: 8px; justify-content: flex-end; }
.msg-edit-cancel, .msg-edit-save { padding: 7px 14px; border-radius: 9px; font-size: 13px; font-weight: 500; cursor: pointer; border: 1px solid var(--border); }
.msg-edit-cancel { background: #fff; color: var(--text); }
.msg-edit-save { background: var(--accent); color: #fff; border-color: var(--accent); }
.msg-edit-save:disabled { opacity: .6; cursor: default; }
.typing span { display: inline-block; width: 7px; height: 7px; margin-right: 3px; border-radius: 50%; background: var(--text-mute); animation: blink 1.2s infinite both; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }

/* ---------- Thinking trace (click the dots to read the reasoning) ---------- */
.think { align-self: flex-start; max-width: 760px; }
.think-toggle { display: inline-flex; align-items: center; gap: 8px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px 6px 14px; color: var(--text-mute); cursor: pointer; font-size: 12.5px; font-weight: 500; }
.think-toggle:hover { color: var(--text); background: var(--bg-hover); }
.think-dots { display: inline-flex; gap: 3px; }
.think-dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: blink 1.2s infinite both; }
.think-dots span:nth-child(2) { animation-delay: .2s; } .think-dots span:nth-child(3) { animation-delay: .4s; }
.think-caret svg { width: 14px; height: 14px; display: block; transition: transform .15s; }
.think.collapsed .think-caret svg { transform: rotate(-90deg); }
.think-body { margin: 8px 0 2px 4px; padding-left: 12px; border-left: 2px solid var(--border); color: var(--text-mute); font-size: 12.5px; line-height: 1.55; white-space: pre-wrap; max-height: 220px; overflow-y: auto; }
.think.collapsed .think-body { display: none; }
.think.pending .think-caret { display: none; }

/* ---------- Generate form ---------- */
.field { display: block; margin: 16px 0; font-size: 13px; color: var(--text-mute); }
.field select, .field textarea, .field input { margin-top: 6px; }
.interview { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 8px 0 4px; }
.interview .q { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-mute); }
.checkbox { display: flex; align-items: center; gap: 9px; margin: 14px 0; font-size: 14px; color: var(--text-dim); }
.checkbox input { width: auto; }
.btn-solid { background: var(--accent); color: #fff; padding: 12px 22px; border-radius: 10px; font-weight: 600; }
.btn-solid:hover { background: var(--accent-hover); }
.btn-solid:disabled { opacity: .5; cursor: default; }
.status { color: var(--text-mute); font-size: 14px; margin-top: 12px; }

/* ---------- Documents ---------- */
.split { display: grid; grid-template-columns: 300px 1fr; gap: 18px; }
.doclist { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; max-height: 70vh; overflow-y: auto; background: #fff; }
.doclist li { padding: 12px 14px; border-bottom: 1px solid var(--border-soft); cursor: pointer; }
.doclist li:hover { background: var(--bg-hover); }
.doclist li.active { background: var(--accent-soft); }
.doclist .t { font-weight: 600; font-size: 14px; }
.doclist .s { font-size: 12px; color: var(--text-mute); margin-top: 2px; }
.detail { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 18px; min-height: 220px; }
.detail.empty { color: var(--text-mute); display: grid; place-items: center; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.pill { font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--bg-elev); color: var(--text-dim); }
.pill.ai { background: rgba(5,150,105,.12); color: var(--accent-2); }
.chip-btn { font-size: 13px; padding: 6px 12px; border: 1px solid var(--border); border-radius: 8px; color: var(--text-dim); background: #fff; }
.chip-btn:hover { background: var(--bg-hover); color: var(--text); }
.docbody { white-space: pre-wrap; line-height: 1.7; max-height: 60vh; overflow-y: auto; background: #fcfcfd; padding: 18px; border: 1px solid var(--border-soft); border-radius: 10px; font-size: 14px; }

/* ---------- Clauses ---------- */
.search-bar { max-width: 420px; margin-bottom: 18px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.clause { background: #fff; border: 1px solid var(--border); border-radius: 13px; padding: 16px; box-shadow: var(--shadow); }
.clause h3 { margin: 0 0 4px; font-size: 15px; }
.clause .meta { font-size: 11px; color: var(--text-mute); margin-bottom: 10px; }
.clause .body { font-size: 13px; color: var(--text-dim); max-height: 130px; overflow: hidden; line-height: 1.5; }
.risk-high { color: var(--danger); } .risk-medium { color: #d97706; } .risk-low { color: var(--accent-2); }

/* ---- Clause library builder (two-panel) ---- */
.clauses-wrap { max-width: 1200px; }
.clause-builder { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.cl-library { min-width: 0; }
.cl-library .search-bar { max-width: none; width: 100%; margin-bottom: 12px; }

.cl-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.cl-filter { font-size: 12px; padding: 6px 11px; border: 1px solid var(--border); border-radius: 999px; background: #fff; color: var(--text-dim); cursor: pointer; }
.cl-filter:hover { background: var(--bg-hover); color: var(--text); }
.cl-filter.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.cl-list { display: flex; flex-direction: column; gap: 16px; max-height: calc(100vh - 230px); overflow-y: auto; padding-right: 4px; }
.cl-group-h { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--text-mute); margin: 0 0 8px; }
.cl-row { border: 1px solid var(--border); border-radius: 12px; background: #fff; margin-bottom: 8px; overflow: hidden; transition: border-color .12s, box-shadow .12s; }
.cl-row:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.cl-row.added { border-color: var(--accent); background: var(--accent-soft); }
.cl-row-main { padding: 12px 14px; cursor: pointer; }
.cl-row-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cl-row-title { font-weight: 600; font-size: 14px; color: var(--text); }
.cl-check { font-size: 12px; font-weight: 600; color: var(--accent); white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.cl-row-intent { font-size: 12.5px; color: var(--text-dim); margin-top: 4px; line-height: 1.45; }
.cl-variants { display: flex; gap: 6px; padding: 0 14px 12px; }
.cl-pill { font-size: 11.5px; padding: 5px 10px; border: 1px solid var(--border); border-radius: 999px; background: #fff; color: var(--text-dim); cursor: pointer; }
.cl-pill:hover { background: var(--bg-hover); color: var(--text); }
.cl-pill.active { background: var(--text); border-color: var(--text); color: #fff; }
.cl-ico svg { width: 14px; height: 14px; display: inline-block; vertical-align: middle; }

.cl-canvas { position: sticky; top: 0; border: 1px solid var(--border); border-radius: 14px; background: var(--bg-elev); padding: 14px; min-width: 0; }
.cl-canvas-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.cl-canvas-count { font-weight: 600; font-size: 14px; }
.cl-canvas-actions { display: flex; gap: 6px; }
.cl-canvas-doc { max-height: calc(100vh - 260px); overflow-y: auto; margin-top: 10px; display: flex; flex-direction: column; gap: 12px; }
.cl-canvas-empty { color: var(--text-mute); font-size: 14px; text-align: center; padding: 50px 16px; border: 1px dashed var(--border); border-radius: 12px; background: #fff; }
.cl-canvas-item { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.cl-canvas-item-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.cl-canvas-item-title { font-weight: 600; font-size: 14px; flex: 1; }
.cl-canvas-tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.cl-canvas-item-actions { display: inline-flex; gap: 2px; }
.cl-canvas-item-actions button { width: 26px; height: 26px; border-radius: 7px; color: var(--text-mute); display: grid; place-items: center; font-size: 15px; }
.cl-canvas-item-actions button:hover { background: var(--bg-hover); color: var(--text); }
.cl-canvas-item-actions .cl-del:hover { color: var(--danger); }
.cl-canvas-item-body { font-size: 13px; line-height: 1.6; color: var(--text-dim); white-space: pre-wrap; }

@media (max-width: 900px) {
  .clause-builder { grid-template-columns: 1fr; }
  .cl-canvas { position: static; }
  .cl-list, .cl-canvas-doc { max-height: none; }
}

/* ---------- Audit ---------- */
.audit { width: 100%; border-collapse: collapse; font-size: 13px; }
.audit th, .audit td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border-soft); }
.audit th { color: var(--text-mute); font-weight: 600; }
.audit td.hash { font-family: monospace; font-size: 11px; color: var(--text-mute); }
.verify-row { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.ok { color: var(--accent-2); } .bad { color: var(--danger); }

@media (max-width: 820px) {
  .shell, .shell.collapsed { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 40; width: 264px; height: 100vh; padding: 10px; overflow: auto; box-shadow: 0 0 40px rgba(0,0,0,.18); }
  /* On mobile the sidebar is a fixed overlay — hide it entirely when collapsed. */
  .shell.collapsed .sidebar { display: none; }
  .split { grid-template-columns: 1fr; }
  .interview { grid-template-columns: 1fr; }
  .lp-footer-inner { grid-template-columns: 1fr; }
}

/* ============================ VERIFY PAGE ============================ */
.verify-screen { min-height: 100%; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(900px 460px at 50% -10%, rgba(99,102,241,.12), transparent 60%), linear-gradient(#fff, #fbfbfd); }
.verify-card { width: 100%; max-width: 440px; background: #fff; border: 1px solid var(--border); border-radius: 18px; padding: 40px 32px 32px; box-shadow: 0 4px 30px rgba(0,0,0,.06); text-align: center; }
.verify-icon { display: inline-flex; align-items: center; justify-content: center; width: 64px; height: 64px; border-radius: 50%; background: var(--accent-soft); margin-bottom: 20px; }
.verify-icon svg { width: 30px; height: 30px; color: var(--accent); }
.verify-card h1 { font-size: 24px; margin: 0 0 10px; font-weight: 700; }
.verify-sub { color: var(--text-dim); font-size: 15px; line-height: 1.55; margin: 0 0 24px; }
.verify-actions { margin-bottom: 18px; }
.verify-actions .btn { padding: 12px 28px; font-size: 15px; }
.verify-hint { color: var(--text-mute); font-size: 13px; margin: 0 0 18px; }
.verify-back { display: inline-flex; align-items: center; gap: 6px; color: var(--text-mute); font-size: 13px; }
.verify-back .ico svg { width: 14px; height: 14px; }
.verify-back:hover { color: var(--text); }

/* ============================ LANDING FOOTER (light) ============================ */
.lp-footer { background: var(--bg-sidebar); border-top: 1px solid var(--border); padding: 56px 24px 0; }
.lp-footer-inner { max-width: 1140px; margin: 0 auto; display: grid; grid-template-columns: 1.8fr 1fr 1fr 1fr; gap: 40px; }
.lp-footer-brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 12px; }
.lp-footer-brand .logo { color: var(--accent); display: inline-grid; place-items: center; }
.lp-footer-brand .logo svg { width: 20px; height: 20px; }
.lp-footer-desc { font-size: 14px; line-height: 1.6; color: var(--text-dim); margin: 0; max-width: 320px; }
.lp-footer-col h4 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-mute); margin: 0 0 14px; }
.lp-footer-col a, .lp-footer-disabled { display: block; padding: 5px 0; font-size: 14px; color: var(--text-dim); }
.lp-footer-col a:hover { color: var(--accent); }
.lp-footer-disabled { opacity: .5; cursor: default; }
.lp-footer-bottom { max-width: 1140px; margin: 40px auto 0; padding: 22px 0; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-mute); text-align: center; }

@media (max-width: 640px) { .lp-footer-inner { grid-template-columns: 1fr 1fr; gap: 28px; } }
