@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Source+Serif+4:wght@400;500;600;700&display=swap');

:root {
  color-scheme: light;
  --page: #f6f7f9;
  --surface: #fff;
  --sidebar: #fbfcfd;
  --ink: #1d2735;
  --muted: #586675;
  --faint: #a7b0bb;
  --line: #e7ebef;
  --accent: #136c5b;
  --accent-soft: #e8f4f0;
  --accent-dark: #0c5849;
  --highlight: #fff0a8;
  --shadow: 0 16px 48px rgba(27, 40, 54, .08);
  --reader-size: 17px;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); font-family: 'DM Sans', sans-serif; font-size: 14px; }
button, input, select { font: inherit; }
button { color: inherit; }
:where(button, a, select, summary, [tabindex]):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.app-shell { display: grid; grid-template-columns: 284px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; display: flex; flex-direction: column; height: 100vh; padding: 26px 18px 19px; background: var(--sidebar); border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; margin: 0 5px 30px; color: inherit; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 13px; background: var(--accent); color: white; font-family: 'Source Serif 4', serif; font-size: 25px; box-shadow: 0 5px 12px #136c5b2b; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; letter-spacing: -.3px; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.search-wrap { position: relative; display: flex; align-items: center; height: 42px; padding: 0 9px 0 12px; background: white; border: 1px solid var(--line); border-radius: 9px; }
.search-wrap:focus-within { border-color: #9dc8bb; box-shadow: 0 0 0 3px #136c5b13; }
.search-icon { margin-right: 8px; color: #85919e; font-size: 24px; line-height: 1; transform: rotate(-20deg); }
.search-wrap input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 12px; }
kbd { flex: 0 0 auto; padding: 3px 5px; border: 1px solid #e8ebee; border-radius: 4px; background: #f8f9fa; color: #87919d; font: 10px 'DM Sans', sans-serif; }
.search-hint { min-height: 30px; padding: 8px 2px 0; color: var(--muted); font-size: 11px; }
.search-wrap input::placeholder { color: var(--muted); }
.nav-heading { display: flex; justify-content: space-between; align-items: center; margin: 18px 7px 9px; color: #98a2ad; font-size: 9px; font-weight: 700; letter-spacing: 1.15px; }
.nav-heading #doc-count { display: grid; place-items: center; min-width: 20px; height: 20px; border-radius: 7px; background: #eef1f3; color: #687584; letter-spacing: 0; }
.document-list { flex: 1; overflow: auto; margin: 0 -7px; padding: 0 4px 12px; scrollbar-width: thin; }
.nav-group-label { margin: 16px 9px 6px; color: #a3acb6; font-size: 9px; font-weight: 700; letter-spacing: .9px; text-transform: uppercase; }
.doc-nav-item { display: flex; align-items: center; width: 100%; gap: 10px; padding: 9px 10px; margin: 2px 0; border: 0; border-radius: 8px; background: transparent; cursor: pointer; text-align: left; transition: background .16s, color .16s; }
.doc-nav-item:hover { background: #f0f3f5; }
.doc-nav-item.active { background: var(--accent-soft); color: var(--accent-dark); }
.nav-copy { min-width: 0; }
.nav-title { display: block; color: var(--ink); font-size: 14px; font-weight: 600; }
.doc-nav-item.active .nav-title { color: var(--accent-dark); }
.nav-detail { display: -webkit-box; overflow: hidden; margin-top: 3px; color: var(--muted); font-size: 11px; line-height: 1.4; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.sidebar-bottom { padding-top: 13px; border-top: 1px solid var(--line); }
.load-status { min-height: 26px; padding: 0 4px; color: var(--muted); font-size: 10px; line-height: 1.4; }
.load-status.ready { color: var(--accent); }
.load-status.error { color: #a64e43; }
.load-button { display: flex; align-items: center; justify-content: center; gap: 7px; height: 37px; border: 1px solid #dfe6e9; border-radius: 8px; color: #485664; cursor: pointer; font-size: 11px; font-weight: 600; transition: .15s; }
.load-button:hover { border-color: #a4cbbf; background: #f5faf8; color: var(--accent-dark); }
.load-button span { font-size: 17px; font-weight: 400; }
.load-link { display: block; margin-top: 9px; color: #7d8995; cursor: pointer; font-size: 10px; text-align: center; }
.load-link:hover { color: var(--accent); text-decoration: underline; }
.main-area { min-width: 0; }
.topbar { position: sticky; z-index: 4; top: 0; display: flex; align-items: center; justify-content: space-between; height: 62px; padding: 0 clamp(22px, 4vw, 56px); border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--page) 91%, transparent); backdrop-filter: blur(14px); }
.breadcrumbs { display: flex; align-items: center; gap: 10px; color: #8d98a4; font-size: 11px; }
.breadcrumbs strong { color: #44505d; font-weight: 600; }
.crumb-separator { color: #c1c8cf; }
.top-actions { display: flex; align-items: center; gap: 7px; }
.icon-button { display: grid; place-items: center; min-width: 32px; height: 32px; padding: 0 7px; border: 1px solid transparent; border-radius: 7px; background: transparent; color: #707c89; cursor: pointer; font-size: 11px; font-weight: 600; }
.icon-button:hover { border-color: var(--line); background: var(--surface); color: var(--ink); }
.icon-button[aria-disabled="true"], .icon-button:disabled { opacity: .45; cursor: default; }
.mobile-search { display: none; }
.magnifier { position: relative; width: 12px; height: 12px; border: 1.5px solid currentColor; border-radius: 50%; }
.magnifier::after { position: absolute; right: -5px; bottom: -3px; width: 6px; height: 1.5px; background: currentColor; content: ''; transform: rotate(45deg); }
.text-button { min-height: 40px; padding: 6px 8px; border: 0; border-radius: 6px; background: transparent; color: var(--accent-dark); cursor: pointer; font-weight: 600; }
.text-button:hover { background: var(--accent-soft); }
.back-to-results { margin-right: auto; margin-left: 12px; white-space: nowrap; }
.action-divider { width: 1px; height: 20px; margin: 0 3px; background: var(--line); }
.mobile-document-select { display: none; max-width: min(44vw, 190px); height: 32px; padding: 0 24px 0 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--ink); font-size: 11px; }
.welcome-state { display: grid; min-height: calc(100vh - 62px); padding: 36px; place-items: center; }
.welcome-card { max-width: 540px; padding: 50px 52px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); text-align: center; }
.welcome-icon { display: grid; width: 60px; height: 60px; margin: 0 auto 25px; place-items: center; border: 1px solid #d8ebe5; border-radius: 18px; background: #f0f8f5; color: var(--accent); font-family: 'Source Serif 4', serif; font-size: 34px; }
.eyebrow { margin: 0 0 11px; color: var(--accent); font-size: 9px; font-weight: 700; letter-spacing: 1.35px; }
.welcome-card h1, .search-page-heading h1 { margin: 0; color: #202b38; font-family: 'Source Serif 4', serif; font-size: clamp(32px, 4vw, 43px); font-weight: 500; letter-spacing: -1.3px; }
.welcome-copy { max-width: 410px; margin: 15px auto 23px; color: #778390; font-size: 13px; line-height: 1.8; }
.primary-button { display: inline-flex; align-items: center; gap: 18px; padding: 12px 17px; border-radius: 8px; background: var(--accent); color: white; cursor: pointer; font-size: 12px; font-weight: 600; transition: background .15s, transform .15s; }
.primary-button:hover { background: var(--accent-dark); transform: translateY(-1px); }
.welcome-note { margin: 18px 0 0; color: #a0a9b3; font-size: 10px; }
.welcome-note strong { color: #7d8995; font-weight: 600; }
.loading-indicator { display: flex; justify-content: center; gap: 5px; margin: 0 auto; }
.loading-indicator span { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: loading-pulse 1.1s ease-in-out infinite; }
.loading-indicator span:nth-child(2) { animation-delay: .15s; }
.loading-indicator span:nth-child(3) { animation-delay: .3s; }
@keyframes loading-pulse { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-4px); } }
.reader { padding: 34px clamp(22px, 4vw, 56px) 90px; }
.reader-layout { display: grid; grid-template-columns: minmax(0, 790px) minmax(175px, 225px); justify-content: center; gap: clamp(28px, 4vw, 62px); max-width: 1210px; margin: 0 auto; }
.reader-layout:has(.outline-panel[hidden]) { grid-template-columns: minmax(0, 790px); }
.document-column { min-width: 0; }
.document-heading { padding: 18px 0 26px; border-bottom: 1px solid var(--line); }
.doc-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.type-pill { padding: 5px 8px; border: 1px solid #d8eae4; border-radius: 5px; background: #eff8f5; color: var(--accent-dark); font-size: 9px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; }
.doc-filename { color: #a1aab4; font-size: 10px; }
.document-heading h1 { max-width: 760px; margin: 0; color: #202b38; font-family: 'Source Serif 4', serif; font-size: clamp(28px, 3.2vw, 39px); font-weight: 500; letter-spacing: -.9px; line-height: 1.22; }
.document-subtitle { margin: 10px 0 0; color: var(--muted); font-size: 14px; line-height: 1.7; }
.document-content { min-width: 0; padding-top: 18px; color: #35404c; font-family: 'Source Serif 4', Georgia, serif; font-size: var(--reader-size); line-height: 1.76; }
.document-content p { margin: 0 0 13px; overflow-wrap: anywhere; scroll-margin-top: 76px; white-space: pre-wrap; }
.document-content p.doc-heading { margin-top: 27px; margin-bottom: 10px; color: #1f2c39; font-family: 'DM Sans', sans-serif; font-size: 16px; font-weight: 700; line-height: 1.5; }
.document-content p.doc-subheading { margin-top: 20px; margin-bottom: 8px; color: #263341; font-family: 'DM Sans', sans-serif; font-size: 14px; font-weight: 600; line-height: 1.55; }
.document-content p.doc-section { margin-top: 20px; color: #223141; font-weight: 600; }
.document-content p.doc-compact { margin-bottom: 5px; }
.document-content table { width: 100%; margin: 0; border-collapse: collapse; background: var(--surface); font-family: 'DM Sans', sans-serif; font-size: max(12px, calc(var(--reader-size) - 5px)); line-height: 1.6; table-layout: fixed; }
.document-content td, .document-content th { min-width: 0; padding: 9px 11px; border: 1px solid #dfe4e8; vertical-align: top; overflow-wrap: anywhere; }
.document-content td p { margin-bottom: 8px; overflow-wrap: anywhere; }
.document-content td p:last-child { margin-bottom: 0; }
.document-content tr:first-child td { background: #f4f7f7; font-weight: 600; }
.table-scroll { max-width: 100%; overflow-x: auto; margin: 0 0 20px; overscroll-behavior-inline: contain; scrollbar-width: thin; }
.table-scroll table { min-width: 100%; }
.table-scroll:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.document-content img { display: block; max-width: min(100%, 720px); max-height: 700px; height: auto; margin: 16px auto 22px; object-fit: contain; }
.document-content a { color: var(--accent); }
.document-content mark, .search-result mark { padding: 0 .08em; border-radius: 2px; background: var(--highlight); color: var(--ink); }
.outline-panel { min-width: 0; }
.outline-sticky { position: sticky; top: 86px; max-height: calc(100vh - 110px); overflow: auto; padding: 17px 0 20px; scrollbar-width: thin; }
.outline-sticky summary { padding: 8px; color: var(--ink); cursor: pointer; font-size: 14px; font-weight: 700; }
.outline-list { display: flex; flex-direction: column; gap: 2px; }
.outline-link { display: block; padding: 8px 9px; border-left: 2px solid var(--line); color: var(--muted); font-size: 12px; line-height: 1.45; text-decoration: none; }
.outline-link:hover { border-color: var(--accent); color: var(--accent-dark); }
.outline-link.level-2 { padding-left: 17px; }
.empty-document { margin-top: 35px; padding: 25px; border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); text-align: center; }
.search-view { max-width: 930px; margin: 0 auto; padding: 48px clamp(22px, 5vw, 65px) 80px; }
.search-page-heading { padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.search-page-heading h1 { font-size: 36px; }
.search-page-heading .text-button { margin: 0 0 8px -8px; }
.search-results { padding-top: 13px; }
.result-count { margin: 8px 0 12px; color: #8b96a2; font-size: 11px; }
.search-result { display: block; width: 100%; padding: 16px 2px; border: 0; border-bottom: 1px solid var(--line); background: transparent; cursor: pointer; text-align: left; }
.search-result:hover .result-title { color: var(--accent); }
.result-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 3px 9px; margin-bottom: 5px; color: var(--muted); font-size: 12px; }
.result-meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-meta strong { color: var(--accent); font-weight: 700; letter-spacing: .5px; text-transform: uppercase; }
.result-title { color: #263341; font-size: 13px; font-weight: 600; transition: color .12s; }
.result-snippet { display: block; margin-top: 6px; color: var(--muted); font-family: 'Source Serif 4', serif; font-size: 15px; line-height: 1.6; }
.no-results { padding: 45px 10px; color: #8d98a4; text-align: center; }
.toast { position: fixed; z-index: 10; right: 24px; bottom: 24px; max-width: 360px; padding: 11px 15px; border: 1px solid #d9e3df; border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); color: var(--ink); font-size: 11px; opacity: 0; pointer-events: none; transform: translateY(8px); transition: .2s; }
.toast.visible { opacity: 1; transform: translateY(0); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; clip-path: inset(50%); }
[hidden] { display: none !important; }

body.dark {
  color-scheme: dark;
  --page: #171d23; --surface: #202830; --sidebar: #1b2229; --ink: #e3e8ec; --muted: #a4afb9; --faint: #8995a0; --line: #303941; --accent: #73c1aa; --accent-soft: #263b38; --accent-dark: #a4deca; --highlight: #645a2c; --shadow: 0 16px 48px #0005;
}
body.dark .search-wrap, body.dark kbd { background: #202830; }
body.dark .nav-title, body.dark .breadcrumbs strong, body.dark .document-heading h1, body.dark .welcome-card h1, body.dark .search-page-heading h1, body.dark .document-content, body.dark .document-content p.doc-heading, body.dark .document-content p.doc-subheading, body.dark .document-content p.doc-section, body.dark .result-title { color: #dce3e8; }
body.dark .doc-nav-item:hover, body.dark .icon-button:hover { background: #263038; }
body.dark .document-content tr:first-child td { background: #29333a; }
body.dark .document-content td, body.dark .document-content th { border-color: #3a454e; }
body.dark .type-pill { background: #263b38; border-color: #34554b; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 248px minmax(0, 1fr); }
  .reader-layout { grid-template-columns: minmax(0, 1fr); }
  .outline-panel { grid-row: 1; }
  .reader-layout { gap: 16px; }
  .outline-sticky { position: static; max-height: none; padding: 2px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); overflow: visible; }
  .outline-list { max-height: 260px; overflow: auto; padding: 0 4px 6px; }
}
@media (max-width: 650px) {
  .app-shell { display: block; }
  .sidebar { position: relative; z-index: 5; height: auto; padding: 13px 15px 10px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { margin: 0 0 12px; }
  .brand-mark { width: 34px; height: 34px; }
  .nav-heading, .document-list, .search-wrap kbd { display: none; }
  .search-wrap input { font-size: 16px; }
  .search-hint { min-height: 0; padding-top: 5px; }
  .sidebar-bottom { display: block; padding-top: 6px; border-top: 0; }
  .topbar { height: 54px; padding: 0 10px; gap: 4px; }
  .welcome-state { min-height: calc(100vh - 160px); padding: 20px 14px; }
  .welcome-card { padding: 35px 22px; }
  .reader { padding: 20px 18px 60px; }
  .document-heading { padding-top: 5px; }
  .search-view { padding: 30px 19px 60px; }
  .mobile-document-select:not([hidden]) { display: block; }
  .mobile-document-select { max-width: min(31vw, 150px); height: 40px; }
  .breadcrumbs { min-width: 0; flex: 1 1 auto; overflow: hidden; white-space: nowrap; }
  .breadcrumbs > span:first-child, .breadcrumbs .crumb-separator { display: none; }
  .breadcrumbs strong { display: block; max-width: 92px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .top-actions { gap: 3px; }
  .top-actions .action-divider { margin: 0 1px; }
  .top-actions .icon-button { min-width: 36px; height: 44px; padding: 0 4px; }
  .mobile-search { display: grid; }
  .back-to-results { margin: 0; font-size: 12px; }
  .topbar:has(.back-to-results:not([hidden])) .breadcrumbs { display: none; }
  .document-heading h1 { font-size: clamp(23px, 6vw, 27px); letter-spacing: -.5px; }
  .document-content td, .document-content th { padding: 7px 8px; }
  .table-scroll { margin-right: -18px; padding-right: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .loading-indicator span { animation: none; }
}
