:root {
  --paper: #eef1f4;
  --surface: #ffffff;
  --sunk: #f6f8fa;
  --ink: #1b2430;
  --muted: #5b6676;
  --line: #d5dbe3;
  --marigold: #e8a317;
  --marigold-hover: #d4930c;
  --on-marigold: #2b1f00;
  --ok: #2f7d5b;
  --err: #b3261e;
  --warn: #8a5d00;
  --focus: #2f6fd6;
  --yt: #e23b30;
  --ig: #c2368b;
  --fb: #2e64d9;
  --li: #2272a8;
  --font-head: "Familjen Grotesk", "Noto Sans Devanagari", system-ui, sans-serif;
  --font-body: "Atkinson Hyperlegible", "Noto Sans Devanagari", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #12171e;
    --surface: #1a212b;
    --sunk: #151b23;
    --ink: #e5e9ef;
    --muted: #97a3b4;
    --line: #2c3542;
    --marigold: #f0b23a;
    --marigold-hover: #f5c160;
    --ok: #5cbf92;
    --err: #f08a82;
    --warn: #e3b55a;
    --focus: #7aa7f0;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-head); line-height: 1.2; margin: 0; }
h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.25rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0; }
a { color: inherit; }
small, .muted { color: var(--muted); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 88px 1fr; min-height: 100vh; }
.rail {
  background: var(--ink);
  color: var(--paper);
  display: flex; flex-direction: column; align-items: center;
  gap: 12px; padding: 18px 0;
  position: sticky; top: 0; height: 100vh;
}
@media (prefers-color-scheme: dark) { .rail { background: #0c1015; color: var(--ink); } }
.rail-home { font-family: var(--font-head); font-weight: 700; font-size: .8rem; text-decoration: none; opacity: .8; margin-bottom: 6px; }
.rail-brands { display: flex; flex-direction: column; gap: 12px; align-items: center; overflow-y: auto; flex: 1; padding: 4px 0; }
.tile {
  width: 56px; height: 56px; border-radius: 16px;
  display: grid; place-items: center;
  font-family: var(--font-head); font-weight: 700; font-size: 1.15rem; letter-spacing: .02em;
  color: #fff; text-decoration: none; position: relative;
  background: var(--c, #3d5a80);
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.18);
  transition: border-radius .15s, transform .15s;
}
.tile:hover { border-radius: 12px; }
.tile[aria-current="page"] { border-radius: 12px; }
.tile[aria-current="page"]::before {
  content: ""; position: absolute; left: -16px; top: 12px; bottom: 12px; width: 4px;
  border-radius: 0 4px 4px 0; background: var(--marigold);
}
.tile-add { background: transparent; border: 2px dashed rgba(238,241,244,.35); color: inherit; box-shadow: none; font-size: 1.6rem; font-weight: 500; cursor: pointer; }
@media (prefers-color-scheme: dark) { .tile-add { border-color: rgba(229,233,239,.3); } }
.rail-foot { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.rail-link { font-size: .78rem; text-decoration: none; opacity: .75; padding: 4px 6px; border-radius: 6px; background: none; border: 0; color: inherit; font-family: inherit; cursor: pointer; }
.rail-link:hover, .rail-link[aria-current="page"] { opacity: 1; text-decoration: underline; }

main { padding: 32px clamp(16px, 4vw, 48px) 64px; max-width: 1240px; width: 100%; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; padding: 10px 16px; gap: 10px; overflow-x: auto; }
  .rail-home { margin: 0 6px 0 0; }
  .rail-brands { flex-direction: row; overflow: visible; flex: 1; }
  .rail-foot { flex-direction: row; }
  .tile { width: 44px; height: 44px; border-radius: 13px; font-size: .95rem; flex: none; }
  .tile[aria-current="page"]::before { left: 10px; right: 10px; top: auto; bottom: -10px; width: auto; height: 4px; border-radius: 4px 4px 0 0; }
  main { padding-top: 24px; }
}

/* ---------- page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.page-head .sub a { color: var(--muted); }

/* ---------- panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 20px; }
.panel + .panel { margin-top: 20px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.grid-2 > .panel { margin-top: 0; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 1000px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- accounts ---------- */
.accounts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); margin-bottom: 20px; }
.acct { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.acct + .acct { border-left: 1px solid var(--line); }
@media (max-width: 1000px) { .accounts { grid-template-columns: 1fr 1fr; } .acct:nth-child(3) { border-left: 0; } .acct:nth-child(n+3) { border-top: 1px solid var(--line); } }
@media (max-width: 520px) { .accounts { grid-template-columns: 1fr; } .acct + .acct { border-left: 0; border-top: 1px solid var(--line); } }
.acct-name { display: flex; align-items: center; gap: 8px; font-family: var(--font-head); font-weight: 600; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--p); flex: none; }
.acct-state { font-size: .9rem; overflow-wrap: anywhere; }
.acct-state.off { color: var(--muted); }
.acct-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: auto; }
.acct select { width: 100%; }
.p-youtube { --p: var(--yt); } .p-instagram { --p: var(--ig); } .p-facebook { --p: var(--fb); } .p-linkedin { --p: var(--li); }

/* ---------- forms ---------- */
label { display: block; font-weight: 700; font-size: .9rem; margin-bottom: 6px; }
.field { margin-bottom: 16px; }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row > .field { flex: 1 1 160px; }
.hint { font-size: .85rem; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=url], input[type=password], input[type=datetime-local], input[type=number], textarea, select {
  width: 100%; font: inherit; color: var(--ink); background: var(--sunk);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.55; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: transparent; }
.count { font-size: .8rem; color: var(--muted); text-align: right; margin-top: 4px; font-variant-numeric: tabular-nums; }
.count.over { color: var(--err); font-weight: 700; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 0; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--ink); }

.btn {
  font: 600 .95rem var(--font-head); border-radius: 8px; padding: 9px 16px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn:hover { background: var(--sunk); }
.btn-primary { background: var(--marigold); border-color: var(--marigold); color: var(--on-marigold); }
.btn-primary:hover { background: var(--marigold-hover); }
.btn-dark { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.btn-dark:hover { background: var(--ink); opacity: .9; }
.btn-small { padding: 5px 10px; font-size: .85rem; }
.btn-link { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; font: inherit; font-size: .85rem; cursor: pointer; }
.btn-danger { color: var(--err); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- composer ---------- */
.drop {
  border: 2px dashed var(--line); border-radius: 10px; padding: 26px 16px;
  text-align: center; cursor: pointer; background: var(--sunk);
}
.drop.drag { border-color: var(--marigold); background: color-mix(in srgb, var(--marigold) 10%, var(--sunk)); }
.drop strong { font-family: var(--font-head); font-size: 1.05rem; display: block; margin-bottom: 4px; }
.video-ready { display: flex; gap: 14px; align-items: center; background: var(--sunk); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.video-ready video { width: 96px; height: 128px; object-fit: cover; border-radius: 6px; background: #000; flex: none; }
.video-ready .meta { min-width: 0; flex: 1; }
.video-ready .meta p { overflow-wrap: anywhere; }
.progress { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; margin-top: 10px; }
.progress > span { display: block; height: 100%; background: var(--marigold); width: 0; transition: width .2s; }

.platform-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.pchip { position: relative; }
.pchip input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.pchip > span {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px 7px 10px;
  border: 1px solid var(--line); border-radius: 999px; font-weight: 700; font-size: .9rem; background: var(--surface);
}
.pchip input:checked + span { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.pchip input:checked + span .dot { box-shadow: 0 0 0 2px var(--surface); }
.pchip input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.pchip input:disabled + span { opacity: .45; }
.pchip input:disabled { cursor: not-allowed; }

details.more { border-top: 1px solid var(--line); padding-top: 12px; margin-bottom: 16px; }
details.more summary { cursor: pointer; font-weight: 700; font-size: .92rem; }
details.more[open] summary { margin-bottom: 12px; }

.when { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 10px; }
.submit-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 16px; }

/* ---------- posts ---------- */
.posts { list-style: none; margin: 0; padding: 0; }
.post { padding: 14px 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 4px 1fr; gap: 12px; }
.post:last-child { border-bottom: 0; }
.post-bar { border-radius: 2px; background: var(--c, var(--line)); }
.post-top { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.post-title { font-weight: 700; overflow-wrap: anywhere; }
.post-when { font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.post-status { font-size: .85rem; font-weight: 700; }
.st-done { color: var(--ok); } .st-failed, .st-partial { color: var(--err); } .st-scheduled { color: var(--ink); } .st-posting, .st-processing { color: var(--warn); } .st-cancelled { color: var(--muted); }
.results { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.res { font-size: .82rem; padding: 2px 9px 2px 7px; border-radius: 999px; border: 1px solid var(--line); display: inline-flex; gap: 6px; align-items: center; text-decoration: none; }
.res .dot { width: 8px; height: 8px; }
.res.ok { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.res.err { border-color: color-mix(in srgb, var(--err) 55%, var(--line)); color: var(--err); }
.res.wait { border-style: dashed; }
a.res:hover { background: var(--sunk); }
.post-errors { margin: 8px 0 0; padding: 0; list-style: none; font-size: .88rem; color: var(--err); }
.post-errors li + li { margin-top: 2px; }
.post-notes { margin-top: 6px; font-size: .85rem; color: var(--muted); }
.post-actions { margin-top: 8px; display: flex; gap: 14px; }
.brand-chip { font-size: .8rem; font-weight: 700; color: var(--muted); }

.empty { padding: 28px 8px; text-align: center; color: var(--muted); }
.empty h3 { color: var(--ink); margin-bottom: 6px; }

/* ---------- overview ---------- */
.site-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-bottom: 28px; }
.site { display: flex; gap: 14px; align-items: center; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; text-decoration: none; }
.site:hover { border-color: var(--muted); }
.site .tile { width: 48px; height: 48px; font-size: 1rem; flex: none; border-radius: 14px; }
.site-name { font-family: var(--font-head); font-weight: 600; font-size: 1.05rem; }
.site-dots { display: flex; gap: 5px; margin-top: 4px; }
.site-dots .dot { opacity: .2; }
.site-dots .dot.on { opacity: 1; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-mark { display: flex; gap: 8px; margin-bottom: 22px; }
.auth-mark span { width: 30px; height: 30px; border-radius: 9px; }
.auth h1 { margin-bottom: 6px; }
.auth p.lead { color: var(--muted); margin-bottom: 22px; }

/* ---------- settings ---------- */
.copy-row { display: flex; gap: 8px; }
.copy-row input { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; }
.keyset { display: grid; grid-template-columns: 220px 1fr; gap: 24px; }
.keyset + .keyset { border-top: 1px solid var(--line); padding-top: 22px; margin-top: 22px; }
@media (max-width: 760px) { .keyset { grid-template-columns: 1fr; gap: 10px; } }
.state-ok { color: var(--ok); font-weight: 700; font-size: .88rem; }
.state-off { color: var(--muted); font-size: .88rem; }

/* ---------- dialog & toasts ---------- */
dialog { border: 1px solid var(--line); border-radius: 12px; padding: 22px; width: min(440px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); }
dialog::backdrop { background: rgba(10, 14, 20, .45); }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 34px; height: 34px; border-radius: 10px; border: 2px solid transparent; cursor: pointer; background: var(--c); }
.swatch[aria-checked="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 2px var(--surface); }
.dialog-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 20px; align-items: center; }

#toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: calc(100vw - 40px); }
.toast { background: var(--ink); color: var(--surface); padding: 11px 16px; border-radius: 8px; font-weight: 700; font-size: .92rem; max-width: 420px; }
.toast.error { background: var(--err); color: #fff; }
.error-text { color: var(--err); font-size: .9rem; margin-top: 10px; }
