:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #1f2933;
  --muted: #627080;
  --line: #e1e5ea;
  --accent: #2f7d4f;
  --accent-ink: #ffffff;
  --accent-soft: #e6f2ea;
  --danger: #b3261e;
  --warn-soft: #fff6d6;
  --radius: 8px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); }
.wrap { max-width: 920px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 720px; }

header.site { background: var(--card); border-bottom: 1px solid var(--line); }
header.site .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-top: .8rem; padding-bottom: .8rem; flex-wrap: wrap; }
header.site .brand { font-weight: 700; text-decoration: none; color: var(--ink); }
header.site .brand span { color: var(--accent); }
header.site nav { display: flex; gap: 1rem; align-items: center; font-size: .95rem; }
header.site nav form { margin: 0; }
main { padding: 2rem 0 3rem; }
footer.site { color: var(--muted); font-size: .85rem; padding: 2rem 0; border-top: 1px solid var(--line); }

h1 { font-size: 1.7rem; margin: 0 0 .5rem; line-height: 1.25; }
h2 { font-size: 1.25rem; margin: 0 0 .5rem; }
h3 { font-size: 1.05rem; margin: 0 0 .4rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.lede { color: var(--muted); font-size: 1.05rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem 1.5rem; margin-bottom: 1.25rem; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }

.btn, button { display: inline-block; font: inherit; font-size: .95rem; padding: .5rem 1rem; border-radius: 6px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); cursor: pointer; text-decoration: none; line-height: 1.3; }
.btn.secondary, button.secondary { background: var(--card); color: var(--accent); }
.btn.ghost, button.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.danger, button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.small, button.small { padding: .25rem .6rem; font-size: .85rem; }
button.link { background: none; border: 0; color: var(--accent); padding: 0; text-decoration: underline; }
form.inline { display: inline; margin: 0; }

.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--line); color: var(--muted); }
.badge.on { background: var(--accent-soft); color: var(--accent); }
.badge.type { background: #eef1f6; color: #3d4b5c; font-weight: 500; }

.messages { list-style: none; padding: 0; margin: 0 0 1.25rem; }
.messages li { padding: .65rem 1rem; border-radius: 6px; background: var(--accent-soft); margin-bottom: .5rem; }
.messages li.error { background: #fdecea; color: var(--danger); }
.notice { background: var(--warn-soft); border-radius: 6px; padding: .65rem 1rem; margin-bottom: 1.25rem; }

/* Forms */
form.stacked .field { margin-bottom: 1.1rem; }
form.stacked label { display: block; font-weight: 600; margin-bottom: .25rem; }
form.stacked .check label { display: inline; font-weight: 600; }
input[type=text], input[type=number], input[type=url], input[type=password], input[type=email], select, textarea {
  width: 100%; padding: .55rem .65rem; border: 1px solid #c8cfd7; border-radius: 6px; font: inherit; background: #fff; color: var(--ink);
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.helptext { display: block; color: var(--muted); font-size: .85rem; margin-top: .25rem; }
ul.errorlist { list-style: none; margin: 0 0 .35rem; padding: 0; color: var(--danger); font-size: .9rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
@media (max-width: 600px) { .grid2 { grid-template-columns: 1fr; } }
fieldset.group { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem .2rem; margin: 0 0 1.1rem; }
fieldset.group legend { font-weight: 700; padding: 0 .4rem; }

/* Builder */
.survey-row { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; align-items: center; }
.page-block { border-left: 4px solid var(--accent); }
.page-head { display: flex; justify-content: space-between; gap: .75rem; flex-wrap: wrap; align-items: baseline; margin-bottom: .75rem; }
.qcard { border: 1px solid var(--line); border-radius: 6px; padding: .75rem 1rem; margin-bottom: .6rem; background: #fcfdfd; scroll-margin-top: 1rem; }
.qcard:target { outline: 2px solid var(--accent); }
.qcard .qhead { display: flex; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.qcard .code { font-family: ui-monospace, Menlo, monospace; font-weight: 700; margin-right: .4rem; }
.qcard .qtext { margin: .3rem 0 0; }
.qcard .meta { font-size: .82rem; color: var(--muted); margin-top: .3rem; }
.tools { display: flex; gap: .3rem; align-items: center; flex-wrap: wrap; }
.add-q { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-top: .75rem; }
.add-q select { width: auto; flex: 1 1 220px; }
.share { display: flex; gap: .5rem; }
.share input { font-family: ui-monospace, Menlo, monospace; font-size: .85rem; }
.empty { text-align: center; padding: 2rem; color: var(--muted); }

/* Results */
.stats { display: flex; gap: 2.5rem; flex-wrap: wrap; margin: .5rem 0 1rem; }
.stat .num { font-size: 1.9rem; font-weight: 700; line-height: 1.1; }
.stat .label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 30%) 1fr 4.5rem; gap: .6rem; align-items: center; margin: .25rem 0; font-size: .92rem; }
.bar { background: #edf0f3; border-radius: 4px; height: 1.1rem; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); }
.bar-row .n { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.table-scroll { overflow-x: auto; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Participant pages */
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-bottom: 1.5rem; }
.progress span { display: block; height: 100%; background: var(--accent); }
.question { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.3rem; margin-bottom: 1rem; }
.question.has-error { border-color: var(--danger); }
.question[hidden] { display: none; }
.question .prompt { font-weight: 600; margin: 0 0 .2rem; white-space: pre-line; }
.question .req { color: var(--danger); margin-left: .15rem; }
.question .hint { color: var(--muted); font-size: .88rem; margin: 0 0 .6rem; }
.question .error { color: var(--danger); font-size: .9rem; margin: 0 0 .5rem; font-weight: 600; }
.question .info { white-space: pre-line; }
.choices { display: grid; gap: .35rem; margin-top: .5rem; }
.choice { display: flex; gap: .55rem; align-items: flex-start; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; }
.choice:hover { background: var(--bg); }
.choice input { margin-top: .3rem; }
.choices.inline { display: flex; flex-wrap: wrap; }
.scale { margin-top: .6rem; }
.scale-points { display: flex; gap: .35rem; }
.scale-points label { flex: 1; text-align: center; border: 1px solid var(--line); border-radius: 6px; padding: .45rem 0; cursor: pointer; min-width: 2.2rem; }
.scale-points label:hover { background: var(--bg); }
.scale-points input { display: block; margin: 0 auto .2rem; }
.anchors { display: flex; justify-content: space-between; color: var(--muted); font-size: .85rem; margin-top: .3rem; gap: 1rem; }
.anchors span:last-child { text-align: right; }
.slider input[type=range] { width: 100%; accent-color: var(--accent); }
.slider.untouched input[type=range] { opacity: .45; }
.slider .readout { font-size: .85rem; color: var(--muted); }
.matrix th, .matrix td { text-align: center; font-size: .88rem; text-transform: none; letter-spacing: 0; }
.matrix td:first-child, .matrix th:first-child { text-align: left; }
.matrix tbody tr:nth-child(odd) { background: #fafbfc; }
.matrix-wrap { overflow-x: auto; margin-top: .5rem; }
.nav-buttons { display: flex; justify-content: space-between; gap: 1rem; margin-top: 1.5rem; }
.welcome-text { white-space: pre-line; }
.preview-bar { background: #2b3440; color: #fff; text-align: center; padding: .4rem 1rem; font-size: .88rem; }
.preview-bar a { color: #9fe0b8; }
