* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; background: #e8e3d7; }
a { color: #7c3a24; text-decoration: none; }
a:hover { text-decoration: underline; }
input, button, select { font: inherit; color: inherit; }
::selection { background: #ffe9a3; }
.sc { scrollbar-width: thin; scrollbar-color: #cdc5b2 transparent; }
.mono { font-family: 'IBM Plex Mono', monospace; }
[x-cloak] { display: none !important; }

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border: 2px solid #cdc5b2;
  border-top-color: #7c3a24;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.spinner.big { width: 26px; height: 26px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

.shell {
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #e8e3d7;
  color: #1f1d18;
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  overflow: hidden;
}

/* header */
.hdr {
  flex: 0 0 auto;
  background: #1f1d18;
  color: #f4f1e9;
  padding: 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.hdr-row { display: flex; align-items: center; gap: 20px; }
.brand { display: flex; flex-direction: column; gap: 1px; min-width: 190px; }
.brand-name { font-family: 'Newsreader', Georgia, serif; font-size: 19px; letter-spacing: 0.01em; }
.brand-sub { font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: #a49b86; }

.search-box {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f4f1e9;
  border: 1px solid #3a362d;
  border-radius: 3px;
  padding: 0 12px;
  height: 42px;
  color: #1f1d18;
}
.search-box input { flex: 1; height: 100%; border: none; outline: none; background: transparent; color: #1f1d18; font-size: 15px; }
.result-summary { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: #6f6a5d; white-space: nowrap; }
.btn-clear { border: none; background: #e4dfd1; color: #6f6a5d; border-radius: 2px; padding: 3px 8px; font-size: 11px; cursor: pointer; }
.btn-clear:hover { background: #d6d0bd; color: #1f1d18; }

.kbd-hints { display: flex; gap: 6px; align-items: center; font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; color: #a49b86; letter-spacing: 0.08em; }
.kbd-hints kbd { border: 1px solid #4a4539; border-radius: 2px; padding: 3px 6px; }
.kbd-hints span:nth-of-type(2) { margin-left: 8px; }
.about-link { margin-left: 14px; border: none; background: transparent; color: #a49b86; font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; letter-spacing: 0.08em; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; padding: 0; }
.about-link:hover { color: #f4f1e9; }

.hdr-row2 { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.label { font-family: 'IBM Plex Mono', monospace; font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: #a49b86; }
.type-pills { display: flex; align-items: center; gap: 6px; }
.pill { border: 1px solid #4a4539; background: transparent; color: #cfc7b3; border-radius: 999px; padding: 4px 11px; font-size: 12px; cursor: pointer; display: inline-flex; align-items: baseline; gap: 5px; }
.pill.on { border-color: #f4f1e9; background: #f4f1e9; color: #1f1d18; }
.pill-count { font-family: 'IBM Plex Mono', monospace; font-size: 10px; opacity: 0.65; }
.flex-spacer { flex: 1; }
.sort-box { display: flex; align-items: center; gap: 8px; }
.sort-box select { background: #2b2820; border: 1px solid #4a4539; color: #f4f1e9; border-radius: 2px; padding: 5px 8px; font-size: 12px; }

/* body */
.body { flex: 1; min-height: 0; display: flex; gap: 1px; background: #cdc5b2; }

.results { flex: 0 0 372px; overflow-y: auto; background: #f1ede3; transition: opacity 120ms; }
.results.pending { opacity: 0.5; pointer-events: none; }
.result {
  border-bottom: 1px solid #ddd6c6;
  border-left: 3px solid transparent;
  padding: 13px 15px 14px 13px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.result.on { border-left-color: #7c3a24; background: #fbf9f4; }
.result-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.result .ref { font-family: 'IBM Plex Mono', monospace; font-size: 12px; font-weight: 500; color: #7c3a24; }
.result .date { font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; color: #8b8474; }
.result .title { font-family: 'Newsreader', Georgia, serif; font-size: 15.5px; line-height: 1.3; }
.result .snippet { font-family: 'Newsreader', Georgia, serif; font-size: 13px; line-height: 1.5; color: #55503f; }
.result .snippet .hit { background: #ffe9a3; border-radius: 2px; }
.result-meta { display: flex; align-items: center; gap: 8px; font-family: 'IBM Plex Mono', monospace; font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: #8b8474; }
.type-badge { border: 1px solid #ddd6c6; background: #e9e4d7; border-radius: 2px; padding: 2px 6px; }
.party { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-transform: none; letter-spacing: 0; }
.pages { white-space: nowrap; flex-shrink: 0; }
.hit-label { color: #7c3a24; white-space: nowrap; flex-shrink: 0; }
.empty { padding: 40px 20px; text-align: center; color: #8b8474; font-size: 13px; line-height: 1.6; }

/* main detail */
.detail { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; background: #fbf9f4; }
.loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(251, 249, 244, 0.6);
}
.detail-head {
  flex: 0 0 auto;
  border-bottom: 1px solid #ddd6c6;
  padding: 16px 22px 14px;
  display: flex;
  align-items: flex-start;
  gap: 14px 20px;
}
.detail-head.narrow { flex-direction: column; align-items: stretch; }
.detail-head-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.detail-refline { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.detail-refline .ref { font-family: 'IBM Plex Mono', monospace; font-size: 13px; font-weight: 500; color: #7c3a24; white-space: nowrap; }
.meta-sub { font-family: 'IBM Plex Mono', monospace; font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: #8b8474; }
.detail-head h1 { margin: 0; font-family: 'Newsreader', Georgia, serif; font-weight: 500; font-size: 25px; line-height: 1.2; }
.fields { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 2px; }
.field { display: flex; flex-direction: column; gap: 1px; flex-shrink: 0; }
.flabel { font-family: 'IBM Plex Mono', monospace; font-size: 9.5px; letter-spacing: 0.14em; text-transform: uppercase; color: #8b8474; white-space: nowrap; }
.field span:last-child { font-size: 13px; }

.detail-head-actions { display: flex; gap: 8px; flex: 0 0 auto; align-items: center; }
.tabbar { display: flex; gap: 2px; border: 1px solid #ddd6c6; border-radius: 3px; padding: 2px; margin-right: 4px; }
.tabbar button { border: none; background: transparent; color: #55503f; border-radius: 2px; padding: 5px 11px; font-size: 12px; cursor: pointer; white-space: nowrap; }
.tabbar button.on { background: #1f1d18; color: #f4f1e9; }
.btn-dark { border: 1px solid #1f1d18; background: #1f1d18; color: #f4f1e9; border-radius: 3px; padding: 7px 14px; font-size: 12px; cursor: pointer; display: inline-block; }
.btn-dark:hover { background: #3a362d; text-decoration: none; }

.panes { flex: 1; min-height: 0; display: flex; gap: 1px; background: #ddd6c6; }
.pane-scan, .pane-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pane-scan { background: #efebe1; }
.pane-text { background: #fbf9f4; }
.pane-bar { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid #ddd6c6; }
.nav-btn { width: 24px; height: 24px; border: 1px solid #ddd6c6; background: #f1ede3; color: #55503f; border-radius: 2px; cursor: pointer; line-height: 1; }
.hit-nav-label { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: #55503f; }

.scan-body { flex: 1; min-height: 0; display: flex; }
.scan-frame { flex: 1; border: none; }
.scan-missing { flex: 1; display: flex; align-items: center; justify-content: center; color: #8b8474; font-size: 13px; }

.ocr-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 26px 34px 60px; }
.ocr-body { max-width: 62ch; margin: 0 auto; font-family: 'Newsreader', Georgia, serif; font-size: 16.5px; line-height: 1.66; color: #26241d; white-space: pre-wrap; }
.ocr-body p { margin: 0 0 1.1em; }
.ocr-body .hit { background: #ffe9a3; border-radius: 2px; }
.ocr-body .hit.cur { background: #ffc94a; box-shadow: 0 0 0 2px #ffc94a; }
.no-ocr { color: #8b8474; font-style: italic; }

/* about-this-data modal */
.about-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(31, 29, 24, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.about-card {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: #fbf9f4;
  border: 1px solid #ddd6c6;
  border-radius: 6px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  padding: 30px 34px 28px;
}
.about-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: #8b8474;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  border-radius: 3px;
}
.about-close:hover { background: #e9e4d7; color: #1f1d18; }
.about-card h2 { font-family: 'Newsreader', Georgia, serif; font-weight: 500; font-size: 24px; margin: 0 0 12px; color: #1f1d18; }
.about-lede { font-family: 'Newsreader', Georgia, serif; font-size: 15.5px; line-height: 1.55; color: #3a362d; margin: 0 0 20px; }
.about-item { margin: 0 0 16px; }
.about-item p { font-family: 'IBM Plex Sans', system-ui, sans-serif; font-size: 13px; line-height: 1.6; color: #3a362d; margin: 6px 0 0; }
.about-tag { display: inline-block; font-family: 'IBM Plex Mono', monospace; font-size: 10px; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; padding: 3px 8px; border-radius: 2px; }
.about-tag.comprehensive { background: #e3ecdf; color: #35603f; }
.about-tag.partial { background: #f6e9c9; color: #8a5a00; }
.about-tag.excluded { background: #e9e4d7; color: #6f6a5d; }
.about-note { font-family: 'IBM Plex Sans', system-ui, sans-serif; font-size: 12.5px; line-height: 1.6; color: #55503f; background: #f1ede3; border: 1px solid #ddd6c6; border-radius: 4px; padding: 10px 12px; margin: 18px 0 0; }
.about-disclaimer { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: #8b8474; margin: 16px 0 0; }
.about-dismiss { margin-top: 22px; width: 100%; text-align: center; }
