:root {
  color-scheme: light;
  --green-950: #0b2f1d;
  --green-800: #155438;
  --green-700: #1f6948;
  --green-100: #e8f2ec;
  --green-50: #f4f8f5;
  --ink: #18211b;
  --muted: #657069;
  --border: #dce6df;
  --paper: #ffffff;
  --background: #f3f7f4;
  --error: #a63c2c;
  --error-bg: #fff3f0;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(11, 47, 29, .05);
  font-family: Inter, Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--background); }
button, input { font: inherit; }
.shell { width: min(1160px, calc(100% - 40px)); margin: 0 auto; padding: 32px 0 48px; }
.page-header { margin-bottom: 22px; }
.brand { display: inline-flex; align-items: center; gap: 10px; margin-bottom: 22px; color: var(--green-950); font-size: 15px; font-weight: 750; text-decoration: none; }
.brand-mark { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 8px; color: white; background: var(--green-800); font-family: Georgia, serif; font-size: 18px; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { margin: 0; color: var(--green-950); font-family: Georgia, serif; font-size: clamp(32px, 4vw, 36px); font-weight: 600; line-height: 1.12; letter-spacing: -.025em; }
.lede { margin: 8px 0 0; color: var(--muted); font-size: 15px; line-height: 1.5; }
.repository-meta { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 0; }
.repository-meta div { display: flex; align-items: baseline; gap: 7px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 7px; background: rgba(255, 255, 255, .68); }
.repository-meta dt { color: var(--muted); font-size: 11px; }
.repository-meta dd { margin: 0; color: var(--green-950); font-size: 12px; font-weight: 700; }
.repository-live dd::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: #2f8a5d; box-shadow: 0 0 0 3px var(--green-100); }

.panel { border: 1px solid var(--border); border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); }
.upload-panel, .result { padding: 20px; }
.panel + .panel { margin-top: 20px; }
.section-heading h2 { margin: 0; color: var(--green-950); font-size: 22px; font-weight: 700; line-height: 1.25; }
.section-heading p { margin: 5px 0 0; color: var(--muted); font-size: 14px; line-height: 1.5; }

form { display: grid; gap: 14px; margin-top: 16px; }
.pdf-dropzone { position: relative; display: grid; justify-items: center; min-height: 250px; align-content: center; gap: 10px; padding: 26px; border: 1px dashed #aac6b5; border-radius: var(--radius); background: #fbfdfc; text-align: center; transition: border-color 150ms ease, background 150ms ease; }
.pdf-dropzone.is-dragging { border-color: var(--green-700); background: var(--green-100); }
.pdf-dropzone.is-invalid { border-color: #dca89f; background: var(--error-bg); }
.pdf-dropzone:focus-visible { outline: 3px solid rgba(31, 105, 72, .2); outline-offset: 3px; }
.pdf-dropzone input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }
.upload-icon { display: grid; width: 46px; height: 46px; place-items: center; border: 1px solid #cce0d3; border-radius: 9px; color: var(--green-700); background: var(--green-100); font-size: 30px; font-weight: 400; line-height: 1; }
.upload-copy { display: grid; min-width: 0; gap: 4px; }
.upload-copy strong { overflow: hidden; color: var(--ink); font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.upload-copy > span { color: var(--muted); font-size: 12px; line-height: 1.4; }
.upload-copy .upload-error { color: var(--error); }
.picker-button, .remove-file, .submit-button { border-radius: 7px; font-size: 14px; font-weight: 650; cursor: pointer; }
.picker-actions { display: flex; gap: 10px; justify-content: center; }
.picker-button { min-width: 116px; padding: 11px 15px; border: 1px solid #b7cfc0; color: var(--green-800); background: var(--paper); }
.picker-button:hover { border-color: var(--green-700); background: var(--green-50); }
.picker-folder { border-color: var(--green-800); color: white; background: var(--green-800); }
.picker-folder:hover { color: white; background: var(--green-700); }
.remove-file { padding: 10px 2px; border: 0; color: var(--muted); background: transparent; }
.remove-file:hover { color: var(--error); }
.upload-limits { color: #77857c; font-size: 12px; }
.selected-files { margin-top: 2px; }
.selected-files-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.selected-files-heading h3 { margin: 0; color: var(--green-950); font-family: Georgia, serif; font-size: 15px; }
.selected-files-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.selected-files-heading button { padding: 6px 0; border: 0; color: var(--error); background: transparent; font-size: 12px; font-weight: 650; cursor: pointer; }
.selection-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; padding: 11px 12px; border: 1px solid var(--border); border-radius: 8px; background: #fbfcfb; }
.add-files { padding: 9px 12px; border: 1px solid #b7cfc0; border-radius: 7px; color: var(--green-800); background: var(--paper); font-size: 13px; font-weight: 650; cursor: pointer; }
.selected-file-list { margin: 12px 0 0; padding: 0; border-top: 1px solid var(--border); list-style: none; }
.selected-file-list li { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.selected-file-type { display: grid; width: 40px; height: 34px; place-items: center; border: 1px solid #cfe0d5; border-radius: 5px; color: var(--green-700); background: var(--green-50); font-size: 9px; font-weight: 800; }
.selected-file-info { display: grid; min-width: 0; gap: 3px; }
.selected-file-info strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.selected-file-info span { color: var(--muted); font-size: 11px; }
.selected-file-list button { width: 28px; height: 28px; border: 0; color: var(--muted); background: transparent; font-size: 18px; cursor: pointer; }
.selected-file-list button:hover { color: var(--error); }
.submit-button { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; justify-self: start; gap: 9px; padding: 0 18px; border: 0; color: white; background: var(--green-800); }
.submit-button:hover:not(:disabled) { background: var(--green-700); }
.submit-button:disabled { opacity: .48; cursor: not-allowed; }
.spinner { display: none; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.4); border-top-color: white; border-radius: 50%; animation: spin 700ms linear infinite; }
.submit-button.is-loading .spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

.result { scroll-margin-top: 16px; }
.result:focus { outline: none; }
.result:focus-visible { outline: 3px solid rgba(31, 105, 72, .2); }
.result-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.result-count { flex: none; padding: 5px 8px; border-radius: 999px; color: var(--green-800); background: var(--green-100); font-size: 11px; font-weight: 700; }
.match-list { max-height: 540px; margin: 16px 0 0; padding: 0; overflow-y: auto; overscroll-behavior: contain; border: 1px solid var(--border); border-radius: 8px; list-style: none; scrollbar-color: #91b19d var(--green-50); scrollbar-width: thin; }
.match-list > li { display: grid; grid-template-columns: 34px minmax(0, 1fr) 92px; gap: 14px; align-items: start; padding: 16px; background: var(--paper); }
.match-list > li + li { border-top: 1px solid var(--border); }
.match-rank { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 7px; color: var(--green-800); background: var(--green-100); font: 700 10px/1 monospace; }
.match-content { min-width: 0; }
.match-content h3 { margin: 1px 0 0; color: var(--ink); font-size: 15px; font-weight: 650; line-height: 1.4; }
.match-badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 9px 0 0; padding: 0; list-style: none; }
.match-badges li { display: inline-flex; align-items: baseline; gap: 5px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 999px; background: var(--green-50); font-size: 12px; line-height: 1; }
.match-badges span { color: var(--muted); }
.match-badges strong { color: var(--green-950); font-weight: 700; }
.match-score { text-align: right; white-space: nowrap; }
.match-score span { display: block; color: var(--muted); font-size: 10px; line-height: 1.2; }
.match-score strong { display: block; margin-top: 3px; color: var(--green-700); font-size: 18px; font-weight: 750; font-variant-numeric: tabular-nums; }
.score-note { margin: 11px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.empty-result { display: flex; align-items: center; gap: 14px; min-height: 88px; }
.empty-result > span { display: grid; width: 48px; height: 48px; place-items: center; border-radius: 50%; color: var(--green-800); background: var(--green-100); font: 700 10px monospace; }
.empty-result h2 { margin: 0; color: var(--green-950); font-size: 20px; }
.empty-result p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.result-error, .result-scope_error, .result-repository_error { border-color: #e3b9b0; background: var(--error-bg); }

.extraction { overflow: hidden; }
.extraction summary { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 16px 20px; cursor: pointer; list-style: none; }
.extraction summary::-webkit-details-marker { display: none; }
.extraction-icon { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 7px; color: var(--green-800); background: var(--green-100); font-size: 9px; font-weight: 800; }
.extraction-summary { display: grid; min-width: 0; gap: 3px; }
.extraction-title { color: var(--green-950); font-size: 15px; font-weight: 700; }
.extraction-meta { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.expand-icon { width: 9px; height: 9px; border-right: 2px solid var(--green-800); border-bottom: 2px solid var(--green-800); transform: rotate(45deg); transition: transform 150ms ease; }
.extraction[open] .expand-icon { transform: rotate(225deg); }
.extraction-body { padding: 0 20px 20px; border-top: 1px solid var(--border); }
.extraction pre { max-height: 420px; margin: 16px 0 0; padding: 16px; overflow: auto; border: 1px solid var(--border); border-radius: 7px; color: #26362c; background: #fbfcfb; font: 12px/1.65 Consolas, monospace; overflow-wrap: anywhere; white-space: pre-wrap; }
.extracted-file h3 { margin: 16px 0 8px; color: var(--green-950); font-size: 12px; font-weight: 700; }
.extracted-file + .extracted-file { margin-top: 16px; border-top: 1px solid var(--border); }
.extracted-file h3 + pre { margin-top: 0; }
footer { margin-top: 20px; color: var(--muted); font-size: 11px; }

@media (max-width: 720px) {
  .shell { width: min(100% - 28px, 1160px); padding-top: 24px; }
  .repository-meta { gap: 7px; }
  .match-list > li { grid-template-columns: 30px minmax(0, 1fr); gap: 10px; }
  .match-score { grid-column: 2; text-align: left; }
  .match-score span, .match-score strong { display: inline; }
  .match-score strong { margin-left: 5px; }
}

@media (max-width: 480px) {
  .upload-panel, .result { padding: 16px; }
  .pdf-dropzone { min-height: 270px; padding: 22px 16px; }
  .picker-actions { width: 100%; flex-direction: column; }
  .picker-button { width: 100%; }
  .selection-actions { align-items: stretch; flex-direction: column; }
  .add-files, .selection-actions .submit-button { width: 100%; }
  .upload-copy strong { white-space: normal; }
  .submit-button { width: 100%; }
  .result-heading { display: block; }
  .result-count { display: inline-block; margin-top: 8px; }
  .match-list > li { padding: 14px; }
  .match-badges { gap: 5px; }
  .match-badges li { font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  .pdf-dropzone, .expand-icon { transition: none; }
  .spinner { animation: none; }
}
