/* Colours follow Telegram's theme inside the Mini App (vars set by app.js),
   and the OS light/dark preference in a normal browser. */
:root {
  --bg: #f4f5f7; --card: #ffffff; --text: #16181d; --muted: #6b7280; --line: #e3e6eb;
  --accent: #2481cc; --accent-text: #ffffff; --ok: #1a8f4c; --warn: #b7791f; --bad: #c62828;
  --ok-bg: #e5f5ec; --warn-bg: #fdf3e1; --bad-bg: #fde8e8; --info-bg: #e6f0fa;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115; --card: #1a1d23; --text: #e8eaed; --muted: #9aa1ab; --line: #2b3038;
    --ok-bg: #173325; --warn-bg: #3a2e14; --bad-bg: #3b1a1a; --info-bg: #172a3d;
  }
}
:root[data-theme="dark"] {
  --ok-bg: #173325; --warn-bg: #3a2e14; --bad-bg: #3b1a1a; --info-bg: #172a3d;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; } /* class display rules must not un-hide elements */
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
.top, .tabs { max-width: 900px; margin-left: auto; margin-right: auto; }
.top { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; }
.brand { display: flex; gap: 8px; align-items: center; font-weight: 700; font-size: 17px; }
.who { color: var(--muted); font-size: 13px; }
.linkbtn { border: 0; background: none; color: var(--accent); font: inherit; font-size: 13px; cursor: pointer; padding: 0; }
.login-form { max-width: 320px; margin: 0 auto; text-align: left; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 0 16px 10px; scrollbar-width: none; position: sticky; top: 0; background: var(--bg); z-index: 5; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 14px; cursor: pointer; }
.tabs button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
main { padding: 0 16px 24px; max-width: 900px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.center { text-align: center; }
h2 { font-size: 17px; margin: 0 0 8px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--bad); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.stat .n { font-size: 26px; font-weight: 700; line-height: 1.1; }
.stat .l { color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.PENDING_APPROVAL, .pill.NOTIFIED { background: var(--warn-bg); color: var(--warn); }
.pill.PUBLISHED, .pill.RETWEETED, .pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.FAILED, .pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.REJECTED, .pill.IGNORED, .pill.FILTERED, .pill.DRAFT, .pill.APPROVED, .pill.off { background: var(--info-bg); color: var(--muted); }
.post .copy { white-space: pre-wrap; word-wrap: break-word; margin: 6px 0; }
.post .label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin-top: 8px; }
.post img.thumb { max-width: 100%; max-height: 260px; border-radius: 8px; display: block; margin-top: 8px; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
button.btn { border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 8px; padding: 8px 12px; font: inherit; font-size: 14px; cursor: pointer; }
button.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.btn.danger { color: var(--bad); }
button.btn:disabled { opacity: .5; cursor: default; }
label { display: block; font-size: 13px; font-weight: 600; margin: 10px 0 4px; }
input[type=text], input[type=password], input[type=url], input[type=number], textarea, select {
  width: 100%; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px;
}
textarea { min-height: 90px; resize: vertical; }
.count { font-size: 12px; color: var(--muted); text-align: right; }
.count.over { color: var(--bad); font-weight: 700; }
.chart { display: flex; align-items: flex-end; gap: 4px; height: 120px; padding-top: 6px; }
.chart .col { flex: 1; height: 100%; display: flex; flex-direction: column-reverse; gap: 1px; min-width: 0; }
.chart .seg { border-radius: 3px 3px 0 0; }
.chart .pub { background: var(--ok); }
.chart .cre { background: var(--accent); opacity: .35; }
.chart .fail { background: var(--bad); }
.chart-x { display: flex; gap: 4px; font-size: 10px; color: var(--muted); }
.chart-x span { flex: 1; text-align: center; overflow: hidden; }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
td, th { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; max-width: 90vw; z-index: 20; font-size: 14px; }
.drop { border: 2px dashed var(--line); border-radius: 10px; padding: 14px; text-align: center; color: var(--muted); cursor: pointer; }
.drop img { max-width: 100%; max-height: 220px; border-radius: 8px; }
.seg-choice { display: flex; gap: 6px; flex-wrap: wrap; }
.seg-choice label { display: inline-flex; gap: 6px; align-items: center; margin: 0; font-weight: 500; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; cursor: pointer; }
details summary { cursor: pointer; font-weight: 600; }
.help ol, .help ul { padding-left: 20px; }
.help code { background: var(--bg); padding: 1px 5px; border-radius: 4px; }
