:root {
  --bg: #f5f6f8;
  --card: #fff;
  --text: #1c2330;
  --muted: #6b7482;
  --line: #dfe3e8;
  --accent: #2563eb;
  --danger: #c0392b;
  --ok: #1e8e4e;
  --warn: #b7791f;
}

* { box-sizing: border-box; }

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

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 16px 64px;
}

body.admin main { max-width: 1000px; }

body.centered {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

h1 { font-size: 28px; line-height: 1.25; margin: 0 0 12px; }
h1.hello { font-size: clamp(40px, 9vw, 84px); margin: 0; }
h2 { font-size: 20px; margin: 0 0 16px; }
h3 { font-size: 16px; margin: 0 0 8px; }
a { color: var(--accent); }

.greeting { font-size: 18px; color: var(--muted); margin: 0 0 8px; }
.lead { color: var(--muted); margin: 0 0 24px; }
.muted { color: var(--muted); }
.req, .error { color: var(--danger); }
.error { margin: 8px 0 0; }

section, .question {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
  margin: 0 0 16px;
}

section { margin-top: 24px; }
.question.invalid { border-color: var(--danger); }
.question legend { font-weight: 600; padding: 0 6px; }

.options { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.options label { display: flex; align-items: center; gap: 10px; cursor: pointer; }

.options.scale { flex-direction: row; gap: 8px; }
.options.scale label { flex: 1; position: relative; }
.options.scale input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.options.scale span {
  flex: 1;
  text-align: center;
  padding: 10px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 600;
}
.options.scale input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.options.scale input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.scale-hint { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; margin-top: 4px; }

input[type="text"], textarea, select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: inherit;
  font: inherit;
}
textarea { resize: vertical; }
.question textarea { margin-top: 8px; }

button {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: inherit;
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; padding: 10px 20px; }
button.danger { color: var(--danger); }

form.stack { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; margin-top: 16px; }
form.stack label { width: 100%; font-size: 14px; color: var(--muted); }
form.stack label > input[type="text"], form.stack label > textarea, form.stack label > select { margin-top: 4px; }
form.stack label.inline { width: auto; color: inherit; font-size: inherit; }
#settings form + form { margin-top: 16px; }

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 0 16px;
  display: flex;
  gap: 4px;
}
.topbar a, .tabs a {
  padding: 12px 14px;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
}
.topbar a.active, .tabs a.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); margin: 0 0 20px; }
.tabs a { padding: 8px 12px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 13px; color: var(--muted); font-weight: 600; }
td form { margin: 0; }
td.link { display: flex; gap: 6px; min-width: 320px; }
.scroll { overflow-x: auto; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 13px; background: #eceff3; color: var(--muted); white-space: nowrap; }
.badge.ok { background: #e3f4ea; color: var(--ok); }
.badge.warn { background: #fbf0d9; color: var(--warn); }
a.badge { text-decoration: none; }

.small { font-size: 13px; }
tr.has-sub td { border-bottom: 0; }
tr.sub > td { padding-top: 0; }
tr.sub summary { cursor: pointer; color: var(--accent); font-size: 14px; }
tr.sub table { margin-top: 6px; font-size: 14px; }
tr.sub table td { border: 0; padding: 3px 16px 3px 0; color: var(--muted); }

.summary { padding: 12px 0; border-top: 1px solid var(--line); }
.summary:first-of-type { border-top: 0; padding-top: 0; }
.bars td { border: 0; padding: 3px 10px 3px 0; }
.bars td:first-child { width: 30%; }
.bars td:last-child { width: 40px; text-align: right; }
.bar { background: #eceff3; border-radius: 4px; padding: 0 !important; }
.bar span { display: block; height: 16px; background: var(--accent); border-radius: 4px; }
blockquote { margin: 8px 0; padding: 6px 12px; border-left: 3px solid var(--line); white-space: pre-wrap; }

@media (max-width: 600px) {
  td.link { min-width: 0; flex-direction: column; }
}
