:root {
  color-scheme: light dark;
  --bg: var(--tg-theme-bg-color, #ffffff);
  --fg: var(--tg-theme-text-color, #111111);
  --muted: var(--tg-theme-hint-color, #6b7280);
  --card: var(--tg-theme-secondary-bg-color, #f2f3f5);
  --accent: var(--tg-theme-button-color, #2481cc);
  --accent-fg: var(--tg-theme-button-text-color, #ffffff);
  --danger: var(--tg-theme-destructive-text-color, #d14343);
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body { font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
main { max-width: 640px; margin: 0 auto; padding: 16px 16px 132px; }
h1 { font-size: 18px; margin: 0 0 12px; }
p { margin: 8px 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.peer { font-weight: 600; }
.state { font-weight: 600; font-size: 17px; }
.detail, .msg { color: var(--danger); }
.text {
  margin: 12px 0 4px;
  padding: 12px 14px;
  background: var(--card);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
figure { margin: 12px 0; }
figure img { display: block; max-width: 100%; max-height: 60vh; border-radius: 10px; }

#actions {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  gap: 8px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--card);
}
#actions[hidden], [hidden] { display: none !important; }
button {
  font: inherit;
  border: 0;
  border-radius: 10px;
  padding: 14px 12px;
  cursor: pointer;
}
button.primary { flex: 2; background: var(--accent); color: var(--accent-fg); font-weight: 600; }
button.secondary { flex: 1; background: var(--card); color: var(--danger); }
button:disabled { opacity: .5; cursor: default; }
