/* ipush: ночной индиго и жёлтый колокольчик — родственник WaterControl и iSchedule */
:root {
  --ink: #13153A;
  --ink-soft: #565A86;
  --bg: #F3F2FB;
  --panel: #FFFFFF;
  --line: #E1DFF2;
  --night: #2B2D6E;
  --night-dark: #181A4A;
  --bell: #FFC83D;
  --bell-ink: #6B4A00;
  --coral: #FF6B6B;
  --mint: #2FCF97;
  --radius-l: 24px;
  --radius-m: 16px;
  --shadow: 0 18px 40px -24px rgba(19, 21, 58, .5);
  --font-display: "Unbounded", "Trebuchet MS", sans-serif;
  --font-body: "Nunito", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; font-family: var(--font-body); font-size: 16px; line-height: 1.5; color: var(--ink); background: var(--bg); }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; margin: 0 0 .5em; }
h1 { font-size: 28px; } h2 { font-size: 19px; } h3 { font-size: 15px; }
p { margin: 0 0 .8em; }
a { color: var(--night); font-weight: 700; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--bell); outline-offset: 2px; border-radius: 8px; }
.hidden { display: none !important; }
.muted, .hint { color: var(--ink-soft); }
.hint { font-size: 14px; }
code, .mono { font-family: var(--mono); font-size: 13.5px; }
pre { background: var(--night-dark); color: #E9E8FF; padding: 12px 14px; border-radius: 12px; overflow-x: auto; font-size: 13px; margin: 6px 0 12px; }

.btn {
  appearance: none; border: 0; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 22px; border-radius: 999px; font-weight: 800; background: var(--night); color: #fff;
  box-shadow: 0 5px 0 var(--night-dark); transition: transform .12s, box-shadow .12s, filter .2s; text-decoration: none;
}
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--night-dark); }
.btn:disabled { opacity: .55; }
.btn-bell { background: var(--bell); color: var(--ink); box-shadow: 0 5px 0 #D29E1B; }
.btn-soft { background: var(--bg); color: var(--night); box-shadow: none; }
.btn-ghost { background: transparent; color: var(--ink-soft); box-shadow: none; }
.btn-danger { background: #FFE3E3; color: #9C1C1C; box-shadow: none; }
.btn-small { min-height: 34px; padding: 0 12px; font-size: 14px; box-shadow: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.input { width: 100%; min-height: 46px; padding: 0 14px; border: 2px solid var(--line); border-radius: 14px; background: #FBFAFF; }
.input:focus { outline: none; border-color: var(--night); background: #fff; }
textarea.input { padding: 10px 14px; min-height: 80px; resize: vertical; }
.field { display: grid; gap: 4px; margin-bottom: 12px; }
.field label { font-weight: 700; font-size: 14px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.error { color: #9C1C1C; background: #FFE3E3; border-radius: 12px; padding: 8px 12px; font-weight: 700; }
.tag { display: inline-block; font-size: 12px; font-weight: 800; padding: 1px 8px; border-radius: 999px; background: var(--bg); color: var(--ink-soft); }
.tag-hot { background: #FFE3E3; color: #9C1C1C; }
.tag-on { background: #D9F8EC; color: #0B6B4A; }

.top { background: var(--night); color: #fff; }
.top-in { max-width: 1100px; margin: 0 auto; padding: 14px 16px; display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 800; font-size: 20px; color: #fff; text-decoration: none; }
.brand img { width: 34px; height: 34px; }
.top .who { margin-left: auto; font-weight: 700; opacity: .85; }
.top .btn-ghost { color: #DAD9FF; }

.layout { max-width: 1100px; margin: 0 auto; padding: 18px 16px 60px; display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 18px; align-items: start; }
.panel { background: var(--panel); border-radius: var(--radius-l); padding: 18px; box-shadow: var(--shadow); }
/* min-width: 0 — иначе длинное имя темы распирает колонку и плашки наезжают на ленту */
.side { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; position: sticky; top: 12px; min-width: 0; }
.layout > main { min-width: 0; }
.layout h1 { overflow-wrap: anywhere; }
.topics { list-style: none; padding: 0; margin: 0 0 10px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
.topics li { min-width: 0; display: flex; align-items: center; gap: 2px; }
.topics li > button[data-topic] { flex: 1; min-width: 0; }
.topics .t-del { width: auto; flex: none; padding: 6px 8px; color: var(--ink-soft); opacity: .45; font-size: 12px; }
.topics li:hover .t-del, .topics .t-del:focus-visible { opacity: 1; }
.topics .t-del:hover { background: #FFE0E8; color: #B42318; }
@media (hover: none) { .topics .t-del { opacity: .8; } }
.topics button { width: 100%; text-align: left; border: 0; background: transparent; cursor: pointer; border-radius: 12px; padding: 9px 12px;
  display: flex; align-items: center; gap: 8px; font-weight: 800; min-width: 0; }
.topics .t-name { min-width: 0; flex: 1; }
.topics button:hover { background: var(--bg); }
.topics button[aria-current="true"] { background: var(--night); color: #fff; }
.topics .count { margin-left: auto; background: var(--coral); color: #fff; border-radius: 999px; font-size: 12px; padding: 0 7px; }
.topics .t-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.add-topic { display: flex; gap: 6px; }
.add-topic .input { min-height: 40px; min-width: 0; flex: 1; }
.push-box { background: linear-gradient(160deg, var(--night), #4B4FB0); color: #fff; }
.push-box p { color: #DAD9FF; font-size: 14px; }

.feed { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.msg { background: #fff; border-radius: 18px; padding: 12px 16px; box-shadow: var(--shadow); border-left: 5px solid var(--line); overflow-wrap: anywhere; }
.msg.p4 { border-left-color: var(--bell); }
.msg.p5 { border-left-color: var(--coral); }
.msg.fresh { animation: pop .4s cubic-bezier(.3, 1.5, .5, 1); }
.msg-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; margin-bottom: 2px; }
.msg-head b { font-size: 16px; }
.msg-head time { margin-left: auto; font-size: 13px; color: var(--ink-soft); }
.msg p { margin: 0; white-space: pre-line; }
.compose { margin-bottom: 14px; }
.compose summary { cursor: pointer; font-weight: 800; color: var(--night); }
.empty { text-align: center; color: var(--ink-soft); padding: 40px 10px; }
.empty .big { font-size: 46px; display: block; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 800; color: var(--ink-soft); }
.live i { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.live.on i { background: var(--mint); box-shadow: 0 0 0 4px rgba(47, 207, 151, .25); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; color: var(--ink-soft); font-size: 12px; padding: 6px 8px; border-bottom: 2px solid var(--line); }
.table td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { border: 2px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 14px; font-weight: 800; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.login { max-width: 420px; margin: 40px auto; }
.modal-back { position: fixed; inset: 0; background: rgba(19, 21, 58, .5); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: #fff; border-radius: var(--radius-l); padding: 22px; width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto; }
#toast-root { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; width: min(420px, calc(100% - 32px)); }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 16px; font-weight: 700; box-shadow: var(--shadow); }
@keyframes pop { from { transform: scale(.94); opacity: 0; } }
@media (max-width: 800px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.msg details.data { margin-top: 6px; }
.msg details.data summary { cursor: pointer; font-size: 13px; font-weight: 800; color: var(--ink-soft); }
.msg details.data pre { margin: 6px 0 0; max-height: 260px; }

/* Администрирование: мастер подключения, токены пользователей, FCM */
.panel + .panel { margin-top: 16px; }
.checks { display: grid; gap: 6px; margin: 10px 0 4px; font-size: 14px; }
.checks input { margin-right: 6px; }
.once { background: #FFF4D1; color: #4A3300; border-radius: 12px; padding: 10px 14px; margin-top: 10px; }
.once pre { white-space: pre-wrap; word-break: break-all; margin: 6px 0; }
.limit-form { display: flex; gap: 6px; align-items: center; }
.input-small { width: 90px; padding-top: 6px; padding-bottom: 6px; }
.nowrap { white-space: nowrap; }
.tokens-row td { background: var(--bg, transparent); }
.token-list { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 6px; }
.token-list li { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.token-list .btn { margin-left: auto; }
.hidden { display: none !important; }
textarea.input { resize: vertical; width: 100%; }

/* Веб-интерфейс только после входа */
.locked { max-width: 440px; margin: 48px auto; padding: 0 16px; }
.switch-row { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.switch-row input { margin-top: 4px; }

/* Подключённые программы */
.apps td > div + div { margin-top: 2px; }
.app-editor td { background: var(--bg); }
.app-edit { display: grid; gap: 8px; }
.app-topics { display: grid; gap: 6px; }
.app-topic { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.app-topic .input[name=pattern] { flex: 1 1 160px; }
.app-topic select { flex: 0 1 190px; }
.panel-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.panel-head h2 { margin: 0; }
#app-new-box:not(:empty) { background: var(--bg); border-radius: 12px; padding: 12px 14px; margin: 10px 0; }
