:root {
  --board: #1e3b2f;
  --board-2: #28503f;
  --chalk: #f4ecd2;
  --marigold: #e9a23b;
  --bg: #f1f4f2;
  --surface: #ffffff;
  --ink: #16211c;
  --muted: #5d6a63;
  --line: #d9e1dc;
  --fb: #1877f2;
  --ig: #c13584;
  --ok: #2e7d4f;
  --bad: #b3261e;
  --warn: #9a6a12;
  --radius-s: 6px;
  --radius-m: 10px;
  --font: "Mukta", "Noto Sans Devanagari", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--board-2); }
:focus-visible { outline: 3px solid var(--marigold); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side {
  background: var(--board);
  color: var(--chalk);
  padding: 28px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; flex-direction: column; padding: 0 10px; }
.brand-mark { font-weight: 800; font-size: 26px; letter-spacing: -0.02em; line-height: 1; }
.brand-sub { font-size: 14px; opacity: .7; margin-top: 6px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  color: var(--chalk);
  text-decoration: none;
  padding: 9px 12px;
  border-radius: var(--radius-s);
  opacity: .78;
  font-weight: 500;
}
.nav a:hover { opacity: 1; background: rgba(255, 255, 255, .06); }
.nav a.on { opacity: 1; background: var(--board-2); box-shadow: inset 3px 0 0 var(--marigold); }
.logout { margin-top: auto; color: var(--chalk); opacity: .6; padding: 0 12px; font-size: 14px; }

.main { padding: 36px 44px 80px; max-width: 1200px; width: 100%; outline: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 28px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 34px; line-height: 1.1; letter-spacing: -0.02em; font-weight: 700; }
.page-head p { margin: 6px 0 0; color: var(--muted); max-width: 60ch; }

h2 { font-size: 20px; margin: 0 0 14px; font-weight: 700; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* ---------- Buttons & fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--surface);
  padding: 8px 16px; border-radius: var(--radius-s);
  font-weight: 600; cursor: pointer; text-decoration: none; color: var(--ink);
  min-height: 40px;
}
.btn:hover { border-color: #b9c6be; }
.btn.primary { background: var(--board); color: var(--chalk); border-color: var(--board); }
.btn.primary:hover { background: var(--board-2); }
.btn.fb { background: var(--fb); border-color: var(--fb); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: 14px; }
.btn[disabled] { opacity: .5; cursor: default; }

label { display: block; font-weight: 600; font-size: 15px; }
label .hint, .hint { display: block; font-weight: 400; color: var(--muted); font-size: 14px; margin-top: 2px; }
input[type=text], input[type=password], input[type=url], input[type=number], input[type=search], select, textarea {
  width: 100%; margin-top: 6px;
  border: 1px solid var(--line); border-radius: var(--radius-s);
  background: #fff; padding: 9px 12px; min-height: 42px;
}
textarea { resize: vertical; min-height: 90px; line-height: 1.45; }
input:focus, select:focus, textarea:focus { border-color: var(--board-2); outline: none; box-shadow: 0 0 0 3px rgba(233, 162, 59, .35); }
.field { margin-bottom: 18px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 40px; height: 22px; border-radius: 11px; background: #c5cfc9; position: relative; flex: none; transition: background .15s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + .track { background: var(--ok); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 3px solid var(--marigold); outline-offset: 2px; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-s); overflow: hidden; margin-top: 6px; background: #fff; }
.seg label { padding: 7px 14px; cursor: pointer; font-weight: 500; border-right: 1px solid var(--line); }
.seg label:last-child { border-right: 0; }
.seg input { position: absolute; opacity: 0; }
.seg label:has(input:checked) { background: var(--board); color: var(--chalk); }
.seg label:has(input:focus-visible) { outline: 3px solid var(--marigold); outline-offset: -3px; }

/* ---------- Chalk chips: the signature element ---------- */
.chip {
  display: inline-block;
  background: var(--board);
  color: var(--chalk);
  padding: 1px 10px 2px;
  border-radius: 4px;
  font-weight: 600;
  margin: 2px 2px;
  white-space: nowrap;
}
.chip.soft { background: #e6ece8; color: var(--board); }
.tag { display: inline-block; font-size: 13px; font-weight: 600; padding: 0 8px; border-radius: 4px; line-height: 22px; }
.tag.fb { background: #e7f0fe; color: #0b5bd3; }
.tag.ig { background: #fbe9f3; color: #9c2468; }
.tag.ok { background: #e3f1e8; color: var(--ok); }
.tag.bad { background: #fbe7e5; color: var(--bad); }
.tag.dim { background: #eceeed; color: var(--muted); }

/* ---------- Overview ---------- */
.today {
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m);
  margin-bottom: 28px;
}
.today > div { padding: 20px 24px; border-right: 1px solid var(--line); }
.today > div:last-child { border-right: 0; }
.today b { display: block; font-size: 38px; line-height: 1.05; font-weight: 700; letter-spacing: -0.02em; }
.today span { color: var(--muted); font-size: 15px; }
.today .bad b { color: var(--bad); }

.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 28px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 22px 24px; }
.panel + .panel { margin-top: 0; }

.bars { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding-top: 10px; }
.bars .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .stack { width: 100%; max-width: 30px; display: flex; flex-direction: column-reverse; border-radius: 3px 3px 0 0; overflow: hidden; background: #eef2ef; min-height: 2px; }
.bars .b-dm { background: var(--marigold); }
.bars .b-c { background: var(--board-2); }
.bars .lbl { font-size: 12px; color: var(--muted); }
.legend { display: flex; gap: 16px; font-size: 14px; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: 0; }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.feed li:last-child { border-bottom: 0; }
.feed .who { font-weight: 600; }
.feed .said { margin: 2px 0 4px; overflow-wrap: anywhere; }

.setup { border: 1px dashed #b8c6bd; border-radius: var(--radius-m); padding: 22px 24px; margin-bottom: 28px; background: #fbfcfb; }
.setup ol { margin: 10px 0 0; padding-left: 22px; }
.setup li { margin: 6px 0; }
.setup li.done { color: var(--muted); text-decoration: line-through; }

/* ---------- Automations ---------- */
.rules { display: flex; flex-direction: column; gap: 12px; }
.rule {
  display: grid; grid-template-columns: auto 1fr auto; gap: 18px; align-items: start;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m);
  padding: 18px 20px;
}
.rule.off { opacity: .6; }
.rule h3 { margin: 0 0 4px; font-size: 17px; }
.sentence { font-size: 17px; line-height: 1.9; margin: 0; }
.rule .meta { color: var(--muted); font-size: 14px; margin-top: 4px; }
.rule .actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }

.empty { text-align: left; padding: 36px; background: var(--surface); border: 1px dashed #b8c6bd; border-radius: var(--radius-m); }
.empty h2 { margin-bottom: 6px; }

/* ---------- Drawer ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(22, 33, 28, .38); z-index: 20; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 100vw);
  background: var(--bg); z-index: 21; transform: translateX(100%);
  transition: transform .22s ease; display: flex; flex-direction: column;
}
.drawer.open { transform: none; }
.drawer-head { padding: 20px 28px; background: var(--board); color: var(--chalk); display: flex; justify-content: space-between; align-items: center; }
.drawer-head h2 { margin: 0; }
.drawer-head .btn { background: transparent; color: var(--chalk); border-color: rgba(244, 236, 210, .35); }
.drawer-body { overflow-y: auto; padding: 24px 28px 40px; flex: 1; }
.drawer-foot { padding: 14px 28px; border-top: 1px solid var(--line); background: var(--surface); display: flex; justify-content: flex-end; gap: 10px; }
.preview-strip {
  background: var(--board); color: var(--chalk); border-radius: var(--radius-m);
  padding: 16px 20px; margin-bottom: 22px; font-size: 17px; line-height: 1.9;
}
.preview-strip .chip { background: var(--chalk); color: var(--board); }
fieldset { border: 0; border-top: 1px solid var(--line); padding: 20px 0 0; margin: 0 0 8px; }
legend { font-weight: 700; font-size: 18px; padding: 0 0 8px; }
.check-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 6px 14px; margin-top: 8px; max-height: 220px; overflow: auto; padding: 4px; }
.check-list label { font-weight: 500; display: flex; gap: 8px; align-items: center; }

.tester { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 16px 18px; margin-top: 8px; }
.tester .result { margin-top: 12px; font-size: 15px; }
.tester .bubble { background: #eef2ef; border-radius: 10px; padding: 8px 12px; margin-top: 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
.tester .bubble.dm { background: #fdf3e2; }

.posts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 10px; max-height: 360px; overflow: auto; }
.post { border: 1px solid var(--line); border-radius: var(--radius-s); background: #fff; cursor: pointer; overflow: hidden; font-size: 13px; text-align: left; padding: 0; }
.post img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; display: block; background: #e6ece8; }
.post span { display: block; padding: 6px 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.post.picked { outline: 3px solid var(--marigold); }

/* ---------- Tables ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filters input, .filters select { width: auto; margin: 0; }
.filters input[type=search] { min-width: 240px; flex: 1; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th { text-align: left; font-weight: 600; color: var(--muted); padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td .said { max-width: 42ch; overflow-wrap: anywhere; }
td .err { color: var(--bad); font-size: 13px; max-width: 40ch; margin-top: 4px; }

/* ---------- Accounts ---------- */
.acct-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.acct { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 16px; display: grid; grid-template-columns: 44px 1fr; gap: 12px; align-items: center; }
.acct img, .acct .ph { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: #e6ece8; }
.acct .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct .ctl { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--line); padding-top: 10px; }

/* ---------- Settings ---------- */
.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; align-items: start; }
.copy { display: flex; gap: 8px; align-items: center; }
.copy input { margin-top: 0; font-size: 14px; }

/* ---------- Misc ---------- */
.alert { padding: 10px 14px; border-radius: var(--radius-s); margin: 0 0 18px; }
.alert.err { background: #fbe7e5; color: var(--bad); }
.alert.ok { background: #e3f1e8; color: var(--ok); }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: var(--radius-s);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 40; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--bad); }
.loading { color: var(--muted); padding: 40px 0; }

/* ---------- Auth ---------- */
body.auth { min-height: 100vh; display: grid; place-items: center; background: var(--board); padding: 20px; }
.auth-card { background: var(--surface); padding: 36px; border-radius: var(--radius-m); width: min(400px, 100%); }
.auth-card .brand-mark { color: var(--board); margin: 0 0 6px; display: block; }
.auth-card p { color: var(--muted); }
.auth-card form { display: flex; flex-direction: column; gap: 16px; }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .grid-2, .settings { grid-template-columns: 1fr; }
  .today { grid-template-columns: repeat(2, 1fr); }
  .today > div:nth-child(2) { border-right: 0; }
  .today > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; padding: 16px; gap: 12px; }
  .nav { flex-direction: row; overflow-x: auto; }
  .nav a { white-space: nowrap; }
  .logout { display: none; }
  .main { padding: 24px 16px 60px; }
  .page-head h1 { font-size: 28px; }
  .rule { grid-template-columns: 1fr; }
  .rule .actions { justify-content: flex-start; }
  .row2 { grid-template-columns: 1fr; }
  .drawer-body, .drawer-head, .drawer-foot { padding-left: 18px; padding-right: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
