/* Full-window research workspace; panes scroll independently. */
#bibliography-items {font-family:Georgia,"Times New Roman",serif;line-height:1.5}
#bibliography-items p {margin:0 0 .75em}
#bibliography-items a {color:var(--accent);text-decoration:underline;text-underline-offset:.15em}
#bibliography-order {max-width:100%}
:root {font-family:Calibri,"Segoe UI",Arial,sans-serif;color:#202e3b;background:#f1f6fa;font-size:16px;line-height:1.5;--accent:#166ba4;--border:#d4e2eb}
* {box-sizing:border-box}
body {margin:0;height:100vh;height:100dvh;display:flex;flex-direction:column;overflow:hidden}
header {flex:none;display:flex;align-items:center;justify-content:space-between;gap:16px;padding:10px 18px;border-top:4px solid #378dc4;border-bottom:1px solid var(--border);background:#fff}
h1 {font-size:1.3rem;font-weight:600;line-height:1.2;margin:0;white-space:nowrap}
h2 {font-size:1.2rem;line-height:1.35;margin:0 0 12px}
main {flex:1;min-height:0;display:flex;flex-direction:column}
#research {flex:1;min-height:0;display:flex;flex-direction:column}
.card {background:#fff;border:1px solid var(--border);border-radius:6px;padding:20px}
.login {width:min(620px,calc(100% - 32px));margin:32px auto;overflow:auto}
.search-box {flex:none;max-height:46vh;overflow:auto;padding:12px 18px;border:0;border-bottom:1px solid var(--border);border-radius:0}
.input-row {display:flex;gap:10px;margin-top:5px}
input[type=search],input[type=password] {min-width:0;flex:1;border:1px solid #9bafbd;border-radius:5px;padding:9px 12px;font:inherit;background:#fff}
button,.button {display:inline-block;border:1px solid var(--accent);border-radius:5px;padding:8px 16px;background:var(--accent);color:#fff;font:inherit;font-weight:600;cursor:pointer;text-decoration:none}
button:hover,.button:hover {filter:brightness(.94)}
button:disabled {opacity:.55;cursor:wait}
.secondary {background:transparent;color:var(--accent);padding:6px 12px}
:where(input,select,button,a,summary):focus-visible {outline:3px solid #e4ad42;outline-offset:2px}
.filters {display:flex;gap:18px;align-items:center;flex-wrap:wrap;margin:10px 0;font-size:.87rem}
select {font:inherit;padding:5px;border:1px solid var(--border);border-radius:4px;max-width:100%}
input[type=checkbox] {accent-color:var(--accent)}
details {font-size:.85rem;color:#516878}
summary {cursor:pointer}
details p {max-width:1000px}
code {background:#edf3f7;padding:2px 4px}
#active-filters {color:#155d90;margin:6px 0}
#active-filters:empty {display:none}
.condition {display:flex;gap:8px;margin:10px 0;align-items:center;flex-wrap:wrap}
.condition input {flex:1;min-width:130px;font:inherit;padding:8px;border:1px solid var(--border);border-radius:5px}
.advanced-options {display:flex;gap:8px 18px;align-items:center;flex-wrap:wrap;margin:10px 0}
.advanced-options label {min-height:32px;display:flex;align-items:center;gap:4px}
#search-message:empty {display:none}
#search-message {flex:none;min-height:24px;font-size:.86rem;margin:0;padding:5px 18px}
.workspace {flex:1;min-height:0;display:flex;position:relative;isolation:isolate;border-top:1px solid var(--border)}
.sidebar {flex:none;width:280px;min-height:0;display:flex;flex-direction:column;background:#fff;border-right:1px solid var(--border)}
#toggle-results {flex:none;align-self:flex-end;width:30px;height:28px;padding:2px;margin:5px 6px;border-color:var(--border);color:#516878;font-size:.85rem;line-height:1}
.results {flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;border:0;border-radius:0;padding:0 0 16px}
.results-collapsed .sidebar {width:44px}
.results-collapsed #toggle-results {align-self:center}
.section-heading {display:flex;justify-content:space-between;align-items:baseline;gap:8px;padding:0 14px}
.section-heading span {font-size:.75rem;color:#516878}
.result-tabs {display:flex;gap:6px;padding:0 14px 12px;flex-wrap:wrap}
.result-tabs button {font-size:.85rem}
[aria-pressed=true] {background:#d9effc;color:#134c79}
#hits {list-style:none;padding:0;margin:0}
#hits li {border-top:1px solid var(--border)}
.hit {display:grid;grid-template-columns:2.2em minmax(0,1fr);column-gap:6px;row-gap:4px;width:100%;border:0;border-radius:0;text-align:left;background:transparent;color:inherit;font-weight:400;padding:10px 14px;font-size:.9rem;overflow-wrap:anywhere}
.hit:hover {background:#eef7fc}
.hit-number {color:#516878;font-variant-numeric:tabular-nums}
.hit-title {grid-column:2}
.hit-year {grid-column:2;text-align:right;font-size:.78rem;color:#516878}
.results #more {margin:12px 14px 0;font-size:.85rem}
.reading {flex:1;min-width:0;min-height:0;overflow:auto;overscroll-behavior:contain;border:0;border-radius:0;padding:22px 28px}
.reading h2 {font-size:1.6rem;font-weight:500;margin-top:10px}
#reading-empty {margin:35px 0;color:#516878}
.eyebrow {font-size:.78rem;letter-spacing:.12em;font-weight:700;color:var(--accent)}
#article-author {display:block;letter-spacing:.04em;text-transform:none}
#article-meta {margin:8px 0 12px}
.article-actions {display:flex;justify-content:space-between;align-items:center;gap:12px;margin-bottom:16px}
.muted {color:#516878}
.small {font-size:.8rem}
.tabs {display:flex;gap:10px;border-top:1px solid var(--border);padding-top:12px;margin-top:12px}
.article-text {white-space:pre-wrap;overflow-wrap:anywhere;font-family:Georgia,serif;font-size:1.08rem;line-height:1.85;padding:8px 0 18px}
mark {background:#ffe09b;color:inherit;border-radius:2px}
.preview-card {display:block;background:#fff;color:inherit;width:100%;text-align:left;border:1px solid var(--border);padding:18px;margin-bottom:14px;font-weight:400}
.preview-card strong {display:block;color:#155d90;margin-bottom:8px}
.preview-card p {margin:10px 0;white-space:pre-wrap}
.preview-card .meta {font-size:.8rem;color:#516878}
.image-grid {display:grid;grid-template-columns:repeat(auto-fill,minmax(180px,1fr));gap:16px}
#image-more {margin-top:16px}
.image-tile {min-width:0;background:#f8fbfd;color:inherit;text-align:left;padding:10px;border:1px solid var(--border);font-weight:400;border-radius:6px;margin:0}
.image-tile img {display:block;width:100%;height:180px;object-fit:contain;background:#edf3f7}
.image-tile figcaption,.image-tile span {display:block;font-size:.85rem;margin-top:8px;overflow-wrap:anywhere}
.image-tile.selected {outline:3px solid #f4b130;outline-offset:2px}
.research-info {flex:none;max-height:24vh;overflow:auto;padding:5px 18px;border-top:1px solid var(--border)}
.pilot-note {margin:8px 0;padding:8px 12px;background:#e5f2fb;border-left:3px solid #378dc4}
footer {font-size:.8rem;color:#516878;padding:6px 0}
[hidden] {display:none!important}
@media(max-width:800px) {
 header {padding:8px 12px;gap:8px}
 h1 {font-size:1.05rem}
 header button {font-size:.8rem}
 .search-box {padding:10px 12px}
 .filters {gap:8px;font-size:.8rem}
 #search-message {padding:4px 12px;font-size:.8rem}
 .sidebar {width:44px}
 #toggle-results {align-self:center}
 .results {position:absolute;left:44px;top:0;bottom:0;width:min(300px,calc(100% - 44px));z-index:2;border-right:1px solid var(--border);box-shadow:6px 0 18px #163c5426}
 .reading {padding:16px}
 .reading h2 {font-size:1.35rem}
 .article-actions {gap:8px}
 .article-actions button,.article-actions a {font-size:.8rem;padding:6px 8px}
 .image-grid {grid-template-columns:repeat(auto-fill,minmax(140px,1fr));gap:10px}
 .research-info {padding:5px 12px}
}

.fulltext-help,.within-help {display:flex;align-items:center;gap:8px}
#search-help {width:26px;height:26px;padding:0;border-radius:50%;border-color:var(--border);font-size:.85rem}
.sidebar-heading {display:flex;align-items:center;min-height:40px;flex:none}
.sidebar-heading .section-heading {flex:1;min-width:0;padding-right:0}
.sidebar-heading h2 {font-size:1.1rem;margin:0}
.sidebar-heading #toggle-results {align-self:auto}
.results-collapsed .sidebar-heading .section-heading {display:none}
.results-collapsed .sidebar-heading {justify-content:center}
#help-dialog {width:min(720px,calc(100% - 28px));max-height:85vh;padding:22px;border:1px solid var(--border);border-radius:10px;color:#202e3b;background:white;overflow:auto}
#help-dialog::backdrop {background:#12304766}
.help-heading {display:flex;align-items:center;justify-content:space-between;gap:16px}
.help-heading h2 {margin:0}
#help-dialog h3 {font-size:1rem;margin-top:22px}
#help-dialog p,#help-dialog table {font-size:.9rem}
#help-dialog table {width:100%;border-collapse:collapse}
#help-dialog th,#help-dialog td {text-align:left;vertical-align:top;padding:10px 8px;border-bottom:1px solid var(--border);overflow-wrap:anywhere}
#help-dialog td:first-child {width:38%}
@media(max-width:800px) {
 .sidebar-heading {position:relative;z-index:3}
 .workspace:not(.results-collapsed) .sidebar-heading {position:absolute;left:0;top:0;width:min(344px,100%);background:#fff;border-bottom:1px solid var(--border)}
 .results {top:40px}
 #help-dialog {padding:16px}
}

.condition .add-condition,.condition .remove-condition {width:30px;height:30px;padding:0;flex:none;font-size:1.1rem;border-color:var(--border)}
.register-menu {position:relative;font-size:inherit;color:inherit}
.register-menu summary {border:1px solid var(--border);border-radius:4px;padding:5px 8px;background:#fff}
.register-options {display:flex;flex-direction:column;gap:6px;padding:10px;background:#fff;border:1px solid var(--border);border-radius:4px}
.register-options label {white-space:nowrap}
.filters {align-items:flex-start}
.fulltext-help,.within-option {min-height:32px;align-content:center}

.register-filter {display:flex;align-items:flex-start;gap:6px}
.register-filter>span {line-height:32px}
.filters select,.register-menu summary {appearance:none;height:32px;font:inherit;line-height:20px;padding:5px 26px 5px 8px;border:1px solid var(--border);border-radius:4px;background-color:#fff;color:inherit;background-image:linear-gradient(45deg,transparent 50%,#354c5e 50%),linear-gradient(135deg,#354c5e 50%,transparent 50%);background-position:calc(100% - 12px) 13px,calc(100% - 8px) 13px;background-size:4px 4px;background-repeat:no-repeat}
.register-menu summary {list-style:none;min-width:90px}
.register-menu summary::-webkit-details-marker {display:none}

/* Interface typography is inherited; source passages retain a serif face. */
input,select,button,textarea,code {font-family:inherit}
#article-title,.article-text,.preview-card p,.image-tile figcaption,.image-tile span {font-family:Georgia,"Times New Roman",serif}
.reading-shell {position:relative;flex:1;min-width:0;min-height:0;display:flex;overflow:hidden}
.reading {padding-top:64px}
#article-toolbar {position:absolute;right:12px;top:10px;z-index:1;display:flex;align-items:center;gap:3px;padding:4px;background:#fffffff5;border:1px solid var(--border);border-radius:8px;box-shadow:0 3px 12px #163c5426;max-width:100%}
#article-toolbar button,#article-toolbar a {display:flex;align-items:center;justify-content:center;width:36px;height:32px;padding:3px;border-color:transparent;font-size:.85rem;line-height:1}
#article-toolbar #back {font-size:1.3rem}
#article-toolbar svg {width:21px;height:21px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
#article-toolbar :disabled,#article-toolbar [aria-disabled=true] {opacity:.4;cursor:default}
#toolbar-grip {display:flex;align-items:center;justify-content:center;width:18px;height:32px;color:#687e8d;cursor:grab;touch-action:none;user-select:none;border-radius:3px}
#toolbar-grip:active {cursor:grabbing}
#toolbar-grip:focus-visible {outline:3px solid #e4ad42;outline-offset:1px}

/* Equal outer columns keep the municipal logo centered in the viewport. */
header {display:grid;grid-template-columns:minmax(0,1fr) auto minmax(0,1fr)}
header h1 {min-width:0;white-space:normal}
header #logout {justify-self:end}
.municipal-logo {display:block;width:210px;max-width:30vw;line-height:0}
.municipal-logo img {display:block;width:100%;height:auto}
@media(max-width:600px) {
 header {gap:8px}
 header h1 {font-size:.9rem}
 .municipal-logo {width:160px}
 header #logout {padding:6px 8px}
}

.session-actions {justify-self:end;display:flex;gap:6px;flex-wrap:wrap;justify-content:flex-end}

#ai-answer-text,#ai-trace{white-space:pre-wrap;overflow-wrap:anywhere;line-height:1.6}
#ai-answer{padding-top:0} #ai-question{font-size:1.12rem;line-height:1.5} .source-reference{padding:0 .25rem;display:inline;font:inherit}

#ai-answer-text{font-family:Georgia,"Times New Roman",serif;font-size:1.08rem;line-height:1.85}
#ai-answer-text h3{font:inherit;font-weight:700;margin:1em 0 .35em;white-space:normal}
#ai-answer-text h3:first-child{margin-top:0}

#research-history{margin-top:24px;border-top:1px solid var(--border);padding-top:14px}
#history-items{list-style:none;padding:0}#history-items li{display:flex;gap:4px;margin:6px 0}.history-open{flex:1;min-width:0;text-align:left;overflow-wrap:anywhere}

/* Research answers and compact saved results. */
#ai-answer-text{white-space:normal;line-height:1.7}
#ai-answer-text p{margin:.7em 0}
#ai-answer-text h3,#ai-answer-text strong{font-weight:700}
#ai-answer-text h3{font-family:Calibri,"Segoe UI",sans-serif;font-size:1.12rem;margin:1.2em 0 .45em}
#ai-answer-text ul,#ai-answer-text ol{padding-left:1.5em;margin:.7em 0}
#ai-answer-text li{margin:.35em 0}
#research-history{padding:14px 10px;margin-top:16px}
.history-heading{display:flex;align-items:center;justify-content:space-between;gap:8px}
.history-heading h3{margin:0;font-size:1rem}
#history-count{color:var(--muted);font-size:.85rem}
#history-items{margin:10px 0}
#history-items li{align-items:start;border-bottom:1px solid var(--border);padding:7px 0;gap:6px}
.history-number{font-size:.8rem;color:var(--muted);padding-top:7px;min-width:16px}
#history-items .history-open{border:0;background:transparent;padding:4px 2px;font-weight:400;line-height:1.45}
#history-items button:last-child{border:0;padding:4px 6px;background:transparent}
#clear-history{font-size:.85rem;padding:4px 8px}

#ai-selection .preview-card span{display:block;margin-top:5px}
#ai-selection{margin-bottom:1.2rem}
.hit.recommended-hit{border-left:3px solid var(--accent)}

/* Independent of the article pane so opening sources preserves progress. */
#research-progress {flex:none;display:flex;align-items:center;gap:10px;padding:8px 18px;background:#edf6fc;border-top:1px solid var(--border);font-size:.9rem;color:#165b89}
#research-progress[hidden] {display:none}
#research-status {flex:1}
#research-progress button {padding:4px 10px}
.research-spinner {width:14px;height:14px;flex:none;border:2px solid #b4d3e8;border-top-color:#176da5;border-radius:50%;animation:research-spin 1s linear infinite}
#research-progress[data-running="false"] .research-spinner {display:none}
@keyframes research-spin {to {transform:rotate(360deg)}}
@media (prefers-reduced-motion:reduce) {.research-spinner {animation:none}}

#image-viewer {width:min(900px,90vw);max-width:90vw;max-height:90vh;padding:16px;border:1px solid var(--border);border-radius:10px;overflow:auto}
#image-viewer::backdrop {background:rgb(0 0 0 / .65)}
.viewer-heading,.viewer-navigation {display:flex;align-items:center;justify-content:space-between;gap:12px}
.viewer-stage {display:flex;align-items:center;justify-content:center;min-height:120px;height:55vh;margin-top:12px}
#viewer-image {max-width:100%;max-height:100%;object-fit:contain}
#viewer-caption {white-space:pre-wrap;overflow-wrap:anywhere;max-height:12vh;overflow:auto}
.viewer-navigation button {min-width:60px;font-size:1.4rem}
