:root {
  --bg: #f6f6f4;
  --card: #fff;
  --text: #1d1d1b;
  --muted: #6b6b66;
  --line: #dcdcd6;
  --accent: #1f5fbf;
  --ok: #2e7d32;
  --warn: #9a6400;
  --bad: #b3261e;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; }
main { padding: 16px; max-width: 1400px; margin: 0 auto; }
h1 { font-size: 1.4rem; margin: 0.5rem 0 1rem; word-break: break-all; }
h2 { font-size: 1.1rem; margin: 0 0 0.5rem; }
a { color: var(--accent); }

.top { display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; text-decoration: none; color: var(--text); }
.top nav { display: flex; align-items: center; gap: 1rem; }
.top form { margin: 0; }

button, .button { font: inherit; padding: 6px 14px; border: 1px solid var(--accent); border-radius: 6px;
  background: var(--accent); color: #fff; cursor: pointer; text-decoration: none; }
button.link { background: none; border: 0; color: var(--accent); padding: 0; text-decoration: underline; }
input, select, textarea { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px;
  background: #fff; max-width: 100%; }
label { display: block; margin: 0 0 0.6rem; }
label > input:not([type=radio]):not([type=checkbox]), label > textarea { display: block; width: 100%; margin-top: 2px; }
label.inline { display: inline-flex; align-items: center; gap: 4px; margin-right: 0.8rem; }
fieldset { border: 0; padding: 0; margin: 0 0 0.8rem; }
legend { padding: 0; margin-bottom: 4px; }
.req, .hint, .meta, .count { color: var(--muted); font-size: 0.9rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin-bottom: 1rem; }
.login { max-width: 360px; margin: 10vh auto; }
.flash { padding: 8px 12px; border-radius: 6px; background: #e8f0fe; }
.flash.ok { background: #e6f4ea; color: var(--ok); }
.flash.error { background: #fce8e6; color: var(--bad); }
.flash.warn { background: #fff4e0; color: var(--warn); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 0.5rem; }
.filters input[type=search] { flex: 1 1 280px; }
.filters label.inline { margin: 0; }

.grid { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.tile a { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  overflow: hidden; color: inherit; text-decoration: none; }
.tile img { display: block; width: 100%; height: 160px; object-fit: contain; background: #ececea; }
.tile .name { display: block; padding: 6px 8px 0; font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .meta { display: block; padding: 0 8px 8px; font-size: 0.8rem; }
.tile.hidden { opacity: 0.5; }
.empty { color: var(--muted); }
.pager { display: flex; gap: 1rem; justify-content: center; margin: 1.5rem 0; }

.badge { display: inline-block; padding: 0 6px; border-radius: 4px; background: #ececea; font-size: 0.8rem; }
.badge.unknown { background: #fff4e0; color: var(--warn); }
.badge.other { background: #fce8e6; color: var(--bad); }
.badge.hidden { background: #ececea; color: var(--muted); }

.drop { border: 2px dashed var(--line); border-radius: 8px; padding: 2rem; text-align: center;
  background: var(--card); cursor: pointer; margin-bottom: 1rem; }
.drop.over, .drop:focus { border-color: var(--accent); outline: none; }
.batch { list-style: none; padding: 0; display: grid; gap: 10px; }
.batch-item { display: flex; gap: 12px; background: var(--card); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px; }
.batch-item .thumb { flex: 0 0 140px; height: 105px; background: #ececea; }
.batch-item .thumb img { width: 140px; height: 105px; object-fit: contain; }
.batch-item .info { flex: 1; min-width: 0; }
.batch-item .status { margin-left: 0.5rem; color: var(--muted); font-size: 0.9rem; }
.batch-item.failed { border-color: var(--bad); }
.batch-item.failed .status { color: var(--bad); }
.batch-item.duplicate .status { color: var(--warn); }
.batch-item progress { display: block; width: 100%; }
#batch-actions { margin: 1rem 0; }

.detail { display: grid; gap: 24px; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; }
.focal { position: relative; display: inline-block; max-width: 100%; cursor: crosshair; margin-bottom: 4px; }
.focal img { display: block; max-width: 100%; height: auto; }
.marker { position: absolute; width: 22px; height: 22px; margin: -11px 0 0 -11px; border: 2px solid #fff;
  border-radius: 50%; box-shadow: 0 0 0 2px #000, inset 0 0 0 2px #000; pointer-events: none; }
.snippet { margin-bottom: 1rem; }
.snippet textarea, .snippet input { width: 100%; font-family: ui-monospace, Menlo, monospace; font-size: 0.8rem; }
.snippet label { margin-bottom: 2px; font-weight: 600; }
.snippet details { margin-top: 0.3rem; }
.snippet summary { cursor: pointer; font-size: 0.85rem; color: #555; }
.langs a, .langs strong { margin-right: 0.5rem; }

@media (max-width: 800px) {
  .detail { grid-template-columns: 1fr; }
  .batch-item { flex-direction: column; }
}

.snippets h3 { font-size: 1rem; margin: 1.2rem 0 0.4rem; padding-top: 0.6rem; border-top: 1px solid var(--line); }
.snippets h3:first-of-type { border-top: 0; padding-top: 0; }
.snippets code { font-size: 0.85em; background: #ececea; padding: 0 3px; border-radius: 3px; }
