:root {
  --bg: #f7f7f4; --surface: #ffffff; --surface-2: #f0f1ec; --text: #1b1f1d; --muted: #5d6662; --line: #dcdfd8;
  --accent: #0f766e; --accent-ink: #ffffff; --accent-soft: #ccfbf1; --danger: #b42318; --sel: #f59e0b; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111413; --surface: #1a1e1c; --surface-2: #222724; --text: #e8ece9; --muted: #9aa5a0; --line: #2f3632;
    --accent: #2dd4bf; --accent-ink: #062b27; --accent-soft: #134e48; --danger: #f97066; --sel: #fbbf24; --shadow: 0 1px 2px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111413; --surface: #1a1e1c; --surface-2: #222724; --text: #e8ece9; --muted: #9aa5a0; --line: #2f3632;
  --accent: #2dd4bf; --accent-ink: #062b27; --accent-soft: #134e48; --danger: #f97066; --sel: #fbbf24; --shadow: 0 1px 2px rgba(0,0,0,.4);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; padding-bottom: 84px; }
a { color: var(--accent); }
h1 { font-size: clamp(1.5rem, 4vw, 2.2rem); line-height: 1.2; margin: 0 0 .5rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .5rem; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.brand-name { font-weight: 700; font-size: 1.05rem; }
.pill { font-size: .78rem; padding: 2px 10px; border-radius: 999px; white-space: nowrap; }
.pill-private { background: var(--accent-soft); color: var(--text); border: 1px solid var(--accent); }
.top-actions { display: flex; align-items: center; gap: 10px; }
.top-link { font-size: .9rem; text-decoration: none; }
.icon-btn { border: 1px solid var(--line); background: var(--surface-2); color: var(--text); width: 34px; height: 34px; border-radius: 8px; cursor: pointer; font-size: 1rem; }
main { max-width: 1180px; margin: 0 auto; padding: 20px 16px; }
.intro { max-width: 820px; margin: 0 auto; }
.lede { color: var(--muted); font-size: 1.05rem; margin: 0 0 1rem; }
.privacy-box { display: grid; gap: 4px; padding: 12px 14px; border-left: 4px solid var(--accent); background: var(--surface); border-radius: 8px; box-shadow: var(--shadow); margin-bottom: 1rem; }
.privacy-box span { color: var(--muted); font-size: .93rem; }
.drop { border: 2px dashed var(--line); border-radius: 14px; padding: 22px 16px; text-align: center; background: var(--surface); transition: border-color .15s, background .15s; }
.drop.is-over { border-color: var(--accent); background: var(--accent-soft); }
.drop-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.drop-hint { color: var(--muted); font-size: .88rem; margin: .7rem 0 .4rem; }
.check { font-size: .9rem; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.matcher-line { font-size: .88rem; color: var(--muted); margin: .8rem 0 0; }
.matcher-line.is-ok::before { content: "\25CF  "; color: var(--accent); }
.matcher-line.is-warn::before { content: "\25CF  "; color: var(--sel); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); }
.btn-small { min-height: 34px; padding: 5px 12px; font-size: .88rem; }
.progress { max-width: 820px; margin: 22px auto; padding: 16px; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); }
.progress-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.bar { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 10px 0 6px; }
.bar-fill { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.progress-sub { margin: 0; color: var(--muted); font-size: .9rem; }
.results { margin-top: 8px; }
.toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.toolbar-right { display: flex; flex-wrap: wrap; gap: 8px; }
.stats { font-size: .95rem; }
.stats b { font-variant-numeric: tabular-nums; }
.tune { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 12px 0; }
.tune label { font-weight: 600; }
.tune input[type=range] { width: min(320px, 60vw); accent-color: var(--accent); }
.tune-end { font-size: .82rem; color: var(--muted); }
.tune-note { flex-basis: 100%; font-size: .85rem; color: var(--muted); }
.manual-note, .suggest { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin: 8px 0 14px; font-size: .92rem; }
.suggest-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 4px 0; }
.suggest-row img { width: 36px; height: 36px; border-radius: 6px; object-fit: cover; }
.hint { color: var(--muted); font-size: .88rem; margin: 0 0 8px; }
.count { color: var(--muted); font-weight: 400; font-size: .9rem; }
.unsorted { background: var(--surface); border-radius: 12px; padding: 14px; margin-bottom: 16px; box-shadow: var(--shadow); }
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.person { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; box-shadow: var(--shadow); min-width: 0; }
.person.is-picked { outline: 3px solid var(--sel); }
.person-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.person-head input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--sel); flex: none; }
.person-name { flex: 1; min-width: 0; font: inherit; font-weight: 600; padding: 5px 8px; border: 1px solid transparent; border-radius: 6px; background: var(--surface-2); color: var(--text); }
.person-name:focus { border-color: var(--accent); outline: none; }
.person-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: .82rem; color: var(--muted); margin-top: 8px; }
.faces { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; }
.face { position: relative; padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; cursor: pointer; aspect-ratio: 1; background: var(--surface-2); }
.face img { width: 100%; height: 100%; object-fit: cover; display: block; }
.face[aria-pressed="true"] { border-color: var(--sel); }
.face[aria-pressed="true"]::after { content: "\2713"; position: absolute; top: 2px; right: 4px; color: #000; background: var(--sel); border-radius: 50%; width: 18px; height: 18px; font-size: 12px; line-height: 18px; text-align: center; font-weight: 700; }
.face:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
.faces-more { grid-column: 1 / -1; }
.once, .nofaces { margin-top: 18px; background: var(--surface); border-radius: 12px; padding: 10px 14px; border: 1px solid var(--line); }
.once summary, .nofaces summary { cursor: pointer; font-weight: 600; }
.people-once { margin-top: 10px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.nofaces ul { margin: 8px 0 0; padding-left: 20px; color: var(--muted); font-size: .88rem; max-height: 240px; overflow: auto; overflow-wrap: anywhere; }
.selbar, .mergebar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 14px; z-index: 30; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 8px 30px rgba(0,0,0,.18); border-radius: 14px; padding: 10px 12px; width: max-content; max-width: calc(100vw - 24px); }
.mergebar { bottom: 84px; }
.selbar select { min-height: 34px; max-width: 200px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font: inherit; padding: 4px 8px; }
.viewer { border: none; border-radius: 14px; padding: 0; max-width: min(96vw, 1100px); width: 100%; background: var(--surface); color: var(--text); }
.viewer::backdrop { background: rgba(0,0,0,.6); }
.viewer-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.viewer-stage { position: relative; line-height: 0; }
.viewer-stage img { width: 100%; height: auto; max-height: 80vh; object-fit: contain; }
.viewer-box { position: absolute; border: 2px solid var(--sel); border-radius: 4px; pointer-events: none; }
.viewer-box span { position: absolute; left: -2px; top: 100%; background: var(--sel); color: #000; font: 600 12px/1.4 system-ui, sans-serif; padding: 0 5px; white-space: nowrap; border-radius: 0 0 4px 4px; }
.toast { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 16px; border-radius: 10px; z-index: 40; font-size: .9rem; max-width: calc(100vw - 32px); }
.foot { max-width: 1180px; margin: 30px auto 0; padding: 16px; color: var(--muted); font-size: .82rem; border-top: 1px solid var(--line); }
@media (max-width: 560px) {
  .top { padding: 10px 12px; }
  .pill { display: none; }
  .people { grid-template-columns: 1fr; }
  .faces { grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); }
  .selbar { bottom: 8px; }
  .mergebar { bottom: 130px; }
}
