:root {
  --bg: #f6f6f4; --panel: #ffffff; --ink: #141414; --muted: #6b6b6b; --line: #e6e5e1; --soft: #f0efeb;
  --accent: #e5383b; --accent-ink: #ffffff; --ok: #1f9d55; --warn: #c27c0e; --bad: #d64545; --info: #2f6fde;
  --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  --font: "Inter", "Hind Siliguri", system-ui, sans-serif; --font-bn: "Hind Siliguri", "Inter", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111112; --panel: #1a1a1c; --ink: #ececec; --muted: #9a9a9a; --line: #2b2b2e; --soft: #222225; --shadow: none; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
.bn { font-family: var(--font-bn); }

/* layout */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { border-right: 1px solid var(--line); padding: 20px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; background: var(--panel); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; padding: 4px 8px 18px; letter-spacing: -.01em; }
.brand .dot { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); position: relative; flex: none; }
.brand .dot::after { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: #fff; animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.6); opacity: .7; } }
.nav a { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 500; transition: background .15s, color .15s; }
.nav a:hover { background: var(--soft); color: var(--ink); }
.nav a.on { background: var(--soft); color: var(--ink); }
.nav .count { font-size: 11px; background: var(--accent); color: var(--accent-ink); border-radius: 99px; padding: 0 7px; }
.side-foot { margin-top: auto; display: grid; gap: 6px; font-size: 12px; color: var(--muted); padding: 8px; }
.main { padding: 28px 32px 80px; max-width: 1280px; width: 100%; }
h1 { font-size: 22px; letter-spacing: -.02em; margin: 0 0 4px; }
h2 { font-size: 15px; margin: 0 0 12px; }
h3 { font-size: 13px; margin: 0 0 8px; color: var(--muted); font-weight: 600; text-transform: none; }
.sub { color: var(--muted); margin: 0 0 20px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.stack { display: grid; gap: 12px; }

/* panels */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.panel + .panel { margin-top: 16px; }
.kpi { font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.kpi small { font-size: 12px; color: var(--muted); font-weight: 500; }

/* controls */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); padding: 7px 12px; border-radius: 8px; cursor: pointer; font-weight: 500; transition: transform .08s, background .15s, border-color .15s; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.busy { pointer-events: none; opacity: .7; }
.btn.busy::before { content: ""; width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.paid::after { content: "$"; font-size: 10px; font-weight: 700; background: var(--warn); color: #fff; border-radius: 4px; padding: 0 4px; margin-left: 2px; }
input[type=text], input[type=password], input[type=number], input[type=url], select, textarea {
  width: 100%; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 8px 10px; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
textarea { resize: vertical; min-height: 70px; }
label.f { display: grid; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 500; }
label.f > span { color: var(--muted); }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch i { width: 34px; height: 20px; border-radius: 99px; background: var(--line); position: relative; transition: background .2s; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(14px); }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--soft); color: var(--muted); white-space: nowrap; }
.badge.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.badge.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.badge.bad { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.badge.info { background: color-mix(in srgb, var(--info) 14%, transparent); color: var(--info); }
.badge.accent { background: var(--accent); color: var(--accent-ink); }

/* tables & lists */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; transition: background .12s; }
tr.click:hover { background: var(--soft); }
.story-title { font-weight: 600; line-height: 1.35; }
.meta { color: var(--muted); font-size: 12px; }
.empty { color: var(--muted); text-align: center; padding: 40px 10px; }

/* tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 18px 0 16px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 9px 12px; cursor: pointer; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .15s, border-color .15s; white-space: nowrap; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }

/* pipeline stepper */
.steps { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin: 16px 0 4px; }
.step { padding: 8px 10px; border-radius: 8px; background: var(--soft); font-size: 12px; color: var(--muted); position: relative; overflow: hidden; }
.step b { display: block; color: var(--ink); font-weight: 600; font-size: 12px; }
.step.done { background: color-mix(in srgb, var(--ok) 12%, transparent); }
.step.done b::before { content: "✓ "; color: var(--ok); }
.step.now { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.step.now::after { content: ""; position: absolute; left: 0; bottom: 0; height: 2px; width: 40%; background: var(--accent); animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(260%); } }

/* claims */
.claim { display: grid; grid-template-columns: 110px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.claim:last-child { border-bottom: 0; }
ul.clean { margin: 0; padding-left: 18px; }
ul.clean li { margin: 3px 0; }

/* scenes */
.scene { display: grid; grid-template-columns: 44px 1fr; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.scene:last-child { border-bottom: 0; }
.scene .n { width: 36px; height: 36px; border-radius: 10px; background: var(--soft); display: grid; place-items: center; font-weight: 700; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.thumb { width: 92px; height: 120px; border-radius: 8px; overflow: hidden; border: 2px solid transparent; position: relative; background: var(--soft); cursor: pointer; transition: border-color .15s, transform .1s; }
.thumb:hover { transform: translateY(-1px); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.sel { border-color: var(--accent); }
.thumb .tag { position: absolute; left: 4px; bottom: 4px; font-size: 10px; background: rgba(0,0,0,.65); color: #fff; padding: 1px 5px; border-radius: 4px; }
.thumb.ref { cursor: default; opacity: .75; }
audio { width: 100%; height: 34px; }

/* post preview */
.preview-wrap { width: 100%; aspect-ratio: 1080 / 1350; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); position: relative; background: var(--soft); }
.preview-wrap iframe { position: absolute; top: 0; left: 0; width: 1080px; height: 1350px; border: 0; transform-origin: 0 0; }

/* add links box */
.addbox textarea { min-height: 84px; font-family: var(--font); }
.drop { border: 1.5px dashed var(--line); border-radius: 10px; padding: 14px; text-align: center; color: var(--muted); transition: border-color .15s, background .15s; }
.drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background:
  radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 60%), var(--bg); }
.login .panel { width: min(380px, 100%); padding: 28px; }

/* toasts */
#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 50; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.18); max-width: 380px; animation: pop .2s ease-out; }
.toast.bad { background: var(--bad); color: #fff; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: grid; place-items: center; z-index: 40; animation: fade .15s; padding: 16px; }
.modal { width: min(460px, 100%); }
@keyframes fade { from { opacity: 0; } }

.fadein { animation: fadeup .25s ease-out; }
@keyframes fadeup { from { opacity: 0; transform: translateY(4px); } }
.skeleton { background: linear-gradient(90deg, var(--soft), var(--line), var(--soft)); background-size: 200% 100%; animation: sk 1.2s linear infinite; border-radius: 8px; height: 14px; }
@keyframes sk { to { background-position: -200% 0; } }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; }
  .brand { padding: 4px 8px; }
  .nav { display: flex; gap: 2px; overflow-x: auto; }
  .side-foot { display: none; }
  .main { padding: 18px 16px 60px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .steps { grid-template-columns: repeat(4, 1fr); }
}
