/* Keyward app (Operate mode). Builds on site.css tokens. */
.app-body { background: var(--paper); }
.muted { color: var(--text-muted); }
.small { font-size: .9rem; }
.nowrap { white-space: nowrap; }
.app-loading { min-height: 100vh; display: grid; place-items: center; color: var(--text-muted); }
[hidden] { display: none !important; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a3202e; text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.link-btn { background: none; border: 0; padding: 8px 4px; font: 600 .92rem var(--font-body); color: var(--cord-text); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; min-height: 44px; display: inline-flex; align-items: center; }
.link-btn.danger { color: var(--danger); }
.pill-live { background: var(--cord-wash); color: var(--cord-text); }
.pill-paused { background: var(--paper); color: var(--text-muted); border: 1px solid var(--line); }
.pill-fail { background: var(--danger-wash); color: var(--danger); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.input.mono { font-family: var(--font-mono); text-transform: uppercase; letter-spacing: .04em; }

/* ---------- Sign in ---------- */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 40px var(--gutter); background: var(--ink); }
.signin-card { width: 100%; max-width: 30rem; background: var(--surface); border-radius: var(--r-lg); padding: clamp(24px, 5vw, 40px); box-shadow: var(--lift); display: grid; gap: 16px; }
.brand-dark { color: var(--ink); }
.signin-card h1 { font-size: clamp(1.6rem, 4vw, 2rem); line-height: 1.12; letter-spacing: -0.025em; }
.signin-options, .connect-row { display: grid; gap: 10px; }
.connect-row { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-top: 8px; }
.connect-opt { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); color: var(--ink); text-decoration: none; min-height: 64px; transition: border-color .18s, box-shadow .18s; }
.connect-opt:hover { border-color: var(--ink); text-decoration: none; }
.connect-opt.suggested { border-color: var(--patch); box-shadow: 0 0 0 3px rgba(255,106,61,.2); }
.connect-opt b { display: block; font-weight: 600; }
.connect-opt small { display: block; color: var(--text-muted); font-size: .85rem; margin-top: 2px; }
.connect-ico { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; flex: none; color: #fff; }
.connect-ico.ig { background: var(--ink); }
.connect-ico.fb { background: #1877f2; }
.connect-opt[aria-disabled="true"] { opacity: .6; }
.perm-details { border-top: 1px solid var(--line); padding-top: 12px; font-size: .92rem; }
.perm-details summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.perm-details summary::after { content: "+"; margin-left: auto; font: 500 1.2rem/1 var(--font-mono); color: var(--text-muted); }
.perm-details[open] summary::after { content: "\2212"; }
.perm-details ul { padding-left: 1.2em; margin: 8px 0; display: grid; gap: 6px; color: var(--text-muted); }
.perm-details p { color: var(--text-muted); }
.fine-print { font-size: .82rem; color: var(--text-muted); }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--ink); color: var(--on-ink); padding: 22px 16px; display: flex; flex-direction: column; gap: 28px; position: sticky; top: 0; height: 100vh; }
.sidebar .brand { padding: 0 8px; }
.side-nav { display: grid; gap: 2px; }
.side-nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; color: var(--on-ink-muted); text-decoration: none; font-weight: 500; min-height: 44px; }
.side-nav a:hover { background: var(--ink-raised); color: var(--on-ink); }
.side-nav a[aria-current="page"] { background: var(--ink-raised); color: var(--on-ink); box-shadow: inset 3px 0 0 var(--cord); }
.side-foot { margin-top: auto; display: grid; gap: 14px; font-size: .88rem; }
.meter { background: var(--ink-raised); border: 1px solid var(--ink-line); border-radius: var(--r-md); padding: 12px; }
.meter-label { display: flex; justify-content: space-between; color: var(--on-ink-muted); margin-bottom: 8px; }
.meter-label span:first-child { color: var(--on-ink); font-weight: 600; }
.meter-bar { height: 6px; background: var(--ink-line); border-radius: 999px; overflow: hidden; }
.meter-fill { display: block; height: 100%; background: var(--cord); border-radius: 999px; }
.who { display: flex; align-items: center; gap: 10px; color: var(--on-ink); min-width: 0; }
.who span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar .link-btn { color: var(--on-ink-muted); padding-left: 0; }
.topbar, .tabbar { display: none; }

.view { padding: clamp(24px, 4vw, 48px); max-width: 1040px; width: 100%; outline: none; display: grid; gap: 22px; align-content: start; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: clamp(1.7rem, 3vw, 2.2rem); letter-spacing: -0.025em; line-height: 1.1; }
.page-head p { margin-top: 6px; max-width: 40rem; }

.avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex: none; background: var(--line); }
.avatar-blank { display: inline-grid; place-items: center; font-weight: 700; color: var(--ink); background: var(--cord-wash); font-size: .85rem; }
.who .avatar { width: 28px; height: 28px; }

/* ---------- Campaigns ---------- */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px 18px; }
.stat b { display: block; font: 700 1.6rem/1.1 var(--font-display); letter-spacing: -0.02em; }
.stat span { display: block; margin-top: 4px; color: var(--text-muted); font-size: .88rem; line-height: 1.4; }
.camp-list { display: grid; gap: 12px; }
.camp { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 16px; align-items: start; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px; }
.camp.is-live { border-left: 3px solid var(--cord); }
.camp-post img, .camp-post .all-posts { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; display: grid; place-items: center; }
.all-posts { background: var(--ink); color: var(--on-ink); font-weight: 700; font-size: .85rem; }
.camp-main { display: grid; gap: 8px; min-width: 0; }
.camp-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.camp-title h2 { font-size: 1.2rem; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.camp-actions { display: flex; align-items: center; gap: 6px; }
.switch { position: relative; width: 48px; height: 28px; border-radius: 999px; border: 0; background: #c9cfdf; cursor: pointer; padding: 0; margin-right: 6px; transition: background-color .2s; flex: none; }
.switch[aria-checked="true"] { background: var(--cord); }
.switch-knob { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(15,19,48,.3); transition: transform .2s var(--ease-out); }
.switch[aria-checked="true"] .switch-knob { transform: translateX(20px); }
.switch:disabled { opacity: .6; }
.empty { background: var(--surface); border: 1px dashed #c9cfdf; border-radius: var(--r-lg); padding: clamp(28px, 5vw, 48px); text-align: center; display: grid; gap: 10px; justify-items: center; }
.empty h2 { font-size: 1.35rem; }
.empty p { color: var(--text-muted); max-width: 30rem; }

/* ---------- Setup + wizard ---------- */
.setup, .wiz-sec, .set-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: clamp(20px, 3vw, 28px); display: grid; gap: 12px; }
.setup h2, .wiz-sec h2, .set-card h2 { font-size: 1.2rem; letter-spacing: -0.01em; }
.stepper { list-style: none; margin: 0; padding: 0; display: flex; gap: 8px; flex-wrap: wrap; font-size: .9rem; font-weight: 600; color: var(--text-muted); }
.stepper li { display: flex; align-items: center; gap: 8px; }
.stepper li + li::before { content: ""; width: 28px; height: 2px; background: var(--line); margin-right: 2px; }
.stepper span { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--line); font-size: .8rem; background: var(--surface); }
.stepper .current { color: var(--ink); }
.stepper .current span { border-color: var(--patch); background: var(--patch); color: var(--ink); }
.stepper .done span { border-color: var(--cord); background: var(--cord); color: #fff; }
.wiz { display: grid; gap: 16px; }
.pick-accounts { border: 0; padding: 0; margin: 0; display: grid; gap: 10px; }
.pick-accounts legend { font: 700 1.2rem var(--font-display); margin-bottom: 10px; }
.pick { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 16px; cursor: pointer; min-height: 64px; }
.pick:has(input:checked) { border-color: var(--cord); box-shadow: 0 0 0 3px rgba(61,90,254,.18); }
.pick input { width: 20px; height: 20px; accent-color: var(--cord); }
.pick b { display: block; } .pick small { color: var(--text-muted); }
.more-connect summary { cursor: pointer; font-weight: 600; color: var(--cord-text); min-height: 44px; display: flex; align-items: center; }
.wiz-nav { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.wiz-go { display: flex; gap: 10px; flex-wrap: wrap; }
.field-row { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; }
.field .count { display: block; text-align: right; font-size: .8rem; color: var(--text-muted); margin-top: 4px; }
.field textarea { min-height: 96px; }
.wiz-sec .chips { margin-top: 8px; }
.check { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--cord); flex: none; }
.check b { display: block; } .check small { color: var(--text-muted); font-size: .9rem; }
.posts { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.post-opt { display: grid; gap: 6px; padding: 6px; border: 2px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; text-align: left; font: 400 .8rem/1.3 var(--font-body); color: var(--ink); }
.post-opt img, .post-opt .all-posts { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: grid; place-items: center; }
.post-opt[aria-checked="true"] { border-color: var(--cord); box-shadow: 0 0 0 3px rgba(61,90,254,.18); }
.post-cap { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.6em; }
.review { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.summary { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 12px 16px; }
.summary dt { font-weight: 600; color: var(--text-muted); font-size: .9rem; }
.summary dd { margin: 0; overflow-wrap: anywhere; }
.phone { background: var(--ink); border-radius: 22px; padding: 16px; display: grid; gap: 8px; color: var(--on-ink); }
.phone-top { display: flex; align-items: center; gap: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--ink-line); font-size: .9rem; }
.phone .bubble { background: var(--ink-raised); color: var(--on-ink); white-space: pre-wrap; overflow-wrap: anywhere; }
.phone .bubble-btn { background: var(--on-ink); color: var(--ink); margin-top: 0; }
.phone-note { font-size: .78rem; color: var(--on-ink-muted); margin-top: 4px; }

/* ---------- Log ---------- */
.log { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); font-size: .92rem; }
.log th, .log td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.log thead th { background: var(--paper); font-weight: 600; font-size: .85rem; color: var(--text-muted); }
.log td small { display: block; color: var(--text-muted); font-size: .8rem; margin-top: 2px; }
.log .clip { display: inline; overflow-wrap: anywhere; }
.log .err-text { color: var(--danger); max-width: 18rem; }
.more-row { display: flex; justify-content: center; }

/* ---------- Accounts + settings ---------- */
.acct-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.acct { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px 18px; }
.acct .avatar { width: 44px; height: 44px; }
.acct-main { flex: 1 1 180px; min-width: 0; }
.acct-main b { display: block; overflow-wrap: anywhere; }
.acct-main small { color: var(--text-muted); }
.acct-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.danger-zone { border-color: #f3c3c9; }
.danger-zone .btn { justify-self: start; }

/* ---------- Confirm dialog ---------- */
.confirm { border: 0; border-radius: var(--r-lg); padding: 0; max-width: min(28rem, calc(100vw - 32px)); box-shadow: var(--lift); color: var(--ink); }
.confirm::backdrop { background: rgba(15,19,48,.55); }
.confirm form { padding: 24px; display: grid; gap: 14px; }
.confirm h2 { font-size: 1.3rem; letter-spacing: -0.015em; }
.confirm p { color: var(--text-muted); }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

/* ---------- Phones ---------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; padding-bottom: 72px; }
  .sidebar { display: none; }
  .topbar { display: flex; justify-content: space-between; align-items: center; background: var(--ink); color: var(--on-ink); padding: 10px var(--gutter); position: sticky; top: 0; z-index: 10; }
  .topbar .link-btn { color: var(--on-ink-muted); }
  .tabbar { display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  .tabbar a { display: grid; place-items: center; min-height: 60px; font-size: .82rem; font-weight: 600; color: var(--text-muted); text-decoration: none; }
  .tabbar a[aria-current="page"] { color: var(--ink); box-shadow: inset 0 3px 0 var(--cord); }
  .view { padding: 20px var(--gutter) 32px; }
  .review { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .stats .stat:last-child { grid-column: span 2; }
  .camp { grid-template-columns: 48px minmax(0, 1fr); }
  .camp-post img, .camp-post .all-posts { width: 48px; height: 48px; }
  .camp-actions { grid-column: 1 / -1; border-top: 1px solid var(--line); padding-top: 10px; }
  .field-row { grid-template-columns: 1fr; }
  .summary { grid-template-columns: 1fr; gap: 4px; }
  .summary dd { margin-bottom: 10px; }
  .wiz-nav .btn, .wiz-go { width: 100%; }
  .wiz-go .btn { flex: 1 1 100%; }
}
.posts-note { grid-column: 1 / -1; margin: 0; }
