:root {
  --bg: #f4f1ea;
  --paper: #fffdf8;
  --ink: #1d2422;
  --muted: #6b726f;
  --line: #e3ddd0;
  --teal: #0f3d3a;
  --teal-2: #1f6b63;
  --accent: #e0783a;
  --red: #c2362b;
  --red-bg: #fbe9e6;
  --green: #2f7a48;
  --green-bg: #e7f3ea;
  --blue: #2a5d9f;
  --blue-bg: #e8eff9;
  --amber: #9a6a12;
  --amber-bg: #fbf1dc;
  --grey-bg: #eeece6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 30, 28, .06), 0 4px 14px rgba(20, 30, 28, .05);
  --fb: #1877f2; --ig: #c13584; --th: #111; --li: #0a66c2; --xx: #111;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: "Hind Siliguri", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.tiny { font-size: 13px; }
.center { text-align: center; }
code { background: var(--grey-bg); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
h2 { font-family: Fraunces, Georgia, serif; font-weight: 600; font-size: 22px; margin: 22px 0 12px; letter-spacing: -.01em; }

/* brand + top bar */
.brand { font-family: Fraunces, Georgia, serif; font-weight: 600; font-size: 19px; display: flex; align-items: center; gap: 8px; letter-spacing: -.01em; }
.brand.big { font-size: 28px; justify-content: center; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(224, 120, 58, .18); }
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--teal); color: #f6f1e7;
}
.topbar .brand { flex: 1; }
.topbar .btn.ghost { color: #f6f1e7; border-color: rgba(255,255,255,.25); }
main { max-width: 720px; margin: 0 auto; padding: 12px 14px calc(96px + env(safe-area-inset-bottom)); }

/* buttons + inputs */
.btn {
  font: inherit; font-weight: 600; border-radius: 11px; border: 1px solid transparent; padding: 10px 16px;
  cursor: pointer; transition: transform .05s, background .15s, opacity .15s; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--teal); color: #fff; }
.btn.primary:hover { background: var(--teal-2); }
.btn.accent { background: var(--accent); color: #fff; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.danger { background: transparent; border-color: #f0c9c3; color: var(--red); }
.btn.small { padding: 6px 12px; font-size: 14px; border-radius: 9px; }
.btn.wide { width: 100%; margin-top: 10px; }
input, textarea, select {
  font: inherit; width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px;
  background: var(--paper); color: var(--ink); outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--teal-2); box-shadow: 0 0 0 3px rgba(31,107,99,.12); }
textarea { resize: vertical; min-height: 44px; }
.field { display: block; margin: 14px 0; }
.field > span { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.row-2 { display: grid; grid-template-columns: 1fr; gap: 0 14px; }
@media (min-width: 640px) { .row-2 { grid-template-columns: 1fr 1fr; } }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 30% 20%, #1f6b63 0, var(--teal) 60%); }
.login-card { width: 100%; max-width: 360px; background: var(--paper); border-radius: 20px; padding: 28px 22px; box-shadow: 0 20px 60px rgba(0,0,0,.25); text-align: center; }
.login-card input { margin-top: 14px; }
.error-text { color: var(--red); min-height: 1.2em; font-size: 14px; }

/* filters */
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.chip {
  font: inherit; font-size: 14px; white-space: nowrap; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink); cursor: pointer;
}
.chip.active { background: var(--teal); color: #fff; border-color: var(--teal); }
.chip b:empty { display: none; }
.chip b { font-weight: 700; margin-left: 2px; }
#platformFilter { width: auto; padding: 6px 10px; font-size: 14px; border-radius: 999px; }
#syncInfo { margin: 8px 2px 4px; }

/* comment cards */
.list { display: flex; flex-direction: column; gap: 12px; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.card.urgent { border-color: #e6a59c; box-shadow: 0 0 0 3px var(--red-bg), var(--shadow); }
.card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.card-head .who { font-weight: 600; }
.card-head .when { color: var(--muted); margin-left: auto; font-size: 13px; }
.pf { font-size: 12px; font-weight: 700; color: #fff; padding: 2px 8px; border-radius: 6px; letter-spacing: .02em; }
.pf.facebook { background: var(--fb); } .pf.instagram { background: var(--ig); } .pf.threads { background: var(--th); }
.pf.linkedin { background: var(--li); } .pf.pinterest { background: #e60023; } .pf.youtube { background: #ff0000; } .pf.x { background: var(--xx); }
.badge { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--grey-bg); color: var(--muted); }
.badge.urgent { background: var(--red); color: #fff; }
.badge.question { background: var(--blue-bg); color: var(--blue); }
.badge.praise { background: var(--green-bg); color: var(--green); }
.badge.complaint { background: var(--amber-bg); color: var(--amber); }
.badge.demo { background: var(--accent); color: #fff; }
.on-post { font-size: 13px; color: var(--muted); margin: 8px 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.comment-text { font-size: 17px; margin: 4px 0 10px; white-space: pre-wrap; word-break: break-word; }
.note { font-size: 13px; background: var(--amber-bg); color: #6d4b0c; border-radius: 8px; padding: 6px 10px; margin-bottom: 10px; }
.card.urgent .note { background: var(--red-bg); color: #8a2219; }
.err { font-size: 13px; background: var(--red-bg); color: #8a2219; border-radius: 8px; padding: 6px 10px; margin-bottom: 10px; }
.draft { border-left: 3px solid var(--teal-2); }
.sent-reply { font-size: 15px; background: var(--green-bg); border-radius: 10px; padding: 8px 12px; white-space: pre-wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; align-items: center; }
.actions .send { flex: 1; min-width: 120px; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.quick .chip { font-size: 13px; padding: 4px 10px; }
.rewrite-row { display: flex; gap: 6px; margin-top: 8px; }
.rewrite-row input { padding: 7px 10px; font-size: 14px; }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .big { font-size: 40px; display: block; margin-bottom: 6px; }
.link { color: var(--teal-2); font-size: 14px; text-decoration: none; font-weight: 600; }

/* compose */
.image-pick { display: flex; gap: 8px; align-items: center; }
.file-btn { white-space: nowrap; }
.image-preview { position: relative; margin-top: 8px; display: inline-block; }
.image-preview img { max-width: 160px; max-height: 160px; border-radius: 10px; display: block; border: 1px solid var(--line); }
.x-btn { position: absolute; top: -8px; right: -8px; width: 26px; height: 26px; border-radius: 50%; border: none; background: var(--ink); color: #fff; cursor: pointer; }
.picks { display: flex; gap: 8px; flex-wrap: wrap; }
.pick { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; background: var(--paper); cursor: pointer; font-size: 15px; user-select: none; }
.pick input { width: auto; margin: 0; accent-color: var(--teal); }
.pick.off { opacity: .45; cursor: not-allowed; }
.versions { margin-top: 16px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); }
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 10px; }
.tab { font: inherit; font-size: 14px; border: 1px solid var(--line); background: var(--bg); border-radius: 9px; padding: 5px 12px; cursor: pointer; white-space: nowrap; }
.tab.active { background: var(--teal); color: #fff; border-color: var(--teal); }
.counter { font-size: 12px; color: var(--muted); text-align: right; margin-top: 4px; }
.counter.over { color: var(--red); font-weight: 700; }
.rewrite { display: flex; gap: 6px; margin-top: 10px; }
.seg { display: flex; gap: 6px; margin-bottom: 8px; }
.seg label { flex: 1; text-align: center; border: 1px solid var(--line); border-radius: 10px; padding: 8px 4px; cursor: pointer; background: var(--paper); font-size: 14px; }
.seg label:has(input:checked) { background: var(--teal); color: #fff; border-color: var(--teal); }
.seg input { display: none; }

/* posts list */
.post-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 13px; color: var(--muted); }
.post-text { margin: 8px 0; white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.results { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.res { font-size: 13px; padding: 3px 9px; border-radius: 7px; text-decoration: none; }
.res.ok { background: var(--green-bg); color: var(--green); }
.res.bad { background: var(--red-bg); color: var(--red); }
.res.wait { background: var(--grey-bg); color: var(--muted); }
.status { font-weight: 700; text-transform: capitalize; }
.status.published { color: var(--green); } .status.failed { color: var(--red); } .status.partial { color: var(--amber); } .status.scheduled { color: var(--blue); }
.thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; float: right; margin-left: 10px; border: 1px solid var(--line); }

/* accounts */
.accounts { display: flex; flex-direction: column; gap: 8px; }
.acct { display: flex; align-items: center; gap: 10px; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.acct .info { flex: 1; font-size: 14px; }
.acct .info small { display: block; color: var(--muted); }
.acct .info small.bad { color: var(--red); }
.state { font-size: 13px; font-weight: 600; }
.state.on { color: var(--green); } .state.off { color: var(--muted); }

/* tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; background: var(--paper);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1; font: inherit; font-size: 12px; background: none; border: none; padding: 8px 0 9px; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 1px; cursor: pointer; position: relative;
}
.tabbar .ico { font-size: 20px; line-height: 1.2; }
.tabbar button.active { color: var(--teal); font-weight: 700; }
.dotcount { position: absolute; top: 4px; left: 54%; background: var(--accent); color: #fff; font-size: 11px; border-radius: 999px; padding: 0 6px; min-width: 18px; }

.toast {
  position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: 90vw; box-shadow: var(--shadow);
}
.toast.bad { background: var(--red); }
.spinner { width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
.btn.ghost .spinner, .btn.danger .spinner { border-color: rgba(0,0,0,.15); border-top-color: var(--teal); }
@keyframes spin { to { transform: rotate(360deg); } }

/* automation switches */
.switch-row { display: flex; gap: 12px; align-items: flex-start; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 8px 0; cursor: pointer; }
.switch-row input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--teal); flex: none; }
.switch-row span { display: flex; flex-direction: column; font-size: 15px; }
.switch-row small { color: var(--muted); font-size: 13px; margin-top: 2px; word-break: break-word; }
.acct select { width: auto; font-size: 13px; padding: 4px 8px; margin-top: 4px; }
.acct .btn { white-space: nowrap; }

.keyline { display: flex; gap: 8px; }
.keyline input { flex: 1; min-width: 0; }
