:root {
  --bg: var(--tg-theme-secondary-bg-color, #f2f3f5);
  --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #ffffff));
  --text: var(--tg-theme-text-color, #16181c);
  --muted: var(--tg-theme-hint-color, #7b8088);
  --accent: var(--tg-theme-button-color, #1f7a5c);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --line: color-mix(in srgb, var(--muted) 22%, transparent);
  --r-md: 14px;
  --r-lg: 18px;
  --gap: 12px;
  --tabs-h: 58px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 "Manrope", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }

.bar { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 14px 16px 8px; }
.bar h1 { margin: 0; font-size: 20px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.view { max-width: 640px; margin: 0 auto; padding: 4px 16px calc(var(--tabs-h) + 24px); min-height: 70vh; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--tabs-h);
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a { flex: 1; display: grid; place-items: center; color: var(--muted); text-decoration: none; font-weight: 600; }
.tabs a.on { color: var(--accent); }

.card { background: var(--card); border-radius: var(--r-lg); padding: 14px; margin-bottom: var(--gap); }
.muted { color: var(--muted); font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 48px 12px; }
.empty b { display: block; color: var(--text); font-size: 17px; margin-bottom: 6px; }

.items { display: grid; gap: 10px; }
.item-row { display: flex; gap: 12px; align-items: center; background: var(--card); border-radius: var(--r-lg);
  padding: 10px; color: inherit; text-decoration: none; }
.item-row img, .item-row .ph { width: 64px; height: 64px; border-radius: var(--r-md); object-fit: cover; flex: none;
  background: var(--line); }
.item-row .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-row .body { min-width: 0; flex: 1; }
.chip { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--line); margin-right: 4px; }
.chip.on { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }

.section-h { font-weight: 700; margin: 18px 2px 8px; }
.strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.strip + .strip { margin-top: 10px; }
.shot { flex: none; width: 104px; color: inherit; text-decoration: none; }
.shot img { width: 104px; height: 104px; object-fit: cover; border-radius: var(--r-md); display: block; background: var(--line); }
.shot span { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shot.src img { outline: 2px dashed var(--line); outline-offset: -2px; }

.field { margin-bottom: 14px; }
.field .h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.field .h b { font-size: 13px; color: var(--muted); font-weight: 600; }
.field .txt { white-space: pre-wrap; word-break: break-word; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.warn { color: #c0392b; font-size: 13px; margin-top: 8px; }

.btn { border: 0; border-radius: var(--r-md); background: var(--accent); color: var(--accent-text); font: inherit;
  font-weight: 600; padding: 10px 16px; cursor: pointer; }
.btn.small { padding: 5px 12px; font-size: 13px; }
.btn.ghost { background: var(--line); color: var(--text); }
.btn.wide { width: 100%; }

.notes { display: grid; gap: 8px; }
.note { display: flex; gap: 10px; align-items: flex-start; }
.note p { flex: 1; margin: 0; }
.note button { background: none; border: 0; color: var(--muted); font-size: 18px; line-height: 1; cursor: pointer; padding: 2px 4px; }
.add { display: flex; gap: 8px; margin-top: 10px; }
.add textarea { flex: 1; min-height: 44px; resize: vertical; border-radius: var(--r-md); border: 1px solid var(--line);
  background: var(--card); color: var(--text); font: inherit; padding: 10px; }

.viewer { position: fixed; inset: 0; z-index: 20; background: #000; display: flex; flex-direction: column; }
.viewer img { flex: 1; min-height: 0; width: 100%; object-fit: contain; }
.viewer-actions { display: flex; gap: 10px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
.viewer-actions .btn { flex: 1; }
.viewer-actions .btn.ghost { background: rgba(255, 255, 255, .16); color: #fff; }

.toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 16px); transform: translateX(-50%); z-index: 30;
  background: rgba(20, 22, 26, .9); color: #fff; padding: 8px 14px; border-radius: 999px; font-size: 14px; }
