/* PVS Team — Design-System. System-Fonts (keine Webfont-Ladezeit), CSS-Variablen, hell/dunkel. */
:root {
  color-scheme: light dark; /* native Controls (Selects, Scrollbars) folgen dem Modus */
  --bg: #f2f5f7;
  --card: #ffffff;
  --ink: #16262e;
  --muted: #61707b;
  --line: #e3e9ed;
  --accent: #0d9488;
  --accent-ink: #ffffff;
  --accent-soft: #d9f2ef;
  --danger: #dc2626;
  --warn: #d97706;
  --now: #e11d48;
  --shadow: 0 1px 3px rgba(16, 42, 51, .08), 0 4px 14px rgba(16, 42, 51, .05);
  --radius: 14px;
  --nav-h: 58px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101a20;
    --card: #1a2830;
    --ink: #e6edf1;
    --muted: #8fa1ac;
    --line: #2a3b45;
    --accent: #2dd4bf;
    --accent-ink: #06302b;
    --accent-soft: #123f3a;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
a, button, .task, .cal-day, .gal-item { touch-action: manipulation; } /* kein Doppeltipp-Zoom-Delay */
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
h1, h2, h3 { line-height: 1.25; }
a { color: var(--accent); }

/* ---------- Buttons & Inputs ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .4em; justify-content: center;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: .5rem .9rem; border-radius: 10px; font-size: .95rem; font-weight: 500;
  cursor: pointer; text-decoration: none; min-height: 40px;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-block { width: 100%; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: .55rem .7rem; width: 100%;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; font-size: .9rem; font-weight: 500; margin-bottom: .8rem; }
label > input, label > select, label > textarea { margin-top: .3rem; font-weight: 400; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; }

/* ---------- Login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 1rem;
  background: linear-gradient(160deg, var(--accent-soft), var(--bg) 55%); }
.login-card { background: var(--card); border-radius: 20px; box-shadow: var(--shadow);
  padding: 2rem 1.6rem; width: 100%; max-width: 380px; }
.login-logo { font-size: 3rem; text-align: center; }
.login-card h1 { text-align: center; margin: .2rem 0 0; }
.login-sub { text-align: center; color: var(--muted); margin: .2rem 0 1.4rem; }
.login-error { color: var(--danger); text-align: center; min-height: 1.2em; margin: .8rem 0 0; }

/* ---------- App-Layout ---------- */
.app { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 1rem; padding: 0 1rem; height: 56px;
  background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar-brand { font-weight: 700; white-space: nowrap; }
.topnav { display: flex; gap: .2rem; overflow-x: auto; flex: 1; }
.topnav a {
  padding: .45rem .8rem; border-radius: 10px; text-decoration: none; color: var(--muted);
  font-weight: 500; white-space: nowrap;
}
.topnav a.active { background: var(--accent-soft); color: var(--accent); }
.topbar-right { display: flex; align-items: center; gap: .2rem; }
.online { color: var(--accent); font-size: .85rem; white-space: nowrap; }
.badge { background: var(--now); color: #fff; border-radius: 999px; font-size: .7rem; padding: 0 .45em; }
main { flex: 1; width: 100%; max-width: 1280px; margin: 0 auto; padding: 1rem; }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap; margin-bottom: 1rem; }
.section-title { margin: 1.4rem 0 .6rem; }
.list { display: flex; flex-direction: column; gap: .5rem; }

/* Mobile Bottom-Nav */
.bottomnav { display: none; }
@media (max-width: 760px) {
  .topnav { display: none; }
  main { padding-bottom: calc(var(--nav-h) + 1.5rem); }
  .bottomnav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; height: var(--nav-h);
    background: var(--card); border-top: 1px solid var(--line); z-index: 30;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottomnav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; font-size: .68rem; text-decoration: none; color: var(--muted); position: relative;
  }
  .bottomnav .badge { position: absolute; top: 5px; right: 22%; }
  .bottomnav a span { font-size: 1.25rem; line-height: 1; }
  .bottomnav a.active { color: var(--accent); }
}

/* ---------- Kanban ---------- */
.today-banner { background: var(--accent-soft); color: var(--ink); border-radius: 10px;
  padding: .5rem .8rem; font-size: .9rem; flex: 1; }
.board { display: grid; grid-template-columns: repeat(5, 1fr); gap: .8rem; align-items: start; }
@media (max-width: 1100px) {
  .board { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: .5rem; }
  .board .col { min-width: 78vw; scroll-snap-align: start; }
  @media (min-width: 500px) { .board .col { min-width: 320px; } }
}
.col { background: color-mix(in srgb, var(--card) 60%, var(--bg)); border-radius: var(--radius); padding: .6rem; }
.col.drag-over { outline: 2px dashed var(--accent); }
.col-head { display: flex; align-items: center; justify-content: space-between; padding: .2rem .4rem .6rem; font-weight: 700; }
.col-head .count { color: var(--muted); font-weight: 500; font-size: .85rem; }
.col-jetzt .col-head { color: var(--now); }
.col-heute .col-head { color: var(--warn); }
.col-erledigt .col-head { color: var(--muted); }
.task {
  background: var(--card); border-radius: 10px; box-shadow: var(--shadow);
  padding: .6rem .7rem; margin-bottom: .55rem; cursor: grab; border-left: 3px solid transparent;
}
.task:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.task.overdue { border-left-color: var(--now); }
.task.recurring { border-left-color: var(--accent); }
.task.dragging { opacity: .4; }
.task-title { font-weight: 600; word-break: break-word; }
.task-meta { display: flex; gap: .6rem; flex-wrap: wrap; color: var(--muted); font-size: .78rem; margin-top: .25rem; }
.task-done .task-title { text-decoration: line-through; color: var(--muted); font-weight: 400; }
.task-actions { display: flex; gap: .3rem; margin-top: .45rem; }
.task-actions .btn { min-height: 30px; padding: .15rem .55rem; font-size: .8rem; }

/* ---------- Kalender ---------- */
.cal-nav { display: flex; align-items: center; gap: .3rem; }
.cal-nav h2 { margin: 0; font-size: 1.15rem; min-width: 10.5rem; text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: .6rem; }
.cal-dow { text-align: center; font-size: .75rem; color: var(--muted); padding: .3rem 0; font-weight: 600; }
.cal-day { min-height: 84px; border-radius: 8px; padding: .25rem .3rem; background: var(--bg);
  cursor: pointer; overflow: hidden; }
.cal-day:hover { outline: 1px solid var(--accent); }
.cal-day.other { opacity: .38; }
.cal-day.today { outline: 2px solid var(--accent); }
.cal-day .d { font-size: .78rem; color: var(--muted); }
.cal-ev { font-size: .72rem; background: var(--accent-soft); color: var(--ink);
  border-radius: 5px; padding: 0 .3em; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 700px) {
  .cal-day { min-height: 52px; }
  .cal-ev { display: none; }
  .cal-day.has-ev .d::after { content: '•'; color: var(--accent); font-size: 1rem; margin-left: 2px; }
}
.event-row { display: flex; gap: .8rem; align-items: baseline; background: var(--card);
  border-radius: 10px; box-shadow: var(--shadow); padding: .55rem .8rem; cursor: pointer; }
.event-date { color: var(--accent); font-weight: 700; white-space: nowrap; font-size: .9rem; }

/* ---------- Chat ---------- */
.chat-convos { display: flex; gap: .4rem; overflow-x: auto; padding: 0 .3rem .6rem; flex-shrink: 0; }
.convo-chip {
  display: inline-flex; align-items: center; gap: .35em; white-space: nowrap;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: .35rem .8rem; border-radius: 999px; font-size: .88rem; cursor: pointer;
}
.convo-chip.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.convo-chip .dm-badge { background: var(--now); color: #fff; border-radius: 999px; font-size: .72rem; padding: 0 .5em; }
.convo-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); opacity: .45; }
.convo-chip .dot.on { background: #22c55e; opacity: 1; }
.view-chat { display: flex; flex-direction: column; height: calc(100dvh - 56px - 2rem); }
@media (max-width: 760px) { .view-chat { height: calc(100dvh - 56px - var(--nav-h) - 2rem); } }
.chat-list { flex: 1; overflow-y: auto; padding: .3rem; overscroll-behavior: contain; }
.chat-msg { max-width: 78%; margin-bottom: .6rem; }
.chat-msg .bubble { background: var(--card); border-radius: 14px; box-shadow: var(--shadow);
  padding: .5rem .8rem; word-break: break-word; white-space: pre-wrap; }
.chat-msg.mine { margin-left: auto; }
.chat-msg.mine .bubble { background: var(--accent); color: var(--accent-ink); }
.chat-msg .who { font-size: .74rem; color: var(--muted); margin: 0 .5rem .15rem; }
.chat-form { display: flex; gap: .5rem; padding-top: .6rem; }
.chat-form textarea { resize: none; max-height: 120px; }

/* ---------- Wiki ---------- */
.view-split { display: grid; grid-template-columns: 250px 1fr; gap: 1rem; align-items: start; }
@media (max-width: 860px) { .view-split { grid-template-columns: 1fr; } }
.wiki-list { display: flex; flex-direction: column; gap: .25rem; margin-top: .6rem; }
.wiki-list a { padding: .45rem .6rem; border-radius: 8px; text-decoration: none; color: var(--ink); }
.wiki-list a.active, .wiki-list a:hover { background: var(--accent-soft); color: var(--accent); }
.wiki-toolbar { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; }
.wiki-toolbar h2 { margin: 0; }
.wiki-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
#wiki-edit-title { margin: .6rem 0; font-weight: 600; }
.editor-split { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
@media (max-width: 860px) { .editor-split { grid-template-columns: 1fr; } }
#wiki-edit-text { min-height: 55vh; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88rem; }
.editor-preview { border: 1px dashed var(--line); border-radius: 10px; padding: .8rem; overflow-y: auto; max-height: 60vh; }
.md-content { line-height: 1.65; }
.md-content h1 { font-size: 1.5rem; } .md-content h2 { font-size: 1.25rem; }
.md-content table { border-collapse: collapse; width: 100%; margin: .6rem 0; display: block; overflow-x: auto; }
.md-content th, .md-content td { border: 1px solid var(--line); padding: .35rem .6rem; text-align: left; }
.md-content code { background: var(--bg); border-radius: 4px; padding: .1em .3em; }
.md-content pre { background: var(--bg); border-radius: 8px; padding: .7rem; overflow-x: auto; }
.md-content blockquote { border-left: 3px solid var(--accent); margin: .6rem 0; padding: .2rem .9rem; background: var(--accent-soft); border-radius: 0 8px 8px 0; }
.md-content img { max-width: 100%; }

/* ---------- Galerie ---------- */
.gal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .7rem; }
.gal-item { position: relative; border-radius: 12px; overflow: hidden; box-shadow: var(--shadow);
  aspect-ratio: 1; background: var(--card); cursor: pointer; border: 0; padding: 0; }
.gal-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gal-item .cap { position: absolute; inset: auto 0 0 0; padding: 1.2rem .5rem .4rem;
  background: linear-gradient(transparent, rgba(0,0,0,.65)); color: #fff; font-size: .82rem; text-align: left; }
.gal-empty { grid-column: 1/-1; text-align: center; color: var(--muted); padding: 3rem 1rem; }

/* Lightbox */
.lightbox { position: fixed; inset: 0; background: rgba(8, 14, 18, .93); z-index: 50;
  display: flex; align-items: center; justify-content: center; overscroll-behavior: contain; }
.lb-del { bottom: 1.2rem; left: 1rem; }
.lightbox img { max-width: 94vw; max-height: 88vh; border-radius: 6px; }
.lightbox button, .lb-dl { position: absolute; background: rgba(255,255,255,.12); color: #fff;
  border: 0; border-radius: 10px; font-size: 1.3rem; padding: .4rem .8rem; cursor: pointer; text-decoration: none; }
.lb-close { top: 1rem; right: 1rem; }
.lb-prev { left: .6rem; top: 50%; transform: translateY(-50%); }
.lb-next { right: .6rem; top: 50%; transform: translateY(-50%); }
.lb-dl { bottom: 1.2rem; right: 1rem; font-size: .95rem; }

/* ---------- Dialog ---------- */
dialog { border: 0; border-radius: var(--radius); box-shadow: var(--shadow); background: var(--card);
  color: var(--ink); padding: 1.2rem; width: min(94vw, 460px); }
dialog::backdrop { background: rgba(10, 20, 25, .45); }
dialog h3 { margin-top: 0; }
.dialog-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: .6rem; flex-wrap: wrap; }
.form-row { display: flex; gap: .6rem; } .form-row > label { flex: 1; }

/* Mail */
.mail-row { background: var(--card); border-radius: 10px; box-shadow: var(--shadow); padding: .6rem .8rem; }
.mail-row .subject { font-weight: 600; }

/* ---------- Druck (Wiki-Seiten, z. B. Facharztlisten für Patienten) ---------- */
@media print {
  .topbar, .bottomnav, .wiki-side, .wiki-actions, #wiki-meta, .view-head, .btn { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  main { max-width: none; padding: 0; }
  .view-split { display: block; }
  .card { box-shadow: none; padding: 0; }
  .md-content a { color: #000; text-decoration: none; }
}
