:root {
  --bg: #f4f5f7; --card: #ffffff; --text: #16181d; --muted: #646b78; --line: #dde1e7;
  --accent: #2f6fed; --accent-text: #fff; --ok: #1f9d55; --bad: #d64545; --chip: #eef1f6;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111317; --card: #1b1e24; --text: #eceef2; --muted: #9aa2af; --line: #2c3139;
    --accent: #5b8cff; --chip: #262a32; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
.bar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); background: var(--card);
  border-bottom: 1px solid var(--line); }
.bar h1 { margin: 0; font-size: 18px; }
main { max-width: 760px; margin: 0 auto; padding: 16px; padding-bottom: 48px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 16px; }
h2 { margin: 0 0 10px; font-size: 18px; }
h3 { margin: 0 0 10px; font-size: 16px; }
.muted { color: var(--muted); } .small { font-size: 14px; } .error { color: var(--bad); min-height: 1.2em; }
[hidden] { display: none !important; }
input[type=password], input[type=text], textarea { width: 100%; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
#start-form { display: flex; gap: 8px; }
button { font: inherit; border-radius: 10px; padding: 11px 16px; border: 1px solid var(--line); background: var(--chip);
  color: var(--text); cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.link { background: none; border: 0; padding: 0 0 0 8px; color: var(--accent); }
.row { display: flex; gap: 8px; margin-top: 12px; } .row > * { flex: 1; } .row.wrap { flex-wrap: wrap; }
.pill { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 22px;
  border: 2px dashed var(--line); border-radius: 12px; cursor: pointer; text-align: center; }
.dropzone.over { border-color: var(--accent); }
.dropzone input { display: none; } .big { font-weight: 600; color: var(--accent); font-size: 17px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; margin-top: 12px; }
.grid.results { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--chip);
  border: 0; padding: 0; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none; }
.tile .name { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 4px;
  font-size: 11px; color: var(--muted); word-break: break-all; }
.tile .badge { position: absolute; left: 4px; bottom: 4px; font-size: 11px; padding: 2px 6px; border-radius: 6px;
  background: rgba(0,0,0,.65); color: #fff; }
.tile .badge.ok { background: var(--ok); } .tile .badge.bad { background: var(--bad); }
.tile .note-flag { position: absolute; right: 4px; top: 4px; font-size: 11px; padding: 2px 6px; border-radius: 6px;
  background: var(--accent); color: #fff; }
.result { display: flex; flex-direction: column; gap: 6px; }
.result .tile { aspect-ratio: auto; } .result .tile img { height: auto; }
.result .tile .badge { left: auto; right: 4px; top: 4px; bottom: auto; }
.result button { padding: 8px; font-size: 14px; }
.result .meta { font-size: 12px; } .result .meta .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chips button { padding: 6px 12px; border-radius: 999px; font-size: 14px; }
.plan { margin-top: 8px; white-space: pre-line; }
.progress { height: 8px; background: var(--chip); border-radius: 99px; overflow: hidden; }
#progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.items { list-style: none; padding: 0; margin: 12px 0 0; }
.items li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.items li .thumb { width: 44px; height: 44px; flex: none; border-radius: 6px; object-fit: cover; background: var(--chip); }
.items li .body { flex: 1; min-width: 0; }
.items li .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.items li .timer { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.items li .st { flex: none; color: var(--muted); } .items li .st.done { color: var(--ok); } .items li .st.failed { color: var(--bad); }
.items li .st.planning, .items li .st.working { color: var(--accent); font-weight: 600; }
.note { margin: 14px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--chip); font-size: 14px; }
dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--text);
  width: min(92vw, 420px); padding: 16px; }
dialog::backdrop { background: rgba(0,0,0,.5); }
#note-img { width: 100%; max-height: 40vh; object-fit: contain; border-radius: 8px; margin-bottom: 8px; }
#toast { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #222; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; max-width: 90vw; z-index: 5; }
