:root {
  --bg: #f6f8fa;
  --fg: #14213d;
  --muted: #5b667a;
  --accent: #1d6fd8;
  --ok: #14833b;
  --bad: #b3261e;
  --card: #fff;
  --border: #d3dae6;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--fg);
  font-size: clamp(16px, 2.2vw, 22px);
}
.app {
  max-width: 1000px;
  margin: 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 16px 16px;
}
.top h1 { font-size: 1.5em; margin: 4px 0 8px; text-align: center; }
.settings { font-size: 0.8em; color: var(--muted); }
.settings summary { cursor: pointer; text-align: center; }
fieldset { border: 1px solid var(--border); border-radius: 8px; margin: 8px 0; padding: 6px 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips label {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  background: var(--card);
  cursor: pointer;
  user-select: none;
}
.chips input { position: absolute; opacity: 0; pointer-events: none; }
.chips label:has(input:checked) { background: var(--accent); border-color: var(--accent); color: #fff; }
.chips label:has(input:focus-visible) { outline: 3px solid #9cc4f5; }
.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  min-height: 240px;
  padding: 8px;
}
.molecule { width: 100%; display: flex; justify-content: center; }
.molecule svg { width: 100%; max-height: 52vh; }
.answer form { display: flex; gap: 8px; }
input[type="text"] {
  flex: 1;
  min-width: 0;
  font: inherit;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: 8px;
}
input[type="text"]:focus { outline: none; border-color: var(--accent); }
button {
  font: inherit;
  padding: 10px 18px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--fg);
  cursor: pointer;
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.active { background: var(--fg); border-color: var(--fg); color: #fff; }
button:hover { filter: brightness(0.96); }
.feedback { min-height: 1.6em; margin: 8px 2px 0; }
.feedback.ok { color: var(--ok); font-weight: 600; }
.feedback.bad { color: var(--bad); }
.feedback.info { color: var(--fg); }
.score { margin: 6px 2px 0; font-size: 0.95rem; }
.score button.link { background: none; border: 0; padding: 0 0 0 8px; color: var(--accent); font: inherit; font-size: 0.85rem; text-decoration: underline; cursor: pointer; min-height: 0; }
.bottom { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.taskid { text-align: center; font-size: 0.7em; color: var(--muted); margin: 0; }
.copy-toast { margin-left: 6px; color: var(--ok); opacity: 0; transition: opacity 0.2s; }
.copy-toast.show { opacity: 1; }
.check { display: block; margin-top: 6px; }
@media (max-width: 560px) {
  .answer form { flex-direction: column; }
  .bottom button { flex: 1; }
}
.modes { justify-content: center; margin-bottom: 6px; }
.prompt { font-size: 1.6em; font-weight: 700; margin: 4px 0 8px; text-align: center; }
.editor svg { width: 100%; max-height: 52vh; touch-action: none; background: #fbfcfe; border: 1px dashed var(--border); border-radius: 8px; cursor: crosshair; user-select: none; }
.editor .sel { fill: rgba(29, 111, 216, 0.15); }
.editor svg.disabled { opacity: 0.6; pointer-events: none; }
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 8px; }
.toolbar button { padding: 6px 12px; min-width: 2.4em; }
.toolbar .sep { width: 10px; }
body[data-mode="benennen"] .only-draw { display: none; }
body[data-mode="zeichnen"] .only-name { display: none; }
body[data-mode="zeichnen"][data-solution="1"] #molecule { display: flex; }
body[data-mode="zeichnen"][data-solution="1"] #editor,
body[data-mode="zeichnen"][data-solution="1"] #toolbar { display: none; }
