:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1c2129;
  --muted: #646d7a;
  --border: #dde1e7;
  --accent: #7a4fb0;
  --accent-text: #ffffff;
  --accent-soft: #f1ebf8;
  --good: #1a7a4f;
  --bad: #c0392b;
  --field: #ffffff;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151a;
    --card: #1b2028;
    --text: #e8ecf2;
    --muted: #99a3b1;
    --border: #2d3440;
    --accent: #b896e6;
    --accent-text: #160d22;
    --accent-soft: #2a2236;
    --good: #4fce94;
    --bad: #ff7b6b;
    --field: #141920;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%; }
.wrap { max-width: 640px; margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top)) 16px calc(96px + env(safe-area-inset-bottom)); }
h1 { font-size: 1.25rem; margin: 0; }
h2 { font-size: 1rem; margin: 0; }
[hidden] { display: none !important; }

.top { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 12px; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 16px; margin-bottom: 12px; }
.card.narrow { margin-top: 10vh; }
.card.narrow h1 { margin-bottom: 0.8rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 40px; }

label { display: block; margin: 0.7rem 0 0.25rem; font-size: 0.85rem; color: var(--muted); }
input[type=password], input[type=search] {
  width: 100%; font: inherit; font-size: 16px; padding: 10px 12px; color: var(--text);
  background: var(--field); border: 1px solid var(--border); border-radius: 10px; }
input:focus-visible, button:focus-visible, .button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; }

button, .button { font: inherit; font-weight: 600; font-size: 0.95rem; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; margin: 0;
  padding: 10px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--field); color: var(--text); white-space: nowrap; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent);
  width: 100%; margin-top: 1rem; padding: 14px; font-size: 1rem; }
button.primary:disabled { opacity: 0.45; cursor: default; }
button.ghost { background: none; border: none; color: var(--muted); padding: 8px; }
.card-head .button { color: var(--accent); }
.actions { display: flex; gap: 8px; }
.button.icon { width: 42px; padding: 8px 0; font-size: 1.15rem; }
.badge { font-size: 0.8rem; font-weight: 600; color: var(--muted); margin-left: 4px;
  font-variant-numeric: tabular-nums; }

.error { color: var(--bad); font-size: 0.9rem; margin: 0.6rem 0 0; }

.list { list-style: none; margin: 0; padding: 0; }
.list:not(:empty) { margin-top: 10px; }

.file { display: flex; align-items: center; gap: 10px; padding: 10px 0;
  border-top: 1px solid var(--border); }
.file .check { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px;
  margin: 0; color: var(--text); font-size: 1rem; cursor: pointer; }
.file input[type=checkbox] { width: 20px; height: 20px; flex: none; accent-color: var(--accent); }
.text { display: flex; flex-direction: column; min-width: 0; }
.name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }
.file.exists .name { color: var(--muted); }
.status { flex: none; font-size: 0.8rem; font-weight: 600; text-align: right; max-width: 40%; }
.status.ok { color: var(--good); }
.status.bad { color: var(--bad); }
.status.muted { color: var(--muted); font-weight: 400; }

.search { display: flex; gap: 8px; margin-top: 10px; }
.search input { flex: 1; min-width: 0; }
.search .button { color: var(--accent); max-width: 50%; overflow: hidden; text-overflow: ellipsis; }

.options { max-height: 50vh; overflow-y: auto; }
.option { display: flex; align-items: center; gap: 12px; margin: 0; padding: 12px 10px;
  border-radius: 10px; color: var(--text); font-size: 1rem; cursor: pointer; }
.option input { position: absolute; opacity: 0; pointer-events: none; }
.option .name { flex: 1; min-width: 0; }
.option .count { flex: none; font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.option.selected { background: var(--accent-soft); font-weight: 600; }
.option.selected .count { color: var(--accent); }
.option:has(input:focus-visible) { outline: 2px solid var(--accent); }

.move summary { list-style: none; cursor: pointer; display: flex; align-items: center;
  justify-content: space-between; min-height: 40px; }
.move summary::-webkit-details-marker { display: none; }
.move summary::after { content: "›"; font-size: 1.4rem; color: var(--muted); transition: transform 0.15s; }
.move[open] summary::after { transform: rotate(90deg); }
button.secondary { background: var(--field); color: var(--accent); border-color: var(--accent); }

.bar { position: fixed; left: 0; right: 0; bottom: 0; padding: 0 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent); }
.bar button { display: block; max-width: 608px; margin: 0 auto; overflow: hidden; text-overflow: ellipsis; }
