:root {
  color-scheme: light;
  --navy-950: #081d33;
  --navy-900: #0d2948;
  --navy-800: #123b66;
  --navy-700: #1c5488;
  --gold-500: #c99a35;
  --gold-300: #e4c275;
  --ink: #142033;
  --muted: #5d6878;
  --line: #d9e0e8;
  --soft: #f3f6f9;
  --paper: #ffffff;
  --draft-bg: #fff5db;
  --draft-ink: #7a5310;
  --shadow: 0 18px 50px rgba(8, 29, 51, 0.18);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.65;
}

.draft-watermark {
  position: fixed;
  z-index: 18;
  top: 50%;
  left: 50%;
  pointer-events: none;
  user-select: none;
  color: #8f6b20;
  font-size: clamp(7rem, 20vw, 17rem);
  font-weight: 900;
  letter-spacing: 0.12em;
  line-height: 1;
  opacity: 0.09;
  text-shadow: 0 0 1px rgba(90, 61, 8, 0.2);
  transform: translate(-50%, -50%) rotate(-24deg);
  white-space: nowrap;
}

.site-version {
  position: fixed;
  z-index: 28;
  left: 1rem;
  bottom: 1rem;
  pointer-events: none;
  padding: 0.32rem 0.58rem;
  border: 1px solid rgba(122, 83, 16, 0.32);
  border-radius: 0.32rem;
  background: rgba(255, 245, 219, 0.94);
  box-shadow: 0 4px 14px rgba(8, 29, 51, 0.09);
  color: var(--draft-ink);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--navy-700); }

.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;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.75rem;
  left: 0.75rem;
  transform: translateY(-160%);
  padding: 0.65rem 0.9rem;
  border-radius: 0.35rem;
  background: var(--navy-950);
  color: white;
  text-decoration: none;
}
.skip-link:focus { transform: translateY(0); }

.site-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: grid;
  grid-template-columns: 260px minmax(260px, 620px) 1fr;
  gap: 1.25rem;
  align-items: center;
  min-height: 78px;
  padding: 0.8rem 2rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--navy-950);
  text-decoration: none;
  line-height: 1.15;
}
.brand strong, .brand small { display: block; }
.brand strong { font-family: Georgia, "Times New Roman", serif; font-size: 1.14rem; }
.brand small { margin-top: 0.2rem; color: var(--muted); font-size: 0.82rem; letter-spacing: 0.08em; text-transform: uppercase; }
.brand-logo {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border-radius: 0.35rem;
  object-fit: cover;
}

.header-search {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  min-height: 46px;
  padding: 0 0.9rem;
  border: 1px solid #cbd4df;
  border-radius: 0.6rem;
  background: var(--soft);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
.header-search:focus-within { border-color: var(--navy-700); background: white; box-shadow: 0 0 0 3px rgba(28, 84, 136, 0.12); }
.header-search svg { width: 20px; fill: none; stroke: var(--muted); stroke-linecap: round; stroke-width: 1.8; }
.header-search input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; color: var(--ink); }
.header-search kbd { padding: 0.05rem 0.4rem; border: 1px solid #cbd4df; border-radius: 0.3rem; background: white; color: var(--muted); font-size: 0.75rem; }
.library-meta { justify-self: end; color: var(--muted); font-size: 0.88rem; }
.header-actions { display: flex; align-items: center; justify-self: end; gap: 0.9rem; }
.admin-link { padding: 0.42rem 0.65rem; border: 1px solid #b9c5d1; border-radius: 0.4rem; color: var(--navy-800); font-size: 0.8rem; font-weight: 800; text-decoration: none; white-space: nowrap; }
.admin-link:hover { border-color: var(--navy-700); background: var(--soft); }
.mobile-nav-button { display: none; }

.app-shell {
  display: grid;
  grid-template-columns: 270px minmax(0, 820px) 220px;
  justify-content: center;
  min-height: calc(100vh - 78px);
}

.policy-sidebar, .section-sidebar {
  position: sticky;
  top: 78px;
  align-self: start;
  height: calc(100vh - 78px);
  overflow: auto;
  scrollbar-width: thin;
}
.policy-sidebar { padding: 2.1rem 1.4rem 7rem 2rem; border-right: 1px solid var(--line); background: #fafbfd; }
.section-sidebar { padding: 2.25rem 1.5rem; border-left: 1px solid var(--line); }
.sidebar-intro { margin-bottom: 1.6rem; }
.sidebar-intro p:last-child { margin: 0.35rem 0 0; color: var(--muted); font-size: 0.9rem; line-height: 1.5; }
.eyebrow { margin: 0; color: var(--navy-700); font-size: 0.75rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }

.policy-group { margin: 0 0 1.5rem; }
.policy-group h2 { margin: 0 0 0.4rem; color: var(--muted); font-size: 0.75rem; letter-spacing: 0.07em; text-transform: uppercase; }
.policy-link {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  width: 100%;
  margin: 0.15rem 0;
  padding: 0.55rem 0.65rem;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 0 0.35rem 0.35rem 0;
  background: transparent;
  color: #344257;
  text-align: left;
  cursor: pointer;
}
.policy-link:hover { background: #eef3f7; color: var(--navy-800); }
.policy-link[aria-current="page"] { border-left-color: var(--gold-500); background: #e9f0f6; color: var(--navy-900); font-weight: 700; }
.status-dot { width: 7px; height: 7px; margin-top: 0.55rem; flex: 0 0 auto; border-radius: 50%; background: var(--navy-700); }
.status-dot.draft { background: var(--gold-500); }
.sidebar-note { margin-top: 2.2rem; padding: 1rem; border: 1px solid #ead9ac; border-radius: 0.45rem; background: #fffaf0; font-size: 0.82rem; line-height: 1.5; }
.sidebar-note p { margin: 0.35rem 0 0; color: #6e5b35; }

.policy-main { min-width: 0; padding: 3.2rem clamp(2rem, 6vw, 5rem) 8rem; }
.policy-document { max-width: 720px; margin: 0 auto; }
.policy-document header { margin-bottom: 2.75rem; }
.policy-kicker { display: flex; flex-wrap: wrap; gap: 0.55rem; align-items: center; margin-bottom: 0.8rem; }
.category-label { color: var(--navy-700); font-size: 0.83rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.status-badge { padding: 0.15rem 0.5rem; border-radius: 999px; background: #e7f0f8; color: var(--navy-800); font-size: 0.74rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; }
.status-badge.draft { background: var(--draft-bg); color: var(--draft-ink); }
.policy-document h1 { margin: 0; color: var(--navy-950); font-family: Georgia, "Times New Roman", serif; font-size: clamp(2.15rem, 5vw, 3.45rem); font-weight: 500; letter-spacing: -0.035em; line-height: 1.08; }
.policy-summary { margin: 1.25rem 0 0; color: #455268; font-family: Georgia, "Times New Roman", serif; font-size: 1.13rem; line-height: 1.75; }
.draft-callout { margin-top: 1.25rem; padding: 0.85rem 1rem; border-left: 4px solid var(--gold-500); background: var(--draft-bg); color: var(--draft-ink); }
.policy-section { scroll-margin-top: 105px; margin: 0 0 2.7rem; }
.policy-section h2 { margin: 0 0 0.85rem; color: var(--navy-900); font-family: Georgia, "Times New Roman", serif; font-size: 1.65rem; font-weight: 600; line-height: 1.25; }
.policy-section p { margin: 0 0 1rem; }
.policy-section ul { margin: 0 0 1rem; padding-left: 1.25rem; }
.policy-section li { margin: 0.45rem 0; padding-left: 0.25rem; }
.source-note { margin-top: 4rem; padding-top: 1rem; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.8rem; }
.document-loading { padding: 3rem 0; color: var(--muted); }

.section-sidebar a { display: block; margin: 0.4rem 0; padding: 0.25rem 0; color: var(--muted); font-size: 0.88rem; line-height: 1.35; text-decoration: none; }
.section-sidebar a:hover { color: var(--navy-700); }

.search-results { max-width: 760px; margin: 0 auto; }
.search-results h1 { margin: 0 0 0.4rem; font-family: Georgia, "Times New Roman", serif; font-size: 2.1rem; font-weight: 500; }
.search-results > p { margin: 0 0 1.8rem; color: var(--muted); }
.search-result { display: block; width: 100%; margin: 0 0 0.8rem; padding: 1rem 1.1rem; border: 1px solid var(--line); border-radius: 0.5rem; background: white; color: var(--ink); text-align: left; cursor: pointer; }
.search-result:hover { border-color: #aebdcc; box-shadow: 0 8px 20px rgba(8, 29, 51, 0.07); }
.search-result strong { display: block; color: var(--navy-900); font-size: 1.05rem; }
.search-result small { display: block; margin: 0.25rem 0 0.5rem; color: var(--navy-700); }
.search-result p { margin: 0; color: var(--muted); line-height: 1.5; }
.empty-search { padding: 2.5rem; border: 1px dashed #bec9d5; border-radius: 0.5rem; color: var(--muted); text-align: center; }
mark { border-radius: 0.15rem; background: #ffedaa; color: inherit; }

.chat-launcher {
  position: fixed;
  z-index: 30;
  right: 1.5rem;
  bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 52px;
  padding: 0.75rem 1rem;
  border: 0;
  border-radius: 999px;
  background: var(--navy-900);
  box-shadow: 0 10px 28px rgba(8, 29, 51, 0.28);
  color: white;
  font-weight: 800;
  cursor: pointer;
}
.chat-launcher:hover { background: var(--navy-800); transform: translateY(-1px); }
.chat-launcher svg { width: 23px; fill: none; stroke: var(--gold-300); stroke-linejoin: round; stroke-width: 1.8; }

.chat-panel {
  position: fixed;
  z-index: 40;
  right: 1.5rem;
  bottom: 1.5rem;
  display: grid;
  grid-template-rows: auto auto minmax(180px, 1fr) auto;
  width: min(430px, calc(100vw - 2rem));
  height: min(690px, calc(100vh - 3rem));
  overflow: hidden;
  border: 1px solid #bcc8d5;
  border-radius: 0.9rem;
  background: white;
  box-shadow: var(--shadow);
}
.chat-panel[hidden] { display: none; }
.chat-panel > header { display: flex; align-items: flex-start; justify-content: space-between; padding: 1.2rem 1.25rem 1rem; border-bottom: 1px solid var(--line); }
.chat-panel h2 { margin: 0.2rem 0 0; color: var(--navy-950); font-family: Georgia, "Times New Roman", serif; font-size: 1.35rem; }
.icon-button { width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--soft); color: var(--navy-900); font-size: 1.55rem; line-height: 1; cursor: pointer; }
.chat-notice { padding: 0.7rem 1.25rem; background: #f7f4ea; color: #66562f; font-size: 0.78rem; line-height: 1.4; }
.chat-messages { overflow: auto; padding: 1.1rem 1.25rem; background: #fbfcfd; }
.message { width: fit-content; max-width: 88%; margin: 0 0 0.9rem; padding: 0.75rem 0.9rem; border-radius: 0.75rem; white-space: pre-wrap; line-height: 1.5; }
.message.assistant { border: 1px solid var(--line); border-bottom-left-radius: 0.2rem; background: white; }
.message.user { margin-left: auto; border-bottom-right-radius: 0.2rem; background: var(--navy-900); color: white; }
.message.pending { color: var(--muted); font-style: italic; }
.message-sources { max-width: 92%; margin: -0.4rem 0 1rem; padding: 0.8rem; border-left: 3px solid var(--gold-500); background: #fffaf0; font-size: 0.78rem; }
.message-sources strong { display: block; margin-bottom: 0.35rem; }
.source-button { display: block; width: 100%; margin: 0.2rem 0; padding: 0; border: 0; background: transparent; color: var(--navy-700); text-align: left; text-decoration: underline; cursor: pointer; }
.chat-panel form { display: grid; grid-template-columns: 1fr auto; gap: 0.65rem; align-items: end; padding: 0.85rem; border-top: 1px solid var(--line); background: white; }
.chat-panel textarea { width: 100%; max-height: 130px; resize: vertical; padding: 0.65rem 0.7rem; border: 1px solid #b8c4d0; border-radius: 0.45rem; outline: none; line-height: 1.4; }
.chat-panel textarea:focus { border-color: var(--navy-700); box-shadow: 0 0 0 3px rgba(28, 84, 136, 0.12); }
.chat-panel form button { min-height: 42px; padding: 0.6rem 0.9rem; border: 0; border-radius: 0.4rem; background: var(--gold-500); color: var(--navy-950); font-weight: 900; cursor: pointer; }
.chat-panel form button:disabled { opacity: 0.55; cursor: wait; }

@media (max-width: 1100px) {
  .site-header { grid-template-columns: 240px minmax(240px, 1fr); }
  .library-meta { display: none; }
  .app-shell { grid-template-columns: 250px minmax(0, 800px); }
  .section-sidebar { display: none; }
}

@media (max-width: 760px) {
  .site-header { grid-template-columns: 1fr auto; gap: 0.7rem; padding: 0.65rem 1rem; }
  .header-search { grid-column: 1 / -1; grid-row: 2; min-height: 42px; }
  .header-search kbd { display: none; }
  .header-actions { display: none; }
  .mobile-nav-button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0.45rem 0.75rem; border: 1px solid #b9c5d1; border-radius: 0.4rem; background: white; color: var(--navy-900); font-weight: 800; }
  .brand small { display: none; }
  .app-shell { display: block; }
  .policy-sidebar { position: fixed; z-index: 19; top: 132px; left: 0; width: min(330px, 90vw); height: calc(100vh - 132px); transform: translateX(-105%); box-shadow: var(--shadow); transition: transform 180ms ease; }
  .policy-sidebar.open { transform: translateX(0); }
  .policy-main { padding: 2.2rem 1.15rem 7rem; }
  .policy-document h1 { font-size: 2.25rem; }
  .chat-launcher { right: 1rem; bottom: 1rem; }
  .chat-panel { right: 0.5rem; bottom: 0.5rem; width: calc(100vw - 1rem); height: calc(100vh - 1rem); }
}

@media print {
  .site-header, .policy-sidebar, .section-sidebar, .chat-launcher, .chat-panel { display: none !important; }
  .app-shell { display: block; }
  .policy-main { padding: 0; }
  .policy-document { max-width: none; }
  .policy-section { break-inside: avoid-page; }
  .draft-watermark { z-index: 999; opacity: 0.08; }
  .site-version { z-index: 1000; right: 0.4in; bottom: 0.25in; left: auto; border: 0; box-shadow: none; background: transparent; }
}
