:root {
  --bg: #f4f3f0; --card: #fff; --ink: #15151a; --muted: #6c6c75; --line: #e4e2dd; --soft: #f0eee9;
  --accent: #ff3d7f; --accent2: #ffb547; --ok: #12a150; --bad: #d93a3a; --bubble: #efefef;
  --grad: linear-gradient(135deg, #ff3d7f, #ff7a45 60%, #ffb547);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0d0d11; --card: #17171d; --ink: #f2f2f5; --muted: #9a9aa6; --line: #2a2a33; --soft: #1f1f27; --bubble: #26262f; color-scheme: dark; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 'Inter Tight', system-ui, sans-serif; }
body.noscroll { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { width: 100%; background: var(--soft); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 0; }
label input, label select { margin-top: 4px; color: var(--ink); }
code { font: 500 12.5px 'JetBrains Mono', monospace; word-break: break-all; }
h1, h2 { margin: 0 0 6px; letter-spacing: -.02em; }
h2 { font-size: 20px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .tiny { font-size: 12px; } .err { color: var(--bad); }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 19px; letter-spacing: -.03em; }
.logo { width: 26px; height: 26px; border-radius: 8px; background: var(--grad); position: relative; }
.logo::after { content: ''; position: absolute; inset: 7px 6px 8px; border: 2.2px solid #fff; border-radius: 4px 4px 4px 1px; }
.top-right { display: flex; align-items: center; gap: 8px; }
.acct { width: auto; padding: 6px 10px; font-weight: 600; }

.tabs { display: flex; gap: 4px; padding: 0 16px 10px; overflow-x: auto; position: sticky; top: 54px; z-index: 4; background: var(--bg); }
.tab { border: 0; background: none; padding: 7px 13px; border-radius: 99px; color: var(--muted); font-weight: 600; cursor: pointer; white-space: nowrap; }
.tab.active { background: var(--ink); color: var(--bg); }

main { max-width: 760px; margin: 0 auto; padding: 6px 16px 80px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin-bottom: 14px; }
.eyebrow { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 8px; }
.row { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.row.end { justify-content: flex-end; }
.row > input { flex: 1; }
.grow { flex: 1; }

.btn { border: 0; border-radius: 10px; padding: 9px 15px; font-weight: 650; cursor: pointer; background: var(--soft); white-space: nowrap; }
.btn.accent { background: var(--grad); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.danger { color: var(--bad); }
.btn.wide { width: 100%; margin-top: 14px; }
.btn.small { padding: 6px 11px; font-size: 13px; }
.btn.tiny { padding: 3px 8px; font-size: 12px; border-radius: 7px; }
.btn:active { transform: scale(.98); }
.icon-btn { border: 0; background: none; font-size: 20px; line-height: 1; padding: 4px 8px; cursor: pointer; color: var(--muted); }

.gate { text-align: center; padding: 40px 20px; margin-top: 30px; }
.gate h1 { font-size: 34px; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

.prompt-card textarea { font-size: 16px; border: 0; background: transparent; padding: 0; min-height: 70px; }
.prompt-card .row { justify-content: flex-end; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 2px; scrollbar-width: none; }
.chip { flex: 0 0 auto; max-width: 260px; border: 1px solid var(--line); background: var(--soft); border-radius: 99px; padding: 5px 11px;
  font-size: 12.5px; color: var(--muted); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

ol { list-style: none; margin: 0; padding: 0; }
.prompt { background: var(--card); border: 1px dashed var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; }
.prompt.working { border-color: var(--accent); } .prompt.failed { border-color: var(--bad); }
.p-status { font-size: 12px; font-weight: 700; color: var(--muted); }
.prompt.working .p-status { color: var(--accent); animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.p-text { margin: 3px 0; font-size: 14px; }
.p-reply { font-size: 13.5px; background: var(--soft); border-radius: 10px; padding: 8px 10px; margin-top: 6px; }

.auto { display: flex; align-items: center; gap: 12px; cursor: pointer; padding: 14px 16px; }
.auto:not(.on) { opacity: .72; }
.a-main { flex: 1; min-width: 0; }
.a-type { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--soft); color: var(--muted); }
.auto.on .a-type { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.a-name { font-weight: 700; font-size: 16px; margin: 4px 0 1px; }
.a-sum { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.a-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

.switch { position: relative; display: inline-block; width: 44px; height: 26px; flex: 0 0 auto; margin: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 99px; transition: .2s; cursor: pointer; }
.switch span::after { content: ''; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px #0003; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(18px); }

/* editor sheet */
.sheet { position: fixed; inset: 0; z-index: 20; background: color-mix(in srgb, #000 40%, transparent); overflow-y: auto; }
.sheet-inner { max-width: 760px; margin: 0 auto; min-height: 100%; background: var(--bg); padding: 0 16px 100px; }
.sheet-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px; padding: 12px 0; background: var(--bg); }
.title-input { font-size: 19px; font-weight: 750; border: 0; background: transparent; padding: 4px 2px; }
.sec { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin-bottom: 12px; }
.seg { display: flex; gap: 4px; background: var(--soft); border-radius: 11px; padding: 3px; flex-wrap: wrap; margin-bottom: 10px; }
.seg button { flex: 1; border: 0; background: none; padding: 7px 8px; border-radius: 8px; font-weight: 600; font-size: 13.5px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.seg.small button { font-size: 12.5px; padding: 5px 6px; }
.seg button.active { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px #0002; }
.kw { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; background: var(--soft); border: 1px solid var(--line); border-radius: 10px; padding: 6px; margin-bottom: 10px; }
.kw-chips { display: contents; }
.kw input { flex: 1; min-width: 140px; border: 0; padding: 4px; background: transparent; }
.kwc { display: inline-flex; align-items: center; gap: 2px; background: var(--ink); color: var(--bg); border-radius: 99px; padding: 3px 4px 3px 10px; font-size: 13px; font-weight: 600; }
.kwc button { border: 0; background: none; color: inherit; cursor: pointer; padding: 0 5px; }
.posts { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; }
.post { position: relative; aspect-ratio: 9/12; border: 2px solid transparent; border-radius: 10px; overflow: hidden; padding: 0; background: var(--soft); cursor: pointer; }
.post img { width: 100%; height: 100%; object-fit: cover; display: block; }
.post.sel { border-color: var(--accent); }
.post.sel::after { content: '✓'; position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 12px; display: grid; place-items: center; }
.ptype { position: absolute; left: 4px; bottom: 4px; font-size: 10px; font-weight: 700; background: #000a; color: #fff; padding: 1px 6px; border-radius: 99px; }
.noimg { font-size: 11px; color: var(--muted); }
#ePub .row { margin: 0 0 6px; }
.step { border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 10px; background: var(--soft); }
.step > * + * { margin-top: 7px; }
.step input, .step textarea, .step select { background: var(--card); }
.step-head { display: flex; align-items: center; gap: 8px; }
.step-head .icon-btn { margin-left: auto; }
.sid { font: 500 12px 'JetBrains Mono', monospace; color: var(--accent); }
.btn-row { display: grid; grid-template-columns: 1fr 120px 1.3fr auto; gap: 6px; margin-bottom: 6px; }
.step-opts { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.step-opts label { margin: 0; display: flex; align-items: center; gap: 6px; }
.step-opts select { width: auto; margin: 0; padding: 4px 8px; }
.check { display: flex !important; align-items: center; gap: 7px; color: var(--ink) !important; margin-top: 10px; }
.check input { width: auto; }
.sheet-foot { position: sticky; bottom: 0; display: flex; gap: 8px; padding: 12px 0; background: var(--bg); border-top: 1px solid var(--line); }

/* try-it bubbles */
#tOut { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; align-items: flex-start; }
.bubble { max-width: 300px; background: var(--bubble); border-radius: 18px; padding: 9px 13px; font-size: 14px; }
.bubble.pub { background: transparent; border: 1px solid var(--line); border-radius: 12px; }
.bubble.sys { background: none; color: var(--muted); font-size: 13px; padding: 2px 0; }
.bubble.img { padding: 0; overflow: hidden; } .bubble.img img { width: 220px; display: block; }
.bbtn { margin: 8px -13px -9px; border-top: 1px solid var(--line); padding: 8px; text-align: center; font-weight: 650; color: #3b82f6; }
.bbtn + .bbtn { margin-top: 9px; }
.qr { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 8px; }
.qr span { border: 1px solid #3b82f6; color: #3b82f6; border-radius: 99px; padding: 2px 10px; font-size: 13px; }

/* feeds */
.list-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 6px 0 12px; }
.search { max-width: 220px; }
.ev { display: flex; gap: 11px; padding: 11px 2px; border-bottom: 1px solid var(--line); }
.ev-ic { flex: 0 0 34px; height: 34px; border-radius: 50%; background: var(--soft); display: grid; place-items: center; font-size: 15px; font-weight: 700; }
.ev.bad .ev-ic { background: color-mix(in srgb, var(--bad) 15%, transparent); }
.ev-body { min-width: 0; font-size: 14px; }
.pill { font-size: 11px; font-weight: 700; color: var(--ok); background: color-mix(in srgb, var(--ok) 13%, transparent); border-radius: 99px; padding: 1px 8px; }

.kv { display: flex; gap: 10px; align-items: baseline; padding: 7px 0; border-bottom: 1px solid var(--line); }
.kv span { flex: 0 0 100px; font-size: 13px; color: var(--muted); }
.out { background: var(--soft); border-radius: 10px; padding: 10px; font-size: 13px; white-space: pre-wrap; }
.hl { padding: 4px 0; font-size: 14px; } .hl.ok { color: var(--ok); } .hl.no { color: var(--bad); }
.acct-list li { display: flex; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.acct-list .btn { margin-left: auto; }
details { margin-top: 12px; } summary { cursor: pointer; font-weight: 600; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 14px; max-width: calc(100% - 32px); box-shadow: 0 6px 24px #0004; }
[hidden] { display: none !important; }

@media (max-width: 560px) {
  .btn-row { grid-template-columns: 1fr 1fr; }
  .btn-row > :nth-child(3) { grid-column: 1; }
  .seg button { flex: 1 1 45%; }
}

.a-type.reel { margin-left: 4px; background: color-mix(in srgb, var(--accent2) 18%, transparent); color: var(--ink); }
