:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1d2330;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #c13584;
  --primary-ink: #ffffff;
  --ok: #15803d;   --ok-bg: #dcfce7;
  --warn: #a16207; --warn-bg: #fef3c7;
  --bad: #b91c1c;  --bad-bg: #fee2e2;
  --mute-bg: #f1f5f9;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12141a; --card: #1b1e26; --text: #e6e8ee; --muted: #9aa1ad; --line: #2c303b;
    --ok: #4ade80; --ok-bg: #133022; --warn: #fbbf24; --warn-bg: #3a2e10;
    --bad: #f87171; --bad-bg: #3b1717; --mute-bg: #252935;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: "Vazirmatn", "IRANSans", Tahoma, system-ui, sans-serif;
  font-size: 15px; line-height: 1.7;
}
a { color: var(--primary); text-decoration: none; }
h1, h2 { margin: 0 0 12px; font-size: 18px; }
code { background: var(--mute-bg); padding: 0 4px; border-radius: 4px; direction: ltr; display: inline-block; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.top { background: var(--card); border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.top-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; min-height: 56px; }
.brand { font-weight: bold; color: var(--text); }
nav { display: flex; gap: 4px; flex-wrap: wrap; }
nav a { color: var(--muted); padding: 6px 10px; border-radius: 8px; }
nav a.on { color: var(--text); background: var(--mute-bg); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.card-head h2 { margin: 0; }

.statusbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; }
.statusbar .dot { width: 10px; height: 10px; border-radius: 50%; background: currentColor; }
.statusbar .msg { color: var(--text); }
.statusbar .acct { margin-inline-start: auto; direction: ltr; color: var(--muted); }
.ok { color: var(--ok); background: var(--ok-bg); }
.warn { color: var(--warn); background: var(--warn-bg); }
.bad { color: var(--bad); background: var(--bad-bg); }
.muted { color: var(--muted); background: var(--mute-bg); }

.flash { padding: 10px 14px; border-radius: 10px; background: var(--mute-bg); margin-bottom: 16px; }
.hint, small { color: var(--muted); font-size: 13px; }
.empty { color: var(--muted); text-align: center; padding: 24px 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.stat span { color: var(--muted); font-size: 13px; display: block; }
.stat b { font-size: 26px; }

.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.actions .hint { margin-inline-start: auto; }

.btn {
  font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--card); color: var(--text);
  padding: 7px 16px; border-radius: 8px; display: inline-block;
}
.btn:hover { background: var(--mute-bg); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.small { padding: 2px 10px; font-size: 13px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: right; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: normal; font-size: 13px; }
td.comment { max-width: 320px; word-break: break-word; }
.nowrap { white-space: nowrap; }
.tag { font-size: 12px; padding: 1px 8px; border-radius: 999px; display: inline-block; }
.err { color: var(--bad); font-size: 12px; margin-top: 4px; }

.filters { display: flex; gap: 4px; flex-wrap: wrap; }
.filters a { color: var(--muted); padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line); font-size: 13px; }
.filters a.on { color: var(--text); background: var(--mute-bg); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.post { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; color: var(--text); display: flex; flex-direction: column; }
.post.active { border-color: var(--ok); box-shadow: 0 0 0 1px var(--ok); }
.post img, .post .noimg { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--mute-bg); }
.post .noimg { display: flex; align-items: center; justify-content: center; color: var(--muted); }
.post-body { padding: 8px 10px; font-size: 13px; }
.post .kw { font-weight: bold; margin-top: 4px; }
.post .cap { color: var(--muted); }
.post .meta { color: var(--muted); font-size: 12px; margin-top: 4px; }

.form label { display: block; margin-bottom: 14px; }
.form input:not([type=checkbox]), .form textarea, .codebox input {
  display: block; width: 100%; margin-top: 4px; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
}
.form textarea { resize: vertical; }
.form .switch { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.form .switch input { width: 18px; height: 18px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 16px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.codebox { border-color: var(--warn); }
.codebox .row input { flex: 1; min-width: 140px; margin: 0; direction: ltr; text-align: center; letter-spacing: 4px; }

.rule-post { display: flex; gap: 14px; margin-bottom: 16px; }
.rule-post img { width: 120px; height: 120px; object-fit: cover; border-radius: 8px; flex-shrink: 0; }
.rule-post .cap { color: var(--muted); font-size: 13px; white-space: pre-line; max-height: 120px; overflow: auto; margin: 4px 0 0; }

body.center { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.login { width: 100%; max-width: 360px; }
.login label { display: block; margin-bottom: 12px; }
.login input { display: block; width: 100%; margin-top: 4px; font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); }
.login .btn { width: 100%; }

@media (max-width: 600px) {
  .rule-post { flex-direction: column; }
  .actions .hint { margin-inline-start: 0; }
}
