:root {
  --red: #E1232B; --red-dark: #B9161D; --yellow: #FFD23F;
  --bg: #F4F4F6; --card: #FFFFFF; --ink: #1D1D1F; --muted: #6E6E73; --line: #E3E3E8;
  --ok: #1E9E57; --warn-bg: #FFF6D6;
  --safe-b: env(safe-area-inset-bottom); --safe-t: env(safe-area-inset-top);
}
@media (prefers-color-scheme: dark) {
  :root { --bg:#111113; --card:#1C1C1F; --ink:#F2F2F4; --muted:#9A9AA2; --line:#2E2E33; --warn-bg:#3A3112; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Anek Malayalam", "Noto Sans Malayalam", sans-serif; }
.ml { font-family: "Anek Malayalam", "Noto Sans Malayalam", -apple-system, sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 14px; }
.err { color: var(--red); min-height: 1.2em; }
.warn { background: var(--warn-bg); padding: 10px 12px; border-radius: 10px; font-size: 14px; }

.wordmark { font-weight: 800; letter-spacing: .5px; font-size: 20px; color: var(--ink); }
.wordmark b { color: var(--red); }
.wordmark.big { font-size: 34px; }

/* login */
.screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-box { width: 100%; max-width: 360px; text-align: center; }
.login-box input { margin: 18px 0 12px; }

/* header */
.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: calc(10px + var(--safe-t)) 16px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.top-right { display: flex; align-items: center; gap: 10px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.dot.ok { background: var(--ok); } .dot.run { background: var(--yellow); } .dot.bad { background: var(--red); }
.status-line { font-size: 12px; color: var(--muted); padding: 6px 16px 0; }

main { padding: 10px 12px calc(84px + var(--safe-b)); max-width: 640px; margin: 0 auto; }

/* inputs */
input, textarea, select { width: 100%; font: inherit; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; outline: none; }
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--red); }

.btn { appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font: 600 15px/1 -apple-system, sans-serif; padding: 13px 16px; border-radius: 12px; cursor: pointer; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:active { background: var(--red-dark); }
.btn.ghost { background: transparent; }
.btn.small { padding: 8px 12px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: .5; }

/* cards */
.card { background: var(--card); border-radius: 18px; padding: 12px; margin-bottom: 18px;
  box-shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.04); }
.poster-wrap { position: relative; border-radius: 12px; overflow: hidden; aspect-ratio: 1/1; background: var(--line); }
.poster { width: 100%; height: 100%; object-fit: cover; display: block; }
.busy { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 10px; align-items: center;
  justify-content: center; background: rgba(255,255,255,.75); color: #333; font-weight: 600; }
.spin { width: 28px; height: 28px; border: 3px solid #ddd; border-top-color: var(--red); border-radius: 50%; animation: s 0.8s linear infinite; }
@keyframes s { to { transform: rotate(360deg); } }
.meta { display: flex; align-items: center; gap: 10px; margin: 10px 0 4px; }
.meta .cat { width: auto; flex: none; padding: 6px 10px; border-radius: 999px; background: var(--yellow);
  color: var(--red-dark); font-weight: 700; border: none; font-size: 14px; }
.meta .source { color: var(--muted); font-size: 13px; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.checks { margin: 6px 0; font-size: 13px; }
.checks summary { color: var(--muted); cursor: pointer; }
.checks p { margin: 6px 0; white-space: pre-wrap; }
.checks .spell:not(:empty) { background: var(--warn-bg); padding: 8px 10px; border-radius: 8px; }
.lbl { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 12px 2px 5px; }
.headline { font-weight: 700; font-size: 18px; }
.caption { font-size: 16px; line-height: 1.55; }
.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0 8px; }
.card.done { opacity: .55; }
.card .result { margin-top: 10px; font-size: 14px; }

/* posted list */
.post-row { display: flex; gap: 12px; align-items: center; background: var(--card); padding: 10px; border-radius: 14px; margin-bottom: 10px; }
.post-row img { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; flex: none; }
.post-row .t { flex: 1; min-width: 0; font-size: 14px; }
.post-row .t b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; }
.pill.posted { background: #DDF5E7; color: var(--ok); } .pill.failed { background: #FDE2E3; color: var(--red); }
.pill.rejected, .pill.skipped { background: var(--line); color: var(--muted); }

/* panels */
.panel { background: var(--card); border-radius: 16px; padding: 16px; margin-bottom: 14px; }
.panel h2 { font-size: 17px; margin: 0 0 6px; }
.field { display: block; margin-top: 12px; } .field span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.switch-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; }
.switch-row input { width: auto; transform: scale(1.3); }
.rules { list-style: none; padding: 0; margin: 14px 0 0; }
.rules li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
.rules li span { flex: 1; }
.rules li button { border: none; background: none; color: var(--red); font-size: 20px; line-height: 1; }
.row { margin: 12px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.chip { padding: 8px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); font-size: 14px; }
.chip.on { background: var(--red); color: #fff; border-color: var(--red); }
.empty { text-align: center; padding: 60px 20px; }

/* tab bar */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line); padding: 6px 0 calc(6px + var(--safe-b)); z-index: 6; }
.tabbar button { position: relative; background: none; border: none; color: var(--muted); font-size: 11px; font-weight: 600; padding: 4px; }
.tabbar .ico { display: block; font-size: 20px; line-height: 1.2; }
.tabbar button.active { color: var(--red); }
.badge { position: absolute; top: 0; left: 55%; background: var(--red); color: #fff; font-style: normal; font-size: 11px;
  min-width: 18px; height: 18px; line-height: 18px; border-radius: 9px; padding: 0 5px; }

/* sheet */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 10; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 11; background: var(--card); border-radius: 20px 20px 0 0;
  padding: 18px 16px calc(16px + var(--safe-b)); max-width: 640px; margin: 0 auto; }
.sheet h3 { margin: 0 0 4px; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }

.toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%); z-index: 20;
  background: #222; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: 90vw; }

/* platforms */
.plats { display: flex; align-items: center; gap: 8px; margin: 4px 0 10px; }
.plats .muted { margin-right: 2px; }
.plat { border: 1px solid var(--line); background: var(--card); color: var(--muted); font: 600 14px/1 -apple-system, sans-serif;
  padding: 9px 14px; border-radius: 999px; }
.plat.on { background: #1D1D1F; color: #fff; border-color: #1D1D1F; }
.plat[disabled] { opacity: .4; text-decoration: line-through; }
@media (prefers-color-scheme: dark) { .plat.on { background: #F2F2F4; color: #111; border-color: #F2F2F4; } }
.panel h2.sub { margin-top: 18px; font-size: 15px; }
.page-list { margin: 12px 0; }
.page-opt { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 8px; color: var(--ink); font: inherit; }
.page-opt.on { border-color: var(--red); box-shadow: 0 0 0 1px var(--red) inset; }
.page-opt .radio { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line); flex: none; }
.page-opt.on .radio { border: 6px solid var(--red); }
.page-opt small { display: block; color: var(--muted); }
.page-opt small.ok { color: var(--ok); }
.links { display: flex; gap: 10px; margin-top: 3px; font-size: 13px; }
.links a { color: var(--red); text-decoration: none; font-weight: 600; }
.plat.done[disabled] { opacity: 1; text-decoration: none; color: var(--ok); border-color: var(--ok); }

.actions.two { grid-template-columns: 1fr 1fr; margin-top: 0; }
.export-row { display: flex; gap: 10px; margin-top: 10px; }
.export-row input { flex: 1; min-width: 0; }
.row-actions { display: flex; gap: 12px; margin-top: 4px; font-size: 13px; }
.row-actions button { background: none; border: none; padding: 0; color: var(--red); font-weight: 600; font: 600 13px -apple-system, sans-serif; }

/* ---------- swipe deck ---------- */
body.no-scroll { overflow: hidden; }
#tab-queue { display: flex; flex-direction: column; }
.deck-wrap { position: relative; }
.deck { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; position: relative; width: min(100%, 62vh); margin: 4px auto 0; aspect-ratio: 1 / 1.32; }
.swipe { position: absolute; inset: 0; background: var(--card); border-radius: 22px; overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,.08), 0 14px 30px rgba(0,0,0,.10);
  transform: translateY(calc(var(--depth, 0) * 12px)) scale(calc(1 - var(--depth, 0) * .04));
  transition: transform .25s ease; touch-action: none; cursor: grab; z-index: calc(10 - var(--depth, 0)); }
.swipe:not(.is-top) { pointer-events: none; }
.swipe.enter { animation: pop .22s ease; }
@keyframes pop { from { transform: scale(.96); opacity: .6; } to { transform: none; opacity: 1; } }
.sw-poster { position: relative; aspect-ratio: 1 / 1; background: var(--line); }
.sw-poster img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; -webkit-user-drag: none; }
.stamp { position: absolute; top: 22px; padding: 6px 14px; border: 4px solid; border-radius: 10px; font: 800 30px/1 -apple-system, sans-serif;
  letter-spacing: 2px; background: rgba(255,255,255,.85); }
.stamp.yes { left: 18px; color: var(--ok); transform: rotate(-14deg); opacity: var(--yes, 0); }
.stamp.nope { right: 18px; color: var(--red); transform: rotate(14deg); opacity: var(--nope, 0); }
.sw-body { padding: 10px 14px 12px; }
.sw-meta { display: flex; gap: 8px; align-items: center; font-size: 13px; overflow: hidden; white-space: nowrap; }
.sw-cat { background: var(--yellow); color: var(--red-dark); font-weight: 700; padding: 3px 10px; border-radius: 999px; flex: none; }
.sw-src { overflow: hidden; text-overflow: ellipsis; }
.sw-head { margin: 6px 0 2px; font-weight: 700; font-size: 17px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sw-cap { margin: 0; font-size: 14px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sw-plats { margin: 4px 0 0; font-size: 12px; }
.sw-fail { margin: 6px 0 0; font-size: 13px; color: var(--red); }
.deck-actions { display: flex; justify-content: center; gap: 26px; margin: 16px 0 6px; }
.round { width: 64px; height: 64px; border-radius: 50%; border: none; background: var(--card); font-size: 28px; font-weight: 700;
  box-shadow: 0 3px 12px rgba(0,0,0,.14); }
.round:active { transform: scale(.94); }
.round.nope { color: var(--red); } .round.yes { color: var(--ok); }
.round.edit { width: 52px; height: 52px; font-size: 22px; color: #3478F6; align-self: center; }
.deck-hint { text-align: center; font-size: 12px; margin: 0; }

/* ---------- undo bar ---------- */
.undo { position: fixed; left: 12px; right: 12px; bottom: calc(80px + var(--safe-b)); z-index: 30; max-width: 616px; margin: 0 auto;
  background: #1f1f22; color: #fff; border-radius: 14px; padding: 12px 14px; display: flex; align-items: center; gap: 12px; overflow: hidden; }
.undo span { flex: 1; font-size: 14px; }
.undo button { background: none; border: none; color: #FFD23F; font: 700 15px -apple-system, sans-serif; padding: 4px; }
.undo i { position: absolute; left: 0; bottom: 0; height: 3px; background: #FFD23F; animation: undoTime 5s linear forwards; }
@keyframes undoTime { from { width: 100%; } to { width: 0; } }

/* ---------- editor ---------- */
.editor { position: fixed; inset: 0; z-index: 20; background: var(--bg); display: flex; flex-direction: column; }
.ed-top { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(10px + var(--safe-t)) 12px 10px; border-bottom: 1px solid var(--line); background: var(--card); }
.ed-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px 12px calc(30px + var(--safe-b)); max-width: 640px; width: 100%; margin: 0 auto; }
.ed-stage { position: relative; width: 100%; border-radius: 14px; overflow: hidden; background: var(--line); }
.ed-stage iframe { position: absolute; left: 0; top: 0; width: 1080px; height: 1080px; border: 0; transform-origin: 0 0; }
.ed-tip { text-align: center; font-size: 13px; margin: 8px 0 12px; }
.slider { display: block; margin: 4px 0 12px; }
.slider span { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.slider em { font-style: normal; }
.slider input { padding: 0; border: none; background: none; accent-color: var(--red); }
.chip.sty i { font-style: normal; font-weight: 800; padding: 1px 6px; border-radius: 6px; margin-right: 4px; border: 1px solid var(--line); }
.ed-tools .chips { margin: 4px 0 12px; }
.ed-tools .lbl { margin-top: 2px; }

.photo-strip { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 8px; margin: 0 -2px; scroll-snap-type: x mandatory; }
.photo-strip button { flex: none; width: 108px; padding: 0; border: 2px solid transparent; border-radius: 12px; background: var(--card);
  overflow: hidden; scroll-snap-align: start; text-align: left; color: var(--ink); }
.photo-strip button.on { border-color: var(--red); }
.photo-strip img { width: 100%; height: 80px; object-fit: cover; display: block; }
.photo-strip small { display: block; padding: 3px 6px 5px; font-size: 11px; line-height: 1.25; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.photo-strip small b { color: var(--ink); }
.photo-strip small b.hd { color: var(--ok); }
.photo-strip .none { padding: 10px; font-size: 13px; color: var(--muted); width: auto; }
.credit { font-size: 12px; margin: 0 0 8px; min-height: 1em; }
.photo-search { display: flex; gap: 8px; margin-bottom: 12px; }
.photo-search input { flex: 1; min-width: 0; }
