:root {
  --ink: #18222b;
  --muted: #66737f;
  --line: #dce2e7;
  --paper: #ffffff;
  --surface: #f4f6f7;
  --nav: #101820;
  --teal: #087f75;
  --teal-soft: #e8f5f3;
  --amber: #ad6a00;
  --amber-soft: #fff5df;
  --red: #a9342f;
  --red-soft: #fff0ef;
  --blue: #315f8d;
  --blue-soft: #edf4fa;
  --green: #28734f;
  --green-soft: #eaf6ef;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--surface);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--surface); }
button, input { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 22px;
  color: white;
  background: var(--nav);
  border-bottom: 3px solid #d4a72c;
}

.brand-mark {
  width: 60px;
  height: 34px;
  display: grid;
  place-items: center;
  color: var(--nav);
  background: #f0c85a;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .8px;
  border-radius: 4px;
}

.brand-copy { display: flex; flex-direction: column; line-height: 1.1; }
.brand-copy strong { font-size: 14px; }
.brand-copy span { margin-top: 4px; color: #aab5bd; font-size: 11px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.mobile-topics-button { display: none; }
.mobile-guide-link { padding: 7px 10px; color: #f8e6a6; border: 1px solid #72683f; border-radius: 4px; font-size: 11px; font-weight: 750; text-decoration: none; }
.mobile-guide-link:hover { color: white; background: #29343d; }
.edition-badge { padding: 6px 9px; color: #f4d978; border: 1px solid #5c6670; border-radius: 4px; font-size: 10px; font-weight: 700; }
.icon-button { width: 34px; height: 34px; color: white; background: transparent; border: 1px solid #4d5861; border-radius: 4px; font-size: 19px; }
.icon-button:hover { background: #29343d; }

.android-install-prompt, .ios-install-prompt { position: fixed; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); z-index: 90; width: min(420px, calc(100vw - 32px)); display: flex; align-items: center; gap: 12px; padding: 13px 14px; color: white; background: #172127; border: 1px solid #42515b; border-left: 4px solid #f0c85a; border-radius: 8px; box-shadow: 0 12px 34px rgba(12, 22, 28, .3); }
.android-install-prompt[hidden], .ios-install-prompt[hidden] { display: none; }
.android-install-prompt div, .ios-install-prompt div { min-width: 0; display: flex; flex: 1; flex-direction: column; gap: 3px; }
.android-install-prompt strong, .ios-install-prompt strong { font-size: 13px; }
.android-install-prompt span, .ios-install-prompt span { color: #c6d0d6; font-size: 10px; line-height: 1.35; }
.install-app-button, .ios-install-button { min-height: 38px; padding: 0 11px; color: #172127; background: #f0c85a; border: 0; border-radius: 5px; font-size: 10px; font-weight: 850; }
.dismiss-install-button { width: 34px; height: 38px; color: #dbe2e6; background: transparent; border: 0; font-size: 22px; line-height: 1; }

.app-shell { height: calc(100vh - 64px); display: grid; grid-template-columns: 310px minmax(0, 1fr); }
.sidebar { overflow: hidden; display: flex; flex-direction: column; background: #fbfcfc; border-right: 1px solid var(--line); }
.sidebar-header { padding: 22px 20px 14px; }
.eyebrow { margin: 0 0 7px; color: var(--teal); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.sidebar h1 { margin: 0; font-family: Georgia, serif; font-size: 26px; font-weight: 600; }
.corpus-stats { display: flex; gap: 13px; margin-top: 15px; color: var(--muted); font-size: 11px; }
.corpus-stats strong { color: var(--ink); font-size: 14px; }
.developer-credit { margin-top: 16px; padding-top: 13px; border-top: 1px solid var(--line); }
.developer-credit img { display: block; width: 190px; max-width: 100%; height: auto; mix-blend-mode: multiply; }
.developer-credit p { display: flex; flex-direction: column; gap: 2px; margin: 8px 0 0; }
.developer-credit span { color: var(--muted); font-size: 9px; font-weight: 750; text-transform: uppercase; }
.developer-credit strong { color: var(--ink); font-size: 11px; }

.search-box { display: flex; align-items: center; gap: 8px; margin: 0 14px 10px; padding: 9px 11px; background: white; border: 1px solid var(--line); border-radius: 5px; }
.search-box span { color: var(--muted); font-size: 18px; }
.search-box input { width: 100%; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 12px; }
.filter-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; padding: 0 14px 12px; }
.filter-button { min-height: 30px; color: var(--muted); background: white; border: 1px solid var(--line); border-radius: 4px; font-size: 11px; }
.filter-button.active { color: white; background: var(--teal); border-color: var(--teal); }

.topic-list { overflow-y: auto; padding: 0 8px 20px; }
.topic-button { position: relative; width: 100%; min-height: 56px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; padding: 9px 28px 9px 12px; text-align: left; color: var(--ink); background: transparent; border: 0; border-left: 3px solid transparent; }
.topic-button:hover { background: #f0f4f4; }
.topic-button.active { background: var(--teal-soft); border-left-color: var(--teal); }
.topic-button span { font-size: 12px; font-weight: 650; line-height: 1.25; }
.topic-button small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.topic-button i { position: absolute; right: 10px; top: 18px; width: 18px; height: 18px; display: grid; place-items: center; color: var(--green); background: var(--green-soft); border-radius: 50%; font-size: 10px; font-style: normal; }
.empty-state { padding: 20px; color: var(--muted); font-size: 12px; }

.workspace { overflow-y: auto; padding: 30px clamp(24px, 4vw, 62px) 70px; background: var(--paper); }
.print-masthead, .print-topic { display: none; }
.workspace-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.workspace h2 { margin: 0; max-width: 820px; font-family: Georgia, serif; font-size: clamp(27px, 3vw, 40px); font-weight: 500; line-height: 1.08; }
.topic-badges { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.badge { padding: 6px 8px; color: var(--blue); background: var(--blue-soft); border-radius: 4px; font-size: 9px; font-weight: 800; }
.badge.critical { color: var(--red); background: var(--red-soft); }
.badge.complete { color: var(--green); background: var(--green-soft); }
.badge.pending { color: var(--amber); background: var(--amber-soft); }

.mobile-install-card { display: grid; grid-template-columns: minmax(0, 1fr) 154px; gap: 24px; align-items: center; margin-top: 22px; padding: 20px 22px; background: linear-gradient(135deg, #f3faf8, #fffaf0); border: 1px solid #cfe1dc; border-left: 4px solid var(--teal); border-radius: 7px; }
.mobile-install-card[hidden] { display: none; }
.mobile-install-copy h3 { margin: 0; font-family: Georgia, serif; font-size: 22px; font-weight: 600; }
.mobile-install-copy > p:not(.eyebrow) { max-width: 780px; margin: 8px 0 0; color: #46545e; font-size: 12px; line-height: 1.5; }
.mobile-install-steps { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 13px; }
.mobile-install-steps p { margin: 0; padding: 9px 10px; color: #34444d; background: rgba(255, 255, 255, .8); border: 1px solid #dce7e3; border-radius: 5px; font-size: 11px; line-height: 1.4; }
.mobile-install-copy .store-note { color: #6a5a32; font-size: 11px; }
.qr-panel { display: flex; flex-direction: column; align-items: center; gap: 7px; }
.qr-panel img { width: 132px; height: 132px; padding: 7px; background: white; border: 1px solid #cbd8d4; border-radius: 6px; }
.qr-panel span { color: var(--muted); font-size: 9px; font-weight: 700; text-transform: uppercase; }
.privacy-note { margin-top: 12px; padding: 10px 12px; color: #53636d; background: #f7faf9; border: 1px solid #dce7e3; border-radius: 5px; font-size: 11px; line-height: 1.5; }
.privacy-note strong { color: #24333e; }
.privacy-note a { color: var(--teal); font-weight: 700; }

.toolbar { min-width: 0; display: flex; align-items: center; gap: 16px; margin-top: 28px; border-bottom: 1px solid var(--line); }
.stage-guide { max-width: 1020px; margin: 10px 0 0; color: #596873; font-size: 13px; line-height: 1.55; }
.stage-guide strong { color: #24333e; }
.stage-tabs { width: 0; min-width: 0; max-width: 100%; flex: 1 1 auto; display: flex; flex-wrap: nowrap; gap: 2px; overflow-x: auto; overflow-y: hidden; }
.stage-button { flex: 0 0 auto; min-height: 46px; padding: 0 14px; white-space: nowrap; color: var(--muted); background: transparent; border: 0; border-bottom: 3px solid transparent; font-size: 12px; font-weight: 650; }
.stage-button.active { color: var(--teal); border-bottom-color: var(--teal); }
.view-switch { flex: 0 0 auto; display: flex; margin-left: auto; padding: 3px; background: var(--surface); border-radius: 5px; }
.view-button { min-height: 30px; padding: 0 11px; color: var(--muted); background: transparent; border: 0; border-radius: 3px; font-size: 10px; font-weight: 750; text-transform: uppercase; }
.view-button.active { color: var(--ink); background: white; box-shadow: 0 1px 3px rgba(20, 30, 38, .12); }

.focus-view { margin-top: 24px; }
.stage-card { min-height: 260px; padding: 28px 30px; background: #fff; border: 1px solid var(--line); border-top: 4px solid var(--blue); border-radius: 6px; box-shadow: 0 10px 28px rgba(32, 48, 58, .06); }
.stage-card.consolidated { border-top-color: var(--teal); background: #fbfefd; }
.stage-card-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.stage-index { color: var(--blue); font-size: 11px; font-weight: 850; text-transform: uppercase; }
.stage-card.consolidated .stage-index { color: var(--teal); }
.status-pill { padding: 6px 8px; border-radius: 4px; font-size: 9px; font-weight: 800; text-transform: uppercase; }
.status-green { color: var(--green); background: var(--green-soft); }
.status-amber { color: var(--amber); background: var(--amber-soft); }
.status-blue { color: var(--blue); background: var(--blue-soft); }
.stage-card h3 { margin: 32px 0 12px; font-size: 14px; }
.summary-label { display: block; margin: 0 0 5px; color: #64727c; font-size: 10px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.stage-card p { max-width: 1000px; margin: 0; color: #33414c; font-family: Georgia, serif; font-size: 17px; line-height: 1.68; }

.compare-view { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 24px; }
.compare-view:not([hidden]) { display: grid; }
.stage-card.compact { min-height: 220px; padding: 18px; box-shadow: none; }
.stage-card.compact:last-child { grid-column: 1 / -1; }
.stage-card.compact h3 { margin: 20px 0 10px; font-size: 12px; }
.stage-card.compact p { font-size: 14px; line-height: 1.52; }

.legal-reading, .traceability { margin-top: 34px; padding-top: 26px; border-top: 1px solid var(--line); }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.section-heading h3 { margin: 0; font-family: Georgia, serif; font-size: 23px; font-weight: 500; }
.review-status { padding: 6px 8px; border-radius: 4px; font-size: 9px; font-weight: 800; }
.review-status.ready { color: var(--green); background: var(--green-soft); }
.review-status.pending { color: var(--amber); background: var(--amber-soft); }
.review-status.neutral { color: var(--blue); background: var(--blue-soft); }
.reading-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1px; margin-top: 18px; background: var(--line); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.reading-grid article { min-height: 150px; padding: 18px; background: white; }
.reading-grid article:nth-child(-n+3) { grid-column: span 2; }
.reading-grid article:nth-child(n+4) { grid-column: span 3; }
.position-card.favorable { box-shadow: inset 3px 0 0 var(--teal); }
.position-card.restrictive { box-shadow: inset 3px 0 0 var(--amber); }
.reading-label { color: var(--teal); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.reading-grid p { margin: 12px 0 0; color: #3c4954; font-size: 13px; line-height: 1.55; }

.source-list { margin-top: 16px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.source-row { display: grid; grid-template-columns: 145px minmax(0, 1fr); gap: 16px; align-items: center; min-height: 70px; padding: 12px 15px; border-bottom: 1px solid var(--line); }
.source-row:last-child { border-bottom: 0; }
.source-kind { color: var(--teal); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.source-row strong, .source-row a { color: var(--ink); font-size: 12px; font-weight: 700; line-height: 1.35; text-decoration: none; }
.source-row a:hover { color: var(--teal); text-decoration: underline; }
.source-row p { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.source-state { justify-self: end; padding: 5px 7px; border-radius: 4px; font-size: 9px; font-weight: 800; text-transform: uppercase; }
.source-state.verified { color: var(--green); background: var(--green-soft); }
.source-state.citable { color: var(--blue); background: var(--blue-soft); }
.source-warning { margin-top: 12px; padding: 13px 15px; color: #5b4a23; background: var(--amber-soft); border-left: 3px solid #d89928; font-size: 11px; line-height: 1.5; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 260px minmax(0, 1fr); }
  .workspace { padding-inline: 24px; }
  .workspace-header { flex-direction: column; }
  .topic-badges { justify-content: flex-start; }
  .reading-grid { grid-template-columns: 1fr; }
  .reading-grid article:nth-child(n) { grid-column: 1; }
  .mobile-install-card { grid-template-columns: minmax(0, 1fr) 138px; }
  .mobile-install-steps { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  html { scroll-padding-top: 56px; }
  body { overflow-x: hidden; }
  button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
  .topbar { position: sticky; top: 0; z-index: 50; height: 56px; padding-inline: 12px; border-bottom-width: 2px; }
  .brand-mark { width: 54px; height: 30px; font-size: 9px; }
  .brand-copy strong { font-size: 12px; }
  .brand-copy span, .edition-badge { display: none; }
  .mobile-guide-link, .mobile-install-card { display: none; }
  .mobile-topics-button { min-width: 64px; height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 0 11px; color: white; background: transparent; border: 1px solid #65717a; border-radius: 6px; font-size: 12px; font-weight: 800; }
  .mobile-topics-button[aria-expanded="true"] { color: #172127; background: #f4d978; border-color: #f4d978; }
  .icon-button { width: 44px; height: 44px; border: 0; font-size: 21px; }
  .android-install-prompt, .ios-install-prompt { right: 10px; bottom: max(10px, env(safe-area-inset-bottom)); width: calc(100vw - 20px); gap: 8px; padding: 11px 10px; }
  .app-shell { height: auto; display: block; }
  .sidebar { display: none; overflow: visible; padding-bottom: 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  body.mobile-nav-open .sidebar { display: flex; }
  .sidebar-header { padding: 18px 14px 10px; }
  .sidebar h1 { font-size: 23px; }
  .corpus-stats { justify-content: space-between; gap: 8px; margin-top: 12px; }
  .developer-credit { display: grid; grid-template-columns: minmax(0, 180px) 1fr; gap: 12px; align-items: center; margin-top: 13px; }
  .developer-credit p { margin: 0; }
  .search-box { min-height: 44px; margin: 0 12px 8px; padding-inline: 12px; border-radius: 8px; }
  .search-box input { font-size: 16px; }
  .filter-row { grid-template-columns: .75fr 1.35fr 1.1fr; gap: 6px; padding: 0 12px 10px; }
  .filter-button { min-height: 44px; padding: 4px 6px; font-size: 10px; line-height: 1.15; }
  .topic-list { display: flex; gap: 8px; max-height: none; overflow-x: auto; overflow-y: hidden; padding: 0 12px 4px; scroll-snap-type: x proximity; scrollbar-width: thin; }
  .topic-button { flex: 0 0 min(76vw, 260px); min-height: 72px; padding: 10px 32px 10px 12px; background: white; border: 1px solid var(--line); border-left: 1px solid var(--line); border-bottom: 3px solid transparent; border-radius: 8px; scroll-snap-align: start; }
  .topic-button.active { border-left-color: var(--line); border-bottom-color: var(--teal); }
  .topic-button span { font-size: 13px; }
  .topic-button i { top: 14px; right: 9px; width: 22px; height: 22px; }
  .empty-state { min-width: 100%; padding: 12px; }
  .workspace { overflow: visible; padding: 22px 14px max(52px, env(safe-area-inset-bottom)); }
  .workspace-header { gap: 12px; }
  .workspace h2 { font-size: clamp(28px, 9vw, 36px); line-height: 1.08; }
  .topic-badges { gap: 6px; }
  .badge { padding: 6px 7px; font-size: 8px; }
  .toolbar { position: static; flex-wrap: wrap; align-items: stretch; gap: 8px; margin: 20px -14px 0; padding: 0 14px 10px; background: rgba(255, 255, 255, .97); box-shadow: 0 5px 12px rgba(20, 30, 38, .06); }
  .stage-guide { margin: 9px 0 0; font-size: 12px; }
  .stage-tabs { width: 100%; order: 1; scrollbar-width: thin; }
  .stage-button { min-height: 48px; padding-inline: 11px; font-size: 11px; }
  .view-switch { width: 100%; order: 2; margin: 0; }
  .view-button { flex: 1; min-height: 42px; font-size: 10px; }
  .focus-view, .compare-view { margin-top: 16px; }
  .stage-card { min-height: auto; padding: 20px 16px; border-radius: 8px; }
  .stage-card-head { align-items: flex-start; }
  .status-pill { max-width: 54%; text-align: center; line-height: 1.25; }
  .stage-card h3 { margin: 24px 0 10px; line-height: 1.4; }
  .stage-card p { font-size: 16px; line-height: 1.6; }
  .compare-view:not([hidden]) { display: block; }
  .stage-card.compact { margin-bottom: 10px; }
  .legal-reading, .traceability { margin-top: 28px; padding-top: 22px; }
  .section-heading { flex-direction: column; gap: 10px; }
  .section-heading h3 { font-size: 22px; }
  .reading-grid { margin-top: 14px; }
  .reading-grid article { min-height: auto; padding: 16px; }
  .reading-grid p { font-size: 14px; }
  .source-row { grid-template-columns: 1fr; gap: 6px; }
  .source-row strong, .source-row a { font-size: 13px; }
  .source-row p { font-size: 11px; line-height: 1.4; }
  .source-warning { font-size: 12px; }
}

@media (max-width: 380px) {
  .corpus-stats { font-size: 10px; }
  .corpus-stats strong { font-size: 13px; }
  .filter-button { font-size: 9px; }
  .topic-button { flex-basis: 82vw; }
  .workspace h2 { font-size: 28px; }
}

@media print {
  @page { size: A4 portrait; margin: 14mm 14mm 16mm; }
  :root { background: white; }
  body { color: #111; background: white; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .topbar, .sidebar, .toolbar, .topic-badges, .review-status, .mobile-install-card { display: none !important; }
  .app-shell { display: block; height: auto; }
  .workspace { overflow: visible; padding: 0; }
  .print-masthead {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12mm;
    margin-bottom: 9mm;
    padding-bottom: 4mm;
    border-bottom: 1.5pt solid #111;
  }
  .print-branding { min-width: 0; display: flex; align-items: center; gap: 6mm; }
  .print-solia-block { min-width: 0; display: flex; align-items: center; gap: 3mm; }
  .print-solia-logo {
    display: block;
    flex: 0 0 auto;
    width: 34mm !important;
    max-width: 34mm !important;
    height: auto !important;
    max-height: 10mm !important;
    object-fit: contain;
  }
  .print-solia-block span { max-width: 36mm; margin: 0; font-size: 7pt; line-height: 1.25; }
  .print-title { min-width: 48mm; max-width: 82mm; }
  .print-masthead > div:last-child { display: flex; flex-direction: column; align-items: flex-end; }
  .print-brand { font-family: Georgia, serif; font-size: 15pt; font-weight: 700; }
  .print-masthead strong { font-size: 9.5pt; }
  .print-masthead span { margin-top: 1.5mm; color: #555; font-size: 8pt; }
  .workspace-header { display: block; margin-bottom: 5mm; }
  .workspace h2 { font-size: 21pt; line-height: 1.12; }
  .print-topic { display: none; }
  .focus-view { display: none !important; }
  .compare-view { display: block !important; margin-top: 0; }
  .stage-card,
  .stage-card.compact {
    min-height: 0;
    margin: 0 0 4mm;
    padding: 4mm 5mm;
    border: .7pt solid #999;
    border-top: 2.2pt solid #315f8d;
    border-radius: 0;
    box-shadow: none;
    break-inside: avoid;
  }
  .stage-card.consolidated { border-top-color: #087f75; }
  .stage-card.compact h3 { margin: 3mm 0 1.5mm; font-size: 9.5pt; }
  .stage-card.compact p { color: #222; font-size: 9.3pt; line-height: 1.42; }
  .stage-index { font-size: 8pt; }
  .status-pill { padding: 1mm 1.5mm; border: .5pt solid #bbb; font-size: 6.8pt; }
  .legal-reading, .traceability { margin-top: 7mm; padding-top: 5mm; break-before: auto; }
  .section-heading h3 { font-size: 15pt; }
  .reading-grid { grid-template-columns: 1fr; border-radius: 0; }
  .reading-grid article { min-height: 0; padding: 3.5mm 4mm; break-inside: avoid; }
  .reading-grid p { margin-top: 1.5mm; font-size: 8.8pt; line-height: 1.42; }
  .source-list { border-radius: 0; }
  .source-row { grid-template-columns: 28mm minmax(0, 1fr); min-height: 0; padding: 2.5mm 3mm; break-inside: avoid; }
  .source-kind { font-size: 6.7pt; }
  .source-row strong { font-size: 8.2pt; }
  .source-row p { font-size: 7.3pt; }
  .source-warning { margin-top: 3mm; padding: 3mm; font-size: 7.5pt; break-inside: avoid; }
}
