:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1a1d21;
  --muted: #6b7280;
  --border: #e3e6ea;
  --accent: #2f80ed;
  --accent-soft: #e8f1fe;
  --scheduled: #d99200;
  --published: #1f9d55;
  --deleted: #9aa0a6;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181d; --card: #1e2127; --text: #e8eaed; --muted: #9aa0a6;
    --border: #2c3038; --accent: #4a9eff; --accent-soft: #1c2b40;
    --scheduled: #e0a92e; --published: #35c46a; --deleted: #6b7280;
    --shadow: 0 1px 3px rgba(0,0,0,.3);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; overflow-x: hidden; max-width: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; background: var(--card);
  border-bottom: 1px solid var(--border); box-shadow: var(--shadow);
}
.brand { font-weight: 700; font-size: 16px; white-space: nowrap; flex-shrink: 0; }
.tabs { display: flex; gap: 4px; flex-shrink: 0; }
.tab {
  border: none; background: transparent; color: var(--muted);
  padding: 7px 14px; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600;
}
.tab:hover { background: var(--bg); }
.tab.active { background: var(--accent-soft); color: var(--accent); }
.me { margin-left: auto; color: var(--muted); font-size: 13px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; min-width: 0; }

main { max-width: 1000px; margin: 0 auto; padding: 16px; }
.loading, .empty { color: var(--muted); text-align: center; padding: 48px 16px; }

.searchbar { margin-bottom: 14px; }
.searchbar input {
  width: 100%; padding: 11px 14px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--card); color: var(--text); font-size: 15px;
}
.searchbar input:focus { outline: none; border-color: var(--accent); }

.daynav { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.daybtn {
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  width: 40px; height: 40px; border-radius: 10px; font-size: 20px; line-height: 1; cursor: pointer; flex: 0 0 auto;
}
.daybtn:disabled { opacity: .35; cursor: default; }
.daytitle { flex: 1; text-align: center; font-weight: 700; font-size: 15px; }
.daycount { color: var(--muted); font-weight: 500; font-size: 13px; }
.daystrip {
  display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 14px;
  -webkit-overflow-scrolling: touch; scrollbar-width: thin;
}
.daychip {
  flex: 0 0 auto; border: 1px solid var(--border); background: var(--card); color: var(--muted);
  padding: 7px 13px; border-radius: 999px; font-size: 13px; font-weight: 600; cursor: pointer;
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
.daychip.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px; box-shadow: var(--shadow); cursor: pointer; transition: transform .06s, border-color .15s;
}
.card:hover { border-color: var(--accent); transform: translateY(-1px); }
.card-title { font-weight: 650; font-size: 15px; margin-bottom: 6px; }
.card-sub { color: var(--muted); font-size: 13px; }
.pill {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent);
}

.crumbs { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.crumbs a { color: var(--accent); cursor: pointer; text-decoration: none; font-weight: 600; }
.crumbs .sep { color: var(--muted); }
.crumbs h2 { font-size: 18px; margin: 0; }

.day-group { margin-bottom: 18px; }
.day-head {
  font-weight: 700; font-size: 13px; color: var(--muted); text-transform: uppercase;
  letter-spacing: .03em; margin: 0 0 8px 2px;
}
.rows { display: flex; flex-direction: column; gap: 6px; }
.row {
  display: flex; align-items: center; gap: 12px; background: var(--card);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; cursor: pointer;
}
.row:hover { border-color: var(--accent); }
.row .time { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 46px; }
.row .st { font-size: 15px; width: 20px; text-align: center; }
.row .txt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.row .meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
.badge-grid { font-size: 11px; padding: 1px 6px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); font-weight: 700; }

.st-scheduled { color: var(--scheduled); }
.st-published { color: var(--published); }
.st-deleted { color: var(--deleted); }

table.chtable { width: 100%; border-collapse: collapse; }
table.chtable th, table.chtable td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 14px; }
table.chtable th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.tablewrap { overflow-x: auto; background: var(--card); border: 1px solid var(--border); border-radius: 12px; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; padding: 24px 12px; overflow-y: auto;
}
/* атрибут hidden должен реально прятать оверлей (авторский display:flex иначе перебивает UA-стиль) */
.modal-backdrop[hidden] { display: none; }
.modal {
  position: relative; background: var(--card); border-radius: 16px; max-width: 620px; width: 100%;
  padding: 22px; box-shadow: 0 12px 40px rgba(0,0,0,.35); border: 1px solid var(--border);
}
.modal-close {
  position: absolute; top: 12px; right: 12px; border: none; background: var(--bg);
  width: 30px; height: 30px; border-radius: 8px; cursor: pointer; color: var(--muted); font-size: 15px;
}
.modal h3 { margin: 0 40px 12px 0; font-size: 17px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; margin: 12px 0; font-size: 14px; }
.kv .k { color: var(--muted); }
.posttext { background: var(--bg); border-radius: 10px; padding: 12px; white-space: pre-wrap; word-break: break-word; max-height: 300px; overflow-y: auto; font-size: 14px; }
.posttext a { color: var(--accent); text-decoration: none; }
.posttext a:hover { text-decoration: underline; }
.posttext code { background: var(--border); padding: 1px 5px; border-radius: 5px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.posttext pre { background: var(--border); padding: 10px; border-radius: 8px; overflow-x: auto; white-space: pre; margin: 6px 0; }
.posttext blockquote { border-left: 3px solid var(--accent); margin: 6px 0; padding: 2px 0 2px 10px; color: var(--muted); }
.tg-spoiler { background: var(--muted); color: transparent; border-radius: 4px; cursor: pointer; transition: color .12s, background .12s; }
.tg-spoiler:hover { background: var(--border); color: inherit; }
.media { margin: 12px 0; display: flex; flex-wrap: wrap; gap: 8px; }
.media img, .media video { max-width: 100%; border-radius: 10px; max-height: 300px; }
.media .ph { background: var(--bg); border: 1px dashed var(--border); border-radius: 10px; padding: 22px; color: var(--muted); text-align: center; flex: 1; }
.flags { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.flag { font-size: 12px; padding: 2px 9px; border-radius: 999px; background: var(--bg); color: var(--muted); }
.link-out { color: var(--accent); text-decoration: none; font-weight: 600; }

/* форма правки */
.btn {
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); margin-top: 4px; }
.btn-primary:hover { filter: brightness(1.05); }
.btn-danger { background: #d64545; color: #fff; border-color: #d64545; }
.btn-danger:hover { filter: brightness(1.05); }
.btnrow-left { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.field { margin: 14px 0; }
.field > label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.field .hint { color: var(--muted); font-weight: 400; font-size: 12px; }
.field textarea, .field input[type="number"], .field input[type="datetime-local"] {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--bg); color: var(--text); font-size: 14px; font-family: inherit;
}
.field textarea { resize: vertical; min-height: 90px; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); }
.field .chk { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; margin-bottom: 8px; cursor: pointer; }
.field input[type="number"]:disabled { opacity: .5; }
.radios { display: flex; gap: 14px; flex-wrap: wrap; }
.radios label { font-weight: 400; display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.btnrow { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.err-msg { background: #fdecec; color: #b3261e; border-radius: 8px; padding: 9px 12px; font-size: 13px; margin-top: 10px; }
@media (prefers-color-scheme: dark) { .err-msg { background: #3a1e1e; color: #f2b8b5; } }

.gate { text-align: center; padding: 60px 20px; }
.gate h2 { font-size: 20px; }
.gate p { color: var(--muted); }

@media (max-width: 560px) {
  .brand .long { display: none; }   /* оставить только иконку 📅 */
  .me { display: none; }            /* длинный «id · роль · N кан.» прячем — он и распирал шапку */
  .row .meta { display: none; }
  .kv { grid-template-columns: 100px 1fr; }
  .grid-cards { grid-template-columns: 1fr; }  /* карточки в один столбец */
  main { padding: 12px; }
}
