:root {
  color-scheme: light dark;
  --bg: #eef1ef;
  --card: #ffffff;
  --line: #dadfdc;
  --text: #1d2320;
  --muted: #5f6a64;
  --accent: #34bbe6;
  --accent-hover: #22a6d0;
  --accent-soft: #e3f5fc;
  --accent-text: #0b78a0; /* darker shade for text on light backgrounds */
  --on-accent: #062431;
  --discord: #5865f2;
  --discord-hover: #4752c4;
  --danger: #c5362c;
  --field-bg: #f8faf9;
  --field-border: #87928c;
  --field-border-hover: #4f5954;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1211;
    --card: #181c1a;
    --line: #2b312e;
    --text: #eef2ef;
    --muted: #9aa59f;
    --accent: #34bbe6;
    --accent-hover: #5fcbee;
    --accent-soft: #11303c;
    --accent-text: #34bbe6;
    --danger: #ff8b82;
    --field-bg: #111513;
    --field-border: #5f6a65;
    --field-border-hover: #95a09a;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { background: var(--bg); }

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

.form-wrap {
  width: min(640px, 100% - 32px);
  margin: 32px auto 48px;
  display: grid;
  gap: 12px;
}

#acceptance-form { display: grid; gap: 12px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
}

.title-card {
  border-top: 8px solid var(--accent);
  padding-top: 20px;
}

.title-card h1 {
  margin: 0 0 6px;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -.01em;
}

.title-card p { margin: 0; color: var(--muted); }

.required-hint {
  margin-top: 14px !important;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

.req { color: var(--danger); }

.question { transition: border-color .15s; }
.question:focus-within { border-left: 4px solid var(--accent); padding-left: 21px; }
.question.has-error { border-color: var(--danger); }
.question.has-error:focus-within { border-left-color: var(--danger); }

.q-title {
  display: block;
  margin: 0 0 14px;
  font-size: 16px;
  font-weight: 500;
}

.q-error {
  margin: 10px 0 0;
  color: var(--danger);
  font-size: 13px;
}
.q-error:empty { display: none; }

/* Input field: container, leading icon, input, trailing icon, helper/error text */
.field {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 300px;
  height: 46px;
  padding: 0 6px 0 12px;
  border: 1px solid var(--field-border);
  border-radius: 8px;
  background: var(--field-bg);
  transition: border-color .15s, box-shadow .15s;
}
.field:hover { border-color: var(--field-border-hover); }
.field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.has-error .field,
.has-error .field:hover { border-color: var(--danger); }
.has-error .field:focus-within { box-shadow: 0 0 0 1px var(--danger); }
.field:has(input:disabled) { opacity: .6; border-style: dashed; }

.field svg { width: 20px; height: 20px; flex: none; fill: currentColor; }
.field-icon { color: var(--muted); }
.field:focus-within .field-icon { color: var(--accent); }
.has-error .field-icon { color: var(--danger); }
.field-valid { display: none; color: var(--accent-text); margin-right: 6px; }
.field.is-valid .field-valid { display: block; }

.field input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 16px; /* no iOS zoom on focus */
  caret-color: var(--accent);
  outline: none;
}
.field input:disabled { cursor: not-allowed; }

.field-clear {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.field-clear:hover { background: var(--line); color: var(--text); }
.field-clear:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.field-help {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

/* Multi-line variant: same container, label, helper and error text */
.field-area {
  max-width: none;
  height: auto;
  padding: 0;
  align-items: stretch;
}
.field-area textarea {
  flex: 1;
  min-height: 112px;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 16px;
  line-height: 1.5;
  caret-color: var(--accent);
  resize: vertical;
  outline: none;
}
.field:has(textarea:disabled) { opacity: .6; border-style: dashed; }
.field-foot {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.field-count {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.has-error .field-help { color: var(--danger); }

.rules-meta { margin: -8px 0 14px; }

.rules-sections {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.rules-sections details + details { border-top: 1px solid var(--line); }

.rules-sections summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  font-weight: 500;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.rules-sections summary::-webkit-details-marker { display: none; }
.rules-sections summary:hover { background: var(--accent-soft); }
.rules-sections summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.rules-sections summary > span:first-child { margin-right: auto; }
.rules-sections summary::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  margin-top: -4px;
  transform: rotate(45deg);
  transition: transform .15s, margin .15s;
  flex: none;
}
.rules-sections details[open] summary::after { margin-top: 4px; transform: rotate(-135deg); }
.rules-sections details[open] summary { border-bottom: 1px solid var(--line); }

.rules-count { color: var(--muted); font-size: 13px; font-weight: 400; }

.rules-scope {
  margin: 12px 14px 0;
  color: var(--muted);
  font-size: 13px;
  font-style: italic;
}

.rules {
  margin: 0;
  padding: 4px 14px 8px;
}
.rules > div { padding: 10px 0; }
.rules > div + div { border-top: 1px dashed var(--line); }
.rules dt { font-weight: 600; font-size: 14px; }
.rules dd { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.rules code, .channel {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 13px;
}
.rules code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }

.rules-note {
  margin: 12px 0 16px;
  color: var(--muted);
  font-size: 13px;
}

.check-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  cursor: pointer;
}
.check-row input {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  flex: none;
  accent-color: var(--accent);
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 22px;
  border: 0;
  border-radius: 6px;
  color: #fff;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s;
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; pointer-events: none; }
.btn:focus-visible, .btn-text:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-discord { background: var(--discord); }
.btn-discord:hover { background: var(--discord-hover); }

.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }

.btn-text {
  padding: 8px 4px;
  border: 0;
  background: none;
  color: var(--accent-text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
.btn-text { text-decoration: none; }
.btn-text:hover { text-decoration: underline; }

.user-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--line);
  flex: none;
}
.user-text { display: grid; min-width: 0; margin-right: auto; }
.user-text strong, .user-text span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-text span { color: var(--muted); font-size: 13px; }

.form-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-top: 4px;
}

.form-status { margin: 0; font-size: 14px; }
.form-status:empty { display: none; }
.form-status.error { color: var(--danger); }

.footnote {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

@media (max-width: 480px) {
  .form-wrap { margin-top: 16px; }
  .card { padding: 18px; }
  .question:focus-within { padding-left: 15px; }
  .title-card h1 { font-size: 24px; }
}

/* Reading gate: 5 min focused reading + every section opened once */
.read-gate {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field-bg);
}
.read-gate-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 16px;
  color: var(--muted);
  font-size: 13px;
}
.read-gate-row strong { color: var(--text); font-variant-numeric: tabular-nums; }
.read-bar {
  height: 6px;
  margin: 10px 0 8px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
}
.read-bar-fill {
  width: 0;
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  transition: width .25s linear;
}
.read-gate-hint { margin: 0; color: var(--muted); font-size: 13px; }
.read-gate.is-paused { border-color: var(--danger); }
.read-gate.is-paused .read-bar-fill { background: var(--muted); }
.read-gate.is-paused .read-gate-hint { color: var(--danger); }
.read-gate.is-done { border-color: var(--accent); }
.read-gate.is-done .read-gate-hint { color: var(--accent-text); font-weight: 500; }

.rules-sections details.was-opened .rules-count::before {
  content: "✓ geöffnet · ";
  color: var(--accent-text);
}

.check-row.is-locked { opacity: .5; cursor: not-allowed; }
.check-row.is-locked input { cursor: not-allowed; }

.pending-text { margin: 0 0 8px; color: var(--muted); }
