:root {
  --paper: #F5F2EE;
  --white: #FFFFFF;
  --ink: #1A1B18;
  --slate: #678291;
  --line: #DDE8EE;
  --teal: #108474;
  --teal-deep: #0B6657;
  --teal-soft: #DDF1EC;
  --night: #16233A;
  --night-2: #1F3150;
  --moon: #F3E9CF;
  --amber: #B45309;
  --amber-soft: #FBEEDC;
  --red: #B42318;
  --radius: 14px;
  --radius-s: 8px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  background-image: radial-gradient(900px 500px at 85% -10%, rgba(16,132,116,.10), transparent 60%),
                    radial-gradient(700px 400px at -10% 30%, rgba(22,35,58,.06), transparent 60%);
  background-attachment: fixed;
  color: var(--ink);
  font: 15px/1.5 "Nunito", -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
}
a { color: var(--teal-deep); }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--ink); }
:focus-visible { outline: 3px solid rgba(16,132,116,.45); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* top bar */
.top {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 24px;
  max-width: 1160px; margin: 0 auto;
  position: sticky; top: 0; z-index: 5;
  background: rgba(245,242,238,.82); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.wordmark { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: .01em; }
.wordmark .moon { width: 22px; height: 22px; }
.top .who { margin-left: auto; color: var(--slate); font-size: 14px; display: flex; gap: 14px; align-items: center; }
.linkbtn { background: none; border: 0; color: var(--teal-deep); padding: 0; font-weight: 600; }
.linkbtn:hover { text-decoration: underline; }

main { max-width: 1160px; margin: 0 auto; padding: 0 24px 72px; }
@media (max-width: 640px) { .top, main { padding-left: 16px; padding-right: 16px; } }

/* the ask: the one dark, memorable element */
.ask {
  background: radial-gradient(1200px 420px at 10% -20%, var(--night-2), var(--night) 60%);
  color: var(--moon);
  border-radius: 22px;
  padding: 28px 28px 24px;
  margin-top: 6px;
  position: relative; overflow: hidden;
  box-shadow: 0 18px 40px -24px rgba(22,35,58,.55);
}
.ask::after {
  content: ""; position: absolute; right: -60px; top: -80px; width: 260px; height: 260px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(243,233,207,.22), rgba(243,233,207,0) 60%);
  pointer-events: none;
}
.ask h1 { margin: 0 0 14px; font-size: 20px; font-weight: 600; color: #fff; }
.ask textarea {
  width: 100%; min-height: 84px; resize: vertical;
  background: rgba(255,255,255,.07); color: #fff;
  border: 1px solid rgba(255,255,255,.18); border-radius: var(--radius);
  padding: 14px 16px; font-size: 19px; line-height: 1.4;
}
.ask textarea::placeholder { color: rgba(243,233,207,.55); }
.ask textarea:focus { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.4); outline: none; }
.readback { margin: 16px 0 6px; font-size: 21px; line-height: 1.35; font-weight: 600; color: var(--moon); min-height: 1.4em; }
.readback.muted { color: rgba(243,233,207,.6); font-weight: 400; }
.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 14px; }
.controls label { display: flex; align-items: center; gap: 8px; font-size: 14px; color: rgba(243,233,207,.85); }
.controls input[type=number], .controls select {
  background: rgba(255,255,255,.1); color: #fff; border: 1px solid rgba(255,255,255,.2);
  border-radius: var(--radius-s); padding: 7px 10px; min-height: 36px;
}
.controls input[type=number] { width: 70px; }
.controls select option { color: var(--ink); }
.controls .check { gap: 6px; }
.controls .check input { width: 16px; height: 16px; accent-color: var(--teal); }
.primary {
  margin-left: auto;
  background: var(--teal); color: #fff; border: 0;
  border-radius: 999px; padding: 11px 20px; font-weight: 800; font-size: 15px;
}
.primary:hover { background: var(--teal-deep); box-shadow: 0 8px 20px -10px rgba(16,132,116,.8); }
.primary:disabled { opacity: .55; cursor: default; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
.chip {
  border: 1px solid rgba(255,255,255,.25); background: transparent; color: var(--moon);
  border-radius: 999px; padding: 4px 11px; font-size: 13px;
}
.chip.on { background: var(--teal); border-color: var(--teal); color: #fff; }
.chips .hint { font-size: 13px; color: rgba(243,233,207,.6); width: 100%; }

/* sections */
section { margin-top: 30px; }
section > h2 { margin: 0 0 12px; font-size: 17px; font-weight: 800; }
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: 0 10px 30px -24px rgba(22,35,58,.35); }
.quiet { color: var(--slate); }
.small { font-size: 13px; }

/* running */
.run-head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: baseline; }
.run-head .title { font-weight: 800; font-size: 17px; }
.stopbtn { margin-left: auto; background: var(--white); color: var(--red); border: 1px solid var(--red); border-radius: 999px; padding: 6px 14px; font-weight: 700; font-size: 13.5px; }
.stopbtn:hover { background: #FBE9E7; }
.stopbtn.armed { background: var(--red); color: #fff; }
.stopbtn:disabled { opacity: .55; cursor: default; }
.ask-echo { margin-top: 2px; font-style: italic; }
.prog { display: flex; align-items: center; gap: 16px; margin: 16px 0 10px; }
.bar { flex: 1; height: 14px; border-radius: 999px; background: var(--line); overflow: hidden; position: relative; }
.bar i {
  display: block; height: 100%; border-radius: 999px; min-width: 6px;
  background: linear-gradient(90deg, var(--teal-deep), var(--teal) 60%, #2FB39F);
  transition: width .9s cubic-bezier(.2,.7,.2,1);
  position: relative; overflow: hidden;
}
.bar i::after {
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(-55deg, rgba(255,255,255,0) 0 10px, rgba(255,255,255,.22) 10px 20px);
  background-size: 200% 100%;
  animation: stripes 1.4s linear infinite;
}
@keyframes stripes { from { background-position: 0 0; } to { background-position: 56px 0; } }
.prog.paused .bar i { background: linear-gradient(90deg, #8A6D2F, var(--amber)); }
.prog.paused .bar i::after { animation-duration: 3.5s; }
.pct { font-weight: 800; font-size: 26px; line-height: 1; color: var(--teal-deep); min-width: 64px; text-align: right; font-variant-numeric: tabular-nums; }
.pct small { font-size: 14px; font-weight: 700; margin-left: 1px; }
.prog.paused .pct { color: var(--amber); }
.statusline { font-size: 15px; margin-bottom: 10px; }
.statusline b { font-weight: 800; }
.statusline .warnline { display: block; color: var(--amber); font-size: 13.5px; margin-top: 2px; }
.stages { display: flex; gap: 6px 8px; margin: 6px 0 10px; flex-wrap: wrap; }
.stage {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 700; color: var(--slate);
  padding: 4px 10px 4px 7px; border-radius: 999px; border: 1px solid var(--line); background: #FBFAF8;
}
.stage i { width: 14px; height: 14px; border-radius: 50%; background: var(--line); display: inline-block; position: relative; }
.stage.done { color: var(--teal-deep); border-color: var(--teal-soft); background: var(--teal-soft); }
.stage.done i { background: var(--teal); }
.stage.done i::after { content: ""; position: absolute; left: 4.5px; top: 2px; width: 3px; height: 7px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.stage.now { color: #fff; background: var(--teal); border-color: var(--teal); }
.stage.now i { background: #fff; animation: pulse 1.3s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255,255,255,.55); } 50% { box-shadow: 0 0 0 5px rgba(255,255,255,0); } }
.logtail {
  margin-top: 10px; background: #FBFAF8; border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: 10px 12px; font: 12.5px/1.45 ui-monospace, Menlo, monospace; color: #444; max-height: 180px; overflow: auto; white-space: pre-wrap;
}
details > summary { cursor: pointer; color: var(--teal-deep); font-weight: 600; font-size: 14px; }
.queue { margin-top: 10px; display: grid; gap: 8px; }
.qitem { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; padding: 10px 12px; border: 1px dashed var(--line); border-radius: var(--radius-s); }
.qitem .linkbtn { margin-left: auto; }
.badge { display: inline-block; font-size: 12px; font-weight: 800; color: #fff; background: var(--teal); border-radius: 999px; padding: 2px 9px; white-space: nowrap; }
.badges { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.badge.warn { background: var(--amber); }
.badge.fail { background: var(--red); }
.badge.ghost { background: var(--line); color: var(--slate); }

/* batches */
.batches { display: grid; grid-template-columns: 250px 1fr; gap: 18px; align-items: start; }
@media (max-width: 820px) { .batches { grid-template-columns: 1fr; } }
.runlist { display: grid; gap: 6px; }
.runbtn {
  text-align: left; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: 10px 12px; width: 100%;
}
.runbtn:hover { border-color: var(--teal); transform: translateY(-1px); }
.runbtn { transition: transform .15s, border-color .15s; }
.runbtn.on { border-color: var(--teal); background: var(--teal-soft); }
.runbtn .d { font-weight: 800; }
.runbtn .c { display: block; font-size: 13px; color: var(--slate); }
.gal-head { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin-bottom: 12px; }
.gal-head .dest { color: var(--slate); font-size: 13px; }
.gal-head .dest.fb { color: var(--amber); }
.alt { background: var(--white); color: var(--teal-deep); border: 1px solid var(--teal); border-radius: 999px; padding: 8px 14px; font-weight: 700; }
.alt:hover { background: var(--teal-soft); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.ad { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; transition: transform .18s, box-shadow .18s; }
.ad:hover { transform: translateY(-2px); box-shadow: 0 16px 34px -22px rgba(22,35,58,.5); }
.ad .tries { margin-left: 8px; font-size: 11px; font-weight: 700; color: var(--slate); background: #F1EEE9; border-radius: 999px; padding: 1px 7px; vertical-align: middle; }
h3.grp { margin: 20px 0 10px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
h3.grp .cnt { font-size: 12px; font-weight: 800; color: #fff; background: var(--teal); border-radius: 999px; padding: 1px 8px; }
h3.grp.needs-post .cnt, h3.grp.rejected .cnt { background: var(--amber); }
h3.grp.judge-fail .cnt, h3.grp.not-generated .cnt { background: var(--slate); }
.ad img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: #eee; }
.ad .body { padding: 10px 12px 12px; }
.ad .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ad .num { font-weight: 800; color: var(--slate); }
.ad .pick { display: flex; align-items: center; gap: 6px; color: var(--teal-deep); font-weight: 700; font-size: 14px; }
.ad .pick input { width: 16px; height: 16px; accent-color: var(--teal); }
.ad .exp { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin: 8px 0 4px; font: 12.5px/1.3 ui-monospace, Menlo, monospace; color: var(--slate); }
.ad .exp input { flex: 1; min-width: 110px; font: inherit; color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; }
.ad .hl { font-weight: 700; margin: 4px 0; }
.ad .meta { font-size: 12.5px; color: var(--slate); }
.ad.needs-post { outline: 2px solid var(--amber); }
.ad.rejected { opacity: .6; }
.empty { padding: 28px; text-align: center; color: var(--slate); border: 1px dashed var(--line); border-radius: var(--radius); }
pre.notes { white-space: pre-wrap; font: 13px/1.5 "Nunito", sans-serif; background: #FBFAF8; border: 1px solid var(--line); border-radius: var(--radius-s); padding: 12px 14px; max-height: 320px; overflow: auto; }

/* toast */
#toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 10px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 92vw;
}
#toast.on { opacity: 1; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login {
  width: 100%; max-width: 380px; background: var(--night); color: var(--moon);
  border-radius: 22px; padding: 30px 28px;
}
.login .wordmark { color: #fff; margin-bottom: 18px; }
.login label { display: block; font-size: 13px; margin: 12px 0 4px; color: rgba(243,233,207,.8); }
.login input { width: 100%; background: rgba(255,255,255,.08); color: #fff; border: 1px solid rgba(255,255,255,.2); border-radius: var(--radius-s); padding: 10px 12px; }
.login .primary { margin: 18px 0 0; width: 100%; }
.login .err { color: #FFB4A8; font-size: 14px; min-height: 1.4em; margin-top: 10px; }
