:root {
  --paper: #f6f3ec;
  --card: #ffffff;
  --ink: #23272a;
  --ink-soft: #6a6558;
  --line: #ddd6c6;
  --accent: #8a6420;
  --accent-ink: #ffffff;
  --accent-soft: #8a642014;
  --ok: #2f6e63;
  --warn: #a6432b;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(35, 39, 42, .05), 0 6px 18px rgba(35, 39, 42, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  padding-bottom: env(safe-area-inset-bottom);
}

.bar {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .7rem 1rem;
  background: var(--ink); color: #f3efe4;
  position: sticky; top: 0; z-index: 5;
}
.bar-title { font-size: .8rem; letter-spacing: .04em; text-transform: uppercase; opacity: .85; }
.team-btn {
  background: rgba(255,255,255,.12); color: #fff; border: 0;
  border-radius: 999px; padding: .3rem .75rem; font-size: .78rem; cursor: pointer;
  font-family: inherit; white-space: nowrap; max-width: 45vw; overflow: hidden; text-overflow: ellipsis;
}
.team-btn:active { background: rgba(255,255,255,.22); }

main { max-width: 640px; margin: 0 auto; padding: 1rem; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.15rem 1.15rem 1.25rem; box-shadow: var(--shadow); margin-bottom: 1rem;
}
.muted-card { text-align: center; color: var(--ink-soft); }
.muted-card p { margin: .4rem 0; }
.waiting-icon { font-size: 2rem; display: block; margin-bottom: .3rem; }

.steps {
  display: flex; gap: .35rem; align-items: center; justify-content: center;
  margin: 0 0 .9rem;
}
.step-dot {
  width: 34px; height: 8px; border-radius: 999px; background: var(--line); border: 0; padding: 0;
  cursor: pointer;
}
.step-dot.done { background: var(--ok); }
/* Completed = the participant has finished with it, whether answered or not.
   Distinguished from "answered" so the two states are not confused. */
.step-dot.complete { background: var(--ink-soft); }
.step-dot.current { background: var(--accent); }
.step-dot.complete.current,
.step-dot.done.current { box-shadow: 0 0 0 2px var(--accent); }

.q-meta { font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: .3rem; }
.q-title { font-size: 1.3rem; line-height: 1.25; margin: 0 0 1rem; font-weight: 650; text-wrap: balance; }
.q-hint { font-size: .84rem; color: var(--ink-soft); margin: -.6rem 0 1rem; }

.opts { display: grid; gap: .55rem; }
.opt {
  display: flex; align-items: center; gap: .7rem; width: 100%;
  padding: .85rem .95rem; font: inherit; text-align: left; cursor: pointer;
  background: var(--card); color: var(--ink);
  border: 1.5px solid var(--line); border-radius: 10px;
}
.opt:active { transform: scale(.995); }
.opt.sel { border-color: var(--accent); background: var(--accent-soft); }
.opt-mark {
  width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--line);
  flex: 0 0 auto; display: grid; place-items: center;
}
.opt.sel .opt-mark { border-color: var(--accent); background: var(--accent); }
.opt.sel .opt-mark::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #fff; }

.grid-rows { display: grid; gap: 1rem; }
.grid-row { border-top: 1px solid var(--line); padding-top: .8rem; }
.grid-row:first-child { border-top: 0; padding-top: 0; }
.grid-label { font-weight: 600; font-size: .98rem; margin-bottom: .5rem; }
.scale {
  display: grid; gap: .35rem;
  grid-template-columns: repeat(auto-fit, minmax(58px, 1fr));
}
.scale.wide { grid-template-columns: 1fr; }
.scale-btn {
  padding: .6rem .4rem; font: inherit; font-size: .86rem; cursor: pointer;
  background: var(--card); color: var(--ink);
  border: 1.5px solid var(--line); border-radius: 8px; text-align: center;
}
.scale.wide .scale-btn { text-align: left; padding-left: .8rem; }
.scale-btn.sel { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }

textarea {
  width: 100%; min-height: 110px; padding: .75rem; font: inherit;
  border: 1.5px solid var(--line); border-radius: 10px; resize: vertical;
  background: var(--card); color: var(--ink);
}
textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.counter { text-align: right; font-size: .78rem; color: var(--ink-soft); margin-top: .3rem; }
.counter.over { color: var(--warn); font-weight: 600; }

.actions { display: flex; gap: .6rem; margin-top: 1.1rem; }
/* long grids: keep Submit reachable without scrolling back down */
.actions.sticky { position: sticky; bottom: 0; background: var(--card); padding: .7rem 0 .3rem; margin-top: .6rem;
  box-shadow: 0 -8px 12px -8px rgba(35,39,42,.18); }
.team-inline { display: grid; gap: .45rem; margin-top: .6rem; }
.opt[aria-pressed="true"], .scale-btn[aria-pressed="true"] { font-weight: 600; }
.btn {
  flex: 1; padding: .85rem 1rem; font: inherit; font-weight: 600; cursor: pointer;
  border-radius: 10px; border: 1.5px solid var(--accent);
  background: var(--accent); color: var(--accent-ink);
}
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--ink-soft); border-color: var(--line); flex: 0 0 auto; padding-inline: 1rem; }
.btn.secondary { background: transparent; color: var(--accent); }
/* "Mark as completed" is a deliberate, secondary action — never competing with
   Submit for attention. */
.btn.subtle {
  background: transparent; color: var(--ink-soft); border-color: transparent;
  font-weight: 500; font-size: .92rem; margin-top: .6rem; width: 100%;
}
.btn.subtle:hover { color: var(--ink); border-color: var(--line); }

/* Locked card shown once a question is marked completed. */
.card.is-complete { background: var(--paper); border-style: dashed; }
.card.is-complete .q-title { color: var(--ink-soft); }
.complete-badge {
  display: inline-block; margin: .1rem 0 .6rem;
  font-size: .8rem; font-weight: 700; letter-spacing: .04em;
  color: var(--ok); background: #2f6e6316;
  padding: .2rem .6rem; border-radius: 999px;
}

.status { display: flex; align-items: center; gap: .5rem; margin-top: .9rem; font-size: .88rem; color: var(--ok); font-weight: 600; }
.status.closed { color: var(--ink-soft); }

.toast {
  position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: .6rem 1rem; border-radius: 999px;
  font-size: .88rem; z-index: 20; max-width: 90vw; text-align: center;
}
.toast.err { background: var(--warn); }

.dialog {
  border: 0; border-radius: var(--radius); padding: 0; max-width: 420px; width: calc(100vw - 2rem);
  box-shadow: 0 12px 40px rgba(0,0,0,.25); color: var(--ink); background: var(--card);
}
.dialog::backdrop { background: rgba(20,20,20,.45); }
.dialog form { padding: 1.2rem; }
.dialog h2 { margin: 0 0 .4rem; font-size: 1.15rem; }
.dialog-note { margin: 0 0 1rem; font-size: .85rem; color: var(--ink-soft); }
.team-list { display: grid; gap: .45rem; max-height: 50vh; overflow-y: auto; }
.dialog-actions { display: flex; justify-content: flex-end; padding: 0; margin: 1rem 0 0; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
