:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --fg: var(--tg-theme-text-color, #111111);
  --muted: var(--tg-theme-hint-color, #777777);
  --accent: var(--tg-theme-button-color, #2481cc);
  --accent-fg: var(--tg-theme-button-text-color, #ffffff);
  --card: var(--tg-theme-secondary-bg-color, #f2f2f5);
  --danger: var(--tg-theme-destructive-text-color, #d93025);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; padding: 12px 12px calc(24px + env(safe-area-inset-bottom)); background: var(--bg); color: var(--fg);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1 { font-size: 20px; margin: 0; }
.muted { color: var(--muted); margin: 2px 0 0; font-size: 13px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.btn { display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 10px; padding: 10px 14px;
  font: inherit; background: var(--card); color: var(--fg); cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-fg); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; width: 100%; margin-top: 4px; }
.btn input[type=file] { display: none; }
.note { background: var(--card); border-radius: 10px; padding: 10px 12px; margin: 8px 0; white-space: pre-line; }
.chips { display: flex; gap: 6px; overflow-x: auto; margin: 8px 0; scrollbar-width: none; }
.chips button { flex: none; border: 0; border-radius: 16px; padding: 6px 12px; background: var(--card); color: var(--fg); font: inherit; }
.chips button.on { background: var(--accent); color: var(--accent-fg); }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.cell { position: relative; aspect-ratio: 1; border-radius: 6px; overflow: hidden; background: var(--card); border: 0; padding: 0; }
.cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cell .ph { position: absolute; inset: 0; display: grid; place-items: center; font-size: 24px; color: var(--muted); }
.cell .badges { position: absolute; left: 4px; bottom: 4px; display: flex; gap: 2px; font-size: 13px; text-shadow: 0 0 3px #000; }
.cell.excluded img { opacity: .45; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
#more { width: 100%; margin-top: 12px; }
.progress .bar { height: 6px; border-radius: 3px; background: var(--card); overflow: hidden; }
.progress .bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
dialog { border: 0; padding: 0; width: min(560px, 100vw); max-height: 92vh; border-radius: 14px 14px 0 0; margin: auto auto 0;
  background: var(--bg); color: var(--fg); }
dialog::backdrop { background: rgba(0, 0, 0, .5); }
.sheet { display: flex; flex-direction: column; gap: 10px; padding: 12px; }
.sheet img { width: 100%; max-height: 50vh; object-fit: contain; border-radius: 10px; background: var(--card); }
.sheet label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.sheet input { font: inherit; padding: 9px 10px; border-radius: 8px; border: 1px solid var(--card); background: var(--card); color: var(--fg); }
.toggles { display: flex; flex-wrap: wrap; gap: 6px; }
.toggle { border: 0; border-radius: 16px; padding: 7px 12px; background: var(--card); color: var(--fg); font: inherit; }
.toggle.on { background: var(--accent); color: var(--accent-fg); }
.row { display: flex; gap: 8px; }
.row .btn { flex: 1; }
