/* LexRadix - app styles. Tokens first; dark mode swaps tokens only.
   <html data-theme> is set before first paint by the inline script in index.html (OS default or saved choice). */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #17202a;
  --muted: #5b6673;
  --line: #e2e6eb;
  --brand: #0f6b5c;
  --brand-hover: #0b5a4d;
  --brand-ink: #ffffff;
  --brand-soft: #e3f2ee;
  --accent: #b86e00;
  --accent-ink: #ffffff;
  --accent-soft: #fdf3e1;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --ok: #177245;
  --ok-soft: #e6f4ec;
  --warn: #8a5a00;
  --warn-soft: #fff4d6;
  --info: #1d4ed8;
  --info-soft: #e8efff;
  --ins: #d9f2e3;
  --del: #fbe0dd;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", sans-serif;
  --paper-font: "Times New Roman", Times, "Noto Serif Devanagari", "Nirmala UI", serif;
  --wrap: 1180px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1418;
  --surface: #161d22;
  --surface-2: #1d262c;
  --text: #e7ecef;
  --muted: #9aa7b1;
  --line: #2a353c;
  --brand: #2fb39a;
  --brand-hover: #3fc6ac;
  --brand-ink: #06201b;
  --brand-soft: #123a33;
  --accent: #e4a23a;
  --accent-ink: #2a1a00;
  --accent-soft: #3a2c12;
  --danger: #f2867c;
  --danger-soft: #3b1a17;
  --ok: #58c58c;
  --ok-soft: #14301f;
  --warn: #e6b84a;
  --warn-soft: #352a10;
  --info: #8fb0ff;
  --info-soft: #18233f;
  --ins: #1d4030;
  --del: #4a2420;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .3);
}
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.55 var(--font); min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; outline: none; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.3rem; margin-top: 1.2em; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: .9em; }
[hidden] { display: none !important; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 16px; }
.page { padding-top: 24px; padding-bottom: 48px; }
.narrow { max-width: 720px; }
.page-head { margin-bottom: 16px; }
.page-head h1 { margin-bottom: 4px; }
.row { display: flex; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; gap: 12px; }
.row.gap { gap: 8px; }
.row.end { justify-content: flex-end; }
.row > input, .row > select { flex: 1; min-width: 0; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.err-text { color: var(--danger); }
.warn-text { color: var(--warn); }
.eyebrow { text-transform: uppercase; letter-spacing: .06em; font-size: .78rem; font-weight: 600; color: var(--brand); margin-bottom: 8px; }
.lead { font-size: 1.1rem; color: var(--muted); }
.section { margin-top: 32px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; }

/* ---------- buttons & controls ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none !important; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: var(--brand-hover); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 5px 10px; font-size: .85rem; }
.btn.lg { padding: 12px 20px; font-size: 1.02rem; }
.btn.block { width: 100%; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: var(--radius-sm); border: 0; background: transparent; color: var(--text); cursor: pointer; font-size: 1rem; }
.icon-btn:hover { background: var(--surface-2); }

input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 11px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .icon-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
input.invalid, textarea.invalid, select.invalid { border-color: var(--danger); }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--brand); }
.lbl { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .9rem; margin-bottom: 12px; }
.lbl input, .lbl select, .lbl textarea { font-weight: 400; }
.lbl small { font-weight: 400; }
.req { color: var(--danger); }
.field-err { color: var(--danger); font-size: .8rem; font-weight: 400; min-height: 0; }
.check, .radio { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; margin: 6px 0; }
.check input, .radio input { margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .span2 { grid-column: 1 / -1; }
fieldset { border: 0; padding: 0; margin: 0 0 18px; }
legend { font-weight: 600; margin-bottom: 6px; }

/* ---------- badges, notes, cards ---------- */

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.note { background: var(--brand-soft); border-radius: var(--radius-sm); padding: 10px 12px; margin: 10px 0; }
.note.warn { background: var(--warn-soft); color: var(--warn); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.empty { text-align: center; padding: 32px 16px; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.grid.three { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.grid .card { margin: 0; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: 12px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .85rem; margin: 18px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.svc-card, .tpl-card { display: flex; gap: 14px; color: var(--text); text-decoration: none !important; transition: border-color .15s, transform .15s; }
.svc-card:hover, .tpl-card:hover { border-color: var(--brand); transform: translateY(-1px); }
.svc-card h3, .tpl-card h3 { margin-bottom: 4px; }
.svc-icon, .tpl-icon { flex: none; width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); font-size: 1.1rem; }
.tpl-icon { background: var(--accent-soft); color: var(--accent); }
.svc-icon.lg { width: 60px; height: 60px; font-size: 1.5rem; }
.svc-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 6px; }
.price { font-weight: 700; color: var(--text); }
.price-old { color: var(--muted); font-weight: 400; }
.attach-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 6px 0; }
.attach-row label.btn { cursor: pointer; }
.attach-row label.btn.disabled { opacity: .5; pointer-events: none; }
.plan-card .plan-price { font-size: 1.6rem; margin: 6px 0 2px; }
.plan-card .plan-price .price-old { font-size: 1rem; }
.plan-card ul { margin: 12px 0 0; padding-left: 18px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 16px 0; }
.toolbar > input[type="search"] { max-width: 280px; }
.toolbar > select { width: auto; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.pills button { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: .85rem; cursor: pointer; }
.pills button.active { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

.tbl-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th, .tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td input, .tbl td select { padding: 5px 8px; font-size: .85rem; }

.list { list-style: none; padding: 0; margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list.compact { border: 0; background: none; margin-bottom: 12px; }
.list.compact li { padding: 6px 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 8px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; }
.stat span { color: var(--muted); font-size: .85rem; }
.stat b { font-size: 1.6rem; }
.stat small { color: var(--muted); }

.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- header / footer ---------- */

.demo-bar { background: var(--warn-soft); color: var(--warn); text-align: center; font-size: .82rem; padding: 6px 16px; }
.site-head { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
.head-row { display: flex; align-items: center; gap: 16px; min-height: 60px; }
.logo { font-size: 1.25rem; color: var(--text); display: inline-flex; align-items: center; gap: 8px; text-decoration: none !important; }
.logo b { color: var(--brand); }
.logo-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--brand); color: var(--brand-ink); font-weight: 800; font-size: .9rem; }
.nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.nav a:not(.btn) { color: var(--text); padding: 8px 12px; border-radius: var(--radius-sm); font-weight: 500; text-decoration: none; }
.nav a:not(.btn):hover { background: var(--surface-2); }
.nav a.active { color: var(--brand); background: var(--brand-soft); }
.nav-user { color: var(--muted); font-size: .85rem; padding: 0 8px; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-toggle { display: none; margin-left: auto; }
.head-tools { display: flex; align-items: center; gap: 2px; }
.dev-form { display: grid; gap: 12px; }
.dev-form label { display: grid; gap: 4px; font-weight: 500; }
.dev-form small { font-weight: 400; }

.site-foot { background: var(--surface); border-top: 1px solid var(--line); padding: 32px 0 16px; margin-top: 32px; }
.foot-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 24px; }
.foot-grid > div { display: flex; flex-direction: column; gap: 6px; }
.foot-grid a { color: var(--muted); font-size: .9rem; }
.foot-note { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); }
body.wide .site-foot, body.wide .demo-bar { display: none; }

/* ---------- home ---------- */

.hero { background: linear-gradient(180deg, var(--brand-soft), var(--bg)); padding: 56px 0 40px; }
.hero h1 { font-size: 2.6rem; max-width: 760px; }
.hero h1 span { color: var(--brand); }
.hero .lead { max-width: 640px; }
.search-box { position: relative; max-width: 680px; margin: 22px 0 12px; }
.search-box > i { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-box input { padding: 15px 16px 15px 44px; font-size: 1.05rem; border-radius: var(--radius); box-shadow: var(--shadow); }
.search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); z-index: 20; overflow: hidden; }
.sr { display: flex; gap: 12px; align-items: flex-start; padding: 10px 14px; color: var(--text); border-bottom: 1px solid var(--line); text-decoration: none !important; }
.sr:hover { background: var(--surface-2); }
.sr > i { color: var(--brand); margin-top: 4px; }
.sr span { display: flex; flex-direction: column; }
.sr small { color: var(--muted); }
.sr.none { display: block; color: var(--muted); }
.hero-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.hero-tags a { background: var(--surface); border: 1px solid var(--line); padding: 4px 12px; border-radius: 999px; font-size: .85rem; color: var(--text); }

.doors { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 8px; }
.door { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 26px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); color: var(--text); text-decoration: none !important; }
.door > i { font-size: 1.8rem; color: var(--brand); }
.door.alt > i { color: var(--accent); }
.door h2 { margin: 6px 0 0; }
.door p { color: var(--muted); }
.door small { color: var(--muted); }
.door:hover { border-color: var(--brand); }

.steps { list-style: none; counter-reset: s; display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; padding: 0; }
.steps li { counter-increment: s; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 4px; }
.steps li::before { content: counter(s); width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-weight: 700; }
.steps span { color: var(--muted); font-size: .9rem; }
.promise { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.promise div { display: flex; flex-direction: column; gap: 4px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.promise i { color: var(--brand); font-size: 1.2rem; }
.promise span { color: var(--muted); font-size: .88rem; }
.cta { background: var(--brand); color: var(--brand-ink); margin-top: 40px; padding: 32px 0; }
.cta .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.cta h2 { margin: 0 0 4px; }
.cta p { margin: 0; opacity: .9; }

/* ---------- detail pages ---------- */

.detail { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.detail-side { position: sticky; top: 76px; }
.detail-head { display: flex; gap: 16px; align-items: flex-start; }
.ticks { list-style: none; padding: 0; }
.ticks li { padding-left: 26px; position: relative; margin: 6px 0; }
.ticks li::before { content: "\f00c"; font-family: "Font Awesome 6 Free"; font-weight: 900; position: absolute; left: 0; color: var(--ok); }
.muted-ticks li::before { content: "\f073"; font-weight: 400; color: var(--muted); }
.docs-list { list-style: none; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.docs-list li { display: flex; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; }
.docs-list li i { color: var(--brand); margin-top: 3px; }
.docs-list small { display: block; }
.timeline { list-style: none; padding: 0; counter-reset: t; }
.timeline li { counter-increment: t; position: relative; padding: 0 0 14px 40px; }
.timeline li::before { content: counter(t); position: absolute; left: 0; top: -2px; width: 26px; height: 26px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
.timeline li:not(:last-child)::after { content: ""; position: absolute; left: 12px; top: 26px; bottom: 2px; width: 2px; background: var(--line); }
.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 8px; }
.faq summary { font-weight: 600; cursor: pointer; }
.faq p { margin: 8px 0 0; color: var(--muted); }
.price-card h3 { margin-bottom: 12px; }
.price-tbl { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: .92rem; }
.price-tbl td { padding: 5px 0; }
.price-tbl td:last-child { text-align: right; white-space: nowrap; }
.price-tbl tr.total td { border-top: 1px solid var(--line); padding-top: 10px; font-weight: 700; font-size: 1.05rem; }
.price-card .btn { margin-top: 8px; }
.result { margin-top: 16px; border-color: var(--brand); }

.ai-finder label { display: block; margin-bottom: 8px; }
.ai-finder label i { color: var(--accent); }
.finder-hit { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; padding: 12px; background: var(--surface-2); border-radius: var(--radius-sm); }
.finder-hit > div { flex: 1; min-width: 200px; }
.finder-hit p { margin: 0; }

.login { max-width: 440px; margin: 24px auto; }

/* ---------- orders ---------- */

.progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-bottom: 14px; }
.progress span { display: block; height: 100%; background: var(--brand); }
.tracker { list-style: none; padding: 0; margin: 0; }
.tracker li { display: flex; justify-content: space-between; gap: 8px; padding: 7px 0 7px 30px; position: relative; color: var(--muted); }
.tracker li::before { content: ""; position: absolute; left: 4px; top: 11px; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); }
.tracker li.done { color: var(--text); }
.tracker li.done::before { background: var(--ok); border-color: var(--ok); }
.files { list-style: none; padding: 0; margin: 0; }
.files li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.files li:last-child { border-bottom: 0; }
.files .right { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.expert { display: flex; gap: 12px; align-items: center; }
.avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-weight: 700; }
.thread { max-height: 340px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.msg { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; max-width: 92%; font-size: .9rem; }
.msg small { display: block; color: var(--muted); font-size: .72rem; margin-top: 2px; }
.msg.me { align-self: flex-end; background: var(--brand-soft); }
.detail-side .card select { margin-bottom: 8px; }

/* ---------- consult ---------- */

.pick { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; cursor: pointer; font: inherit; color: var(--text); }
.pick i { color: var(--brand); font-size: 1.3rem; }
.pick.active { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand); }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; margin: 12px 0; }
.slots button { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-sm); padding: 8px; cursor: pointer; font: inherit; color: var(--text); }
.slots button.active { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }

/* ---------- admin ---------- */

.admin-tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.admin-tabs a { padding: 10px 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; text-decoration: none; }
.admin-tabs a.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
/* live admin tabs (views/admin_settings.js) */
.task-checks { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 12px; margin: 4px 0 12px; }
.task-checks legend { font-weight: 600; font-size: .9rem; padding: 0 4px; }
.tbl td input[type="number"] { width: 130px; }
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); }
.notes { list-style: none; padding: 0; margin: 0 0 10px; }
.notes li { background: var(--warn-soft); border-radius: var(--radius-sm); padding: 8px 10px; margin-bottom: 6px; font-size: .9rem; }
.notes small { display: block; }

/* ---------- modal, toast ---------- */

.modal-wrap { position: fixed; inset: 0; background: rgba(10, 15, 20, .5); display: grid; place-items: center; padding: 16px; z-index: 100; }
.modal { background: var(--surface); border-radius: var(--radius); width: 100%; max-width: 480px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.modal.wide { max-width: 820px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
#toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 200; width: min(460px, calc(100vw - 32px)); }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: var(--radius-sm); box-shadow: var(--shadow); font-size: .9rem; animation: up .2s ease-out; }
.toast.ok { background: var(--ok); color: #fff; }
.toast.error { background: var(--danger); color: #fff; }
.toast.warn { background: var(--warn); color: #fff; }
@keyframes up { from { opacity: 0; transform: translateY(8px); } }

/* ---------- AI review diff ---------- */

.change { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 10px; }
.change > .check { font-weight: 600; margin: 0 0 6px; }
.diff { white-space: pre-wrap; font-family: var(--paper-font); font-size: 1rem; line-height: 1.6; background: var(--surface-2); padding: 10px; border-radius: 6px; }
.diff-title { font-weight: 700; margin-bottom: 6px; }
ins { background: var(--ins); text-decoration: none; }
del { background: var(--del); text-decoration: line-through; opacity: .85; }
ins.block, del.block { display: block; padding: 4px 6px; border-radius: 4px; margin: 4px 0; white-space: pre-wrap; }

/* ---------- editor ---------- */

body.wide main { display: flex; flex-direction: column; }
.ed { display: flex; flex-direction: column; height: calc(100vh - 61px); height: calc(100dvh - 61px); position: relative; }
.ed-top { display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.ed-name { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ed-name strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ed-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.ed-tabs { display: none; }
.ed-main { flex: 1; display: grid; grid-template-columns: 340px minmax(0, 1fr); min-height: 0; }
.ed-left { overflow-y: auto; background: var(--surface); border-right: 1px solid var(--line); padding: 12px 14px 24px; }
.ed-right { overflow-y: auto; padding: 18px 24px 40px; background: var(--surface-2); }
.ed-right > .note { max-width: 820px; margin: 0 auto 10px; }

.fgroup { border-bottom: 1px solid var(--line); padding: 6px 0 10px; }
.fgroup summary { font-weight: 700; cursor: pointer; padding: 6px 0; font-size: .9rem; color: var(--brand); }
.field { margin: 8px 0; }
.field-label { display: flex; justify-content: space-between; align-items: center; font-size: .82rem; font-weight: 600; margin-bottom: 3px; }
.field input, .field select, .field textarea { padding: 7px 9px; font-size: .9rem; }
.mini { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 2px 4px; border-radius: 4px; }
.mini:hover { color: var(--brand); background: var(--brand-soft); }
.left-foot { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }

.paper {
  max-width: 820px; margin: 0 auto; background: #fff; color: #111; min-height: 1000px;
  padding: 64px 72px; box-shadow: 0 2px 10px rgba(0, 0, 0, .12); border-radius: 2px;
  font-family: var(--paper-font); font-size: 16.5px; line-height: 1.7;
  background-repeat: repeat; background-position: center top; /* watermark set from config in editor.js */
}
.paper [contenteditable="true"] { outline: none; border-radius: 3px; }
.paper [contenteditable="true"]:focus { background: rgba(207, 227, 255, .25); box-shadow: 0 0 0 2px #cfe3ff; }
.doc-title { text-align: center; font-size: 1.35rem; text-transform: uppercase; letter-spacing: .03em; margin-bottom: 1.2em; text-decoration: underline; text-underline-offset: 5px; text-decoration-thickness: 1px; }
.clause { position: relative; margin: 0 0 1em; display: flex; gap: 8px; }
.clause:hover { background: rgba(0, 0, 0, .025); box-shadow: 0 0 0 6px rgba(0, 0, 0, .025); }
.clause .num { flex: none; font-weight: 700; min-width: 1.6em; }
.clause-content { flex: 1; min-width: 0; }
.clause-title { font-weight: 700; }
.clause:not(.titled) .clause-title:not(:focus) { display: none; }
.clause:not(.titled):hover .clause-title { display: block; color: #999; font-weight: 400; font-size: .8em; }
.clause-title:empty::before, .doc-title:empty::before { content: attr(data-ph); color: #aaa; }
.clause-body { white-space: pre-wrap; word-wrap: break-word; text-align: justify; }
.clause-tools { position: absolute; right: -8px; top: -14px; display: none; gap: 2px; background: #fff; border: 1px solid #ddd; border-radius: 6px; padding: 2px; box-shadow: 0 2px 6px rgba(0, 0, 0, .1); z-index: 2; font-family: var(--font); }
.clause:hover .clause-tools, .clause:focus-within .clause-tools { display: flex; }
.clause-tools button { border: 0; background: none; color: #555; cursor: pointer; padding: 4px 7px; border-radius: 4px; font-size: .8rem; }
.clause-tools button:hover { background: #eef6f4; color: #0f6b5c; }
.chip { background: #e3f2ee; color: #0b5a4d; border-radius: 3px; padding: 0 3px; cursor: pointer; border-bottom: 1px dashed #0f6b5c; }
.chip.empty { background: #fff4d6; color: #8a5a00; border-bottom-color: #b86e00; font-style: italic; }
/* Professional layout (rules in js/editor/layout.js). Shared by editor paper and PDF. */
.clause-body .ln, .pp-text .ln { display: block; }
.ln-center { text-align: center; font-weight: 700; letter-spacing: .02em; }
.ln-bold { font-weight: 700; }
.ln-sigline { margin-top: 2.2em; }
/* Court-order clause formats (clause.fmt, see js/data/court/drafts.js). Same rules on paper and print. */
.fmt-half { margin-left: 50%; }
.fmt-half .clause-body, .fmt-half .pp-text { text-align: left; }
.fmt-indent .clause-body, .fmt-indent .pp-text { text-indent: 3em; }
.fmt-indent .ln-center { text-indent: 0; }
.fmt-bold .clause-body, .fmt-bold .pp-text { font-weight: 700; }
.fmt-under .clause-body, .fmt-under .pp-text { text-decoration: underline; }
.sig-grid { display: grid; grid-template-columns: 1fr 1fr; column-gap: 3em; row-gap: .4em; margin: .4em 0 .8em; text-align: left; }
.sig { display: block; break-inside: avoid; }
.sig-grid.right .sig { grid-column: 2; }
.sep { display: none; }
.add-clause { display: flex; margin: 18px auto 0; font-family: var(--font); color: #0f6b5c; }

.ed-ai { background: var(--surface); border-top: 1px solid var(--line); padding: 8px 16px 10px; }
.ed-ai.busy { opacity: .85; }
.ai-chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
.chip-btn { flex: none; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); border-radius: 999px; padding: 4px 11px; font: inherit; font-size: .8rem; cursor: pointer; }
.chip-btn:hover { border-color: var(--brand); }
.chip-btn.alt { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.ai-form { display: flex; gap: 8px; align-items: center; }
.ai-form > i { color: var(--accent); }
.ai-form input { flex: 1; }
.ai-meta { margin-top: 4px; }

.drawer { position: absolute; top: 53px; right: 0; bottom: 0; width: min(420px, 100%); background: var(--surface); border-left: 1px solid var(--line); box-shadow: -8px 0 24px rgba(0, 0, 0, .12); display: flex; flex-direction: column; z-index: 15; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.drawer-head h3 { margin: 0; }
.drawer-body { padding: 14px 16px; overflow-y: auto; }
.explain { line-height: 1.7; }
.issues { list-style: none; padding: 0; margin: 0; }
.issues li { border: 1px solid var(--line); border-left-width: 4px; border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 10px; }
.issues p { margin: 4px 0 8px; }
.sev-high { border-left-color: var(--danger) !important; }
.sev-high i { color: var(--danger); }
.sev-medium { border-left-color: var(--warn) !important; }
.sev-medium i { color: var(--warn); }
.sev-low { border-left-color: var(--info) !important; }
.sev-low i { color: var(--info); }

.pop-menu { position: absolute; z-index: 60; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 4px; min-width: 220px; }
.pop-menu button { display: flex; gap: 8px; align-items: center; width: 100%; text-align: left; border: 0; background: none; color: var(--text); padding: 7px 10px; border-radius: 6px; font: inherit; font-size: .88rem; cursor: pointer; }
.pop-menu button:hover { background: var(--surface-2); }
.pop-menu button i { width: 16px; color: var(--brand); }
.pop-menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.pop-note { font-size: .78rem; color: var(--muted); padding: 4px 10px; }

/* ---------- print (PDF export) ---------- */

#print-root { display: none; }
@media print {
  /* @page margins + page numbers injected from config by export.js */
  body.printing > *:not(#print-root) { display: none !important; }
  body.printing { background: #fff; display: block; }
  body.printing #print-root { display: block; }
  .print-paper { color: #000; font-family: var(--paper-font); }
  .print-paper h1 { text-align: center; text-transform: uppercase; letter-spacing: .03em; text-decoration: underline; text-underline-offset: 4px; margin: 0 0 16pt; }
  .pp-clause { margin: 0 0 9pt; }
  .pp-clause.num { display: grid; grid-template-columns: 2.2em 1fr; }
  .pp-num { font-weight: 700; }
  .pp-head { font-weight: 700; break-after: avoid; }
  .pp-text { white-space: pre-wrap; word-wrap: break-word; text-align: justify; }
  .pp-text .sig-grid { break-inside: avoid; }
  .ln-center, .ln-sigline { break-after: avoid; }
}

/* ---------- responsive ---------- */

@media (max-width: 1000px) {
  .detail { grid-template-columns: 1fr; }
  .detail-side { position: static; }
  .steps { grid-template-columns: 1fr 1fr; }
  .foot-grid { grid-template-columns: 1fr 1fr; }
}

/* ---------- legal notices (#/notices) ---------- */
.nt-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.nt-side { position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow-y: auto; }
.nt-side .card h3, .nt-result h3 { margin-top: 0; }
.nt-checks { list-style: none; padding: 0; margin: 0 0 8px; }
.nt-checks li { display: flex; gap: 8px; align-items: flex-start; font-size: .88rem; padding: 7px 10px; border-radius: var(--radius-sm); margin-bottom: 6px; background: var(--surface-2); }
.nt-checks li i { margin-top: 3px; }
.nt-checks .lv-error { background: var(--danger-soft); color: var(--danger); }
.nt-checks .lv-warn { background: var(--warn-soft); color: var(--warn); }
.nt-checks .lv-info { background: var(--info-soft); color: var(--info); }
.nt-checks .lv-ok { background: var(--ok-soft); color: var(--ok); }
.link-btn { border: 0; background: none; padding: 0; font: inherit; color: inherit; text-decoration: underline; cursor: pointer; font-weight: 600; }
.ok-text { color: var(--ok); }
.law-list { display: flex; flex-direction: column; gap: 6px; }
.law-item { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px 10px; background: var(--surface); }
.law-item summary { cursor: pointer; font-size: .88rem; }
.law-item summary small { display: block; margin-left: 1.1em; }
.law-item.rule summary b { color: var(--accent); }
.law-text { white-space: pre-wrap; font-family: var(--paper-font); font-size: .92rem; line-height: 1.55; margin: 8px 0; max-height: 360px; overflow-y: auto; }
.nt-paras { padding-left: 1.3em; font-family: var(--paper-font); line-height: 1.6; }
.nt-paras li { margin-bottom: 10px; white-space: pre-wrap; }
input.filled, textarea.filled, select.filled { background: var(--ok-soft); }
.nt-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.paper .cite { text-decoration: underline dotted var(--brand); text-underline-offset: 3px; }
.paper .cite.bad { text-decoration: underline wavy var(--danger); }
.cite-tip { position: absolute; z-index: 70; max-width: 420px; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 10px 12px; font-size: .85rem; line-height: 1.5; pointer-events: none; }
.cite-tip p { margin: 6px 0 0; white-space: pre-wrap; }

/* ---------- Bare Act viewer (#/acts) ---------- */
.act-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; align-items: start; }
.act-index { position: sticky; top: 76px; max-height: calc(100vh - 92px); display: flex; flex-direction: column; gap: 8px; padding: 12px; }
.act-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; font-size: .85rem; flex: 1; min-height: 0; }
.act-list li a { display: block; padding: 5px 8px; border-radius: 6px; color: var(--text); text-decoration: none; }
.act-list li a:hover { background: var(--surface-2); }
.act-list li.sub a { padding-left: 22px; font-size: .8rem; }
.act-list li.active a { background: var(--brand-soft); color: var(--brand); }
.act-list b { color: var(--brand); margin-right: 4px; }

/* ---------- court drafts: law box ---------- */
.lp { display: flex; flex-direction: column; gap: 8px; }
.lp h4 { margin: 10px 0 0; font-size: .9rem; }
.lp h4 small { font-weight: 500; margin-left: 4px; }
.lp textarea { font-family: var(--paper-font); font-size: .9rem; }
.lp-picked .badge .link-btn { font-size: 1rem; line-height: 1; padding: 0 0 0 2px; }
.lp-list { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: .85rem; }
.lp-item { border-bottom: 1px solid var(--line); }
.lp-item:last-child { border-bottom: 0; }
.lp-item.sub .lp-row { padding-left: 22px; }
.lp-row { display: flex; align-items: center; gap: 6px; padding: 2px 4px 2px 8px; }
.lp-nobox { width: 13px; flex: none; }
.lp-name { flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: 5px 0; color: var(--text); cursor: pointer; font: inherit; }
.lp-name b { color: var(--brand); margin-right: 4px; }
.lp-chev { width: 28px; height: 28px; font-size: .75rem; }
.lp-body { padding: 4px 10px 10px 28px; }
.lp-body .law-text { max-height: 220px; }
.lp-subs { list-style: none; margin: 0 0 6px; padding: 0; }
.lp-subs label { display: flex; gap: 6px; align-items: baseline; padding: 2px 0; cursor: pointer; }
.act-sec h2 { margin: 0; }
.act-sec-title { font-weight: 600; margin: 4px 0 8px; }
.act-text { max-height: none; font-size: 1rem; }
.act-text mark, .act-hits mark { background: var(--accent-soft); color: inherit; padding: 0 1px; border-radius: 2px; }
.act-hits { padding-left: 1.2em; margin: 8px 0 0; }
.act-hits li { margin-bottom: 10px; }
.act-notes summary { cursor: pointer; }
.act-ask textarea { width: 100%; }
.act-ask-form { margin-top: 10px; }
.qa { border-top: 1px solid var(--line); padding: 12px 0; }
.qa-q { font-weight: 600; margin-bottom: 6px; }
.qa-a { line-height: 1.6; }
.cite-unchecked { text-decoration: underline wavy var(--danger); }

@media (max-width: 900px) {
  .act-grid { grid-template-columns: 1fr; }
  .act-index { position: static; max-height: 300px; }
  .nt-grid { grid-template-columns: 1fr; }
  .nt-side { position: static; max-height: none; }
  .ed-tabs { display: flex; background: var(--surface); border-bottom: 1px solid var(--line); }
  .ed-tabs button { flex: 1; padding: 10px; border: 0; background: none; font: inherit; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; }
  .ed-tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }
  .ed-main { grid-template-columns: 1fr; }
  .ed-main.show-fields .ed-right, .ed-main.show-doc .ed-left { display: none; }
  .ed-left { border-right: 0; }
  .ed-right { padding: 10px 8px 24px; }
  .paper { padding: 28px 20px; font-size: 15px; min-height: 0; }
  .hide-sm { display: none; }
  .drawer { top: 0; }
}

@media (max-width: 760px) {
  h1 { font-size: 1.5rem; }
  .hero { padding: 32px 0 24px; }
  .hero h1 { font-size: 1.8rem; }
  .doors { grid-template-columns: 1fr; }
  .steps { grid-template-columns: 1fr; }
  .grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .docs-list { grid-template-columns: 1fr; }
  .toolbar > input[type="search"] { max-width: none; }
  .nav-toggle { display: inline-flex; margin-left: 0; }
  .head-tools { margin-left: auto; }
  .nav { display: none; position: absolute; top: 60px; left: 0; right: 0; flex-direction: column; align-items: stretch; background: var(--surface); border-bottom: 1px solid var(--line); padding: 8px 16px 14px; box-shadow: var(--shadow); }
  .site-head.open .nav { display: flex; }
  .ed-top { padding: 8px; gap: 6px; }
  .ed-actions .btn.sm { padding: 5px 8px; }
  .clause-tools { right: 0; }
  .sig-grid { column-gap: 1.2em; }
}
