:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --border: #d9e0e6;
  --text: #1c2733;
  --muted: #64748b;
  --accent: #185fa5;
  --accent-soft: #e6f1fb;
  --danger: #b3261e;
  --ok: #0f6e56;
  --water: #d8ebf7;
  --radius: 10px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 22px; font-weight: 600; margin: 0 0 16px; }
h2 { font-size: 18px; font-weight: 600; margin: 0 0 12px; }

/* Topbar */
#topbar {
  display: flex; align-items: center; gap: 24px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 0 20px; height: 56px; position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 600; font-size: 17px; color: var(--text); text-decoration: none; }
#mainnav { display: flex; gap: 4px; }
#mainnav a {
  padding: 8px 14px; border-radius: var(--radius); color: var(--text);
}
#mainnav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.topright { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.userbox { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }

main { max-width: 1080px; margin: 0 auto; padding: 24px 20px 60px; }

/* Buttons & inputs */
button {
  font: inherit; cursor: pointer; border: 1px solid var(--border);
  background: var(--surface); border-radius: 8px; padding: 8px 14px;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.primary:hover { filter: brightness(1.07); }
button.danger { color: var(--danger); border-color: #e7c3c0; }
.linkbtn { background: none; border: none; color: var(--accent); padding: 4px; }
.iconbtn { position: relative; border: none; background: none; font-size: 20px; padding: 4px; }
.badge {
  position: absolute; top: -2px; right: -6px; background: var(--danger); color: #fff;
  border-radius: 10px; font-size: 11px; padding: 1px 5px; min-width: 16px; text-align: center;
}
input, select, textarea {
  font: inherit; width: 100%; padding: 9px 11px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface); color: var(--text);
}
textarea { resize: vertical; min-height: 70px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 5px; }

/* Cards & lists */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 12px;
}
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.row { display: flex; gap: 12px; align-items: center; }
.spacer { flex: 1; }
.muted { color: var(--muted); font-size: 13px; }
.tag {
  display: inline-block; background: var(--accent-soft); color: var(--accent);
  border-radius: 6px; padding: 2px 8px; font-size: 12px; margin: 2px 4px 2px 0;
}
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }

/* Auth screens */
.auth-wrap { max-width: 380px; margin: 8vh auto; }
.auth-wrap .card { padding: 28px; }
.auth-wrap h1 { text-align: center; }

/* Notifications panel */
.panel {
  position: fixed; top: 56px; right: 12px; width: 340px; max-height: 70vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(0,0,0,.12); z-index: 30; padding: 8px;
}
.notif { padding: 10px 12px; border-radius: 8px; border-bottom: 1px solid var(--border); }
.notif.unread { background: var(--accent-soft); }
.notif .t { font-weight: 500; font-size: 14px; }
.notif .b { font-size: 13px; color: var(--muted); margin-top: 2px; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 50;
}

/* Editor */
.editor { display: grid; grid-template-columns: 168px 1fr 230px; gap: 12px; }
.editor .palette, .editor .props {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px;
}
.tool {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px;
  cursor: pointer; font-size: 14px; user-select: none;
}
.tool:hover { background: var(--bg); }
.tool.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.canvas-wrap {
  background: var(--water); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; min-height: 520px;
}
#stage { width: 100%; height: 100%; display: block; touch-action: none; }
.sel { outline: 2px dashed var(--accent); }
.hidden { display: none; }

/* Kalender */
.calgrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.calhead { font-size: 12px; color: var(--muted); margin-bottom: 4px; text-align: center; }
.calcell { min-height: 84px; border: 1px solid var(--border); border-radius: 6px; padding: 4px; background: var(--bg); }
.calcell.empty { background: transparent; border: none; }
.caldate { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.calev { font-size: 11px; color: #fff; border-radius: 4px; padding: 2px 5px; margin-bottom: 3px; cursor: pointer; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* Protokoll */
.protocol { max-width: 800px; margin: 0 auto; }
.protocol .addrbox { border: 1px solid var(--border); padding: 8px 12px; font-size: 13px; min-width: 220px; }
.protocol label { margin-top: 12px; }
.sigline { border-top: 1px solid #333; padding-top: 4px; font-size: 12px; text-align: center; min-height: 30px; }
.sigline div { color: var(--muted); }

/* Sortierbare Listentabellen */
.ltable { width: 100%; border-collapse: collapse; font-size: 14px; }
.ltable th { text-align: left; padding: 8px 10px; border-bottom: 2px solid var(--border); cursor: pointer; user-select: none; color: var(--muted); white-space: nowrap; }
.ltable th:hover { color: var(--accent); }
.ltable td { padding: 7px 10px; border-bottom: 1px solid var(--border); }
.ltable tbody tr:hover { background: var(--bg); }

/* Übungs-Druckansicht */
.exprint { display: none; }
.exprint .exprint-img svg { width: 100%; height: auto; max-width: 760px; border: 1px solid #ccc; border-radius: 6px; }

/* Druck / PDF */
@media print {
  #topbar, .toolbar, #notifpanel, #toast, .noprint, button, select { display: none !important; }
  body { background: #fff; font-size: 12px; }
  main { max-width: 100%; padding: 0; }
  .card { border: none; break-inside: avoid; box-shadow: none; }
  .protocol input, .protocol textarea { border: none; border-bottom: 1px solid #999; border-radius: 0; padding: 2px 0; }
  a { color: #000; text-decoration: none; }
  /* Beim Übungsdruck nur die Druckansicht zeigen */
  body.print-exercise #topbar,
  body.print-exercise #view > *:not(.exprint) { display: none !important; }
  body.print-exercise .exprint { display: block !important; }
}
