:root {
  --surface-1: #fcfcfb;
  --page: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --danger: #d03b3b;
  --ok-bg: #e4f3e4;
  --warn-bg: #fdf2d8;
  --error-bg: #fbe3e3;
  --series-1: #2a78d6;
  --series-2: #1baf7a;
  --series-3: #eda100;
  --series-4: #008300;
  --series-5: #4a3aa7;
  --series-6: #e34948;
}
@media (prefers-color-scheme: dark) {
  :root {
    --surface-1: #1a1a19;
    --page: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --danger: #e66767;
    --ok-bg: #143814;
    --warn-bg: #3d3010;
    --error-bg: #3f1a1a;
    --series-1: #3987e5;
    --series-2: #199e70;
    --series-3: #c98500;
    --series-4: #008300;
    --series-5: #9085e9;
    --series-6: #e66767;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--text-primary);
  line-height: 1.45;
}
main { max-width: 1200px; margin: 0 auto; padding: 1rem; }

.topbar {
  display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
  padding: 0.6rem 1rem;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
}
.topbar .brand { font-weight: 700; }
.topbar nav { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.topbar a { color: var(--text-secondary); text-decoration: none; }
.topbar a:hover { color: var(--text-primary); }

a { color: var(--accent); }
h1 { font-size: 1.4rem; margin: 0 0 0.75rem; }
h2 { font-size: 1.05rem; margin: 1.5rem 0 0.5rem; }
.count { color: var(--muted); font-weight: 400; font-size: 0.9em; }
.subtitle, .meta, .note, .chart-hint { color: var(--text-secondary); font-size: 0.9rem; }
.chart-hint { margin: 0 0 0.5rem; }

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.card.narrow { max-width: 420px; margin: 3rem auto; }

.flash { padding: 0.6rem 1rem; border-radius: 6px; margin-bottom: 0.75rem; }
.flash-ok { background: var(--ok-bg); }
.flash-warn { background: var(--warn-bg); }
.flash-error { background: var(--error-bg); }
.flash-password { background: var(--warn-bg); font-weight: 600; user-select: all; }

form label { display: block; margin-bottom: 0.75rem; font-size: 0.95rem; }
input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  display: block; width: 100%; margin-top: 0.2rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--baseline); border-radius: 6px;
  background: var(--surface-1); color: var(--text-primary);
  font: inherit;
}
input:disabled, select:disabled, textarea:disabled { color: var(--muted); }
fieldset { border: 0; padding: 0; margin: 0; }
label.checkbox { display: flex; align-items: center; gap: 0.4rem; }
label.checkbox input { width: auto; margin: 0; }

button, .button-secondary {
  font: inherit; cursor: pointer;
  padding: 0.5rem 1.1rem; border-radius: 6px;
  border: 1px solid transparent;
  background: var(--accent); color: #fff;
  text-decoration: none; display: inline-block;
}
.button-secondary {
  background: transparent; color: var(--accent);
  border-color: var(--accent);
}
button.danger { background: var(--danger); }
button.linklike {
  background: none; border: 0; padding: 0;
  color: var(--accent); text-decoration: underline; cursor: pointer;
  font-size: inherit;
}
.actions { display: flex; gap: 0.75rem; align-items: center; margin-top: 1rem; }
form.inline { display: inline; margin: 0; }

.field-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0 1rem;
}
.field-error { color: var(--danger); font-size: 0.85rem; margin-left: 0.4rem; }
tr.has-error th { color: var(--danger); }
.statement-lead { margin: 0.75rem 0 0.25rem; font-style: italic; }

.likert-hint { color: var(--muted); font-size: 0.85rem; margin: 0 0 0.5rem; }
.likert-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.5rem 1.5rem; flex-wrap: wrap;
  border-top: 1px solid var(--grid); padding: 0.35rem 0;
}
.likert-statement { flex: 1 1 20rem; min-width: 16rem; }
.likert-item.has-error .likert-statement { color: var(--danger); }
.likert-scale { display: flex; align-items: center; gap: 0.25rem; }
label.likert-opt {
  display: flex; flex-direction: column; align-items: center; gap: 0.1rem;
  margin: 0; padding: 0.3rem 0.55rem; border-radius: 6px; cursor: pointer;
}
.likert-opt:hover { background: var(--grid); }
.likert-opt input[type="radio"] { width: 1.2rem; height: 1.2rem; margin: 0; }
.likert-num { font-size: 0.72rem; color: var(--muted); }
.likert-reset { font-size: 0.8rem; color: var(--muted); margin-left: 0.5rem; }

table.data { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
table.data th, table.data td { text-align: left; padding: 0.4rem 0.6rem; }
table.data thead th { color: var(--text-secondary); font-weight: 600; border-bottom: 1px solid var(--baseline); }
table.data tbody tr { border-bottom: 1px solid var(--grid); }
table.data.kv th { width: 14rem; font-weight: 400; color: var(--text-secondary); }
.truncate { max-width: 24rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.truncate details pre { white-space: pre-wrap; }
.muted-row { color: var(--muted); }
.actions-cell form { margin-right: 0.75rem; }

.pill {
  display: inline-block; font-size: 0.72rem; font-weight: 600;
  padding: 0.1rem 0.5rem; border-radius: 999px;
  background: var(--grid); color: var(--text-secondary);
  vertical-align: middle;
}

.filterbar {
  display: flex; gap: 1rem; align-items: end; flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.filterbar label { margin: 0; }
.filterbar select { width: auto; min-width: 7rem; }

.sheet-layout.with-image {
  display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 1rem; align-items: start;
}
@media (max-width: 900px) { .sheet-layout.with-image { grid-template-columns: 1fr; } }
.image-panel img { max-width: 100%; border: 1px solid var(--border); border-radius: 4px; }

.viz-root { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.viz-root .chart-card.wide { grid-column: 1 / -1; }
@media (max-width: 900px) { .viz-root { grid-template-columns: 1fr; } }
.chart-card { margin-bottom: 0; }
.chart-box { position: relative; height: 320px; }
.chart-card.wide .chart-box { height: 380px; }

.scroll-x { overflow-x: auto; }
table.matrix td { text-align: center; width: 2.4rem; }
table.matrix .cell-missing { background: var(--error-bg); }
table.matrix .cell-multi { background: var(--warn-bg); }

.anmerkung { border-top: 1px solid var(--grid); padding: 0.6rem 0; }
.anmerkung p { margin: 0 0 0.2rem; }
.row-form { display: flex; gap: 1rem; align-items: end; flex-wrap: wrap; }
.row-form label { margin: 0; }

/* --- mobile (tutors fill the form on their phones) --- */
@media (max-width: 640px) {
  main { padding: 0.5rem; }
  .card { padding: 0.9rem; }
  .topbar { gap: 0.5rem 1rem; padding: 0.5rem 0.75rem; }
  .topbar nav { gap: 0.5rem 0.9rem; font-size: 0.95rem; }
  .field-grid { grid-template-columns: 1fr 1fr; gap: 0 0.75rem; }
  .likert-item { flex-direction: column; align-items: stretch; gap: 0.2rem; }
  .likert-statement { flex: none; min-width: 0; }
  .likert-scale { width: 100%; }
  label.likert-opt { flex: 1; min-height: 44px; justify-content: center; padding: 0.4rem 0; }
  .likert-opt input[type="radio"] { width: 1.5rem; height: 1.5rem; }
  .likert-reset { margin-left: 0.25rem; }
  .actions { flex-direction: column; align-items: stretch; }
  .actions button, .actions .button-secondary { width: 100%; padding: 0.8rem; text-align: center; }
}
