:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --text: #1c2330;
  --muted: #5d6675;
  --line: #dde1e7;
  --accent: #2f5fd0;
  --accent-soft: #e8eefb;
  --ai: #6b4fbb;
  --ai-soft: #f1edfb;
  --warn: #b3261e;
  --warn-soft: #fdeceb;
  --red: #d64541;
  --blue: #2f6fde;
  --green: #2e9d5b;
  --yellow: #e2b100;
  --radius: 10px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .9em; }
button, .button {
  font: inherit;
  cursor: pointer;
  border: 0;
  border-radius: 8px;
  padding: .65em 1.2em;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  display: inline-block;
}
button:disabled { opacity: .45; cursor: not-allowed; }
.button.secondary, button.secondary { background: var(--ai); }
input, textarea {
  font: inherit;
  width: 100%;
  padding: .55em .7em;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
.badge { font-size: .85rem; padding: .25em .8em; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.badge.with_ai { background: var(--ai-soft); color: var(--ai); }
.pilot { background: #fff4d6; color: #6b4d00; text-align: center; padding: 6px 16px; font-size: .9rem; }
main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 40px; }
.footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 0 16px 24px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
}
.narrow { max-width: 680px; margin-left: auto; margin-right: auto; }
.center { text-align: center; }
.muted { color: var(--muted); font-size: .9rem; }
.link-row { display: flex; gap: 12px; flex-wrap: wrap; }
.error { color: var(--warn); background: var(--warn-soft); padding: .6em .8em; border-radius: 8px; }

/* Instructions */
.intro { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; align-items: start; }
.rules { border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin-bottom: 1em; transition: background .3s; }
.rules.highlight { background: #fff8e1; border-color: #e2b100; }
.rules dl { margin: 0; }
.rules dt { font-weight: 700; margin-top: .6em; }
.rules dd { margin: 0 0 0 0; color: var(--text); }
.eg { color: var(--muted); font-style: italic; }
.ai-explain { background: var(--ai-soft); border-radius: 8px; padding: 14px 16px; margin-bottom: 1em; }
.field { display: block; font-weight: 600; margin-bottom: 1em; }
.field input, .field textarea { margin-top: .3em; font-weight: 400; }
.field small { display: block; font-weight: 400; color: var(--muted); margin-top: .3em; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px; margin: 0 0 1em; }
legend { font-weight: 600; padding: 0 .3em; }
.quiz p { margin: .6em 0 .3em; }
.radio { display: inline-flex; gap: .4em; align-items: center; margin-right: 1.2em; }
.radio input, .consent input { width: auto; }
.consent { display: flex; gap: .6em; align-items: flex-start; font-size: .92rem; margin-bottom: 1em; }
.consent input { margin-top: .3em; }

/* Card chips */
.chip { display: inline-flex; align-items: center; gap: .35em; font-size: .88rem; white-space: nowrap; }
.chip i { width: .8em; height: 1.1em; border-radius: 2px; display: inline-block; }
.chip.red i { background: var(--red); }
.chip.blue i { background: var(--blue); }
.chip.green i { background: var(--green); }
.chip.yellow i { background: var(--yellow); }
.chip.big { font-size: 1em; font-weight: 700; padding: .05em .45em; border: 1px solid var(--line); border-radius: 6px; }
.holder { display: inline-flex; align-items: center; gap: .45em; }
.holder b { font-weight: 600; font-size: .9rem; }

/* Trial */
.progress-head { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; color: var(--muted); font-size: .9rem; }
.progress { flex: 1; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.progress div { height: 100%; background: var(--accent); }
.question { font-size: 1.3rem; }
.label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; margin: 1.2em 0 .5em; display: flex; justify-content: space-between; gap: 12px; }
.ai-col-label { color: var(--ai); text-transform: none; letter-spacing: 0; font-size: .85rem; }
.start-state { display: flex; flex-wrap: wrap; gap: 10px 24px; padding: 10px 14px; background: var(--bg); border-radius: 8px; }
.events { list-style: none; margin: 0; padding: 0; }
.events li {
  display: grid;
  grid-template-columns: 2em 1fr;
  gap: 4px 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.events.with-ai li { grid-template-columns: 2em minmax(0, 1fr) minmax(0, 1.05fr) auto; }
.events li:last-child { border-bottom: 0; }
.num { width: 1.8em; height: 1.8em; border-radius: 50%; background: var(--bg); display: grid; place-items: center; font-size: .85rem; font-weight: 600; }
.event-text { margin: 0; }
.ai-state { display: flex; flex-wrap: wrap; gap: 4px 12px; background: var(--ai-soft); border-radius: 8px; padding: 6px 10px; }
.ai-state .holder.changed { outline: 2px solid var(--ai); outline-offset: 1px; border-radius: 4px; padding: 0 3px; }
.flag { background: transparent; color: var(--muted); border: 1px solid var(--line); padding: .3em .6em; font-size: .8rem; }
.flag[aria-pressed="true"] { background: var(--warn); border-color: var(--warn); color: #fff; }
.events li.flagged .ai-state { background: var(--warn-soft); }
.ai-answer { margin-top: 16px; padding: 14px 16px; background: var(--ai-soft); border-left: 4px solid var(--ai); border-radius: 8px; display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: baseline; }
.ai-answer span { color: var(--ai); font-weight: 600; font-size: .9rem; }
.ai-answer strong { font-size: 1.15rem; }
.ai-answer small { color: var(--muted); flex-basis: 100%; }

.choices { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.choice { background: #fff; color: var(--text); border: 2px solid var(--line); text-align: left; display: flex; gap: .6em; align-items: center; }
.choice span { font-weight: 700; color: var(--muted); }
.choice[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.scale { display: flex; gap: 8px; }
.scale button { flex: 1; max-width: 64px; background: #fff; color: var(--text); border: 2px solid var(--line); padding: .5em 0; }
.scale button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: #fff; }
.scale-ends { display: flex; justify-content: space-between; color: var(--muted); font-size: .8rem; margin: .3em 0 1em; }
.scale:not(.seven) + .scale-ends { max-width: 360px; }
.seven + .scale-ends { max-width: 500px; }
.likert { border: 0; padding: 0; margin-bottom: .6em; }
.likert legend { padding: 0; margin-bottom: .4em; font-weight: 500; }
#submit, #finish { margin-top: 4px; }
.check { width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 50%; background: #e3f4ea; color: var(--green); display: grid; place-items: center; font-size: 1.6rem; }

@media (max-width: 860px) {
  .intro { grid-template-columns: 1fr; }
  .events.with-ai li { grid-template-columns: 2em minmax(0, 1fr) auto; }
  .events.with-ai .ai-state { grid-column: 2 / 3; }
  .events.with-ai .flag { grid-column: 3; grid-row: 2; align-self: center; }
  .choices { grid-template-columns: repeat(2, 1fr); }
  .label { flex-direction: column; gap: 2px; }
}
@media (max-width: 520px) {
  .panel { padding: 16px; }
  .topbar { padding: 10px 16px; }
}

.condition-banner { text-align: center; font-size: 1.15rem; font-weight: 700; padding: 10px 16px; background: var(--accent-soft); color: var(--accent); }
.condition-banner.with_ai { background: var(--ai-soft); color: var(--ai); }
#change-uniqname { color: var(--accent); }
