:root {
  --bg: #f7f4f2;
  --surface: #ffffff;
  --ink: #2b2a33;
  --muted: #6b6875;
  --line: #e4dfdb;
  --accent: #b5476b;
  --accent-ink: #ffffff;
  --accent-soft: #f8e7ed;
  --ok: #2f7d5b;
  --danger: #b3261e;
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); line-height: 1.45; }
main { max-width: 860px; margin: 0 auto; padding: 24px 16px 80px; }
h1 { font-size: 1.6rem; margin: 0 0 4px; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
p { margin: 0 0 12px; }
a { color: var(--accent); }
.muted { color: var(--muted); font-size: 0.92rem; }
.hidden { display: none !important; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1 1 200px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.card.narrow { max-width: 380px; margin: 60px auto; }

label.field { display: block; font-weight: 600; font-size: 0.92rem; margin: 10px 0 4px; }
input[type=text], input[type=password], input[type=number], input[type=date], textarea, select {
  width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
}
textarea { min-height: 90px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }

button, .button {
  font: inherit; font-weight: 600; border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 9px 14px; border-radius: 8px; cursor: pointer; text-decoration: none; display: inline-block;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.danger { color: var(--danger); }
.small { padding: 5px 9px; font-size: 0.85rem; }
button:disabled { opacity: 0.55; cursor: default; }

.badge { display: inline-block; font-size: 0.78rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--line); }
.badge.on { background: #dff1e8; color: var(--ok); }

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table-wrap { overflow-x: auto; }

.question-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.question-number { font-weight: 800; color: var(--accent); min-width: 34px; }
.question-head select { width: auto; flex: 1 1 180px; }
.option-row { display: flex; gap: 6px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.option-row input { flex: 2 1 180px; }
.option-row select { flex: 1 1 160px; width: auto; }
.jump { background: var(--accent-soft); border-radius: 8px; padding: 8px 10px; margin-top: 10px; }
.jump select { margin-top: 4px; }

.link-box { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: var(--accent-soft); padding: 10px; border-radius: 8px; margin-top: 10px; }
.link-box code { flex: 1 1 220px; word-break: break-all; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 10; }
.error { color: var(--danger); font-weight: 600; }

/* Help dialog */
.help-button { background: var(--accent-soft); border-color: var(--accent-soft); color: var(--accent); }
dialog#help { width: min(720px, calc(100vw - 24px)); max-height: calc(100vh - 40px); border: 0; border-radius: var(--radius); padding: 18px; color: var(--ink); }
dialog#help::backdrop { background: rgb(43 42 51 / 0.45); }
.help-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; position: sticky; top: -18px; background: #fff; padding: 4px 0 8px; }
.help-head h2 { margin: 0; }
dialog#help details { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; padding: 0 12px; }
dialog#help details[open] { border-color: var(--accent); }
dialog#help summary { cursor: pointer; font-weight: 700; padding: 12px 0; }
dialog#help ol, dialog#help ul { padding-left: 20px; margin: 0 0 12px; }
dialog#help li { margin-bottom: 6px; }
dialog#help table { margin-bottom: 10px; }

/* Public form */
.form-question { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.form-question.invalid { border-color: var(--danger); }
.form-question .title { font-weight: 700; margin-bottom: 4px; }
.form-question .required { color: var(--danger); }
.choice { display: flex; gap: 10px; align-items: center; padding: 8px 4px; cursor: pointer; }
.choice input { width: 20px; height: 20px; accent-color: var(--accent); }
.privacy { border: 2px solid var(--accent); background: var(--accent-soft); }
.privacy .muted { color: var(--ink); }
.choice.consent { align-items: flex-start; font-weight: 600; }
.choice.consent input { flex: 0 0 auto; margin-top: 2px; }
.submit-bar { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; }
.submit-bar button { width: 100%; padding: 14px; font-size: 1.05rem; }
