:root {
  --bg: #0b0d14; --panel: #141824; --panel2: #1b2030; --line: #262c3d; --text: #e9ecf3; --muted: #8b93a7;
  --accent: #7c5cff; --crit: #ff4d4f; --imp: #f5a524; --gen: #7c8599; --mute: #4b5263; --ok: #22c55e;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif; -webkit-font-smoothing: antialiased; }
body { padding-bottom: env(safe-area-inset-bottom); }
#app { max-width: 720px; margin: 0 auto; min-height: 100vh; }
a { color: inherit; }
button { font: inherit; color: inherit; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: rgba(11, 13, 20, .92); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.ttl { flex: 1; min-width: 0; }
.ttl h1 { font-size: 20px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ttl small { color: var(--muted); }
.acts { display: flex; gap: 2px; }
.ib { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 0; background: transparent; color: var(--text); cursor: pointer; text-decoration: none; flex: none; }
.ib:hover, .ib:active { background: var(--panel2); }
.ib svg { width: 20px; height: 20px; }
.ib.dotted { position: relative; }
.ndot { position: absolute; top: 7px; right: 7px; width: 10px; height: 10px; border-radius: 50%; background: var(--crit); border: 2px solid var(--bg); }
.search { padding: 10px 16px 0; }
.search.hide { display: none; }

input, select, textarea { width: 100%; font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; }
input[type=checkbox] { width: auto; accent-color: var(--accent); margin: 0; }
input[type=color] { width: 42px; height: 40px; padding: 2px; flex: none; }
#c_text, #reply, #c_when { font-size: 16px; }

.chips, .tiers { display: flex; gap: 8px; overflow-x: auto; padding: 10px 16px 0; scrollbar-width: none; }
.chips::-webkit-scrollbar, .tiers::-webkit-scrollbar { display: none; }
.chip { flex: none; display: flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-size: 14px; white-space: nowrap; }
.chip i { width: 9px; height: 9px; border-radius: 50%; }
.chip b, .tier b { font-size: 12px; border-radius: 999px; padding: 0 6px; min-width: 18px; text-align: center; }
.chip b { background: var(--crit); color: #fff; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.tiers { gap: 18px; border-bottom: 1px solid var(--line); }
.tier { flex: none; padding: 6px 0 9px; border: 0; background: none; color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; font-weight: 600; white-space: nowrap; font-size: 14px; text-decoration: none; }
.tier.on { color: var(--text); border-color: var(--accent); }
.tier b { background: var(--panel2); color: var(--text); margin-left: 4px; }
.t-critical b, .t-attention b { background: var(--crit); color: #fff; }
.t-important b { background: var(--imp); color: #1a1200; }
.t-critical.on { border-color: var(--crit); }
.t-important.on { border-color: var(--imp); }
.subbar { display: flex; gap: 14px; align-items: center; padding: 8px 16px; border-bottom: 1px solid var(--line); }
.subbar select { width: auto; padding: 6px 10px; font-size: 14px; }
.tgl { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 14px; white-space: nowrap; font-weight: 500; }
.tgl.block { margin: 10px 0 0; color: var(--text); }

.banner { display: block; width: calc(100% - 32px); margin: 12px 16px 0; text-align: left; padding: 12px 14px; border-radius: 14px; border: 1px solid #3b2f7a; background: linear-gradient(135deg, #231a52, #141824); cursor: pointer; text-decoration: none; }
.banner b { display: block; }
.banner span { color: var(--muted); font-size: 14px; }

.list { padding: 0 0 48px; }
.row { position: relative; display: flex; gap: 12px; padding: 13px 16px 13px 18px; text-decoration: none; border-bottom: 1px solid var(--line); }
.row::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 4px; border-radius: 0 4px 4px 0; background: var(--t); }
.row:active { background: var(--panel); }
.avatar { position: relative; flex: none; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 32%, var(--panel2)); font-weight: 700; font-size: 15px; }
.plat { position: absolute; right: -5px; bottom: -4px; min-width: 21px; height: 19px; padding: 0 3px; border-radius: 7px; display: grid; place-items: center; font-size: 9.5px; font-style: normal; font-weight: 800; background: var(--p); color: var(--pf); border: 2px solid var(--bg); }
.row.unread .avatar::after { content: ""; position: absolute; left: -2px; top: -2px; width: 11px; height: 11px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg); }
.body { flex: 1; min-width: 0; }
.line1 { display: flex; align-items: center; gap: 6px; }
.line1 b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.line1 time { margin-left: auto; color: var(--muted); font-size: 13px; flex: none; }
.badge { flex: none; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 6px; background: var(--panel2); color: var(--muted); }
.badge.critical { background: color-mix(in srgb, var(--crit) 22%, transparent); color: #ff8a8c; }
.badge.important { background: color-mix(in srgb, var(--imp) 20%, transparent); color: #ffc65c; }
.line2 { color: #b8bfcd; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 2px; word-break: break-word; }
.line3 { color: var(--muted); font-size: 12.5px; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.line3 .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; }
.row.unread .line1 b { font-weight: 800; color: #fff; }
.row.unread .line2 { color: var(--text); }
.empty { padding: 56px 24px; text-align: center; color: var(--muted); }
.empty big { display: block; font-size: 30px; margin-bottom: 8px; }
.more { display: block; margin: 16px auto; padding: 10px 18px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; }

.detail { padding: 16px 16px 60px; }
.who { display: flex; gap: 12px; align-items: center; }
.who b { font-size: 17px; }
.tierbox { display: flex; gap: 8px; align-items: center; margin: 16px 0 12px; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--t) 14%, var(--panel)); border: 1px solid color-mix(in srgb, var(--t) 40%, transparent); flex-wrap: wrap; }
.tdot { width: 10px; height: 10px; border-radius: 50%; background: var(--t); flex: none; }
.ctx { white-space: pre-wrap; color: var(--muted); border-left: 3px solid var(--line); padding: 4px 10px; margin: 10px 0; font-size: 14px; word-break: break-word; }
.msg { white-space: pre-wrap; font-size: 17px; line-height: 1.5; margin: 12px 0 16px; word-break: break-word; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 16px; border-radius: 12px; border: 0; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: var(--panel2); color: var(--text); border: 1px solid var(--line); }
.btn.sm { padding: 7px 12px; font-size: 14px; border-radius: 10px; }
.btn.danger { color: #ff8a8c; }
.btn.wide { width: 100%; margin-top: 14px; }
.btn svg { width: 18px; height: 18px; }
.row2 { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.row2 .btn { flex: 1; }
.composer { display: flex; flex-direction: column; gap: 8px; margin: 16px 0; }
.composer .btn { align-self: flex-end; min-width: 110px; }
.sent { background: color-mix(in srgb, var(--accent) 18%, var(--panel)); border-radius: 14px 14px 4px 14px; padding: 10px 12px; margin: 8px 0 8px 40px; }
.sent div { white-space: pre-wrap; word-break: break-word; }
.sent small { color: var(--muted); }
.sent.bad { background: color-mix(in srgb, var(--crit) 14%, var(--panel)); }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 24px 0 8px; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.seg2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.segb { padding: 9px 2px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-size: 13px; font-weight: 600; }
.segb.on { background: color-mix(in srgb, var(--t) 24%, var(--panel)); border-color: var(--t); }

.settings, .compose { padding: 12px 16px 60px; display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.card h2 { font-size: 17px; margin: 0 0 6px; }
.compose .card h2 { font-size: 15px; margin-bottom: 10px; }
.sh { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.sh h2 { margin: 0; }
label { display: block; margin: 14px 0 0; font-size: 14px; font-weight: 600; }
label input, label select, label textarea { margin-top: 6px; font-weight: 400; }
label small { font-weight: 400; color: var(--muted); }
label > small:last-child { display: block; margin-top: 5px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: #ff8a8c; background: color-mix(in srgb, var(--crit) 10%, transparent); padding: 8px 10px; border-radius: 8px; margin-top: 8px; word-break: break-word; font-size: 13px; white-space: pre-wrap; }
.warn { background: color-mix(in srgb, var(--imp) 14%, transparent); border: 1px solid color-mix(in srgb, var(--imp) 40%, transparent); padding: 10px 12px; border-radius: 10px; margin: 12px 0; }
#c_warn .warn, #c_warn .err { margin: 0 0 8px; }
#c_warn:empty { display: none; }
.acct { border-top: 1px solid var(--line); padding: 14px 0 4px; }
.acct:first-of-type { border-top: 0; }
.acct-h { display: flex; gap: 10px; align-items: center; }
.grow { flex: 1; min-width: 0; }
.acct-f { display: grid; grid-template-columns: 1fr 1fr; gap: 0 8px; }
.acct-f .tgl, .acct-f .span2 { grid-column: 1 / -1; }
.acct-f .tgl { margin-top: 10px; }
.pbadge { flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; font-size: 12px; }
.status { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: color-mix(in srgb, var(--ok) 18%, transparent); color: #6ee7a0; flex: none; }
.status.err { background: color-mix(in srgb, var(--crit) 18%, transparent); color: #ff8a8c; margin: 0; padding: 3px 8px; }
.status.off { background: var(--panel2); color: var(--muted); }
.brandrow { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.copy { display: block; width: 100%; text-align: left; font: 13px ui-monospace, Menlo, monospace; padding: 9px 10px; border-radius: 8px; background: var(--bg); border: 1px dashed var(--line); cursor: pointer; word-break: break-all; margin: 6px 0; color: var(--text); }
.kv > span { display: block; font-size: 13px; color: var(--muted); margin-top: 10px; }
.steps { padding-left: 20px; margin: 0 0 4px; color: #c9cfdc; }
.steps li { margin: 7px 0; }
details { margin-top: 16px; }
summary { cursor: pointer; color: var(--muted); }
.pgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 16px; }
.pcard { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); text-decoration: none; }
.pcard small { color: var(--muted); }

/* Posts queue */
.day { padding: 16px 16px 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; }
.pcard2 { display: flex; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--line); text-decoration: none; }
.pcard2:active { background: var(--panel); }
.thumb { width: 58px; height: 58px; border-radius: 10px; object-fit: cover; flex: none; background: var(--panel2); }
.pmeta { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }
.pst { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 6px; background: var(--panel2); color: var(--muted); }
.pst.scheduled, .pst.posting { background: color-mix(in srgb, var(--accent) 22%, transparent); color: #c4b5ff; }
.pst.done { background: color-mix(in srgb, var(--ok) 16%, transparent); color: #6ee7a0; }
.pst.failed, .pst.partial { background: color-mix(in srgb, var(--crit) 16%, transparent); color: #ff8a8c; }
.ptext { margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; word-break: break-word; }
.tchips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tchip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 2px 8px 2px 3px; border-radius: 999px; background: var(--panel2); color: #c9cfdc; }
.tchip.sent b { color: #6ee7a0; }
.tchip.failed b { color: #ff8a8c; }
.pg { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 3px; border-radius: 6px; font-style: normal; font-size: 9.5px; font-weight: 800; flex: none; }

/* Composer */
.tgroup + .tgroup { margin-top: 14px; }
.tg-h { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; color: var(--muted); }
.tg-h i { width: 8px; height: 8px; border-radius: 50%; }
.tg-h button { margin-left: auto; background: none; border: 0; color: #a995ff; font-size: 13px; cursor: pointer; font-weight: 600; padding: 2px 4px; }
.tsel { display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px 6px 6px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel2); cursor: pointer; font-size: 14px; }
.tsel.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 26%, var(--panel)); }
.tsel:disabled { opacity: .55; cursor: default; }
.tsel small { color: var(--muted); font-size: 11px; }
.counter { font-size: 12px; color: var(--muted); text-align: right; margin-top: 4px; }
.counter.over { color: #ff8a8c; font-weight: 700; }
.airow { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.airow .btn[hidden] { display: none; }
.photoarea { margin-top: 12px; }
.photo { position: relative; display: inline-block; max-width: 100%; }
.photo img { max-width: 100%; max-height: 300px; border-radius: 12px; display: block; }
.photo .ib { position: absolute; top: 6px; right: 6px; background: rgba(0, 0, 0, .6); }
.addphoto { margin: 0; font-weight: 600; }
.addphoto input { display: none; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.result { display: flex; gap: 10px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--line); }
.result:first-of-type { border-top: 0; }
.result .pg { margin-top: 2px; }
.result a { display: inline-block; margin-top: 4px; color: #a995ff; }

.center { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login { width: 100%; max-width: 360px; text-align: center; }
.logo { width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 14px; background: url(/icon-192.png) center / cover; }
.login form { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.setup { max-width: 480px; }
.setup li { margin: 10px 0; }
code { font: 13px ui-monospace, Menlo, monospace; background: var(--panel2); padding: 1px 5px; border-radius: 5px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: #232a3d; color: var(--text); padding: 10px 16px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .45); transition: .2s; max-width: calc(100% - 32px); z-index: 20; font-size: 14px; white-space: pre-wrap; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: #4a1d22; }
