/* Labbook – ruhiges Arbeitswerkzeug. Ein Akzent, Haarlinien, keine Verläufe. */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --line: #e3e6eb;
  --line-strong: #cfd4dc;
  --text: #14181f;
  --muted: #667085;
  --faint: #98a2b3;
  --accent: #2456d3;
  --accent-ink: #ffffff;
  --accent-soft: #e8eefc;
  --ok: #1a7f4b;
  --ok-soft: #e4f4ec;
  --warn: #a15c07;
  --warn-soft: #fbf0dc;
  --bad: #b42318;
  --bad-soft: #fbe8e6;
  --info-soft: #eef1f6;
  --radius: 6px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, "Liberation Mono", monospace;
  --ease: cubic-bezier(.2, .0, .0, 1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216; --surface: #161a20; --surface-2: #1d222a; --line: #262c35; --line-strong: #353d49;
    --text: #e8ebf0; --muted: #98a2b3; --faint: #667085;
    --accent: #6f93f2; --accent-ink: #0b1020; --accent-soft: #1b2540;
    --ok: #4cc38a; --ok-soft: #13291f; --warn: #e3a74a; --warn-soft: #2d2412;
    --bad: #f08076; --bad-soft: #301816; --info-soft: #1c2129;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1216; --surface: #161a20; --surface-2: #1d222a; --line: #262c35; --line-strong: #353d49;
  --text: #e8ebf0; --muted: #98a2b3; --faint: #667085;
  --accent: #6f93f2; --accent-ink: #0b1020; --accent-soft: #1b2540;
  --ok: #4cc38a; --ok-soft: #13291f; --warn: #e3a74a; --warn-soft: #2d2412;
  --bad: #f08076; --bad-soft: #301816; --info-soft: #1c2129;
}
:root[data-theme="dark"] { color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }
input[type=time], input[type=number] { width: 100%; min-height: 34px; padding: 6px 10px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); }
input[type=time]:focus, input[type=number]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; text-wrap: balance; }
h1 { font-size: 20px; line-height: 1.25; }
h2 { font-size: 15px; }
h3 { font-size: 13px; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.num, time { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.label-caps { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 16px;
  padding: 16px 12px; background: var(--surface); border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 15px; padding: 4px 8px; letter-spacing: -.01em; }
.brand-mark { width: 14px; height: 14px; border-radius: 3px; background: var(--accent); box-shadow: inset 0 0 0 3px var(--accent-soft); }
#nav, .sidebar-foot { display: flex; flex-direction: column; gap: 2px; }
.sidebar-foot { margin-top: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 8px; border: 0; border-radius: var(--radius);
  background: none; color: var(--muted); cursor: pointer; text-align: left; font-weight: 500;
  transition: background .12s var(--ease), color .12s var(--ease);
}
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.nav-item .count { margin-left: auto; font-size: 12px; color: var(--faint); }
.icon { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.main { min-width: 0; padding: 28px clamp(16px, 4vw, 48px) 64px; max-width: 1180px; width: 100%; }
.main:focus { outline: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head .sub { color: var(--muted); margin-top: 2px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.tabbar { display: none; }

/* ---------- Basics ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.card-body { padding: 16px; }
.card-empty { padding: 28px 16px; text-align: center; color: var(--muted); }

.stat { padding: 14px 16px; }
.stat .v { font-size: 24px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin-top: 2px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 32px; padding: 5px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--text);
  cursor: pointer; font-weight: 500; white-space: nowrap;
  transition: background .12s var(--ease), border-color .12s var(--ease);
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { border-color: transparent; background: none; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--bad); }
.btn.sm { min-height: 28px; padding: 3px 9px; font-size: 13px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.lbl { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=date], input[type=password], input[type=search], select, textarea {
  width: 100%; min-height: 34px; padding: 6px 10px; background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius); transition: border-color .12s var(--ease), box-shadow .12s var(--ease);
}
textarea { resize: vertical; min-height: 84px; line-height: 1.55; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[disabled], textarea[disabled], select[disabled] { background: var(--surface-2); color: var(--muted); }
.field { display: flex; flex-direction: column; min-width: 0; }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.inline-input { width: auto; min-height: 28px; padding: 2px 6px; font-size: 13px; }

.chip { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--info-soft); color: var(--muted); white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.progress { height: 4px; background: var(--surface-2); border-radius: 2px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); transition: width .3s var(--ease); }

.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 4px 12px; cursor: pointer; color: var(--muted); font-weight: 500; }
.seg button + button { border-left: 1px solid var(--line-strong); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }

/* ---------- Listen ---------- */
.list { display: flex; flex-direction: column; }
.row {
  display: grid; align-items: center; gap: 12px; padding: 9px 16px; border-top: 1px solid var(--line);
  transition: background .1s var(--ease);
}
.row:first-child { border-top: 0; }
.row.click { cursor: pointer; }
.row.click:hover { background: var(--surface-2); }
.task-row { grid-template-columns: 22px minmax(0, 1fr) auto auto; }
.task-title { min-width: 0; overflow-wrap: anywhere; }
.task-title.done { color: var(--faint); text-decoration: line-through; }
.check {
  width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--line-strong); background: var(--surface);
  display: grid; place-items: center; cursor: pointer; padding: 0; color: transparent;
  transition: background .12s var(--ease), border-color .12s var(--ease);
}
.check:hover { border-color: var(--accent); }
.check[data-s="done"] { background: var(--ok); border-color: var(--ok); color: #fff; }
.check[data-s="running"] { border-color: var(--accent); background: linear-gradient(90deg, var(--accent) 50%, transparent 50%); }
.check[data-s="blocked"] { border-color: var(--bad); background: var(--bad-soft); }
.gate { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--warn); font-weight: 500; }

.phase { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); overflow: hidden; }
.phase-head { display: grid; grid-template-columns: 20px minmax(0, 1fr) 120px auto; gap: 12px; align-items: center; padding: 12px 16px; cursor: pointer; width: 100%; border: 0; background: none; text-align: left; }
.phase-head:hover { background: var(--surface-2); }
.phase-head .chev { transition: transform .15s var(--ease); color: var(--faint); }
.phase[data-open="1"] .chev { transform: rotate(90deg); }
.phase-body { border-top: 1px solid var(--line); }
.phase:not([data-open="1"]) .phase-body { display: none; }

/* ---------- Woche ---------- */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.day { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; min-height: 180px; display: flex; flex-direction: column; }
.day.today { border-color: var(--accent); }
.day-head { padding: 8px 10px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: baseline; }
.day-head .d { font-weight: 600; font-variant-numeric: tabular-nums; }
.day-body { padding: 8px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.pill { display: block; padding: 5px 8px; border-radius: 5px; background: var(--info-soft); font-size: 12.5px; line-height: 1.35; cursor: pointer; border: 0; text-align: left; width: 100%; overflow-wrap: anywhere; }
.pill:hover { background: var(--line); }
.pill.entry { background: var(--accent-soft); color: var(--accent); }
.pill.done { opacity: .55; text-decoration: line-through; }
.pill.gate { box-shadow: inset 2px 0 0 var(--warn); }
.day-add { margin-top: auto; border: 1px dashed var(--line-strong); background: none; color: var(--faint); border-radius: 5px; padding: 3px; cursor: pointer; font-size: 12px; }
.day-add:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- Laborbuch ---------- */
.nb { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; align-items: start; }
.nb-list { position: sticky; top: 16px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; overflow: hidden; }
.nb-list .list { overflow: auto; }
.nb-item { display: block; width: 100%; text-align: left; padding: 10px 14px; border: 0; border-top: 1px solid var(--line); background: none; cursor: pointer; }
.nb-item:hover { background: var(--surface-2); }
.nb-item[aria-current="true"] { background: var(--accent-soft); }
.nb-item .t { font-weight: 550; overflow-wrap: anywhere; }
.nb-item .m { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); margin-top: 2px; }
.editor-section { display: flex; flex-direction: column; }
.save-state { font-size: 12px; color: var(--faint); }
.locked-note { padding: 10px 14px; border-radius: var(--radius); background: var(--ok-soft); color: var(--ok); display: flex; gap: 8px; align-items: center; }
.addendum { padding: 10px 14px; border-left: 2px solid var(--line-strong); background: var(--surface-2); border-radius: 0 var(--radius) var(--radius) 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.readonly-text { white-space: pre-wrap; overflow-wrap: anywhere; padding: 8px 0; }

/* ---------- Assistent ---------- */
.chat { display: flex; flex-direction: column; height: calc(100vh - 170px); min-height: 420px; }
.chat-log { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 760px; overflow-wrap: anywhere; }
.msg .who { font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--faint); margin-bottom: 3px; }
.msg.user .body { background: var(--surface-2); padding: 8px 12px; border-radius: 8px; white-space: pre-wrap; }
.msg.assistant .body p + p, .msg.assistant .body ul, .msg.assistant .body ol { margin-top: 8px; }
.msg.assistant .body code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.msg.assistant .body pre { background: var(--surface-2); padding: 10px 12px; border-radius: var(--radius); overflow: auto; margin: 8px 0 0; }
.chat-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); align-items: flex-end; }
.chat-input textarea { min-height: 38px; max-height: 180px; }

/* ---------- Modal / Toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(10, 13, 18, .45); display: grid; place-items: center; padding: 16px; z-index: 50; animation: fade .12s var(--ease); }
.modal { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 16px 48px rgba(0, 0, 0, .22); animation: rise .16s var(--ease); }
.modal.wide { width: min(720px, 100%); }
.modal-head { padding: 16px 20px 0; }
.modal-body { padding: 16px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--text); color: var(--bg); padding: 9px 14px; border-radius: var(--radius); font-size: 13px; animation: rise .16s var(--ease); max-width: 340px; }
.toast.bad { background: var(--bad); color: #fff; }
@keyframes fade { from { opacity: 0 } }
@keyframes rise { from { opacity: 0; transform: translateY(6px) } }

/* ---------- Login ---------- */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login { width: min(360px, 100%); display: flex; flex-direction: column; gap: 20px; }
.login form { display: flex; flex-direction: column; gap: 6px; }
.login .btn { margin-top: 12px; min-height: 38px; }
.form-error { color: var(--bad); font-size: 13px; margin-top: 4px; }

/* ---------- Mobil ---------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .main { padding: 18px 16px calc(84px + env(safe-area-inset-bottom, 0px)); padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .tabbar {
    display: grid; grid-template-columns: repeat(6, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: var(--surface); border-top: 1px solid var(--line); padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px));
  }
  .tabbar button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border: 0; background: none; color: var(--muted); font-size: 10.5px; cursor: pointer; border-radius: var(--radius); min-width: 0; }
  .tabbar button[aria-current="page"] { color: var(--accent); }
  .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-2 { grid-template-columns: minmax(0, 1fr); }
  .nb { grid-template-columns: minmax(0, 1fr); }
  .nb-list { position: static; max-height: 360px; }
  .nb[data-mode="edit"] .nb-list { display: none; }
  .nb[data-mode="list"] .nb-editor { display: none; }
  .week { grid-template-columns: minmax(0, 1fr); }
  .day { min-height: 0; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .phase-head { grid-template-columns: 20px minmax(0, 1fr) auto; }
  .phase-head .progress { display: none; }
  .chat { height: calc(100vh - 230px); }
  .toasts { bottom: 76px; left: 16px; right: 16px; }
  .hide-sm { display: none !important; }
}
@media (min-width: 861px) { .show-sm { display: none !important; } }

.print-root { display: none; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
