:root {
  --ink: #1d2127; --muted: #5b6672; --line: #d8dee4; --bg: #f4f7fa; --card: #fff;
  --brand: #11324d; --brand-ink: #fff; --ok: #1a7f4b; --bad: #b3261e; --warn-bg: #fbf6e8; --warn-line: #ecdca0;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 -apple-system, "Helvetica Neue", Arial, sans-serif; }
header { display: flex; justify-content: space-between; align-items: center; padding: 14px 24px; background: var(--brand); color: var(--brand-ink); }
header .brand { display: flex; align-items: center; gap: 10px; }
header .logo { height: 28px; width: auto; display: block; }
header h1 { margin: 0; font-size: 18px; }
header .link { color: var(--brand-ink); opacity: .85; }
main { max-width: 760px; margin: 24px auto; padding: 0 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 20px; margin-bottom: 16px; }
.card.narrow { max-width: 380px; margin: 60px auto; }
h2 { margin: 0 0 12px; font-size: 17px; color: var(--brand); }
label { display: block; font-weight: 600; margin-bottom: 14px; }
input, select { display: block; width: 100%; margin-top: 4px; padding: 9px 10px; font: inherit; border: 1px solid #b8c1ca; border-radius: 6px; background: #fff; }
input:focus-visible, select:focus-visible, button:focus-visible, #dropzone:focus-visible { outline: 2px solid #3b82c4; outline-offset: 1px; }
button { font: inherit; cursor: pointer; }
button.primary { background: var(--brand); color: var(--brand-ink); border: 0; border-radius: 6px; padding: 10px 22px; font-weight: 600; }
button.primary:disabled { opacity: .45; cursor: not-allowed; }
button.link { background: none; border: 0; color: #1f5f99; padding: 4px 6px; text-decoration: underline; }
.muted { color: var(--muted); font-weight: 400; }
.error { color: var(--bad); margin: 8px 0; }
.actions { display: flex; align-items: center; gap: 14px; margin-top: 8px; }

#dropzone { border: 2px dashed #b8c1ca; border-radius: 8px; padding: 26px 16px; text-align: center; cursor: pointer; background: #fafcfe; }
#dropzone small { display: block; color: var(--muted); margin-top: 4px; }
#dropzone.over { border-color: var(--brand); background: #eef3f8; }

ul.files, ul.results { list-style: none; margin: 12px 0; padding: 0; }
ul.files li { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
ul.files .name { flex: 1; overflow-wrap: anywhere; }
.chip { font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 4px; background: #eef3f8; color: var(--brand); }
.chip.unknown { background: #fdecea; color: var(--bad); }

.pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.pill { background: #fff; color: var(--brand); border: 1px solid #b8c1ca; border-radius: 999px; padding: 4px 14px; font-size: 13px; }
.pill:hover { background: #eef3f8; }
.pill[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
#label-row { margin-bottom: 14px; }
#label-row > label { margin-bottom: 0; }
.conflicts { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 6px; padding: 12px 14px; margin: 12px 0; }
.conflicts h3 { margin: 0 0 6px; font-size: 15px; }
.conflicts .choice { display: block; font-weight: 400; margin: 6px 0; }
.conflicts .choice input { display: inline; width: auto; margin: 0 6px 0 0; }
.existing { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0; }
.existing a { font-size: 13px; }
.existing img { display: block; height: 64px; border: 1px solid var(--line); border-radius: 4px; background: #fff; }

.results-head { display: flex; justify-content: space-between; align-items: center; }
.results-head h2 { margin: 0; }
ul.results li { display: flex; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line); }
.thumb { width: 84px; height: 84px; flex: none; border: 1px solid var(--line); border-radius: 6px; background: #fafcfe; display: flex; align-items: center; justify-content: center; overflow: hidden; font-weight: 700; color: var(--muted); }
.thumb img { max-width: 100%; max-height: 100%; }
.res-body { flex: 1; min-width: 0; }
.res-title { font-weight: 600; overflow-wrap: anywhere; }
.badge { font-size: 12px; font-weight: 600; margin-left: 6px; color: var(--muted); }
.badge.replaced { color: #9a6a00; }
.linkrow { display: flex; gap: 6px; margin-top: 6px; }
.linkrow input { margin: 0; font-size: 13px; }
.linkrow button { flex: none; background: #fff; border: 1px solid #b8c1ca; border-radius: 6px; padding: 0 12px; }
.res-fail { color: var(--bad); }
.res-fail .res-title { color: var(--ink); }
@media (max-width: 520px) { ul.results li { flex-direction: column; } .thumb { width: 100%; height: 120px; } }
