:root {
  --bg: #f6f5f2; --panel: #ffffff; --text: #1d1d1b; --muted: #6b6a66; --line: #dedcd6; --accent: #e8792b; --accent-ink: #ffffff; --chip: #efede8; --warn: #a15c00; --warn-bg: #fff3df;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #17181a; --panel: #212226; --text: #ecebe8; --muted: #a2a09b; --line: #34353a; --accent: #f08a3e; --accent-ink: #1b1b1b; --chip: #2b2c31; --warn: #ffc26b; --warn-bg: #3a2c17; color-scheme: dark; }
}
:root[data-theme="dark"] { --bg: #17181a; --panel: #212226; --text: #ecebe8; --muted: #a2a09b; --line: #34353a; --accent: #f08a3e; --accent-ink: #1b1b1b; --chip: #2b2c31; --warn: #ffc26b; --warn-bg: #3a2c17; color-scheme: dark; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 "Noto Sans Thai", "Leelawadee UI", system-ui, sans-serif; }
a { color: var(--accent); }
.top { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 2; }
.brand { display: flex; gap: 10px; align-items: center; }
.brand img { width: 32px; height: 32px; }
.brand small { display: block; color: var(--muted); font-size: 12px; }
.packs { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 13px; }
select, input[type=search] { font: inherit; color: inherit; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.btn { display: inline-block; padding: 6px 12px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); text-decoration: none; font-weight: 600; font-size: 13px; border: 0; cursor: pointer; }
.btn.line { background: transparent; color: var(--text); border: 1px solid var(--line); font-weight: 500; }
.btn[aria-disabled=true] { opacity: .45; pointer-events: none; }
main { max-width: 1200px; margin: 0 auto; padding: 16px; }
.filters { display: grid; gap: 10px; margin-bottom: 14px; }
.filters input { width: 100%; padding: 10px 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { font: inherit; font-size: 13px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--chip); color: var(--text); cursor: pointer; }
.chips button[aria-pressed=true] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.count { margin: 0; color: var(--muted); font-size: 13px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.card { display: flex; flex-direction: column; text-align: left; font: inherit; color: inherit; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px; cursor: pointer; gap: 6px; }
.card:hover, .card:focus-visible { border-color: var(--accent); outline: none; }
.card .thumb { display: flex; gap: 6px; height: 110px; background: #fff; border-radius: 8px; padding: 8px; }
.card .thumb img { flex: 1; min-width: 0; object-fit: contain; }
.card b { font-size: 14px; line-height: 1.35; }
.card small { color: var(--muted); font-size: 12px; }
.tag { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 6px; background: var(--chip); color: var(--muted); margin-right: 4px; }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.foot { color: var(--muted); font-size: 12px; margin-top: 24px; }
dialog { width: min(1000px, calc(100vw - 24px)); max-height: calc(100vh - 24px); padding: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--text); }
dialog::backdrop { background: #0007; }
.dhead { display: flex; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.dhead h2 { margin: 0; font-size: 18px; }
.dhead p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.x { font-size: 22px; background: none; border: 0; color: inherit; cursor: pointer; line-height: 1; }
.dbody { display: grid; grid-template-columns: 1.1fr 1fr; gap: 16px; padding: 16px; }
@media (max-width: 760px) { .dbody { grid-template-columns: 1fr; } }
.tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.tabs button { font: inherit; font-size: 13px; padding: 4px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--chip); color: var(--text); cursor: pointer; }
.tabs button[aria-selected=true] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.view { background: #fff; border-radius: 10px; border: 1px solid var(--line); aspect-ratio: 4 / 3; position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.view[hidden] { display: none; }
.view canvas { width: 100%; height: 100%; display: block; }
.view img { max-width: 92%; max-height: 82%; }
.view .hint { position: absolute; bottom: 4px; left: 8px; margin: 0; font-size: 11px; color: #666; }
.info table { width: 100%; border-collapse: collapse; font-size: 13px; }
.info th { text-align: left; color: var(--muted); font-weight: 500; padding: 4px 8px 4px 0; vertical-align: top; width: 38%; }
.info td { padding: 4px 0; }
.info tr + tr th, .info tr + tr td { border-top: 1px solid var(--line); }
.dl { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.src { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.verify { background: var(--warn-bg); color: var(--warn); border-radius: 8px; padding: 6px 8px; font-size: 12px; margin-top: 8px; }
.missing { margin-top: 20px; font-size: 13px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
.missing summary { cursor: pointer; color: var(--warn); font-weight: 600; }
.missing li { margin: 6px 0; color: var(--muted); overflow-wrap: anywhere; }
.missing b { color: var(--text); }
