:root {
  --navy: #13252e;
  --navy-2: #1d3743;
  --cream: #f2eee5;
  --paper: #fbfaf6;
  --white: #fff;
  --ink: #1e2d33;
  --muted: #607078;
  --rust: #d56a47;
  --teal: #3f8f83;
  --line: #d9d9d1;
  --amber: #e1aa49;
  --shadow: 0 24px 70px rgba(19,37,46,.12);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--cream); color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.topbar { width: min(1220px, calc(100% - 40px)); height: 76px; margin: auto; display: flex; align-items: center; justify-content: space-between; }
.brand { color: var(--navy); text-decoration: none; display: flex; align-items: center; gap: 11px; font-weight: 800; letter-spacing: -.025em; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px 14px 10px 14px; display: grid; place-items: center; color: var(--white); background: var(--rust); font-family: Georgia, serif; font-size: 1.2rem; }
.privacy { display: flex; align-items: center; gap: 8px; color: var(--navy); font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.privacy span { width: 8px; height: 8px; border-radius: 50%; background: #54a67b; box-shadow: 0 0 0 4px rgba(84,166,123,.13); }
main { width: min(1220px, calc(100% - 40px)); margin: 0 auto 70px; }
section { scroll-margin-top: 24px; }
.builder-section { min-height: calc(100vh - 92px); display: grid; grid-template-columns: .82fr 1.18fr; gap: clamp(28px, 6vw, 82px); align-items: center; padding: 42px 0 68px; }
.eyebrow { margin: 0 0 14px; color: var(--rust); font-size: .72rem; font-weight: 850; text-transform: uppercase; letter-spacing: .14em; }
h1, h2 { font-family: Georgia, "Times New Roman", serif; }
h1 { margin: 0 0 22px; color: var(--navy); font-size: clamp(3rem, 6vw, 5.6rem); line-height: .94; letter-spacing: -.055em; font-weight: 500; }
h1 em { color: var(--rust); font-style: normal; }
.intro { max-width: 610px; margin: 0; color: var(--muted); font-size: 1.07rem; line-height: 1.7; }
.source-count { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 28px; color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; }
.source-count strong { color: var(--navy); font-size: 1rem; }
.source-count span { width: 3px; height: 3px; border-radius: 50%; background: var(--rust); margin: 0 3px; }
.builder-card { background: var(--paper); border: 1px solid rgba(19,37,46,.08); border-radius: 24px; padding: clamp(22px, 4vw, 38px); box-shadow: var(--shadow); }
.notice { padding: 15px 17px; border-left: 4px solid var(--amber); border-radius: 0 10px 10px 0; background: #f8f0dc; color: #655632; font-size: .78rem; line-height: 1.5; }
.notice strong { display: block; color: #4e411f; margin-bottom: 2px; }
form { margin-top: 24px; }
label, .field-title { color: var(--navy); font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.search-box { position: relative; margin-top: 9px; }
.search-box svg { position: absolute; left: 15px; top: 50%; width: 21px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; }
input, textarea { width: 100%; border: 1px solid #cfd4d2; border-radius: 11px; background: var(--white); color: var(--ink); outline: 0; }
input { height: 49px; padding: 0 13px; }
.search-box input { height: 59px; padding-left: 47px; font-size: 1.05rem; }
textarea { padding: 12px 13px; resize: vertical; line-height: 1.5; }
input:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(63,143,131,.14); }
.examples { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-top: 10px; }
.examples span { color: var(--muted); font-size: .72rem; }
.examples button { border: 1px solid var(--line); border-radius: 99px; background: transparent; color: var(--muted); padding: 5px 9px; font-size: .68rem; }
.examples button:hover { border-color: var(--rust); color: var(--rust); }
.topic-panel { display: grid; grid-template-columns: .85fr 1.15fr; gap: 18px; margin-top: 27px; padding-top: 23px; border-top: 1px solid var(--line); }
.topic-panel p { margin: 6px 0 0; color: var(--muted); font-size: .72rem; line-height: 1.45; }
.topic-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.topic-chip { position: relative; cursor: pointer; }
.topic-chip input { position: absolute; opacity: 0; pointer-events: none; }
.topic-chip span { display: block; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); color: var(--muted); font-size: .66rem; font-weight: 700; text-transform: none; letter-spacing: 0; }
.topic-chip input:checked + span { border-color: var(--topic); color: var(--navy); box-shadow: inset 3px 0 var(--topic); background: color-mix(in srgb, var(--topic) 8%, white); }
.case-details { margin-top: 23px; padding-top: 17px; border-top: 1px solid var(--line); }
.case-details-heading { margin-bottom: 17px; }
.case-details-heading p { margin: 6px 0 0; color: var(--muted); font-size: .82rem; line-height: 1.5; }
.details-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; margin-top: 17px; }
.details-grid label { display: grid; gap: 7px; }
.details-grid .wide { grid-column: 1 / -1; }
.form-footer { display: flex; justify-content: space-between; align-items: center; gap: 15px; margin-top: 26px; }
.form-actions { display: flex; align-items: center; gap: 9px; }
.toggle { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: .68rem; text-transform: none; letter-spacing: 0; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; }
.toggle span { width: 34px; height: 19px; border-radius: 99px; background: #bdc4c1; position: relative; transition: .2s; }
.toggle span::after { content: ""; position: absolute; width: 15px; height: 15px; left: 2px; top: 2px; border-radius: 50%; background: white; transition: .2s; }
.toggle input:checked + span { background: var(--teal); }
.toggle input:checked + span::after { transform: translateX(15px); }
.generate-button { min-width: 190px; height: 50px; padding: 0 18px; border: 0; border-radius: 11px; display: flex; align-items: center; justify-content: space-between; gap: 20px; background: var(--rust); color: white; font-weight: 800; box-shadow: 0 10px 22px rgba(213,106,71,.23); }
.generate-button:hover { background: #be5838; }
.clear-button { height: 50px; padding: 0 17px; border: 1px solid var(--line); border-radius: 11px; background: white; color: var(--navy); font-weight: 800; }
.clear-button:hover { border-color: var(--rust); color: var(--rust); }
.form-error { min-height: 18px; margin: 8px 0 -8px; color: #b74635; font-size: .76rem; }
.draft-status { min-height: 18px; margin: 8px 0 -8px; color: #27695f; font-size: .82rem; font-weight: 750; }
.results-section, .library-section { margin-top: 20px; padding: clamp(24px, 4vw, 48px); border: 1px solid rgba(19,37,46,.08); border-radius: 24px; background: var(--paper); box-shadow: var(--shadow); }
.section-title-row { display: flex; justify-content: space-between; align-items: center; gap: 22px; }
h2 { margin: 0; color: var(--navy); font-size: clamp(2rem, 4vw, 3.2rem); letter-spacing: -.035em; font-weight: 500; }
.actions { display: flex; gap: 8px; }
.actions button { height: 41px; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; background: white; color: var(--navy); font-size: .73rem; font-weight: 800; }
.actions button.dark { border-color: var(--navy); background: var(--navy); color: white; }
.strength-strip { display: grid; grid-template-columns: repeat(3, 1fr); margin: 28px 0 22px; border: 1px solid var(--line); border-radius: 13px; background: white; overflow: hidden; }
.strength-strip > div { padding: 14px 17px; border-right: 1px solid var(--line); }
.strength-strip > div:last-child { border: 0; }
.strength-strip span { display: block; color: var(--muted); font-size: .63rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.strength-strip strong { display: block; margin-top: 5px; color: var(--navy); font-size: .88rem; }
.results-grid { display: grid; grid-template-columns: 285px 1fr; gap: 18px; align-items: start; }
.results-grid aside { position: sticky; top: 16px; padding: 18px; border-radius: 14px; background: #e7eeeb; }
.results-grid aside h3 { margin: 0 0 5px; color: var(--navy); font-size: .95rem; }
.results-grid aside > p { margin: 0 0 15px; color: var(--muted); font-size: .72rem; line-height: 1.45; }
.matched-sources { display: grid; gap: 7px; max-height: 600px; overflow: auto; }
.matched-source { display: grid; grid-template-columns: 34px 1fr auto; gap: 8px; align-items: center; padding: 9px; border-radius: 9px; color: var(--ink); background: rgba(255,255,255,.72); text-decoration: none; }
.matched-source b { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 7px; background: var(--navy); color: white; font-size: .63rem; }
.matched-source strong, .matched-source small { display: block; }
.matched-source strong { font-size: .67rem; line-height: 1.25; }
.matched-source small { margin-top: 3px; color: var(--muted); font-size: .57rem; }
.draft-panel { min-width: 0; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: white; }
.tabs { display: flex; padding: 7px 7px 0; gap: 4px; background: #eef0ec; }
.tabs button { padding: 11px 14px; border: 0; border-radius: 8px 8px 0 0; background: transparent; color: var(--muted); font-size: .75rem; font-weight: 800; }
.tabs button.active { background: white; color: var(--navy); }
.draft { padding: clamp(19px, 4vw, 38px); }
.draft-banner { margin: -6px 0 27px; padding: 12px 14px; border: 1px solid #e9d4a4; border-radius: 9px; background: #fff7e5; color: #765c23; font-size: .72rem; font-weight: 850; letter-spacing: .04em; }
.draft h3 { margin: 25px 0 8px; color: var(--navy); font-size: .92rem; }
.draft p { margin: 0 0 7px; color: #34464e; font-family: ui-serif, Georgia, serif; font-size: .88rem; line-height: 1.65; white-space: pre-wrap; }
.draft .bullet { position: relative; padding-left: 17px; }
.draft .bullet::before { content: "•"; position: absolute; left: 2px; color: var(--rust); }
.draft .checkline { padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; font-family: inherit; font-size: .76rem; }
.draft .space { height: 5px; }
.library-section { margin-top: 20px; }
.library-search input { width: min(330px, 42vw); background: white; }
.tier-key { display: flex; flex-wrap: wrap; gap: 15px; margin: 25px 0 18px; color: var(--muted); font-size: .68rem; }
.tier-key span { display: flex; align-items: center; gap: 6px; }
.tier-key i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.tier-key i.official { background: var(--teal); }
.tier-key i.context { background: #5e83a6; }
.tier-key i.research { background: var(--amber); }
.tier-key i.manual { background: #906bb0; }
.evidence-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.evidence-card { display: flex; flex-direction: column; padding: 18px; border: 1px solid var(--line); border-radius: 13px; background: white; }
.evidence-card header { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.source-id { color: var(--navy); font-size: .7rem; font-weight: 900; }
.tier { padding: 4px 7px; border-radius: 99px; color: #4d5d64; background: #e5e7e3; font-size: .56rem; font-weight: 850; text-transform: uppercase; letter-spacing: .06em; }
.tier.official { color: #23675e; background: #dceee9; }
.tier.context { color: #315f84; background: #e1eaf2; }
.tier.research { color: #71541c; background: #f8edcf; }
.tier.manual { color: #66447d; background: #eee3f3; }
.tier.low { color: #76574d; background: #eee7e4; }
.evidence-card h3 { margin: 14px 0 5px; color: var(--navy); font-size: .91rem; line-height: 1.25; }
.authority { margin: 0 0 12px; color: var(--muted); font-size: .67rem; }
.topics { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 12px; }
.topics span { padding: 3px 6px; border-left: 3px solid var(--topic); border-radius: 3px; background: #f2f3ef; color: #58676e; font-size: .57rem; }
.evidence-card > p:not(.authority) { color: #45565d; font-size: .74rem; line-height: 1.5; }
.limitation { margin-top: auto; padding: 10px; border-radius: 7px; background: #f7f1e5; color: #685a3d; font-size: .66rem; line-height: 1.45; }
.evidence-card > a { margin-top: 13px; color: var(--rust); font-size: .68rem; font-weight: 800; text-decoration: none; }
.library-section footer { margin-top: 20px; padding: 15px; border-radius: 9px; background: #e7eeeb; color: var(--muted); font-size: .7rem; line-height: 1.5; }
.no-results { grid-column: 1 / -1; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: 22px; z-index: 10; transform: translate(-50%, 80px); padding: 10px 15px; border-radius: 99px; background: var(--navy); color: white; font-size: .75rem; font-weight: 800; opacity: 0; transition: .25s; pointer-events: none; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 980px) {
  .builder-section { grid-template-columns: 1fr; min-height: 0; padding-top: 30px; }
  .hero { max-width: 760px; }
  .results-grid { grid-template-columns: 1fr; }
  .results-grid aside { position: static; }
  .matched-sources { grid-template-columns: repeat(2, 1fr); max-height: none; }
  .evidence-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .topbar, main { width: calc(100% - 24px); }
  .topbar { height: 62px; }
  .privacy { font-size: .61rem; }
  .builder-section { gap: 28px; padding: 28px 0 44px; }
  h1 { font-size: clamp(2.75rem, 14vw, 4.2rem); }
  .builder-card, .results-section, .library-section { padding: 19px 16px; border-radius: 18px; }
  .topic-panel { grid-template-columns: 1fr; }
  .details-grid { grid-template-columns: 1fr; }
  .details-grid .wide { grid-column: auto; }
  .form-footer { align-items: stretch; flex-direction: column; }
  .form-actions { width: 100%; }
  .clear-button { min-width: 88px; }
  .generate-button { width: 100%; min-width: 0; }
  .section-title-row { align-items: flex-start; flex-direction: column; }
  .actions { width: 100%; }
  .actions button { flex: 1; }
  .strength-strip { grid-template-columns: 1fr; }
  .strength-strip > div { border-right: 0; border-bottom: 1px solid var(--line); }
  .strength-strip > div:last-child { border: 0; }
  .matched-sources { grid-template-columns: 1fr; }
  .tabs button { flex: 1; padding: 11px 7px; }
  .evidence-grid { grid-template-columns: 1fr; }
  .library-search, .library-search input { width: 100%; }
}

@media print {
  body { background: white; }
  .topbar, .builder-section, .results-section > .section-title-row, .strength-strip, .results-grid aside, .tabs, .library-section, .toast { display: none !important; }
  main { width: 100%; margin: 0; }
  .results-section { display: block !important; margin: 0; padding: 0; border: 0; box-shadow: none; }
  .results-grid, .draft-panel { display: block; border: 0; }
  .draft { display: block !important; padding: 0 0 28px; break-after: page; }
  .draft[hidden] { display: block !important; }
  .draft p { color: black; font-size: 10.5pt; }
}

@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } .toast { transition: none; } }
