:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --ink: #18212f;
  --muted: #5d6879;
  --line: #dde2ea;
  --accent: #2456d6;
  --accent-ink: #ffffff;
  --accent-soft: #e8eefc;
  --ok: #157a4a;
  --ok-soft: #e3f5ec;
  --warn: #9a5b00;
  --warn-soft: #fdf1dc;
  --bad: #b42318;
  --bad-soft: #fde8e7;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  font-size: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.55;
}
a { color: var(--accent); }
h1 { font-size: 1.45rem; margin: 0 0 .75rem; }
h2 { font-size: 1.1rem; margin: 1.25rem 0 .6rem; }
h3 { font-size: 1.1rem; margin: 0 0 .6rem; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }

/* layout */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: .75rem 1.25rem; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .75rem; }
.logo { height: 40px; width: auto; }
.logo.preview { height: 56px; }
.logo-mark {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; letter-spacing: .02em;
}
.brand-title { font-weight: 650; }
.brand-sub { color: var(--muted); font-size: .85rem; }
.wrap { max-width: 820px; margin: 1.25rem auto 3rem; padding: 0 1rem; }
body.admin .wrap { max-width: 1280px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.25rem 1.4rem; margin-bottom: 1rem;
}
.card.narrow { max-width: 420px; margin: 2rem auto; }
.stack > * + * { margin-top: .9rem; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }
.prose p { margin: .5rem 0; }
.note { background: var(--accent-soft); border-radius: 10px; padding: .75rem 1rem; }
.fine { color: var(--muted); font-size: .85rem; }
.muted, tr.muted td { color: var(--muted); }
.bad { color: var(--bad); }

/* forms */
.field { display: flex; flex-direction: column; gap: .35rem; }
.field > span { font-weight: 550; font-size: .95rem; }
input[type=text], input[type=number], input[type=email], input[type=password], input:not([type]), select, textarea {
  font: inherit; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
  width: 100%;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.check { display: flex; gap: .6rem; align-items: flex-start; cursor: pointer; }
.check input { margin-top: .3rem; width: 1.05rem; height: 1.05rem; }
fieldset.item { border: 1px solid var(--line); border-radius: 10px; padding: .8rem 1rem 1rem; margin: 0 0 .9rem; }
fieldset.item legend { font-weight: 550; padding: 0 .3rem; }
fieldset.item.missing { border-color: var(--bad); background: var(--bad-soft); }

.btn {
  display: inline-block; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  padding: .6rem 1.1rem; border-radius: 9px; border: 1px solid var(--line); background: #fff; color: var(--ink);
}
.btn:hover { border-color: #b9c2d0; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; padding: .85rem; font-size: 1.05rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn-row { display: flex; gap: .6rem; flex-wrap: wrap; }
.linklike { background: none; border: none; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; }
.linklike.bad { color: var(--bad); }
form.inline { display: inline; }

.alert { background: var(--bad-soft); color: var(--bad); border-radius: 9px; padding: .65rem .9rem; font-weight: 500; }
.alert.info { background: var(--accent-soft); color: var(--accent); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert ul { margin: 0; padding-left: 1.1rem; }

/* trial */
.progress-wrap { display: flex; align-items: center; gap: .6rem; color: var(--muted); font-size: .9rem; }
progress { width: 140px; height: 8px; accent-color: var(--accent); }
.briefing { border-top: 4px solid var(--accent); }
.source { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .9rem; padding-bottom: .8rem; border-bottom: 1px dashed var(--line); }
.source-label { color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; }
.source-badge { font-weight: 650; padding: .2rem .65rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.source-desc { color: var(--muted); font-size: .9rem; }
.briefing-body ul { padding-left: 1.2rem; }
.briefing-body li { margin: .2rem 0; }
.timer { text-align: right; color: var(--muted); margin: -.25rem 0 .75rem; font-size: .9rem; }
.timer.urgent { color: var(--bad); font-weight: 600; }
.q h2 { margin-top: 0; display: flex; gap: .5rem; align-items: baseline; }
.qnum { display: inline-grid; place-items: center; min-width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--accent); color: #fff; font-size: .85rem; }
.choices { display: flex; flex-wrap: wrap; gap: .5rem; }
.choices.vertical { flex-direction: column; }
.pill { display: flex; align-items: center; gap: .55rem; border: 1px solid var(--line); border-radius: 10px; padding: .6rem .8rem; cursor: pointer; background: #fff; }
.pill:hover { border-color: #b9c2d0; }
.pill:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.pill.muted span { color: var(--muted); font-style: italic; }
.likert { display: grid; grid-template-columns: repeat(7, 1fr); gap: .4rem; }
.likert.count { grid-template-columns: repeat(auto-fill, minmax(2.6rem, 1fr)); }
.likert-opt { display: grid; place-items: center; border: 1px solid var(--line); border-radius: 9px; padding: .55rem 0; cursor: pointer; background: #fff; font-weight: 600; }
.likert-opt input { position: absolute; opacity: 0; pointer-events: none; }
.likert-opt:has(input:checked) { background: var(--accent); color: #fff; border-color: var(--accent); }
.likert-opt:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.likert-ends { display: flex; justify-content: space-between; color: var(--muted); font-size: .8rem; margin-top: .35rem; gap: 1rem; }
.wait-msg { text-align: center; color: var(--muted); }
body.no-copy .briefing { user-select: none; -webkit-user-select: none; }
.debrief-list li { margin-bottom: .6rem; }

/* admin */
.admin-nav { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; font-size: .95rem; }
.admin-nav a { text-decoration: none; font-weight: 550; }
.table-scroll { overflow-x: auto; }
table.data { border-collapse: collapse; width: 100%; font-size: .9rem; }
table.data th, table.data td { text-align: left; padding: .5rem .55rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th { font-weight: 600; color: var(--muted); white-space: nowrap; }
.sd { color: var(--muted); font-size: .8em; white-space: nowrap; }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip { display: inline-block; font-size: .78rem; padding: .12rem .55rem; border-radius: 999px; background: #eef1f6; color: var(--muted); text-decoration: none; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.actions { white-space: nowrap; }
.cond-form { display: grid; grid-template-columns: 1fr 2fr 2fr 2fr 2fr 1fr auto auto; gap: .6rem; align-items: end; padding: .8rem 0; border-bottom: 1px solid var(--line); }
@media (max-width: 900px) { .cond-form { grid-template-columns: 1fr 1fr; } }
.text-row textarea { min-height: 2.6rem; }
pre.default { white-space: pre-wrap; background: #f6f7f9; padding: .5rem; border-radius: 6px; font-size: .8rem; }
.danger-zone { border-color: #f3c3bf; }
.lang-switch { display: flex; gap: .4rem; justify-content: flex-end; margin-bottom: .5rem; }
.lang-switch .chip { font-size: .85rem; padding: .2rem .7rem; }
.side-by-side { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 900px) { .side-by-side { grid-template-columns: 1fr; } }
.side-by-side h3.col { margin: 0 0 .4rem; font-size: .95rem; color: var(--muted); }
