:root {
  --bg: var(--tg-theme-bg-color, #fff);
  --fg: var(--tg-theme-text-color, #111);
  --hint: var(--tg-theme-hint-color, #777);
  --card: var(--tg-theme-secondary-bg-color, #f2f2f4);
  --accent: var(--tg-theme-button-color, #2481cc);
  --accent-fg: var(--tg-theme-button-text-color, #fff);
  --radius: 14px;
  --line: color-mix(in srgb, var(--hint) 22%, transparent);
  --tabbar-h: 56px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.4 system-ui, sans-serif;
  padding: env(safe-area-inset-top) 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px); }
[hidden] { display: none !important; }
.bar { position: sticky; top: 0; background: var(--bg); padding: 10px 0 6px; z-index: 2; }
.search { width: 100%; padding: 10px 12px; border-radius: 10px; border: 0; background: var(--card); color: var(--fg); font: inherit; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0; scrollbar-width: none; }
.chip { flex: none; border: 0; border-radius: 16px; padding: 6px 12px; background: var(--card); color: var(--fg); font: inherit; }
.chip.on { background: var(--accent); color: var(--accent-fg); }
.row { display: flex; gap: 8px; align-items: center; color: var(--hint); }
.row select { flex: 1; padding: 8px; border-radius: 8px; border: 0; background: var(--card); color: var(--fg); font: inherit; }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 8px 0 24px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, 1fr); } }
.tile, .look { display: flex; flex-direction: column; min-width: 0; border: 1px solid var(--line); padding: 0; text-align: left;
  background: var(--bg); border-radius: var(--radius); overflow: hidden; color: var(--fg); font: inherit; }
.ph { position: relative; aspect-ratio: 4 / 5; background: var(--card); }
.ph img { display: block; width: 100%; height: 100%; object-fit: contain; padding: 8px; }
.badge { position: absolute; left: 8px; top: 8px; padding: 2px 8px; border-radius: 10px; font-size: 12px; background: var(--bg); color: var(--hint); border: 1px solid var(--line); }
.tile .t, .look .t { padding: 8px 10px 10px; }
.tile .n, .look .n { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-height: 1.4em; }
.tile .s, .look .s { color: var(--hint); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-height: 1.4em; }
.tile:disabled { opacity: 1; }
.sheet-back { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 5; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-height: 88vh; overflow-y: auto; background: var(--bg);
  border-radius: 18px 18px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); z-index: 6; }
.sheet h3 { margin: 4px 36px 10px 0; }
.sheet > img { display: block; width: 100%; max-height: 50vh; object-fit: contain; background: var(--card); border-radius: var(--radius); }
.grab { width: 36px; height: 4px; border-radius: 2px; background: var(--line); margin: -6px auto 10px; }
.close { position: absolute; right: 12px; top: 12px; width: 32px; height: 32px; border: 0; border-radius: 16px; background: var(--card); color: var(--fg); font-size: 18px; line-height: 1; }
.kv { display: grid; grid-template-columns: 9em 1fr; gap: 4px 10px; margin-top: 12px; }
.kv dt { color: var(--hint); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.msg { text-align: center; color: var(--hint); padding: 40px 0; }
.looks { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 8px 0 24px; }
.collage { display: grid; gap: 2px; aspect-ratio: 1; background: var(--line); overflow: hidden; }
.collage > * { min-width: 0; min-height: 0; width: 100%; height: 100%; background: var(--card); }
.collage img { object-fit: contain; padding: 6px; }
.collage.c1 { grid-template: 1fr / 1fr; }
.collage.c2 { grid-template: 1fr / 1fr 1fr; }
.collage.c3 { grid-template: 1fr 1fr / 1.4fr 1fr; }
.collage.c3 > :first-child { grid-row: span 2; }
.collage.c4 { grid-template: 1fr 1fr / 1fr 1fr; }
.gone { display: flex; align-items: center; justify-content: center; color: var(--hint); font-size: 12px; background: var(--card); }
.ph .gone { position: absolute; inset: 0; }
.viz { margin: 8px 0 12px; }
.viz img { width: 100%; max-height: 60vh; object-fit: contain; background: var(--card); border-radius: var(--radius); }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 3; display: flex; background: var(--bg);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tab { flex: 1; height: var(--tabbar-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 0; background: none; color: var(--hint); font: inherit; font-size: 12px; }
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab.on { color: var(--accent); }
