:root {
  --ink: #07171d;
  --deep: #0a2028;
  --panel: #102b34;
  --panel-raised: #173640;
  --line: rgba(194, 216, 211, 0.16);
  --line-strong: rgba(194, 216, 211, 0.28);
  --text: #f4f1e7;
  --muted: #91a9aa;
  --soft: #b7c7c1;
  --amber: #e5b56b;
  --amber-bright: #f4c879;
  --mint: #8dd6c2;
  --coral: #f19b7b;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.26);
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  color: var(--text);
  background: var(--ink);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { background: var(--ink); color: var(--text); overflow: hidden; }
button, input { font: inherit; }
button { color: inherit; }

.app-shell { min-height: 100vh; background: linear-gradient(138deg, #07171d 0%, #0b2029 54%, #0b1b22 100%); }
.topbar { height: 74px; display: flex; align-items: center; justify-content: space-between; padding: 0 30px; border-bottom: 1px solid var(--line); background: rgba(7, 23, 29, 0.82); position: relative; z-index: 3; }
.brand-lockup { display: flex; align-items: center; gap: 13px; }
.brand-mark { width: 30px; height: 30px; position: relative; display: grid; align-content: center; gap: 3px; }
.brand-mark::before { content: ""; position: absolute; inset: 0; border: 1px solid var(--amber); transform: rotate(45deg); opacity: .7; }
.brand-mark span { display: block; width: 16px; height: 2px; background: var(--amber); margin-left: 7px; position: relative; z-index: 1; }
.brand-mark span:nth-child(2) { width: 11px; background: var(--mint); }
.brand-mark span:nth-child(3) { width: 7px; }
.eyebrow { margin: 0 0 5px; color: var(--amber); font-size: 9px; letter-spacing: .17em; line-height: 1.1; text-transform: uppercase; }
.topbar h1, .rail-intro h2, .inspector h2, .sources-dialog h2 { margin: 0; font-family: "Baskervville", Georgia, serif; font-weight: 400; letter-spacing: -.02em; }
.topbar h1 { font-size: 24px; line-height: 1; }
.topbar-status { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 10px; letter-spacing: .04em; }
.status-dot, .footer-led { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 4px rgba(141,214,194,.12), 0 0 14px rgba(141,214,194,.45); }
.status-slash { color: var(--line-strong); }

.workspace { height: calc(100vh - 74px); min-height: 620px; display: grid; grid-template-columns: 292px minmax(420px, 1fr) 350px; }
.control-rail, .inspector { background: rgba(12, 33, 41, .92); overflow: auto; scrollbar-width: thin; scrollbar-color: rgba(229,181,107,.35) transparent; }
.control-rail { border-right: 1px solid var(--line); padding: 29px 22px 24px; }
.rail-intro { padding-bottom: 23px; }
.rail-intro h2 { font-size: 28px; line-height: 1.06; max-width: 220px; }
.intro-copy { margin: 13px 0 0; color: var(--muted); font-size: 11px; line-height: 1.75; max-width: 241px; }
.rail-section { border-top: 1px solid var(--line); padding: 18px 0 19px; }
.field-label { color: var(--soft); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 11px; }
.section-index { color: var(--amber); font-size: 9px; letter-spacing: .15em; }
.search-section { padding-top: 16px; }
.search-section .field-label { display: block; margin-bottom: 9px; }
.search-box, .date-box { height: 39px; display: flex; align-items: center; gap: 9px; border: 1px solid var(--line-strong); background: rgba(7, 23, 29, .55); padding: 0 11px; }
.search-box:focus-within, .date-box:focus-within { border-color: var(--amber); box-shadow: 0 0 0 3px rgba(229,181,107,.08); }
.search-glyph, .calendar-glyph { color: var(--amber); font-size: 20px; line-height: 1; }
.search-box input, .date-box input { min-width: 0; flex: 1; border: 0; outline: 0; color: var(--text); background: transparent; font-size: 10px; }
.search-box input::placeholder { color: #6f8588; }
.search-box kbd { color: #819394; border: 1px solid var(--line); padding: 3px 5px; font-size: 8px; white-space: nowrap; }
.date-box input { color-scheme: dark; }
.search-results { margin-top: 5px; border: 1px solid var(--line); background: #102a33; box-shadow: var(--shadow); position: relative; z-index: 4; }
.search-result { width: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; border: 0; border-bottom: 1px solid var(--line); background: transparent; padding: 10px 11px; cursor: pointer; text-align: left; }
.search-result:last-child { border-bottom: 0; }
.search-result:hover { background: rgba(229,181,107,.1); }
.search-result strong { color: var(--text); font-size: 11px; font-weight: 500; }
.search-result span { color: var(--muted); font-size: 9px; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line-strong); }
.segment { min-height: 34px; border: 0; border-right: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; font-size: 9px; line-height: 1.25; padding: 5px 4px; }
.segment:last-child { border-right: 0; }
.segment:hover { color: var(--text); }
.segment.is-active { background: var(--amber); color: var(--ink); }
.helper-text { margin: 10px 0 0; color: #7f9798; font-size: 9px; line-height: 1.6; }
.topic-list { display: flex; flex-wrap: wrap; gap: 7px; }
.topic-chip { border: 1px solid var(--line); border-radius: 999px; padding: 7px 9px; background: transparent; color: var(--muted); cursor: pointer; font-size: 9px; }
.topic-chip:hover { border-color: var(--amber); color: var(--text); }
.topic-chip.is-active { border-color: var(--amber); color: var(--amber-bright); background: rgba(229,181,107,.09); }
.rail-note { display: flex; gap: 10px; border: 1px solid rgba(141,214,194,.2); background: rgba(141,214,194,.04); margin-top: 3px; padding: 12px 11px; }
.note-pin { color: var(--mint); font-size: 13px; }
.rail-note strong { display: block; margin-bottom: 5px; color: var(--mint); font-size: 10px; font-weight: 500; }
.rail-note p { margin: 0; color: #7e9a9a; font-size: 9px; line-height: 1.6; }

.map-stage { position: relative; min-width: 0; overflow: hidden; background: #0b2931; }
.map-canvas { position: absolute; inset: 0; }
.map-wash { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(circle at 52% 48%, transparent 18%, rgba(6, 18, 24, .12) 70%, rgba(6, 18, 24, .55) 100%), linear-gradient(180deg, rgba(6, 18, 24, .15), transparent 30%, rgba(6, 18, 24, .16)); mix-blend-mode: multiply; }
.map-stage .maplibregl-canvas { outline: none; }
.map-stage .maplibregl-ctrl-attrib { background: rgba(5, 20, 26, .78); color: #799394; font: 8px "IBM Plex Mono", monospace; }
.map-stage .maplibregl-ctrl-attrib a { color: var(--amber); }
.map-toolbar { position: absolute; top: 22px; right: 19px; display: flex; flex-direction: column; gap: 4px; z-index: 2; }
.map-tool { min-width: 34px; height: 32px; border: 1px solid var(--line-strong); background: rgba(10, 32, 40, .85); color: var(--text); cursor: pointer; font-size: 17px; line-height: 1; backdrop-filter: blur(8px); }
.map-tool:hover { border-color: var(--amber); color: var(--amber); }
.map-tool-wide { display: flex; align-items: center; justify-content: center; gap: 5px; font-size: 12px; }
.map-tool-wide span { font-size: 9px; }
.map-caption { position: absolute; left: 21px; bottom: 20px; display: flex; align-items: center; gap: 8px; color: #7c9798; font-size: 9px; letter-spacing: .05em; z-index: 2; }
.caption-rule { display: inline-block; width: 30px; height: 1px; background: var(--amber); }
.map-legend { position: absolute; right: 20px; bottom: 21px; display: grid; gap: 7px; padding: 10px 11px; border: 1px solid var(--line); background: rgba(10,32,40,.76); backdrop-filter: blur(8px); z-index: 2; }
.legend-row { display: flex; align-items: center; gap: 7px; color: #97adae; font-size: 8px; }
.legend-swatch { width: 12px; height: 7px; border: 1px solid var(--mint); background: rgba(94,160,157,.28); }
.legend-swatch.is-admin { border-color: var(--amber); background: rgba(229,181,107,.25); }
.legend-swatch.is-selected { border-color: var(--coral); background: rgba(241,155,123,.45); }
.map-loading { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: flex; align-items: center; gap: 10px; padding: 10px 13px; border: 1px solid var(--line); background: rgba(10,32,40,.84); color: var(--soft); font-size: 9px; z-index: 3; transition: opacity .3s ease, visibility .3s ease; }
.map-loading.is-hidden { opacity: 0; visibility: hidden; }
.spinner { width: 12px; height: 12px; border: 1px solid rgba(229,181,107,.25); border-top-color: var(--amber); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.inspector { border-left: 1px solid var(--line); padding: 29px 23px 18px; display: flex; flex-direction: column; }
.inspector-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.inspector h2 { font-size: 34px; line-height: .98; }
.confidence-badge { border: 1px solid rgba(141,214,194,.35); color: var(--mint); padding: 6px 7px; font-size: 8px; white-space: nowrap; letter-spacing: .06em; }
.jurisdiction-meta { margin-top: 10px; color: var(--muted); font-size: 9px; line-height: 1.6; }
.inspector-rule { height: 1px; margin: 20px 0 0; background: linear-gradient(90deg, var(--amber), rgba(229,181,107,0)); }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--line); }
.stat-cell { min-height: 74px; display: flex; flex-direction: column; justify-content: center; gap: 8px; border-right: 1px solid var(--line); padding: 10px 8px 9px 0; }
.stat-cell + .stat-cell { padding-left: 10px; }
.stat-cell:last-child { border-right: 0; }
.stat-label { color: #778f91; font-size: 8px; text-transform: uppercase; letter-spacing: .08em; }
.stat-cell strong { color: var(--text); font-size: 11px; font-weight: 500; }
.law-section { padding-top: 22px; }
.law-list { display: grid; gap: 9px; }
.law-card { border: 1px solid var(--line); background: rgba(23,54,64,.58); padding: 13px 12px; transition: border-color .2s ease, transform .2s ease; }
.law-card:hover { border-color: rgba(229,181,107,.55); transform: translateY(-1px); }
.law-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.law-card h3 { margin: 0; color: var(--text); font-family: "Baskervville", Georgia, serif; font-size: 19px; font-weight: 400; line-height: 1.08; }
.law-status { color: var(--mint); font-size: 8px; white-space: nowrap; }
.law-card .law-article { margin: 8px 0 0; color: var(--amber); font-size: 9px; }
.law-card .law-summary { margin: 8px 0 0; color: #94abad; font-size: 9px; line-height: 1.65; }
.law-metadata { display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 11px; padding-top: 8px; border-top: 1px solid var(--line); color: #789092; font-size: 8px; }
.law-metadata span::before { color: var(--amber); content: "· "; }
.law-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }
.topic-tag { color: var(--mint); font-size: 8px; }
.source-link { color: var(--amber); text-decoration: none; font-size: 8px; }
.source-link:hover { color: var(--amber-bright); text-decoration: underline; }
.empty-state { border: 1px dashed var(--line-strong); padding: 18px 13px; color: #8da4a4; font-size: 9px; line-height: 1.7; }
.empty-state strong { display: block; color: var(--soft); font-size: 11px; font-weight: 500; margin-bottom: 7px; }
.culture-section { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 17px; }
.culture-topline { display: flex; justify-content: space-between; margin-bottom: 9px; }
.culture-section p { margin: 0; color: #8fa6a6; font-size: 9px; line-height: 1.7; }
.inspector-footer { display: flex; align-items: center; justify-content: space-between; gap: 9px; margin-top: auto; padding-top: 22px; color: #789092; font-size: 8px; }
.inspector-footer > div { display: flex; align-items: center; gap: 7px; }
.text-button { border: 0; padding: 0; background: transparent; color: var(--amber); cursor: pointer; font-size: 8px; }
.text-button:hover { color: var(--amber-bright); }

.sources-dialog { width: min(680px, calc(100vw - 32px)); max-height: 80vh; border: 1px solid var(--line-strong); padding: 0; background: #0e2831; color: var(--text); box-shadow: var(--shadow); }
.sources-dialog::backdrop { background: rgba(1, 8, 11, .72); backdrop-filter: blur(4px); }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; padding: 22px 22px 17px; border-bottom: 1px solid var(--line); }
.sources-dialog h2 { font-size: 30px; }
.close-button { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 24px; line-height: 1; }
.close-button:hover { color: var(--amber); }
.sources-list { display: grid; gap: 11px; padding: 17px 22px 22px; overflow: auto; }
.source-row { border: 1px solid var(--line); padding: 12px; }
.source-row strong { display: block; margin-bottom: 6px; color: var(--text); font-family: "Baskervville", Georgia, serif; font-size: 17px; font-weight: 400; }
.source-row p { margin: 0; color: var(--muted); font-size: 9px; line-height: 1.65; }
.source-row a { display: inline-block; margin-top: 9px; color: var(--amber); font-size: 8px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); border: 1px solid var(--line-strong); background: #132f38; color: var(--soft); padding: 10px 13px; font-size: 9px; opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; z-index: 10; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1180px) {
  .workspace { grid-template-columns: 250px minmax(360px, 1fr) 310px; }
  .control-rail { padding-left: 17px; padding-right: 17px; }
  .inspector { padding-left: 18px; padding-right: 18px; }
  .rail-intro h2 { font-size: 25px; }
}

@media (max-width: 880px) {
  body { overflow: auto; }
  .topbar { padding: 0 18px; }
  .topbar-status { display: none; }
  .workspace { height: auto; min-height: 0; display: block; }
  .control-rail, .inspector { overflow: visible; }
  .control-rail { border-right: 0; border-bottom: 1px solid var(--line); padding: 22px 18px 16px; }
  .rail-intro h2 { max-width: none; }
  .intro-copy { max-width: 520px; }
  .rail-section { display: inline-block; width: calc(50% - 9px); margin-right: 14px; vertical-align: top; }
  .rail-section:nth-of-type(even) { margin-right: 0; }
  .search-section { width: 100%; margin-right: 0; }
  .rail-note { margin-top: 10px; }
  .map-stage { height: 540px; }
  .inspector { border-left: 0; border-top: 1px solid var(--line); min-height: 520px; padding: 24px 18px; }
}

@media (max-width: 560px) {
  .topbar { height: 64px; }
  .workspace { min-height: 0; }
  .rail-section { display: block; width: 100%; margin-right: 0; }
  .map-stage { height: 430px; }
  .map-caption { left: 12px; bottom: 12px; font-size: 8px; }
  .map-legend { right: 12px; bottom: 12px; }
  .inspector h2 { font-size: 30px; }
}
