/* ============ Tokens ============ */
:root {
  --sidebar: #f6f6f6;
  /* Hover/Active werden aus der Sidebar-Farbe abgeleitet -> immer gleicher Farbton */
  --hover: color-mix(in oklab, var(--sidebar), #000 3%);
  --active: var(--hover);
  --ink: #25252c;
  --panel: #ffffff;
  --border: #e6e6ea;
  --border-soft: #efeff2;
  --muted: #74747f;
  --muted-2: #a3a3ad;
  --row-hover: #fafafb;
  --field: #ffffff;
  --primary: #25252c;
  --on-primary: #ffffff;
  --focus: rgba(37, 37, 44, .18);
  --shadow: 0 1px 2px rgba(20, 20, 28, .05);
  --shadow-lg: 0 18px 48px -12px rgba(20, 20, 28, .25), 0 2px 6px rgba(20, 20, 28, .06);

  --green-bg: #e9f8ef; --green: #15803d;
  --red-bg: #fdecec;   --red: #c62828;
  --amber-bg: #fdf3e2; --amber: #b45309;
  --blue-bg: #eaf1fe;  --blue: #2557d6;
  --violet-bg: #f1edfd; --violet: #6d3fd8;
  --gray-bg: #f1f1f4;  --gray: #5c5c66;
  --star: #f5a524;

  /* Hugeicons ArrowDown01 – einheitlicher Pfeil für alle Dropdowns */
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2374747f' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 9.00005C18 9.00005 13.5811 15 12 15C10.4188 15 6 9 6 9'/%3E%3C/svg%3E");

  /* Drag-&-Drop-Mauszeiger: Hugeicons HandIcon (greifbar) und HandGrabIcon (wird gezogen).
     Dunkle Linie mit weissem Rand -> auf hellem und dunklem Untergrund sichtbar. Fallback: System-Cursor. */
  --cur-grab: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' viewBox='0 0 24 24' fill='none' stroke-linecap='round' stroke-linejoin='round'%3E%3Cdefs%3E%3Cg id='h'%3E%3Cpath d='M18.5 11.5V8.75C18.5 7.7835 19.2835 7 20.25 7C21.2165 7 22 7.7835 22 8.75V14.8C22 18.7765 18.7764 22 14.8 22H12.0588M8 14L5.61507 11.2176C5.22468 10.7621 4.65476 10.5 4.05489 10.5H3.91898C2.85916 10.5 2 11.3592 2 12.419C2 12.7978 2.11214 13.1682 2.32229 13.4834L5.7812 18.6718C7.16738 20.7511 9.50102 22 12 22'/%3E%3Cpath d='M18.5 8.5V5.75C18.5 4.7835 17.7165 4 16.75 4C15.7835 4 15 4.7835 15 5.75V10.5'/%3E%3Cpath d='M15 10.5V3.75C15 2.7835 14.2165 2 13.25 2C12.2835 2 11.5 2.7835 11.5 3.75V10'/%3E%3Cpath d='M11.5 10V5.75C11.5 4.7835 10.7165 4 9.75 4C8.7835 4 8 4.7835 8 5.75V14'/%3E%3C/g%3E%3C/defs%3E%3Cuse href='%23h' stroke='%23fff' stroke-width='3.4'/%3E%3Cuse href='%23h' stroke='%2325252c' stroke-width='1.6'/%3E%3C/svg%3E") 11 11, grab;
  --cur-grabbing: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' viewBox='0 0 24 24' fill='none' stroke-linecap='round' stroke-linejoin='round'%3E%3Cdefs%3E%3Cg id='h'%3E%3Cpath d='M17.5 9.5V8.75C17.5 7.7835 18.2835 7 19.25 7C20.2165 7 21 7.7835 21 8.75V12.8C21 16.7765 17.7765 20 13.8 20H10.0588C6.16034 20 3 16.8397 3 12.9412V12C3 10.8954 3.89543 10 5 10C6.10457 10 7 10.8954 7 12V12.9412'/%3E%3Cpath d='M17.5 9.5V6.75C17.5 5.7835 16.7165 5 15.75 5C14.7835 5 14 5.7835 14 6.75V8.5'/%3E%3Cpath d='M14 8.5V5.75C14 4.7835 13.2165 4 12.25 4C11.2835 4 10.5 4.7835 10.5 5.75V8'/%3E%3Cpath d='M10.5 8V6.75C10.5 5.7835 9.7165 5 8.75 5C7.7835 5 7 5.7835 7 6.75V12'/%3E%3C/g%3E%3C/defs%3E%3Cuse href='%23h' stroke='%23fff' stroke-width='3.4'/%3E%3Cuse href='%23h' stroke='%2325252c' stroke-width='1.6'/%3E%3C/svg%3E") 11 11, grabbing;

  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --sidebar: #1b1b20;
  --hover: color-mix(in oklab, var(--sidebar), #fff 7%);
  --active: var(--hover);
  --ink: #f2f2f5;
  --panel: #25252c;
  --border: #34343d;
  --border-soft: #2e2e36;
  --muted: #a0a0ab;
  --muted-2: #74747f;
  --row-hover: #2a2a32;
  --field: #1f1f25;
  --primary: #f2f2f5;
  --on-primary: #25252c;
  --focus: rgba(242, 242, 245, .2);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-lg: 0 18px 48px -12px rgba(0, 0, 0, .6), 0 2px 6px rgba(0, 0, 0, .3);

  --green-bg: rgba(34, 197, 94, .14);  --green: #5fd98c;
  --red-bg: rgba(239, 68, 68, .15);    --red: #ff8a8a;
  --amber-bg: rgba(245, 158, 11, .15); --amber: #f7b955;
  --blue-bg: rgba(59, 130, 246, .16);  --blue: #86aefc;
  --violet-bg: rgba(139, 92, 246, .17); --violet: #b79cff;
  --gray-bg: #30303a;                  --gray: #b4b4be;
  color-scheme: dark;
}

/* ============ Base ============ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--sidebar);
  color: var(--ink);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

.ic {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.5;
  stroke-linecap: round; stroke-linejoin: round;
}
.ic-sm { width: 16px; height: 16px; }
.ic-xs { width: 13px; height: 13px; }
.muted { color: var(--muted); }

/* Theme-Icons */
:root[data-theme="light"] .theme-ic-light,
:root[data-theme="dark"] .theme-ic-dark { display: none; }

/* ============ Layout ============ */
.app {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}

.sidebar {
  position: sticky; top: 0;
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  padding: 16px 12px 12px;
  background: var(--sidebar);
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-mark { width: 28px; height: 28px; display: grid; place-items: center; flex: none; }
/* Abgerundetes Sechseck mit sechseckiger Aussparung */
.brand-mark svg { width: 28px; height: 28px; fill: none; stroke: var(--ink); stroke-width: 5.5; stroke-linejoin: round; }
.brand-name { display: flex; flex-direction: column; font-weight: 650; font-size: 17px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; letter-spacing: -.02em; flex: 1; }
.brand-sub { font-size: 11px; font-weight: 500; line-height: 1.3; letter-spacing: 0; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  margin: 18px 10px 6px;
  font-size: 12px; font-weight: 500; color: var(--muted);
}
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  height: 36px; padding: 0 10px; border-radius: 8px;
  color: var(--ink); font-weight: 500; text-align: left;
  transition: background-color .12s ease;
}
.nav-item .ic { color: var(--muted); }
.nav-item:hover { background: var(--hover); }
.nav-item.active { background: var(--active); }
.nav-item.active .ic { color: var(--ink); }
.nav-item span:not(.nav-count) { flex: 1; }
.nav-count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.sidebar-foot { margin-top: auto; padding-top: 16px; display: flex; flex-direction: column; gap: 6px; }
.user {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; color: var(--ink);
  padding: 10px; border-top: 1px solid var(--border); margin-top: 4px;
  border-radius: 0 0 8px 8px; transition: background-color .12s ease;
}
.user:hover { background: var(--hover); }
.avatar-btn { cursor: pointer; transition: box-shadow .12s ease; }
.avatar-btn:hover { box-shadow: 0 0 0 3px var(--focus); }
.user-meta { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.user-meta strong { font-weight: 600; font-size: 13px; }
.user-meta small { color: var(--muted); font-size: 12px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--ink); color: var(--sidebar);
  font-size: 12px; font-weight: 600; letter-spacing: .02em;
}
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }

.scrim { display: none; }

.main { padding: 8px 8px 8px 0; min-width: 0; }
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  min-height: calc(100dvh - 16px);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}

/* ============ Topbar ============ */
.topbar {
  display: flex; align-items: center; gap: 12px;
  height: 56px; padding: 0 16px 0 14px;
  border-bottom: 1px solid var(--border-soft);
}
.crumbs { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; min-width: 0; }
.crumb-current { color: var(--ink); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 34px; height: 34px; border-radius: 8px; flex: none;
  display: inline-grid; place-items: center; color: var(--ink);
  border: 1px solid transparent;
  transition: background-color .12s ease;
}
.icon-btn:hover { background: var(--hover); }
.icon-btn.bordered { border-color: var(--border); }

.gsearch {
  position: relative; display: flex; align-items: center; gap: 8px;
  width: 260px; height: 34px; padding: 0 8px 0 10px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--field); color: var(--muted);
}
.gsearch:focus-within { border-color: var(--muted-2); box-shadow: 0 0 0 3px var(--focus); }
.gsearch input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--ink); font-size: 13px; }
.gsearch input::-webkit-search-cancel-button { display: none; }
kbd {
  font: 11px/1 var(--font); color: var(--muted);
  border: 1px solid var(--border); border-radius: 5px; padding: 3px 6px;
}
.gresults {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 30;
  width: min(380px, calc(100vw - 32px));
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-lg); padding: 6px; max-height: 60vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px;
}
.gres-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px; border-radius: 8px; color: var(--ink); text-align: left; line-height: 1.35;
}
.gres-item > span:last-child { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.gres-item > span:last-child > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gres-item:hover, .gres-item.sel { background: var(--hover); }
.gres-item small { color: var(--muted); display: block; font-size: 12px; }
.gres-empty { padding: 14px; color: var(--muted); font-size: 13px; text-align: center; }

/* ============ Content ============ */
.content { padding: 28px 32px 32px; flex: 1; min-width: 0; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head h1 { margin: 0 0 4px; font-size: 26px; font-weight: 650; letter-spacing: -.025em; line-height: 1.2; }
.page-head p { margin: 0; color: var(--muted); font-size: 13px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--panel);
  font-size: 13px; font-weight: 500; white-space: nowrap;
  box-shadow: var(--shadow);
  transition: background-color .12s ease, border-color .12s ease;
}
.btn:hover { background: var(--hover); }
.btn-primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary); opacity: .88; }

/* Tabs */
.tabs {
  display: flex; gap: 22px; border-bottom: 1px solid var(--border-soft);
  margin-bottom: 16px; overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative; padding: 8px 0 11px; color: var(--muted);
  font-size: 13px; font-weight: 500; white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); }
.tab.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--ink); border-radius: 2px; }
.tab .cnt { margin-left: 6px; font-size: 11px; color: var(--muted); background: var(--gray-bg); padding: 1px 6px; border-radius: 99px; }

/* Toolbar */
.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.field {
  display: flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--field); color: var(--muted);
}
.field:focus-within { border-color: var(--muted-2); box-shadow: 0 0 0 3px var(--focus); }
.field input { border: 0; outline: 0; background: none; color: var(--ink); font-size: 13px; width: 100%; min-width: 0; }
.field.search { width: 260px; }
.select {
  appearance: none; -webkit-appearance: none;
  height: 34px; padding: 0 30px 0 12px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--field) var(--chevron) no-repeat right 9px center / 14px;
  font-size: 13px; font-weight: 500; color: var(--ink); cursor: pointer;
}

/* Ansicht-Umschalter (Segmented Control) */
.seg {
  margin-left: auto; display: inline-flex; gap: 2px; padding: 2px; height: 34px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--sidebar);
}
.seg-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 0 10px; border-radius: 6px;
  color: var(--muted); font-size: 13px; font-weight: 500;
  transition: background-color .12s ease, color .12s ease;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.on { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }

/* Stat-Karten */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 28px; }
.stat {
  display: flex; flex-direction: column; gap: 14px;
  padding: 16px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--panel); box-shadow: var(--shadow);
  transition: border-color .12s ease;
}
.stat:hover { border-color: var(--muted-2); }
.stat-top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 13px; font-weight: 500; }
.stat-ic { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: var(--sidebar); border: 1px solid var(--border-soft); color: var(--ink); }
.stat-num { font-size: 28px; font-weight: 650; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 12px; color: var(--muted); }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 0 12px; }
.section-title h2 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -.01em; }

/* ============ Tabelle ============ */
.card { border: 1px solid var(--border); border-radius: 12px; background: var(--panel); overflow: hidden; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; font-weight: 500; color: var(--muted); font-size: 12px;
  padding: 10px 14px; background: var(--panel); border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}
.tbl td { padding: 10px 14px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr.row:hover { background: var(--row-hover); }
.tbl tr.group td {
  background: var(--sidebar); padding: 8px 14px; font-weight: 600; font-size: 12px;
}
.tbl tr.group small { color: var(--muted); font-weight: 400; margin-left: 6px; }
.w-act { width: 1%; white-space: nowrap; text-align: right; }
.nowrap { white-space: nowrap; }

.cell-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cell-main .txt { min-width: 0; }
.cell-main .t { font-weight: 500; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 44ch; }
.cell-main .s { color: var(--muted); font-size: 12px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 52ch; }
.done .cell-main .t { text-decoration: line-through; color: var(--muted); }

.tile {
  width: 32px; height: 32px; border-radius: 8px; flex: none;
  display: grid; place-items: center;
  border: 1px solid var(--border); background: var(--panel); color: var(--muted);
  font-size: 13px; font-weight: 600;
}
.tile.letter { background: var(--ink); color: var(--panel); border-color: var(--ink); text-transform: uppercase; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px; border-radius: 6px;
  font-size: 12px; font-weight: 500; white-space: nowrap;
  background: var(--gray-bg); color: var(--gray);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: none; }
.badge.dot::before { display: block; }
.b-green { background: var(--green-bg); color: var(--green); }
.b-red { background: var(--red-bg); color: var(--red); }
.b-amber { background: var(--amber-bg); color: var(--amber); }
.b-blue { background: var(--blue-bg); color: var(--blue); }
.b-violet { background: var(--violet-bg); color: var(--violet); }
.outline { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.due-over { color: var(--red); font-weight: 500; }

.row-actions { display: inline-flex; gap: 2px; opacity: .55; transition: opacity .12s ease; }
tr.row:hover .row-actions, .row-actions:focus-within { opacity: 1; }
.row-actions .icon-btn { width: 30px; height: 30px; color: var(--muted); }
.row-actions .icon-btn:hover { color: var(--ink); }
.row-actions .danger:hover { color: var(--red); }

.check {
  width: 20px; height: 20px; border-radius: 6px; flex: none;
  border: 1.5px solid var(--muted-2); display: grid; place-items: center;
  color: transparent; transition: background-color .12s ease, border-color .12s ease;
}
.check .ic { width: 14px; height: 14px; stroke-width: 2.2; }
.check:hover { border-color: var(--ink); }
.check.on { background: var(--ink); border-color: var(--ink); color: var(--panel); }

.star-btn { color: var(--muted-2); }
.star-btn:hover { color: var(--star); }
.star-btn.on { color: var(--star); }
.star-btn.on .ic { fill: var(--star); }
.act-cell { display: flex; align-items: center; justify-content: flex-end; gap: 2px; }
.act-cell > .star-btn { width: 30px; height: 30px; }

/* Link-Karten */
.link-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.link-card {
  position: relative; display: flex; flex-direction: column; gap: 12px; min-width: 0;
  padding: 14px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--panel); box-shadow: var(--shadow);
  transition: border-color .12s ease;
}
.link-card:hover { border-color: var(--muted-2); }
.lc-top { display: flex; align-items: flex-start; justify-content: space-between; }
.lc-top .star-btn { width: 30px; height: 30px; margin: -4px -6px 0 0; }
.lc-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.lc-title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.lc-title::after { content: ""; position: absolute; inset: 0; border-radius: inherit; } /* ganze Karte klickbar */
a.lc-title:focus-visible { outline: 0; }
.link-card:has(a.lc-title:focus-visible) { outline: 2px solid var(--ink); outline-offset: 2px; }
.lc-domain { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lc-note {
  margin: 6px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.lc-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 30px; }
.link-card .star-btn, .link-card .row-actions { position: relative; z-index: 1; }
.link-card:hover .row-actions, .link-card:focus-within .row-actions { opacity: 1; }
.tbl-foot.bare { border-top: 0; padding: 14px 2px 0; }
/* Ideas-/Wiki-Karten */
.lc-badges { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; position: relative; z-index: 1; }
.lc-title-btn { display: block; max-width: 100%; padding: 0; text-align: left; color: var(--ink); cursor: pointer; }
.lc-title-btn:hover, a.lc-title:hover { text-decoration: underline; text-underline-offset: 2px; }
.lc-badges button.badge { cursor: pointer; }
.wiki-card .lc-note { -webkit-line-clamp: 3; }

/* Todo: Status-Badge in der Liste */
.cell-main .t .badge { height: 18px; padding: 0 6px; font-size: 11px; margin-left: 8px; vertical-align: 1px; }

/* ============ Todo-Board ============ */
.board {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 1fr);
  gap: 12px; align-items: start; overflow-x: auto; padding-bottom: 6px;
}
.lane {
  display: flex; flex-direction: column; gap: 8px; min-width: 0;
  padding: 8px; border: 1px solid var(--border-soft); border-radius: 12px;
  background: var(--sidebar);
  transition: background-color .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.lane.over { border-color: var(--muted-2); background: var(--hover); box-shadow: inset 0 0 0 1px var(--muted-2); }
.lane-head { display: flex; align-items: center; gap: 8px; padding: 0 0 0 6px; min-height: 30px; font-size: 13px; font-weight: 600; }
.lane-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lane-head .cnt { font-size: 11px; font-weight: 500; color: var(--muted); background: var(--panel); border: 1px solid var(--border-soft); padding: 0 6px; border-radius: 99px; }
.lane-add { margin-left: auto; width: 28px; height: 28px; color: var(--muted); }
.lane-add:hover { color: var(--ink); }
.lane-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--muted-2); }
.k-gray { background: var(--muted-2); }
.k-blue { background: var(--blue); }
.k-green { background: var(--green); }
.k-red { background: var(--red); }
.k-amber { background: var(--amber); }
.lane-body { display: flex; flex-direction: column; gap: 8px; min-height: 64px; }
.lane-empty {
  display: grid; place-items: center; min-height: 64px; padding: 12px;
  border: 1.5px dashed var(--border); border-radius: 10px;
  color: var(--muted-2); font-size: 12px; text-align: center;
}

.todo-card {
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px 8px 8px 10px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--panel); box-shadow: var(--shadow);
  cursor: var(--cur-grab); user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: border-color .12s ease, opacity .12s ease;
}
.todo-card:hover { border-color: var(--muted-2); }
.tc-top { display: flex; align-items: flex-start; gap: 10px; }
.tc-top .check { margin-top: 1px; }
.tc-txt { flex: 1; min-width: 0; }
.tc-title { display: block; font-size: 13px; font-weight: 500; line-height: 1.4; overflow-wrap: anywhere; }
.todo-card.done .tc-title { text-decoration: line-through; color: var(--muted); }
.tc-note {
  margin: 2px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tc-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-height: 30px; padding-left: 30px; }
.tc-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; font-size: 12px; color: var(--muted); }
.due { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.todo-card .row-actions { opacity: 0; }
.todo-card:hover .row-actions, .todo-card:focus-within .row-actions { opacity: 1; }
@media (hover: none) { .todo-card .row-actions { opacity: 1; } }

.drag-src { display: none !important; }
/* Platzhalter: zeigt beim Ziehen, wo die Karte landet */
.drop-ph {
  flex: none; border: 1.5px dashed var(--muted-2); border-radius: 10px;
  background: color-mix(in oklab, var(--panel), transparent 40%);
}
.lane-body:has(.drop-ph) .lane-empty { display: none; }
.drag-ghost {
  position: fixed; top: 0; left: 0; z-index: 70; margin: 0;
  pointer-events: none; box-shadow: var(--shadow-lg); border-color: var(--muted-2);
}
.is-dragging, .is-dragging * { cursor: var(--cur-grabbing) !important; user-select: none; -webkit-user-select: none; }
.is-dragging .board { scroll-snap-type: none; }

/* ============ Todo-Kalender ============ */
.cal-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 12px; align-items: start; }
.cal-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 12px; padding: 12px 14px; border-bottom: 1px solid var(--border-soft); }
.cal-title { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; }
.cal-nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cal-span { margin-left: 0; margin-right: 4px; }
.cal-span .seg-btn { padding: 0 10px; }
.cal-wd, .cal-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-wd span { padding: 8px 10px; font-size: 12px; font-weight: 500; color: var(--muted); border-bottom: 1px solid var(--border-soft); }
.cal-wd .wknd { color: var(--muted-2); }
.cal-day {
  display: flex; flex-direction: column; gap: 4px; min-width: 0; min-height: 112px; padding: 6px;
  border-right: 1px solid var(--border-soft); border-bottom: 1px solid var(--border-soft);
  transition: background-color .12s ease, box-shadow .12s ease;
}
.cal-day:nth-child(7n) { border-right: 0; }
.cal-month .cal-day:nth-last-child(-n+7), .cal-week .cal-day { border-bottom: 0; }
.cal-dayview.over { background: var(--hover); box-shadow: inset 0 0 0 1.5px var(--muted-2); }
.cal-day.wknd { background: color-mix(in oklab, var(--sidebar), transparent 50%); }
.cal-day.out .cal-num, .cal-day.out .cal-items { opacity: .45; }
.cal-day.sel { background: var(--row-hover); }
.cal-day.over { background: var(--hover); box-shadow: inset 0 0 0 1.5px var(--muted-2); }
.cal-dh { display: flex; align-items: center; justify-content: space-between; min-height: 26px; }
.cal-num {
  min-width: 26px; height: 26px; padding: 0 6px; border-radius: 99px;
  font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums; color: var(--ink);
}
.cal-num:hover { background: var(--hover); }
.cal-day.today .cal-num { background: var(--primary); color: var(--on-primary); font-weight: 600; }
.cal-add { width: 24px; height: 24px; color: var(--muted); opacity: 0; transition: opacity .12s ease; }
.cal-add:hover { color: var(--ink); }
.cal-day:hover .cal-add, .cal-add:focus-visible { opacity: 1; }
@media (hover: none) { .cal-add { display: none; } }
.cal-items { display: flex; flex-direction: column; gap: 3px; min-width: 0; }

.cal-chip {
  display: flex; align-items: center; gap: 6px; width: 100%; min-width: 0;
  padding: 3px 6px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--panel); box-shadow: var(--shadow);
  font-size: 12px; line-height: 1.35; text-align: left; color: var(--ink);
  cursor: var(--cur-grab); user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: border-color .12s ease, opacity .12s ease;
}
.cal-chip:hover { border-color: var(--muted-2); }
.cal-chip .lane-dot { width: 6px; height: 6px; }
.cc-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-chip.doing { border-left: 3px solid var(--blue); padding-left: 4px; }
.cal-chip.over { border-color: color-mix(in oklab, var(--red), transparent 60%); background: var(--red-bg); color: var(--red); }
.cal-chip.done .cc-t { text-decoration: line-through; color: var(--muted); }
.cal-chip.done { box-shadow: none; }
.drag-dim { opacity: .35; }
.cal-chip.drag-ghost { width: auto; max-width: 220px; }

.cal-nodate .cal-chip { padding: 6px 8px; font-size: 13px; }
.cal-nodate .lane-body { gap: 6px; min-height: 48px; }
.cal-nodate .lane-empty { min-height: 48px; }
.cal-agenda { display: none; }
.cal-agenda .todo-card, .cal-dayview .todo-card { cursor: default; user-select: auto; -webkit-user-select: auto; }

/* Woche: 7 hohe Spalten */
.cal-week .cal-day { min-height: 420px; padding: 8px 6px; }
.cal-wdh { display: inline-flex; align-items: center; gap: 6px; padding: 2px 6px 2px 2px; border-radius: 99px; color: var(--ink); }
.cal-wdh:hover { background: var(--hover); }
.cal-wdh .wd { order: 2; font-size: 12px; font-weight: 500; color: var(--muted); }
.cal-wdh .cal-num { display: inline-grid; place-items: center; font-size: 13px; }
.cal-week .cal-day.today .cal-wdh .cal-num { background: var(--primary); color: var(--on-primary); }
.cal-week .cal-chip { align-items: flex-start; padding: 5px 6px; }
.cal-week .cal-chip .lane-dot { margin-top: 5px; }
.cal-week .cc-t { white-space: normal; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }

/* Tag: Aufgabenliste */
.cal-dayview { display: flex; flex-direction: column; gap: 8px; min-height: 260px; padding: 14px; transition: background-color .12s ease, box-shadow .12s ease; }
.cal-dayview > .todo-card { max-width: 720px; }
.cal-dv-add { align-self: flex-start; margin-top: 4px; }

/* Jahr: 12 Mini-Monate */
.cal-year { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 22px 26px; padding: 16px 18px 20px; }
.cy-m { min-width: 0; }
.cy-title { display: block; margin: 0 0 6px 2px; padding: 2px 6px; border-radius: 6px; font-size: 13px; font-weight: 600; color: var(--ink); text-transform: capitalize; }
.cy-title:hover { background: var(--hover); }
.cy-wd, .cy-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); text-align: center; }
.cy-wd span { font-size: 10px; font-weight: 500; color: var(--muted-2); padding-bottom: 2px; }
.cy-d {
  position: relative; display: grid; place-items: center; aspect-ratio: 1; min-width: 0;
  border-radius: 99px; font-size: 11px; font-variant-numeric: tabular-nums; color: var(--muted);
}
.cy-d:hover { background: var(--hover); color: var(--ink); }
.cy-d.has { color: var(--ink); font-weight: 600; }
.cy-d.has::after { content: ""; position: absolute; bottom: 1px; width: 4px; height: 4px; border-radius: 50%; background: var(--blue); }
.cy-d.alldone::after { background: var(--muted-2); }
.cy-d.over::after { background: var(--red); }
.cy-d.sel { box-shadow: inset 0 0 0 1px var(--muted-2); }
.cy-d.today { background: var(--primary); color: var(--on-primary); font-weight: 600; }
.cy-d.today::after { background: var(--on-primary); }

.tbl-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 14px; border-top: 1px solid var(--border-soft); color: var(--muted); font-size: 12px;
}
.pager { display: flex; align-items: center; gap: 4px; }
.pg {
  min-width: 30px; height: 30px; padding: 0 6px; border-radius: 7px;
  display: inline-grid; place-items: center; font-size: 12px; color: var(--ink);
  border: 1px solid transparent;
}
.pg:hover:not(:disabled) { background: var(--hover); }
.pg.cur { border-color: var(--border); background: var(--panel); font-weight: 600; box-shadow: var(--shadow); }
.pg:disabled { opacity: .35; cursor: default; }
.pg.bordered { border-color: var(--border); }

.empty { padding: 48px 16px; text-align: center; color: var(--muted); }
.empty .tile { margin: 0 auto 12px; width: 44px; height: 44px; }
.empty strong { display: block; color: var(--ink); font-weight: 600; margin-bottom: 4px; }
.empty .btn { margin-top: 14px; }

.footnote { margin-top: 14px; color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; }

/* ============ Wiki ============ */
a.cell-main { color: inherit; }
a.cell-main:hover .link-t { text-decoration: underline; text-underline-offset: 3px; }
.article-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 24px; }
.article { max-width: 760px; }
.article h1 { margin: 10px 0 18px; font-size: 30px; font-weight: 650; letter-spacing: -.025em; line-height: 1.2; }
.article-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: 12px; }
.prose { font-size: 15px; line-height: 1.7; color: var(--ink); }
.prose > :first-child { margin-top: 0; }
.prose p, .prose ul, .prose ol, .prose pre, .prose blockquote { margin: 0 0 14px; }
.prose h2 { font-size: 20px; font-weight: 650; letter-spacing: -.015em; margin: 28px 0 10px; line-height: 1.3; }
.prose h3 { font-size: 17px; font-weight: 600; margin: 22px 0 8px; }
.prose h4 { font-size: 15px; font-weight: 600; margin: 18px 0 6px; }
.prose ul, .prose ol { padding-left: 22px; }
.prose li { margin: 3px 0; }
.prose li::marker { color: var(--muted); }
.prose li.task { list-style: none; margin-left: -22px; display: flex; align-items: flex-start; gap: 9px; }
.prose .tbox {
  width: 18px; height: 18px; margin-top: 4px; flex: none; border-radius: 5px;
  border: 1.5px solid var(--muted-2); display: grid; place-items: center;
}
.prose .tbox .ic { width: 12px; height: 12px; stroke-width: 2.4; }
.prose li.task.checked { color: var(--muted); text-decoration: line-through; }
.prose li.task.checked .tbox { background: var(--ink); border-color: var(--ink); color: var(--panel); }
.prose a { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--muted-2); }
.prose a:hover { text-decoration-color: currentColor; }
.prose code { font: 13px/1.5 ui-monospace, "Cascadia Code", Consolas, monospace; background: var(--gray-bg); border-radius: 5px; padding: 1px 5px; }
.prose pre { background: var(--sidebar); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; overflow-x: auto; }
.prose pre code { background: none; padding: 0; }
.prose blockquote { border-left: 3px solid var(--border); padding: 2px 0 2px 14px; color: var(--muted); }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 24px 0; }
.prose h1 { font-size: 23px; font-weight: 650; letter-spacing: -.02em; margin: 30px 0 12px; line-height: 1.25; }
.prose s { color: var(--muted); }
.prose table { width: 100%; border-collapse: collapse; margin: 0 0 16px; font-size: 14px; line-height: 1.5; }
.prose td, .prose th { border: 1px solid var(--border); padding: 7px 10px; vertical-align: top; text-align: left; overflow-wrap: anywhere; min-width: 48px; }
.prose th { background: var(--sidebar); font-weight: 600; }
.prose td > :last-child, .prose th > :last-child { margin-bottom: 0; }
.dlg.dlg-wide { width: min(820px, calc(100vw - 24px)); }

/* ============ Wiki-Editor ============ */
.fld .lbl { font-size: 12px; font-weight: 500; color: var(--muted); }
.rte { border: 1px solid var(--border); border-radius: 10px; background: var(--field); }
.rte:focus-within { border-color: var(--muted-2); box-shadow: 0 0 0 3px var(--focus); }
.rte-bar {
  position: sticky; top: 0; z-index: 2;
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px;
  padding: 6px; border-bottom: 1px solid var(--border-soft);
  background: var(--panel); border-radius: 10px 10px 0 0;
}
.rte-btn {
  min-width: 30px; height: 30px; padding: 0 6px; border-radius: 7px;
  display: inline-grid; place-items: center;
  color: var(--muted); font-size: 12px; font-weight: 650; letter-spacing: .01em;
  transition: background-color .12s ease, color .12s ease;
}
.rte-btn:hover { background: var(--hover); color: var(--ink); }
.rte-btn.on { background: var(--gray-bg); color: var(--ink); }
.rte-sep { width: 1px; height: 18px; margin: 0 4px; background: var(--border); }
.rte-area {
  min-height: 160px;
  padding: 14px 16px; outline: 0; font-size: 14.5px; line-height: 1.65;
  overflow-wrap: anywhere;
}

/* Wiki-Popup: feste Höhe passend zum Bildschirm. Der Editor füllt den Restplatz,
   nur das Inhaltsfeld scrollt – Titel, Kategorie, Werkzeugleiste und Speichern bleiben stehen. */
.dlg.dlg-wide { height: min(880px, calc(100dvh - 32px)); }
.dlg-wide form { height: 100%; }
.dlg-wide .dlg-body { display: flex; flex-direction: column; }
.dlg-wide .dlg-body > .fld, .dlg-wide .dlg-body > .fld-row { flex: none; }
.dlg-wide .dlg-body > .fld-grow { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.dlg-wide .rte { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.dlg-wide .rte-bar { flex: none; position: static; }
.dlg-wide .rte-area { flex: 1 1 auto; min-height: 120px; overflow-y: auto; overscroll-behavior: contain; }
.rte-area table td, .rte-area table th { min-width: 60px; }
.rte-area table td:focus-within, .rte-area table th:focus-within { outline: 0; }

.rte-pop-wrap { position: relative; display: inline-flex; }
.rte-pop {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 5;
  padding: 10px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--panel); box-shadow: var(--shadow-lg);
}
.tg-title { font-size: 12px; font-weight: 600; margin: 0 0 8px; white-space: nowrap; }
.tg { display: grid; grid-template-columns: repeat(5, 22px); gap: 4px; }
.tg-c { width: 22px; height: 22px; border: 1px solid var(--border); border-radius: 5px; background: var(--field); }
.tg-c.on { background: var(--blue-bg); border-color: var(--blue); }
.tg-lbl { margin-top: 8px; text-align: center; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rte-menu { display: flex; flex-direction: column; min-width: 210px; margin: -4px; }
.rte-menu button { text-align: left; padding: 7px 10px; border-radius: 7px; font-size: 13px; white-space: nowrap; }
.rte-menu button:hover, .rte-menu button:focus-visible { background: var(--hover); }
.rte-menu button.danger { color: var(--red); }
.rte-menu hr { border: 0; border-top: 1px solid var(--border-soft); margin: 4px 0; }

/* ============ Dialog ============ */
.dlg {
  width: min(520px, calc(100vw - 24px));
  padding: 0; border: 1px solid var(--border); border-radius: 16px;
  background: var(--panel); color: var(--ink); box-shadow: var(--shadow-lg);
}
.dlg::backdrop { background: rgba(15, 15, 20, .42); }
.dlg[open] { animation: pop .16s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.985); } }
/* Kopf und Fuss fix, nur der Body scrollt – Speichern bleibt immer sichtbar */
.dlg { max-height: calc(100dvh - 32px); overflow: hidden; }
.dlg form { display: flex; flex-direction: column; max-height: calc(100dvh - 34px); }
.dlg-head { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 0 20px; }
.dlg-head h2 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.dlg-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 16px 20px 4px; display: grid; align-content: start; gap: 14px; }
.dlg-foot { flex: none; display: flex; justify-content: flex-end; gap: 8px; padding: 16px 20px 20px; }
.fld { display: grid; gap: 6px; }
.fld label { font-size: 12px; font-weight: 500; color: var(--muted); }
.fld-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fld .hint { font-size: 12px; color: var(--muted); line-height: 1.4; }
.dlg-sec {
  margin: 6px 0 -4px; padding-top: 14px; border-top: 1px solid var(--border-soft);
  font-size: 13px; font-weight: 600; letter-spacing: -.005em;
}
.dlg-sec:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.inp {
  width: 100%; height: 38px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--field); color: var(--ink); font-size: 14px; outline: 0;
}
textarea.inp { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; line-height: 1.45; }
.inp:focus { border-color: var(--muted-2); box-shadow: 0 0 0 3px var(--focus); }
.inp.invalid { border-color: var(--red); }
select.inp { appearance: none; -webkit-appearance: none; background: var(--field) var(--chevron) no-repeat right 10px center / 15px; padding-right: 32px; cursor: pointer; }
/* Textfelder mit Vorschlagsliste (datalist): gleicher Pfeil statt Browser-Dreieck.
   Der native Auslöser bleibt unsichtbar über dem Pfeil liegen, damit ein Klick die Liste öffnet. */
input.inp[list] { background: var(--field) var(--chevron) no-repeat right 10px center / 15px; padding-right: 32px; }
input.inp[list]::-webkit-calendar-picker-indicator { opacity: 0; width: 32px; height: 36px; margin: 0 -12px 0 0; cursor: pointer; }
input.inp[list]::-webkit-list-button { opacity: 0; }

/* ============ Toast ============ */
.toast {
  position: fixed; left: 50%; bottom: 20px; z-index: 60;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 10px;
  background: var(--primary); color: var(--on-primary);
  font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lg);
  animation: pop .16s ease-out;
  max-width: calc(100vw - 32px);
}
.toast button { color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }

/* ============ Sidebar einklappen (Desktop) ============ */
@media (min-width: 901px) {
  .app { transition: grid-template-columns .2s cubic-bezier(.2, .8, .2, 1); }
  .sidebar { overflow-x: hidden; }
  :root[data-sidebar="collapsed"] .app { grid-template-columns: 68px minmax(0, 1fr); }
  :root[data-sidebar="collapsed"] .sidebar { padding: 16px 10px 12px; }
  :root[data-sidebar="collapsed"] .brand { justify-content: center; padding: 4px 0 18px; }
  :root[data-sidebar="collapsed"] .brand-name,
  :root[data-sidebar="collapsed"] .nav-count,
  :root[data-sidebar="collapsed"] .user-meta { display: none; }
  :root[data-sidebar="collapsed"] .nav-item { justify-content: center; padding: 0; }
  /* Text visuell ausblenden, für Screenreader aber behalten */
  :root[data-sidebar="collapsed"] .nav-item span:not(.nav-count) {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  /* Abschnittstitel werden zu Trennlinien */
  :root[data-sidebar="collapsed"] .nav-label { height: 1px; margin: 14px 10px; overflow: hidden; color: transparent; background: var(--border); }
  :root[data-sidebar="collapsed"] .user { justify-content: center; padding: 10px 0; }

  /* Umschalter: ausgeklappt rechts neben dem Titel in der Sidebar, eingeklappt oben in der Kopfzeile */
  .sb-collapse { width: 30px; height: 30px; margin-right: -4px; color: var(--muted); }
  .sb-collapse:hover { color: var(--ink); }
  :root[data-sidebar="collapsed"] .sb-collapse,
  :root:not([data-sidebar="collapsed"]) .sb-expand { display: none; }
  :root:not([data-sidebar="collapsed"]) .topbar { padding-left: 24px; }
}

/* ============ Laden & Login ============ */
.boot, .auth { display: none; }
:root[data-auth="loading"] .boot { display: flex; }
:root[data-auth="out"] .auth { display: grid; }
:root:not([data-auth="in"]) .app { display: none; }
.boot {
  position: fixed; inset: 0; align-items: center; justify-content: center; gap: 10px;
  background: var(--sidebar); color: var(--muted); font-size: 13px;
}
.boot-spinner {
  width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--ink);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.auth { min-height: 100dvh; place-items: center; padding: 24px 16px; background: var(--sidebar); }
.auth-wrap { width: min(380px, 100%); display: grid; gap: 16px; }
.auth-card {
  display: grid; gap: 14px; padding: 28px 24px 24px;
  border: 1px solid var(--border); border-radius: 14px; background: var(--panel); box-shadow: var(--shadow-lg);
}
.auth-panel { display: grid; gap: 14px; }
.auth-panel[hidden] { display: none; }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.auth h1 { margin: 0; font-size: 20px; font-weight: 650; letter-spacing: -.02em; }
.auth-lead { margin: -6px 0 4px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.auth-lead strong { color: var(--ink); font-weight: 600; word-break: break-all; }
.auth-hint { margin: -6px 0 0; color: var(--muted); font-size: 12px; }
.auth-err { margin: 0; padding: 8px 10px; border-radius: 8px; background: var(--red-bg); color: var(--red); font-size: 13px; line-height: 1.5; }
.auth-err.ok { background: var(--green-bg); color: var(--green); }
.auth-link {
  padding: 0; border: 0; background: none; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer;
  text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 3px;
}
.auth-link:hover, .auth-link:focus-visible { color: var(--ink); text-decoration-color: currentColor; }
.auth-forgot { justify-self: end; margin-top: 2px; }
.auth-back { justify-self: center; margin-top: 2px; }
.auth-foot { display: flex; justify-content: center; gap: 16px; font-size: 12px; }
.auth-foot a { color: var(--muted); text-decoration: none; }
.auth-foot a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.auth-submit { justify-content: center; height: 38px; margin-top: 4px; }
.auth-submit[disabled] { opacity: .6; cursor: progress; }

/* ============ Impressum ============ */
.legal { width: min(720px, 100%); margin: 0 auto; padding: 32px 16px 48px; display: grid; gap: 16px; }
.legal-back { justify-self: start; display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 13px; }
.legal-back:hover { color: var(--ink); }
.legal-card {
  display: grid; gap: 22px; padding: 32px 28px;
  border: 1px solid var(--border); border-radius: 14px; background: var(--panel); box-shadow: var(--shadow);
}
.legal-card h1 { margin: 0; font-size: 24px; font-weight: 650; letter-spacing: -.02em; }
.legal-card section { display: grid; gap: 8px; }
.legal-card h2 { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.legal-card p, .legal-card address { margin: 0; font-style: normal; line-height: 1.6; }
.legal-card p { color: color-mix(in oklab, var(--ink), var(--muted) 30%); }
.legal-dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 4px 0 0; }
.legal-dl dt { color: var(--muted); }
.legal-dl dd { margin: 0; overflow-wrap: anywhere; }
.legal-link { text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 3px; }
.legal-link:hover { text-decoration-color: currentColor; }
.legal-stand { padding-top: 14px; border-top: 1px solid var(--border-soft); font-size: 12px; color: var(--muted) !important; }
@media (max-width: 560px) {
  .legal-card { padding: 24px 18px; }
  .legal-dl { grid-template-columns: 1fr; gap: 0; }
  .legal-dl dd { margin-bottom: 8px; }
}

/* ============ Einstellungen (Dialog mit Bereichsnavigation) ============ */
.dlg.dlg-settings { width: min(760px, calc(100vw - 24px)); }
.dlg-settings .dlg-body { padding-top: 12px; }
.set { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 24px; min-height: 380px; }
.set-nav { display: flex; flex-direction: column; gap: 2px; padding-right: 16px; border-right: 1px solid var(--border-soft); }
.set-tab {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 34px; padding: 0 10px; border-radius: 8px;
  color: var(--muted); font-size: 13px; font-weight: 500; text-align: left; transition: background-color .12s ease, color .12s ease;
}
.set-tab:hover { background: var(--hover); color: var(--ink); }
.set-tab[aria-selected="true"] { background: var(--hover); color: var(--ink); }
.set-panel { display: grid; align-content: start; gap: 14px; min-width: 0; }
.set-value { font-size: 14px; overflow-wrap: anywhere; }
.set-pending { margin: 0; padding: 8px 10px; border-radius: 8px; background: var(--amber-bg); color: var(--amber); font-size: 13px; line-height: 1.5; }
.set-pending strong { font-weight: 600; overflow-wrap: anywhere; }
.set-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: var(--red-bg); border-color: color-mix(in oklab, var(--red), transparent 70%); }
@media (max-width: 640px) {
  .set { grid-template-columns: 1fr; gap: 16px; min-height: 0; }
  .set-nav { flex-direction: row; padding: 0 0 12px; border-right: 0; border-bottom: 1px solid var(--border-soft); }
  .set-tab { width: auto; }
}

/* ============ Benutzermenü ============ */
.umenu {
  position: fixed; top: 0; left: 0; z-index: 65; width: 240px; max-width: calc(100vw - 16px);
  display: flex; flex-direction: column; padding: 6px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--panel); box-shadow: var(--shadow-lg);
  animation: umenu-in .12s ease-out;
}
@keyframes umenu-in { from { opacity: 0; transform: translateY(var(--umenu-dy, 4px)); } }
.umenu-head { display: flex; flex-direction: column; gap: 1px; padding: 6px 10px 8px; line-height: 1.3; min-width: 0; }
.umenu-head strong { font-size: 13px; font-weight: 600; }
.umenu-head small { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.umenu-head small:empty { display: none; }
.umenu hr { border: 0; border-top: 1px solid var(--border-soft); margin: 4px 0; }
.umenu [role="menuitem"] {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 8px;
  color: var(--ink); font-size: 13px; text-align: left; white-space: nowrap;
}
.umenu [role="menuitem"] .ic { color: var(--muted); }
.umenu [role="menuitem"]:hover, .umenu [role="menuitem"]:focus-visible { background: var(--hover); outline: none; }
.umenu [role="menuitem"]:hover .ic, .umenu [role="menuitem"]:focus-visible .ic { color: var(--ink); }
.umenu [role="menuitem"].danger:hover, .umenu [role="menuitem"].danger:focus-visible { background: var(--red-bg); color: var(--red); }
.umenu [role="menuitem"].danger:hover .ic, .umenu [role="menuitem"].danger:focus-visible .ic { color: var(--red); }
.user[aria-expanded="true"] { background: var(--hover); }
.avatar-btn[aria-expanded="true"] { box-shadow: 0 0 0 3px var(--focus); }

/* Speicherstatus in der Topbar */
.sync { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.sync[hidden] { display: none; }
.sync .boot-spinner { width: 12px; height: 12px; border-width: 1.5px; }
.sync.err { color: var(--red); }

/* ============ Responsive ============ */
.only-mobile { display: none; }
@media (max-width: 900px) { .only-desktop { display: none !important; } }

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gsearch { width: 200px; }
  .cell-main .t { max-width: 30ch; }
  .cell-main .s { max-width: 36ch; }
  .cal-wrap { grid-template-columns: minmax(0, 1fr); }
  .cal-year { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .only-mobile { display: inline-grid; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 50;
    width: min(290px, 86vw);
    transform: translateX(-102%);
    transition: transform .22s cubic-bezier(.2, .8, .2, 1);
    box-shadow: var(--shadow-lg);
    visibility: hidden;
  }
  .nav-open .sidebar { transform: none; visibility: visible; }
  .scrim {
    display: block; position: fixed; inset: 0; z-index: 40;
    background: rgba(15, 15, 20, .4);
    opacity: 0; pointer-events: none; transition: opacity .2s ease;
  }
  .nav-open .scrim { opacity: 1; pointer-events: auto; }
  .main { padding: 0; }
  .panel { border: 0; border-radius: 0; min-height: 100dvh; box-shadow: none; }
  .topbar { padding: 0 12px; position: sticky; top: 0; z-index: 20; background: var(--panel); }
  .content { padding: 22px 16px 28px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
}

@media (max-width: 680px) {
  .article h1 { font-size: 24px; }
  .prose { font-size: 15px; }
  .crumbs > :not(.crumb-current) { display: none; }
  .crumb-current { font-weight: 600; font-size: 15px; }
  .gsearch { width: 38px; padding: 0; justify-content: center; border-color: transparent; background: none; }
  .gsearch kbd { display: none; }
  .gsearch input { position: absolute; opacity: 0; width: 1px; pointer-events: none; }
  .gsearch.open { position: absolute; left: 12px; right: 12px; width: auto; height: 38px; padding: 0 10px; background: var(--field); border-color: var(--border); z-index: 25; justify-content: flex-start; }
  .gsearch.open input { position: static; opacity: 1; width: auto; pointer-events: auto; font-size: 16px; }
  .gresults { left: 0; right: 0; width: auto; }

  .page-head { flex-direction: column; align-items: stretch; }
  .page-head h1 { font-size: 22px; }
  .head-actions { justify-content: flex-start; }
  .head-actions .btn-primary { margin-left: auto; }
  /* Seiten mit „Neu“-Button: Plus nur als Icon, auf Höhe des Titels */
  .page-head:has(.btn-new) { flex-direction: row; align-items: flex-start; }
  .page-head:has(.btn-new) > div:first-child { flex: 1; min-width: 0; }
  .btn-new { width: 38px; height: 38px; padding: 0; justify-content: center; margin-left: 0; }
  .btn-new .ic { width: 18px; height: 18px; }
  .btn-new .btn-label { display: none; }
  .stats { grid-template-columns: minmax(0, 1fr); }
  .stat { flex-direction: row; align-items: center; justify-content: space-between; padding: 14px; }
  .stat-top { order: 2; }
  .stat-top > span:first-child { display: none; }
  .stat-num { font-size: 24px; }
  .field.search { width: 100%; flex: 1 1 100%; }
  .toolbar .select { flex: 1; }
  .fld-row { grid-template-columns: 1fr; }

  /* Board: Lanes horizontal wischen, eine Lane fast bildschirmbreit */
  .board {
    grid-auto-columns: 84%; margin: 0 -16px; padding: 0 16px 6px;
    scroll-snap-type: x mandatory; scroll-padding: 0 16px;
  }
  .lane { scroll-snap-align: start; }
  .field input, .inp { font-size: 16px; } /* verhindert iOS-Zoom */

  /* Kalender: kompaktes Raster mit Punkten, Aufgaben des gewählten Tags darunter */
  .cal-head { padding: 10px 12px; }
  .cal-title { font-size: 15px; width: 100%; }
  .cal-nav { gap: 4px; width: 100%; flex-wrap: nowrap; }
  .cal-span { flex: 1; min-width: 0; }
  .cal-span .seg-btn { flex: 1; justify-content: center; padding: 0 4px; }
  .cal-add { display: none; }
  .cal-foot { display: none; }

  /* Monat: kompaktes Raster mit Punkten, Aufgaben des gewählten Tags darunter */
  .cal-wd span { padding: 6px 0; text-align: center; }
  .cal-month .cal-day { min-height: 54px; padding: 4px 2px; align-items: center; cursor: pointer; }
  .cal-month .cal-dh { justify-content: center; }
  .cal-month .cal-items { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 3px; }
  .cal-month .cal-chip { pointer-events: none; width: 6px; height: 6px; padding: 0; border: 0; box-shadow: none; background: none; }
  .cal-month .cal-chip .cc-t { display: none; }
  .cal-month .cal-chip.done { opacity: .4; }
  .cal-month .cal-day.sel { background: var(--hover); }
  .cal-agenda { display: flex; }

  /* Woche: Tage untereinander */
  .cal-week .cal-days { grid-template-columns: minmax(0, 1fr); }
  .cal-week .cal-day { min-height: 0; padding: 8px 12px 10px; border-right: 0; border-bottom: 1px solid var(--border-soft); }
  .cal-week .cal-day:last-child { border-bottom: 0; }
  .cal-week .cal-day:not(:has(.cal-chip)) .cal-items { display: none; }
  .cal-week .cal-chip { padding: 6px 8px; font-size: 13px; }

  /* Jahr: zwei Mini-Monate nebeneinander */
  .cal-year { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 16px; padding: 12px; }
  .cal-dayview { padding: 12px; }

  /* Tabelle -> Karten */
  .tbl thead { display: none; }
  .tbl, .tbl tbody { display: block; }
  .tbl tr.row {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px;
    padding: 12px 14px; border-bottom: 1px solid var(--border-soft);
  }
  .tbl tr.row::before { content: ""; order: 3; flex-basis: 100%; height: 0; }
  .tbl tr.group, .tbl tr.group td { display: block; }
  .tbl tr.row td { padding: 0; border: 0; display: block; width: auto !important; }
  .tbl tr.row td.c-lead { order: 0; }
  .tbl tr.row td.c-main { order: 1; flex: 1 1 0; min-width: 0; }
  .tbl tr.row td.c-act { order: 2; }
  .tbl tr.row td.c-meta { order: 4; color: var(--muted); font-size: 12px; }
  .tbl tr.row td.c-meta:empty { display: none; }
  .tbl tr.row.has-tile td.c-meta.first,
  .tbl tr.row.has-tile td.c-meta.first:empty + td.c-meta { margin-left: 44px; }
  .tbl tr.row.has-lead td.c-meta.first,
  .tbl tr.row.has-lead td.c-meta.first:empty + td.c-meta { margin-left: 30px; }
  .cell-main .t, .cell-main .s { max-width: none; white-space: normal; }
  .row-actions { opacity: 1; }
  .tbl-foot { justify-content: center; }
  .tbl-foot .info { width: 100%; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
