[hidden] { display: none !important; }
:root {
  --bg: #f5f6f8; --card: #fff; --text: #1b1d21; --muted: #6b7280; --line: #e5e7eb;
  --accent: #5b5bf0; --accent-text: #fff; --ok: #16a34a; --bad: #dc2626; --wait: #d97706;
  --ok-bg: #e8f7ee; --bad-bg: #fdecec; --input: #fff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317; --card: #1a1d23; --text: #e8eaed; --muted: #9aa0a9; --line: #2c3038;
    --accent: #7c7cff; --ok-bg: #12301f; --bad-bg: #3a1717; --input: #14171c;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
body.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; margin: 0 0 16px; }
h2 { font-size: 18px; margin: 0 0 12px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 24px; background: var(--card); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 18px; color: var(--text); }
.top nav { display: flex; gap: 18px; align-items: center; }
.top nav form { margin: 0; }
main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 64px; }
.card { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; margin-bottom: 18px; color: var(--text); }
a.card:hover { text-decoration: none; border-color: var(--accent); }
.card.narrow { max-width: 460px; }
.login { width: 100%; max-width: 360px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-bottom: 18px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid .card { margin: 0; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.row.gap { justify-content: flex-start; }
.row.head { margin-bottom: 16px; }
.row.head h1 { margin: 0; }
.status { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.status form { margin: 0 0 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nums { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); margin-top: 8px; }
.nums b { color: var(--text); }
.nums.big { margin: 0 0 14px; }
.nums.big b { font-size: 20px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: var(--muted); flex: none; }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--bad); } .dot.wait { background: var(--wait); }
label { display: block; margin-bottom: 12px; font-weight: 500; }
input, textarea, select { display: block; width: 100%; margin-top: 4px; padding: 9px 11px; font: inherit; color: var(--text); background: var(--input); border: 1px solid var(--line); border-radius: 8px; }
input[type=file] { padding: 7px; }
textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button { font: inherit; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.danger { color: var(--bad); }
button.small { padding: 5px 10px; font-size: 13px; }
button.link { border: 0; background: none; padding: 0; color: var(--accent); }
button.icon { padding: 3px 7px; }
form.inline { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
form.inline input, form.inline select { flex: 1 1 260px; margin: 0; width: auto; }
.copy { display: flex; gap: 8px; margin-bottom: 14px; }
.copy input { margin: 0; font-size: 13px; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.err { background: var(--bad-bg); color: var(--bad); }
table { width: 100%; border-collapse: collapse; font-size: 14px; display: block; overflow-x: auto; }
thead, tbody { display: table; width: 100%; }
th, td { text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 13px; }
td.actions { white-space: nowrap; }
td.actions form { display: inline; margin: 0; }
.errrow td { color: var(--bad); font-size: 13px; border-top: 0; }
.bar { width: 120px; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-bottom: 3px; }
.bar i { display: block; height: 100%; background: var(--accent); }
.st-done { color: var(--ok); } .st-failed { color: var(--bad); } .st-running { color: var(--accent); }
@media (max-width: 600px) {
  .top { padding: 10px 16px; }
  .copy { flex-direction: column; }
}

/* --- composer (same layout as the RPDX Hub admin) --- */
.row.end { justify-content: flex-end; }
.head p { margin: 4px 0 0; }
.save-dirty, .save-saving { color: var(--wait); } .save-error { color: var(--bad); }
.notice { margin: 0 0 18px; padding: 10px 14px; border-left: 4px solid var(--accent); background: var(--card); border-radius: 0 8px 8px 0; }
.over { color: var(--bad); }
.composer-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.composer-preview { position: sticky; top: 16px; }
@media (max-width: 900px) { .composer-layout { grid-template-columns: minmax(0, 1fr); } .composer-preview { position: static; } }
.rte { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--input); }
.toolbar { display: flex; flex-wrap: wrap; gap: 2px; padding: 4px; border-bottom: 1px solid var(--line); background: var(--bg); }
.toolbar button { min-width: 32px; height: 30px; padding: 0 8px; border: 1px solid transparent; background: none; font-size: 14px; border-radius: 6px; }
.toolbar button:hover { border-color: var(--line); background: var(--card); }
.toolbar button.active { border-color: var(--accent); color: var(--accent); }
.toolbar .tool-html { margin-left: auto; }
.tool-b { font-weight: 800; } .tool-i { font-style: italic; font-family: Georgia, serif; } .tool-u { text-decoration: underline; } .tool-s { text-decoration: line-through; }
.rte-area { min-height: 220px; max-height: 60vh; overflow-y: auto; padding: 12px 14px; outline: none; }
.rte-area:empty::before { content: attr(data-placeholder); color: var(--muted); }
.rte-source { margin: 0; border: 0; border-radius: 0; min-height: 260px; }
.rte-foot { display: flex; justify-content: space-between; gap: 12px; padding: 6px 10px; border-top: 1px solid var(--line); font-size: 12px; }
.rte-foot > :last-child { flex: none; white-space: nowrap; }
.rte-foot code, .modal code { padding: 0 3px; background: var(--bg); border-radius: 3px; }
.dropzone { display: grid; gap: 8px; padding: 2px; outline: 2px dashed transparent; outline-offset: 4px; border-radius: 8px; }
.dropzone.over { outline-color: var(--accent); }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.media { position: relative; margin: 0; aspect-ratio: 1; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.media img, .media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.doc-thumb { height: 100%; display: grid; place-content: center; justify-items: center; gap: 4px; padding: 8px; text-align: center; }
.doc-thumb span { font-size: 34px; } .doc-thumb small { font-size: 11px; word-break: break-all; color: var(--muted); }
.media-kind { position: absolute; left: 6px; top: 6px; padding: 1px 6px; background: rgb(0 0 0 / .6); color: #fff; font-size: 11px; border-radius: 4px; }
.media figcaption { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: center; gap: 4px; padding: 4px; background: linear-gradient(transparent, rgb(0 0 0 / .65)); color: #fff; font-size: 12px; }
.media figcaption button { width: 24px; height: 22px; padding: 0; border: 0; border-radius: 4px; background: rgb(255 255 255 / .2); color: #fff; }
.media figcaption button:disabled { opacity: .35; cursor: default; }
.media figcaption .media-remove { margin-left: auto; background: rgb(200 30 60 / .85); }
.media.uploading img, .media.uploading video { opacity: .5; }
.media-progress { position: absolute; left: 8px; right: 8px; top: 50%; height: 4px; background: rgb(255 255 255 / .4); }
.media-progress span { display: block; height: 100%; background: var(--accent); transition: width .2s; }
.media-add { display: grid; place-content: center; justify-items: center; gap: 4px; aspect-ratio: 1; margin: 0; border: 1px dashed var(--muted); border-radius: 8px; color: var(--muted); text-align: center; cursor: pointer; font-weight: 400; }
.media-add:hover { border-color: var(--accent); color: var(--accent); }
.media-add span { font-size: 28px; line-height: 1; } .media-add small { font-size: 11px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px; margin-bottom: 8px; border: 1px dashed var(--line); border-radius: 8px; }
.btn-cell { display: flex; gap: 4px; align-items: center; flex: 1 1 280px; }
.btn-cell input { margin: 0; }
.btn-cell input:first-child { flex: 0 1 40%; }
.modal { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 16px; background: rgb(0 0 0 / .45); }
.modal[hidden] { display: none; }
.modal-box { width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; background: var(--card); border-radius: 12px; padding: 18px 20px; }
.modal-box label { flex: 1 1 160px; }
.emoji-grid { display: flex; flex-wrap: wrap; gap: 4px; min-height: 44px; }
.emoji { width: 44px; height: 44px; padding: 0; display: grid; place-items: center; font-size: 22px; }
.emoji img { width: 28px; height: 28px; }
.phone { border: 1px solid var(--line); background: var(--card); overflow: hidden; border-radius: 18px; box-shadow: 0 10px 30px rgb(0 0 0 / .08); }
.phone-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.phone-head div { display: grid; line-height: 1.2; } .phone-head small { color: var(--muted); font-size: 12px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; font-weight: 700; }
.phone-body { min-height: 320px; max-height: calc(100vh - 160px); overflow-y: auto; padding: 16px 12px; display: flex; flex-direction: column; justify-content: flex-end; background: linear-gradient(160deg, #c9dcb4, #a9c99a 45%, #d4c79c); }
@media (prefers-color-scheme: dark) { .phone-body { background: linear-gradient(160deg, #17212b, #0e1621); } }
.tg-message { display: grid; gap: 4px; max-width: 92%; }
.tg-bubble { position: relative; background: #fff; color: #111; border-radius: 14px 14px 14px 4px; overflow: hidden; box-shadow: 0 1px 1px rgb(0 0 0 / .12); }
@media (prefers-color-scheme: dark) { .tg-bubble { background: #182533; color: #f5f5f5; } }
.tg-bubble-text { padding: 7px 11px 20px; font-size: 14.5px; line-height: 1.38; }
.tg-time { position: absolute; right: 9px; bottom: 4px; font-size: 11px; color: #8a9aa9; }
.tg-album { display: grid; gap: 2px; }
.tg-album img, .tg-album video { width: 100%; height: 100%; object-fit: cover; display: block; min-height: 0; }
.tg-album-1 > * { max-height: 340px; }
.tg-album-2 { grid-template-columns: 1fr 1fr; } .tg-album-2 > * { aspect-ratio: 3 / 4; }
.tg-album-3 { grid-template-columns: 1fr 1fr; } .tg-album-3 > :first-child { grid-column: 1 / -1; aspect-ratio: 16 / 10; }
.tg-album-3 > :not(:first-child), .tg-album-4 > * { aspect-ratio: 1; }
.tg-album-4 { grid-template-columns: repeat(3, 1fr); } .tg-album-4 > :first-child { grid-column: 1 / -1; aspect-ratio: 16 / 10; }
.tg-doc { display: flex; gap: 10px; align-items: center; padding: 8px 11px 0; }
.tg-doc-icon { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: #3390ec; font-size: 18px; flex: none; }
.tg-doc div { display: grid; min-width: 0; } .tg-doc b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .tg-doc small { color: #8a9aa9; }
.tg-buttons { display: flex; gap: 4px; }
.tg-button { flex: 1; padding: 9px; text-align: center; border-radius: 10px; background: rgb(0 0 0 / .22); color: #fff; font-size: 14px; font-weight: 600; backdrop-filter: blur(4px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.tg-text b { font-weight: 700; }
.tg-text a { color: #2481cc; text-decoration: none; }
.tg-text code { padding: 0 3px; border-radius: 4px; background: rgb(127 127 127 / .16); font-family: ui-monospace, Consolas, monospace; font-size: .92em; color: #c43a5f; }
.tg-text pre { display: block; margin: 4px 0; padding: 8px 10px; border-radius: 6px; background: rgb(127 127 127 / .14); font-family: ui-monospace, Consolas, monospace; font-size: .9em; white-space: pre-wrap; }
.tg-text blockquote { margin: 4px 0; padding: 4px 8px 4px 10px; border-left: 3px solid #3390ec; border-radius: 4px; background: rgb(51 144 236 / .1); }
.tg-text .tg-spoiler { background: repeating-linear-gradient(45deg, rgb(127 127 127 / .55) 0 2px, rgb(127 127 127 / .35) 2px 4px); color: transparent; border-radius: 3px; }
.rte-area .tg-spoiler { color: inherit; background: rgb(127 127 127 / .25); outline: 1px dashed rgb(127 127 127 / .7); }
.tg-text .tg-spoiler:hover { color: inherit; background: rgb(127 127 127 / .2); }
.tg-text img.tg-emoji { width: 1.25em; height: 1.25em; vertical-align: -0.25em; object-fit: contain; }
