:root {
  color-scheme: light;
  --ink: #17211e;
  --ink-soft: #53605a;
  --paper: #f4f1e9;
  --paper-deep: #e9e4d8;
  --card: #fffdf8;
  --line: #d8d2c5;
  --forest: #173f35;
  --forest-soft: #dfe9e3;
  --copper: #ba5f38;
  --copper-soft: #f2dfd5;
  --acid: #cfe55b;
  --shadow: 0 24px 70px rgba(35, 42, 38, 0.14);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(23, 33, 30, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 33, 30, 0.035) 1px, transparent 1px),
    var(--paper);
  background-size: 32px 32px;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.top-rule {
  position: fixed;
  inset: 0 0 auto;
  z-index: 50;
  height: 5px;
  background: var(--acid);
}

.access-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 48px 20px;
}

.access-card {
  width: min(100%, 580px);
  padding: 46px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  margin-bottom: 28px;
  border-radius: 17px 17px 17px 4px;
  color: white;
  background: var(--forest);
  box-shadow: 8px 8px 0 var(--acid);
}

.mark span {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 31px;
  font-weight: 700;
}

.mark-small {
  width: 42px;
  height: 42px;
  margin: 0;
  border-radius: 12px 12px 12px 3px;
  box-shadow: 5px 5px 0 var(--acid);
}

.mark-small span { font-size: 23px; }

.eyebrow,
.section-kicker {
  margin: 0 0 8px;
  color: var(--copper);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.access-card h1,
.workspace-header h1,
.explorer h2,
.document-drawer h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  letter-spacing: -.035em;
}

.access-card h1 {
  max-width: 460px;
  font-size: clamp(38px, 7vw, 56px);
  line-height: .98;
}

.access-copy {
  margin: 24px 0 30px;
  color: var(--ink-soft);
  font-size: 16px;
  line-height: 1.65;
}

.primary-button,
.search-button {
  border: 0;
  border-radius: 12px;
  color: white;
  background: var(--forest);
  font-weight: 750;
  transition: transform .16s ease, background .16s ease;
}

.primary-button {
  width: 100%;
  min-height: 54px;
  padding: 14px 18px;
  font-size: 15px;
}

.primary-button:hover,
.search-button:hover { background: #0d3028; transform: translateY(-1px); }
.primary-button:disabled,
.search-button:disabled { cursor: wait; opacity: .6; transform: none; }
.button-icon { margin-right: 9px; font-size: 19px; }

.microcopy {
  margin: 12px 0 0;
  color: #7d867f;
  font-size: 12px;
  text-align: center;
}

.setup-panel {
  margin-top: 28px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

.setup-heading {
  display: flex;
  gap: 14px;
  margin-bottom: 20px;
}

.step-number {
  flex: 0 0 auto;
  color: var(--copper);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 800;
}

.setup-heading h2 { margin: 0 0 4px; font-size: 18px; }
.setup-heading p { margin: 0; color: var(--ink-soft); font-size: 13px; }

.setup-panel label {
  display: block;
  margin: 15px 0 7px;
  font-size: 12px;
  font-weight: 750;
}

.setup-panel input,
.search-box,
.search-row select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink);
  background: white;
}

.setup-panel input {
  height: 48px;
  padding: 0 13px;
  outline: none;
}

.setup-panel input:focus,
.search-box:focus-within,
.search-row select:focus {
  border-color: var(--forest);
  box-shadow: 0 0 0 3px rgba(23, 63, 53, .1);
}

.setup-panel .primary-button { margin-top: 20px; }
.status-message { min-height: 20px; margin: 16px 0 0; color: var(--copper); font-size: 13px; }

.privacy-note {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 25px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  color: #6f7a74;
  font-size: 12px;
}

.privacy-note span { color: var(--acid); -webkit-text-stroke: 1px var(--forest); }
.privacy-note p { margin: 0; }

.dashboard { min-height: 100vh; display: grid; grid-template-columns: 270px minmax(0, 1fr); }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 30px 22px 24px;
  border-right: 1px solid rgba(255, 255, 255, .11);
  color: #f5f3eb;
  background: var(--forest);
}

.brand-row { display: flex; align-items: center; gap: 14px; margin-bottom: 44px; }
.brand-name { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 18px; }
.brand-caption { margin: 3px 0 0; color: #9eb0a9; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }

.nav-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  color: #9eb0a9;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.count-pill {
  min-width: 24px;
  padding: 3px 7px;
  border-radius: 99px;
  color: var(--forest);
  background: var(--acid);
  text-align: center;
}

.source-list { display: grid; gap: 4px; max-height: calc(100vh - 220px); overflow: auto; }
.source-button {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 11px;
  border: 0;
  border-radius: 9px;
  color: #dfe7e2;
  background: transparent;
  font-size: 12px;
  text-align: left;
}
.source-button:hover { background: rgba(255,255,255,.07); }
.source-button.active { color: white; background: rgba(207,229,91,.14); box-shadow: inset 3px 0 0 var(--acid); }
.source-button .source-number { color: #8fa198; font-family: ui-monospace, monospace; }
.source-button.active .source-number { color: var(--acid); }

.sidebar-footer { margin-top: auto; display: grid; gap: 4px; padding-top: 20px; }
.text-button {
  padding: 8px 4px;
  border: 0;
  color: #dfe7e2;
  background: transparent;
  font-size: 12px;
  text-align: left;
}
.text-button:hover { color: white; }
.text-button.muted { color: #91a39a; }

.workspace { min-width: 0; padding: 44px clamp(24px, 5vw, 72px) 80px; }
.workspace-header { display: flex; justify-content: space-between; align-items: end; gap: 20px; }
.workspace-header h1 { font-size: clamp(36px, 5vw, 58px); }
.secure-indicator { display: flex; align-items: center; gap: 8px; color: var(--ink-soft); font-size: 11px; font-weight: 750; }
.secure-indicator span { width: 8px; height: 8px; border-radius: 50%; background: #3f9e66; box-shadow: 0 0 0 4px rgba(63,158,102,.13); }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 32px 0; }
.stat-card { min-height: 112px; padding: 20px; border: 1px solid var(--line); border-radius: 15px; background: rgba(255,253,248,.78); }
.stat-label { margin: 0 0 18px; color: var(--ink-soft); font-size: 10px; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.stat-value { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 30px; line-height: 1; }
.stat-detail { margin: 8px 0 0; color: #7a847e; font-size: 11px; }

.explorer { border: 1px solid var(--line); border-radius: 20px; background: var(--card); overflow: hidden; }
.explorer-heading-row { display: flex; justify-content: space-between; align-items: end; gap: 20px; padding: 26px 28px 20px; }
.explorer h2 { font-size: 29px; }
.current-toggle { display: flex; align-items: center; gap: 8px; color: var(--ink-soft); font-size: 12px; }
.current-toggle input { accent-color: var(--forest); }

.search-row { display: grid; grid-template-columns: minmax(220px, 1fr) 190px auto; gap: 10px; padding: 0 28px 24px; }
.search-box { height: 44px; display: flex; align-items: center; gap: 9px; padding: 0 13px; }
.search-box span { color: var(--copper); font-size: 20px; }
.search-box input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; }
.search-row select { height: 44px; padding: 0 12px; outline: 0; }
.search-button { min-width: 92px; padding: 0 18px; }
.active-query { padding: 10px 28px; border-top: 1px solid var(--line); color: var(--copper); background: var(--copper-soft); font-size: 12px; }

.document-list { border-top: 1px solid var(--line); }
.document-row {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 125px;
  gap: 20px;
  padding: 22px 28px;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: inherit;
  background: transparent;
  text-align: left;
  transition: background .14s ease;
}
.document-row:hover { background: #f7f4ed; }
.document-row:last-child { border-bottom: 0; }
.document-title { margin: 0 0 7px; font-family: Georgia, "Times New Roman", serif; font-size: 20px; font-weight: 600; line-height: 1.2; }
.document-excerpt { max-width: 760px; margin: 0; color: var(--ink-soft); font-size: 12px; line-height: 1.55; }
.document-meta { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.badge { padding: 4px 7px; border-radius: 5px; color: var(--forest); background: var(--forest-soft); font-size: 9px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.badge.kind { color: #7d3b22; background: var(--copper-soft); }
.badge.superseded { color: #6b5c1a; background: #efe8bc; }
.document-date { color: #7e8983; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; text-align: right; }
.empty-state { padding: 64px 30px; color: var(--ink-soft); text-align: center; }
.empty-state strong { display: block; margin-bottom: 7px; color: var(--ink); font-family: Georgia, serif; font-size: 22px; }
.load-more { display: block; width: calc(100% - 56px); margin: 16px 28px 22px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--forest); background: transparent; font-weight: 750; }
.load-more:hover { background: var(--forest-soft); }

.drawer-backdrop { position: fixed; inset: 0; z-index: 70; background: rgba(15, 25, 21, .42); backdrop-filter: blur(3px); }
.document-drawer { position: fixed; inset: 0 0 0 auto; z-index: 80; width: min(720px, 92vw); overflow: auto; border-left: 1px solid var(--line); background: var(--card); box-shadow: -20px 0 70px rgba(20,30,25,.22); }
.drawer-header { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; gap: 20px; padding: 30px 34px 24px; border-bottom: 1px solid var(--line); background: rgba(255,253,248,.95); backdrop-filter: blur(12px); }
.document-drawer h2 { max-width: 570px; font-size: 32px; line-height: 1.05; }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%; color: var(--ink); background: transparent; font-size: 23px; }
.drawer-content { padding: 28px 34px 70px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; margin-bottom: 28px; }
.detail-cell { padding: 13px; border: 1px solid var(--line); border-radius: 10px; }
.detail-label { margin: 0 0 6px; color: var(--ink-soft); font-size: 9px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.detail-value { margin: 0; overflow-wrap: anywhere; font-size: 12px; }
.detail-section { margin-top: 30px; }
.detail-section h3 { margin: 0 0 12px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }
.document-body { color: #34413b; font-family: Georgia, "Times New Roman", serif; font-size: 17px; line-height: 1.7; white-space: pre-wrap; }
.payload-block { overflow: auto; padding: 18px; border-radius: 12px; color: #dbe7e1; background: #13231e; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; line-height: 1.55; white-space: pre-wrap; }
.history-list { display: grid; gap: 7px; }
.history-item { display: flex; justify-content: space-between; gap: 15px; padding: 10px 12px; border-radius: 8px; background: var(--paper); font-size: 11px; }
.history-item.current { box-shadow: inset 3px 0 0 #3f9e66; }
.external-link { color: var(--copper); font-weight: 750; }

.toast { position: fixed; right: 22px; bottom: 22px; z-index: 100; max-width: 360px; padding: 14px 17px; border-radius: 10px; color: white; background: var(--ink); box-shadow: var(--shadow); font-size: 13px; }

@media (max-width: 900px) {
  .dashboard { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 20px; }
  .brand-row { margin-bottom: 20px; }
  .source-list { display: flex; max-height: none; overflow-x: auto; padding-bottom: 8px; }
  .source-button { width: auto; min-width: max-content; }
  .sidebar-footer { display: flex; gap: 18px; padding-top: 8px; }
  .workspace { padding-top: 28px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 620px) {
  .access-card { padding: 34px 24px; }
  .workspace { padding: 24px 14px 60px; }
  .workspace-header { align-items: start; flex-direction: column; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-card { min-height: 100px; padding: 16px; }
  .search-row { grid-template-columns: 1fr; padding: 0 18px 20px; }
  .search-button { min-height: 44px; }
  .explorer-heading-row { align-items: start; flex-direction: column; padding: 22px 18px 18px; }
  .document-row { grid-template-columns: 1fr; padding: 20px 18px; }
  .document-date { text-align: left; }
  .drawer-header, .drawer-content { padding-left: 22px; padding-right: 22px; }
  .detail-grid { grid-template-columns: 1fr; }
}
