:root {
  --bg: #f6f3ee;
  --card: #ffffff;
  --ink: #1f2328;
  --muted: #5d6672;
  --line: #e5e0d6;
  --red: #9c1c2b;
  --red-dark: #7d1421;
  --gold: #b59a5f;
  --ok: #2f7d4f;
  --sage: #e7ecea;
  --sage-ink: #4f6f63;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}

[hidden] { display: none !important; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }

/* ---------- Header ---------- */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 28px 0 8px;
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand img { height: 44px; width: auto; display: block; }
.brand .t1 { font-weight: 700; font-size: 1.05rem; line-height: 1.2; }
.brand .t2 { font-size: 0.85rem; color: var(--muted); }

.by { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.by a { text-decoration: none; }
.by .neurvana { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.9rem; font-weight: 500; }
.by .neurvana:hover { color: var(--ink); }
.by .neurvana img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.by .connect {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--sage);
  color: var(--sage-ink);
}
.by .connect:hover { background: #d9e2df; }

/* ---------- Hero ---------- */

.hero { padding: 28px 0 8px; max-width: 720px; }
.hero h1 { margin: 0 0 8px; font-size: clamp(1.7rem, 4vw, 2.4rem); line-height: 1.15; letter-spacing: -0.01em; }
.hero p { margin: 0; color: var(--muted); font-size: 1.05rem; }

/* ---------- Cards ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
}

.composer {
  margin-top: 24px;
  display: grid;
  grid-template-columns: minmax(0, 340px) minmax(0, 1fr);
  gap: 28px;
}

/* ---------- Drop zone ---------- */

.drop {
  position: relative;
  border: 2px dashed #cfc7b6;
  border-radius: 14px;
  background: #faf8f4;
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  overflow: hidden;
}

.drop:hover, .drop.is-over { border-color: var(--red); background: #fdf6f6; }
.drop:focus-visible { outline: 3px solid rgba(156, 28, 43, 0.35); outline-offset: 2px; }
.drop.has-image { border-style: solid; border-color: var(--line); padding: 0; background: #111; }

.drop .prompt strong { display: block; font-size: 1rem; margin-bottom: 4px; }
.drop .prompt span { color: var(--muted); font-size: 0.9rem; }
.drop .prompt svg { width: 40px; height: 40px; color: var(--gold); margin-bottom: 10px; }

.drop img.preview { display: block; width: 100%; height: 100%; max-height: 420px; object-fit: contain; }

.drop .swap {
  position: absolute;
  right: 10px;
  top: 10px;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  border: 0;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  cursor: pointer;
}

.error { color: #b3261e; font-size: 0.9rem; margin: 8px 0 0; }

/* ---------- Form ---------- */

form { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.field label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 6px; }
.field .hint { font-weight: 400; color: var(--muted); }

input[type="text"], textarea {
  width: 100%;
  font: inherit;
  font-size: 16px; /* prevents iOS zoom on focus */
  color: var(--ink);
  background: #fff;
  border: 1px solid #d5cfc3;
  border-radius: 10px;
  padding: 10px 12px;
}

textarea { resize: vertical; min-height: 110px; }

input[type="text"]:focus, textarea:focus {
  outline: 3px solid rgba(156, 28, 43, 0.22);
  border-color: var(--red);
}

.actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 4px; }

.btn {
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: 12px;
  padding: 12px 22px;
  cursor: pointer;
  background: var(--red);
  color: #fff;
  transition: background 0.15s;
}

.btn:hover:not(:disabled) { background: var(--red-dark); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.note { color: var(--muted); font-size: 0.82rem; margin: 0; }

.linkbtn {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--red);
  background: none;
  border: 0;
  padding: 4px 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.linkbtn:hover { color: var(--red-dark); }

/* ---------- Progress ---------- */

.progress { margin-top: 24px; }
.progress h2 { margin: 0 0 12px; font-size: 1.05rem; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.steps li { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 0.95rem; }
.steps li .dot {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid #d5cfc3;
  display: inline-flex; align-items: center; justify-content: center;
  flex: none;
  font-size: 11px; line-height: 1; color: #fff;
}
.steps li.is-active { color: var(--ink); font-weight: 600; }
.steps li.is-active .dot { border-color: var(--red); border-top-color: transparent; animation: spin 0.8s linear infinite; }
.steps li.is-done { color: var(--ink); }
.steps li.is-done .dot { background: var(--ok); border-color: var(--ok); }

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Results ---------- */

.results { margin-top: 28px; }
.results-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.results-head h2 { margin: 0; font-size: 1.3rem; }
.results-head p { margin: 0; color: var(--muted); font-size: 0.9rem; }

.grid {
  display: grid;
  gap: 20px;
  align-items: start;
}

/* Only the channels that were chosen get a card, so the grid adapts to 1-3. */
.grid[data-count="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid[data-count="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid[data-count="1"] { grid-template-columns: minmax(0, 1fr); max-width: 520px; margin: 0 auto; }

.result { padding: 16px; animation: rise 0.45s ease both; }
.result:nth-child(2) { animation-delay: 0.08s; }
.result:nth-child(3) { animation-delay: 0.16s; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.result header { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.result h3 { margin: 0; font-size: 1rem; }
.result .tag { color: var(--muted); font-size: 0.8rem; }

.frame {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #111;
  cursor: zoom-in;
}

.frame canvas { display: block; width: 100%; height: auto; }

.ring {
  position: absolute;
  border: 2px solid #f0c24a;
  border-radius: 6px;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35), 0 0 18px rgba(240, 194, 74, 0.55);
  pointer-events: none;
  animation: pulse 1.6s ease-out 0.5s 2;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35), 0 0 0 0 rgba(240, 194, 74, 0.7); }
  100% { box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35), 0 0 0 16px rgba(240, 194, 74, 0); }
}

.result footer { display: flex; justify-content: space-between; gap: 12px; margin-top: 10px; }

/* ---------- Stepper, roles, banner ---------- */

.stepper {
  list-style: none;
  margin: 24px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.stepper li {
  flex: 1 1 0;
  min-width: 170px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.stepper .num {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  flex: none;
  background: #ece7db;
  color: var(--muted);
  font-size: 0.8rem;
}

.stepper li.is-active { border-color: var(--red); color: var(--ink); }
.stepper li.is-active .num { background: var(--red); color: #fff; }
.stepper li.is-done { color: var(--ink); }
.stepper li.is-done .num { background: var(--ok); color: #fff; }

.role {
  margin: 24px 0 8px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.stage .composer { margin-top: 0; }

.banner {
  margin-top: 24px;
  background: #fff8e6;
  border: 1px solid #f0d58a;
  border-radius: 12px;
  padding: 12px 16px;
  color: #5c4710;
  font-size: 0.92rem;
}

.banner strong { display: block; }
.banner .banner-hint { display: block; margin-top: 2px; opacity: 0.85; }
.banner + .role { margin-top: 16px; }

/* ---------- Channel checkboxes ---------- */

.channels { border: 0; padding: 0; margin: 0; min-width: 0; }
.channels legend { font-weight: 600; font-size: 0.9rem; margin-bottom: 8px; padding: 0; }
.chan-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }

.chan { position: relative; display: block; cursor: pointer; }

.chan input {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  margin: 0; opacity: 0; cursor: pointer;
}

.chan-box {
  display: flex; align-items: center; gap: 10px;
  height: 100%;
  padding: 10px 12px;
  background: #fff;
  border: 1.5px solid #d5cfc3;
  border-radius: 12px;
  transition: border-color 0.15s, background 0.15s;
}

.chan-box > span:last-child { min-width: 0; }
.chan-box strong { display: block; font-size: 0.92rem; line-height: 1.2; }
.chan-box small { display: block; color: var(--muted); font-size: 0.75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chan .tick {
  width: 20px; height: 20px;
  flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid #c9c2b3;
  border-radius: 6px;
  color: transparent;
  font-size: 13px; line-height: 1;
}

.chan input:checked + .chan-box { border-color: var(--red); background: #fdf6f6; }
.chan input:checked + .chan-box .tick { background: var(--red); border-color: var(--red); color: #fff; }
.chan input:focus-visible + .chan-box { outline: 3px solid rgba(156, 28, 43, 0.35); outline-offset: 2px; }

.chips { display: inline-flex; flex-wrap: wrap; gap: 6px; }

.chip {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: #f1ece2;
  border: 1px solid var(--line);
  color: #4a4335;
}

/* ---------- Submitted ---------- */

.submitted { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 22px; }
.submitted .thumb { width: 120px; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); flex: none; }
.sub-body { flex: 1 1 320px; min-width: 0; }
.sub-body h2 { margin: 0 0 4px; font-size: 1.5rem; }
.sub-body .lead { margin: 0 0 14px; color: var(--muted); }
.sub-body .note { margin-top: 10px; }

dl.facts { margin: 0; display: grid; gap: 14px; }
dl.facts dt { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: 3px; }
dl.facts dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
dl.facts.compact { gap: 10px; margin-bottom: 4px; }

/* ---------- Commander admin screen ---------- */

.admin {
  border: 1px solid #2b323b;
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 8px 30px rgba(20, 24, 30, 0.12);
}

.admin-bar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px;
  padding: 12px 18px;
  background: #1f2933;
  color: #e9edf1;
  font-size: 0.88rem;
}

.admin-bar .who { color: #aab4bf; }

.admin-body { display: grid; grid-template-columns: 260px minmax(0, 1fr); }

.queue { background: #f4f1ea; border-right: 1px solid var(--line); padding: 18px; }

.queue h3 {
  display: flex; justify-content: space-between; align-items: center;
  margin: 0 0 12px;
  font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted);
}

.queue .count { background: var(--red); color: #fff; border-radius: 999px; padding: 1px 8px; font-size: 0.72rem; }

.q-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px;
  background: #fff;
  border: 1.5px solid var(--red);
  border-radius: 10px;
}

.q-item img { width: 44px; height: 56px; object-fit: cover; border-radius: 6px; flex: none; }
.q-item .qt { font-weight: 600; font-size: 0.9rem; line-height: 1.25; overflow-wrap: anywhere; }
.q-item .qs { font-size: 0.75rem; color: var(--muted); }

.detail { padding: 22px 24px; min-width: 0; }
.detail h2 { margin: 0; font-size: 1.35rem; }
.detail .meta { margin: 2px 0 18px; color: var(--muted); font-size: 0.85rem; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 220px) minmax(0, 1fr); gap: 22px; }
.detail-grid img { display: block; width: 100%; border-radius: 10px; border: 1px solid var(--line); }
.decision { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.decision textarea { min-height: 64px; }

.btn.secondary { background: #fff; color: var(--ink); border: 1px solid #cfc7b6; }
.btn.secondary:hover:not(:disabled) { background: #f6f3ee; }

/* ---------- Published: sub-heading and activity log ---------- */

.results-sub { margin: -4px 0 14px; color: var(--muted); font-size: 0.9rem; }
.log { margin-top: 24px; }
.log h3 { margin: 0 0 12px; font-size: 1rem; }
.timeline { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 10px; }
.timeline li { display: flex; align-items: baseline; gap: 14px; font-size: 0.92rem; }
.timeline time { min-width: 92px; color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }

/* ---------- Caveat, footer, lightbox ---------- */

.caveat {
  margin-top: 28px;
  background: #efeae0;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 20px;
}

.caveat h4 { margin: 0 0 6px; font-size: 0.9rem; }
.caveat p { margin: 0; color: var(--muted); font-size: 0.88rem; }

.foot { padding: 32px 0 40px; text-align: center; color: var(--muted); font-size: 0.8rem; }

dialog {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: 96vw;
  max-height: 96vh;
  overflow: visible;
}

dialog::backdrop { background: rgba(10, 12, 16, 0.78); }
dialog img { display: block; max-width: 96vw; max-height: 90vh; border-radius: 10px; }
dialog .close {
  position: absolute; top: -14px; right: -14px;
  width: 34px; height: 34px; border-radius: 50%;
  border: 0; background: #fff; color: var(--ink);
  font-size: 20px; line-height: 1; cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* ---------- Responsive ---------- */

@media (max-width: 1000px) {
  .grid[data-count="3"] { grid-template-columns: 1fr; max-width: 520px; margin: 0 auto; }
}

@media (max-width: 860px) {
  .admin-body { grid-template-columns: 1fr; }
  .queue { border-right: 0; border-bottom: 1px solid var(--line); }
}

@media (max-width: 760px) {
  .composer { grid-template-columns: 1fr; padding: 16px; }
  .drop { min-height: 220px; }
  .by { align-items: flex-start; }
  .grid[data-count="2"] { grid-template-columns: 1fr; max-width: 520px; margin: 0 auto; }
  .chan-list { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-grid img { max-width: 260px; }
  .stepper li { flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .result { animation: none; }
  .ring { animation: none; }
  .steps li.is-active .dot { animation: none; }
}

[tabindex="-1"]:focus { outline: none; }
