/* Workspace – ruhiges, app-artiges Layout. Hell/Dunkel folgt dem System. */
:root {
  --bg: #f6f7f9; --surface: #ffffff; --surface-2: #f0f2f5; --border: #e3e6eb;
  --text: #1b1f24; --muted: #667085; --accent: #2f6fed; --accent-soft: #e8efff; --accent-text: #ffffff;
  --good: #16a34a; --warn: #d97706; --bad: #dc2626;
  --radius: 12px; --radius-sm: 8px; --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
  --shadow-lg: 0 12px 32px rgba(16,24,40,.18);
  --sidebar: 232px; --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a; --surface: #1c1f24; --surface-2: #252930; --border: #2e333b;
    --text: #e7e9ec; --muted: #9aa3af; --accent: #5b8cff; --accent-soft: #233257; --accent-text: #0b1020;
    --good: #22c55e; --warn: #f59e0b; --bad: #f87171;
    --shadow: 0 1px 2px rgba(0,0,0,.3); --shadow-lg: 0 12px 32px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
button { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
.ic { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.warn-text { color: var(--warn); }
.center { text-align: center; margin: 16px 0; }
.spacer { flex: 1; }
[hidden] { display: none !important; }

/* ---------- Grundlayout ---------- */
#app { min-height: 100%; }
body.authed #app { display: flex; }
.sidebar { width: var(--sidebar); flex: none; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 8px; padding: 16px 12px; background: var(--surface); border-right: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; padding: 4px 8px 8px; }
.search-trigger { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius-sm); color: var(--muted); cursor: pointer; text-align: left; }
.search-trigger span { flex: 1; }
kbd { font: 11px var(--font); padding: 2px 6px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface); color: var(--muted); }
.sidebar ul { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow: auto; }
.sidebar li a { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: var(--radius-sm); color: var(--text); font-weight: 500; }
.sidebar li a:hover { background: var(--surface-2); }
.sidebar li a.active { background: var(--accent-soft); color: var(--accent); }
.sidebar-foot { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--border); padding-top: 10px; }
.user { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; font-weight: 700; }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 14px 28px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid transparent; }
.topbar h1 { font-size: 22px; flex: 1; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
main { padding: 8px 28px 40px; outline: none; max-width: 1400px; width: 100%; }
.bottom-nav, .mobile-only { display: none; }

/* ---------- Bausteine ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.small { padding: 6px 10px; font-size: 14px; }
.btn.block { width: 100%; padding: 11px; }
.btn:disabled { opacity: .6; cursor: default; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius-sm); border: 0; background: transparent; cursor: pointer; color: var(--muted); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.small { width: 28px; height: 28px; }
.input { width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; }
.input:focus, .btn:focus-visible, .icon-btn:focus-visible, a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea.input { resize: vertical; }
.select { width: auto; padding-right: 28px; }
.search { max-width: 280px; }
.lbl { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 12px; }
.lbl .input, .lbl .static { font-weight: 400; color: var(--text); font-size: 15px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); cursor: pointer; }
.form { min-width: min(520px, 80vw); }
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.toolbar.wrap { flex-wrap: wrap; }
.toolbar .search { margin-left: auto; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 3px; border-radius: 10px; }
.tab { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 500; }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.seg-btn { display: inline-flex; gap: 6px; align-items: center; padding: 6px 12px; border: 0; background: var(--surface); cursor: pointer; color: var(--muted); }
.seg-btn.active { background: var(--accent-soft); color: var(--accent); }
.chip { display: inline-block; padding: 1px 8px; border: 1px solid var(--border); border-radius: 99px; font-size: 12px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text); white-space: nowrap; }
.badge.bad { background: color-mix(in srgb, var(--bad) 15%, transparent); color: var(--bad); }
.badge.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.badge.muted { color: var(--muted); }
.count { margin-left: 6px; font-size: 12px; color: var(--muted); font-weight: 500; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; background: var(--muted); }
.spinner { width: 28px; height: 28px; margin: 40px auto; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.empty .ic { opacity: .6; }
.error-box { padding: 16px; border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent); background: color-mix(in srgb, var(--bad) 8%, transparent); border-radius: var(--radius); color: var(--text); }
.error-box p { margin: 0 0 8px; }

/* ---------- Karten / Heute ---------- */
.today-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 4px 0 16px; }
.today-head h2 { font-size: 26px; }
.today-head p { margin: 4px 0 0; }
.quick-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.quick-note { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; box-shadow: var(--shadow); }
.quick-note .ic { margin-top: 9px; color: var(--muted); }
.quick-note-input { border: 0; padding: 7px 0; resize: none; background: transparent; }
.quick-note-input:focus { outline: none; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; min-width: 0; }
.card.full { grid-column: 1 / -1; margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 8px; }
.card-head h3 { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.card-more { display: inline-flex; align-items: center; font-size: 13px; color: var(--muted); }
.card-more:hover { color: var(--accent); }
.card-body { padding: 4px 16px 14px; display: flex; flex-direction: column; gap: 2px; }
.card-body > p { margin: 6px 0; }
.row { display: flex; align-items: center; gap: 10px; padding: 7px 8px; margin: 0 -8px; border-radius: var(--radius-sm); color: var(--text); min-width: 0; }
.row:hover { background: var(--surface-2); }
.row-main { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; width: 70px; flex: none; }
.row-meta { color: var(--muted); font-size: 12px; white-space: nowrap; max-width: 40%; overflow: hidden; text-overflow: ellipsis; }
.day-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-top: 8px; }
.stat-line { display: flex; gap: 16px; margin-bottom: 6px; font-size: 13px; color: var(--muted); }
.stat b { font-size: 18px; color: var(--text); }
.stat.bad b { color: var(--bad); } .stat.warn b { color: var(--warn); }
.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.thumb { display: flex; flex-direction: column; gap: 4px; color: var(--text); font-size: 12px; min-width: 0; }
.thumb img { width: 100%; aspect-ratio: 3/4; object-fit: cover; object-position: top; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); }
.thumb span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.health { display: flex; align-items: center; gap: 8px; font-weight: 500; margin: 4px 0 10px; }
.health.good .dot { background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 25%, transparent); }
.health.bad .dot { background: var(--bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 25%, transparent); }
.meter { margin-bottom: 10px; }
.meter-top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.meter-bar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.meter-fill { height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s; }
.meter-fill.warn { background: var(--warn); } .meter-fill.bad { background: var(--bad); }

/* ---------- Dateien ---------- */
.crumbs { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; margin-bottom: 10px; color: var(--muted); }
.crumb { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; padding: 4px 8px; border-radius: 6px; cursor: pointer; color: var(--text); font-weight: 500; }
.crumb:hover { background: var(--surface-2); }
.crumb-open { margin-left: 8px; color: var(--muted); display: inline-flex; }
.drop-zone { position: relative; border-radius: var(--radius); }
.drop-hint { display: none; }
.drop-zone.dragging .drop-hint { display: flex; position: absolute; inset: 0; align-items: center; justify-content: center; flex-direction: column; gap: 8px; background: color-mix(in srgb, var(--accent) 12%, var(--bg)); border: 2px dashed var(--accent); border-radius: var(--radius); color: var(--accent); font-weight: 600; z-index: 2; min-height: 160px; }
.file-list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; min-height: 120px; }
.file-row { display: flex; align-items: center; gap: 12px; padding: 4px 8px 4px 4px; border-bottom: 1px solid var(--border); }
.file-row:last-child { border-bottom: 0; }
.file-row:hover { background: var(--surface-2); }
.file-row.highlight { background: var(--accent-soft); }
.file-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; border: 0; background: transparent; padding: 8px; cursor: pointer; text-align: left; }
.file-ic { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 8px; background: var(--surface-2); color: var(--muted); flex: none; }
.file-ic.dir { color: var(--accent); background: var(--accent-soft); }
.file-thumb { width: 36px; height: 36px; object-fit: cover; border-radius: 8px; flex: none; background: var(--surface-2); }
.file-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; flex-direction: column; }
.file-path { font-size: 12px; color: var(--muted); }
.file-size, .file-date { width: 110px; color: var(--muted); font-size: 13px; text-align: right; flex: none; }
.upload-progress { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.upload-row { display: grid; grid-template-columns: 1fr 200px; gap: 12px; align-items: center; font-size: 13px; padding: 8px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.quota { margin-top: 10px; }
.popover { position: fixed; z-index: 50; min-width: 190px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: 4px; display: flex; flex-direction: column; }
.popover button { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 0; background: transparent; border-radius: 6px; cursor: pointer; text-align: left; }
.popover button:hover { background: var(--surface-2); }
.popover .danger { color: var(--bad); }
.preview-img { max-width: 100%; max-height: 70vh; display: block; margin: 0 auto; border-radius: 6px; }
.preview-frame { width: 100%; height: 70vh; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; }
.preview-text { max-height: 70vh; overflow: auto; background: var(--surface-2); padding: 12px; border-radius: var(--radius-sm); font-size: 13px; white-space: pre-wrap; }

/* ---------- Aufgaben ---------- */
.task-group { margin-bottom: 20px; }
.group-title { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 6px; }
.task-row { display: flex; align-items: center; gap: 12px; padding: 4px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 6px; }
.task-row.closed .task-subject { text-decoration: line-through; color: var(--muted); }
.task-check { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border); background: transparent; cursor: pointer; display: grid; place-items: center; flex: none; padding: 0; color: var(--good); }
.task-check:hover { border-color: var(--good); }
.task-row.closed .task-check { border-color: var(--good); background: color-mix(in srgb, var(--good) 15%, transparent); }
.task-main { flex: 1; min-width: 0; border: 0; background: transparent; text-align: left; padding: 8px 0; cursor: pointer; display: flex; flex-direction: column; gap: 3px; }
.task-subject { font-weight: 500; }
.task-meta { display: flex; gap: 10px; align-items: center; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 12px; }
.board-col { background: var(--surface-2); border-radius: var(--radius); padding: 10px; min-height: 200px; border: 2px solid transparent; }
.board-col.over { border-color: var(--accent); }
.board-col-head { display: flex; align-items: center; gap: 8px; font-weight: 600; padding: 2px 4px 10px; }
.board-cards { display: flex; flex-direction: column; gap: 8px; }
.board-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; cursor: grab; box-shadow: var(--shadow); }
.board-card.dragging { opacity: .5; }
.bc-subject { font-weight: 500; margin-bottom: 6px; }
.bc-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 12px; }
.static { padding: 9px 0; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; margin-bottom: 16px; }
.task-detail h4 { margin: 8px 0; }
.activities { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; max-height: 260px; overflow: auto; }
.activity { background: var(--surface-2); padding: 8px 12px; border-radius: var(--radius-sm); }
.activity p { margin: 4px 0 0; white-space: pre-wrap; }
.act-head { display: flex; justify-content: space-between; gap: 8px; }
.comment-box { display: flex; gap: 8px; align-items: flex-end; }

/* ---------- Dokumente ---------- */
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; min-height: 120px; }
.doc-card { display: flex; flex-direction: column; text-align: left; border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius); overflow: hidden; cursor: pointer; padding: 0; box-shadow: var(--shadow); }
.doc-card:hover { border-color: var(--accent); }
.doc-thumb { aspect-ratio: 4/3; background: var(--surface-2); overflow: hidden; }
.doc-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.doc-info { padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.doc-title { font-weight: 600; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.doc-meta { font-size: 12px; color: var(--muted); }
.doc-snippet { font-size: 12px; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { font-size: 11px; padding: 1px 8px; border-radius: 99px; border: 1px solid var(--border); }
.tag.pick { cursor: pointer; font-size: 13px; padding: 3px 10px; background: transparent; }
.tag-picker { display: flex; flex-wrap: wrap; gap: 6px; font-weight: 400; color: var(--text); }
.doc-detail-grid { display: grid; grid-template-columns: 1fr 300px; gap: 20px; }
.doc-side { min-width: 0; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0 0 14px; font-size: 14px; }
.facts dt { color: var(--muted); } .facts dd { margin: 0; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 14px; }
.ocr summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.ocr pre { white-space: pre-wrap; font-size: 12px; max-height: 240px; overflow: auto; background: var(--surface-2); padding: 10px; border-radius: 6px; }

/* ---------- Kalender ---------- */
.cal-layout { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.month-title { font-size: 18px; min-width: 170px; text-align: center; text-transform: capitalize; }
.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.month-grid > .spinner, .month-grid > .error-box { grid-column: 1 / -1; background: var(--surface); margin: 0; padding: 40px; }
.wd { background: var(--surface-2); text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); padding: 6px; }
.day { background: var(--surface); border: 0; min-height: 96px; padding: 6px; display: flex; flex-direction: column; gap: 3px; text-align: left; cursor: pointer; min-width: 0; }
.day:hover { background: var(--surface-2); }
.day.other { color: var(--muted); background: color-mix(in srgb, var(--surface) 60%, var(--bg)); }
.day.sel { box-shadow: inset 0 0 0 2px var(--accent); }
.day-num { font-size: 13px; font-weight: 600; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; }
.day.today .day-num { background: var(--accent); color: var(--accent-text); }
.day-events { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ev-pill { font-size: 11px; padding: 1px 4px; border-left: 3px solid; border-radius: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.ev-more { font-size: 11px; color: var(--muted); }
.day-dots { display: none; gap: 3px; }
.day-dots .dot { width: 6px; height: 6px; }
.agenda { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; position: sticky; top: 76px; }
.agenda-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.agenda-head h3 { font-size: 16px; }
.agenda-item { border-left: 3px solid; padding: 6px 10px; margin-bottom: 10px; background: var(--surface-2); border-radius: 0 6px 6px 0; }
.ai-time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ai-title { font-weight: 600; }
.ai-meta, .ai-desc { font-size: 13px; color: var(--muted); white-space: pre-wrap; }
.ai-foot { display: flex; justify-content: space-between; align-items: center; }

/* ---------- Notizen ---------- */
.notes-layout { display: grid; grid-template-columns: 300px 1fr; gap: 16px; height: calc(100vh - 120px); }
.note-side { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.note-side .search { max-width: none; }
.note-list { overflow: auto; display: flex; flex-direction: column; gap: 2px; }
.note-item { display: flex; flex-direction: column; gap: 2px; text-align: left; border: 0; background: transparent; padding: 9px 12px; border-radius: var(--radius-sm); cursor: pointer; }
.note-item:hover { background: var(--surface-2); }
.note-item.active { background: var(--accent-soft); }
.ni-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ni-meta { font-size: 12px; color: var(--muted); }
.note-editor { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.note-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.note-title { border: 0; background: transparent; font: 700 24px var(--font); color: var(--text); padding: 18px 24px 6px; outline: none; }
.note-text { flex: 1; border: 0; background: transparent; resize: none; padding: 8px 24px 24px; font: 15px/1.6 ui-monospace, "Cascadia Code", Consolas, monospace; color: var(--text); outline: none; }
.note-preview { flex: 1; overflow: auto; padding: 8px 24px 24px; }
.md h2, .md h3, .md h4, .md h5 { margin: 18px 0 8px; }
.md p { margin: 0 0 10px; }
.md pre { background: var(--surface-2); padding: 10px; border-radius: 6px; overflow: auto; }
.md code { background: var(--surface-2); padding: 1px 4px; border-radius: 4px; font-size: 90%; }
.md blockquote { border-left: 3px solid var(--border); margin: 0 0 10px; padding-left: 12px; color: var(--muted); }
.md ul.tasks { list-style: none; padding-left: 4px; }
.md ul.tasks li { display: flex; gap: 8px; align-items: baseline; }
.md .cb { width: 16px; height: 16px; border: 1.5px solid var(--muted); border-radius: 4px; display: inline-grid; place-items: center; font-size: 11px; flex: none; }
.md li.done { color: var(--muted); text-decoration: line-through; }

/* ---------- Status & Apps ---------- */
.services { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; padding: 4px 16px 16px; }
.service { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.service.up .dot { background: var(--good); } .service.down .dot { background: var(--bad); }
.service.down { border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); }
.svc-name { flex: 1; font-weight: 500; }
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-top: 14px; }
.app-tile { display: flex; flex-direction: column; gap: 6px; padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); box-shadow: var(--shadow); }
.app-tile:hover { border-color: var(--accent); }
.app-ic { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 12px; background: var(--accent-soft); color: var(--accent); margin-bottom: 4px; }
.app-name { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.app-desc { font-size: 13px; color: var(--muted); }
.vpn { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 4px; background: var(--surface-2); color: var(--muted); }

/* ---------- Dialoge, Palette, Toasts ---------- */
.modal { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 0; max-width: min(640px, calc(100vw - 32px)); width: max-content; min-width: min(420px, calc(100vw - 32px)); box-shadow: var(--shadow-lg); }
.modal.wide { width: min(1100px, calc(100vw - 32px)); max-width: none; }
.modal::backdrop { background: rgba(10,12,16,.45); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 6px 20px; }
.modal-head h2 { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-body { padding: 8px 20px 16px; max-height: calc(100vh - 180px); overflow: auto; }
.modal-body p { margin: 0 0 8px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.palette-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(10,12,16,.4); display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; }
.palette { width: min(640px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden; display: flex; flex-direction: column; max-height: 70vh; }
.palette-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); color: var(--muted); }
.palette-input { flex: 1; border: 0; background: transparent; font: 16px var(--font); color: var(--text); outline: none; }
.palette-results { overflow: auto; padding: 6px; }
.palette-group { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 10px 10px 4px; }
.palette-item { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; padding: 8px 10px; border-radius: 8px; cursor: pointer; text-align: left; }
.palette-item.sel { background: var(--accent-soft); }
.pi-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pi-hint { font-size: 12px; color: var(--muted); max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-empty { padding: 24px; text-align: center; color: var(--muted); }
#toasts { position: fixed; z-index: 100; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow-lg); max-width: 380px; animation: toastIn .2s ease-out; }
.toast a { color: inherit; text-decoration: underline; }
.toast.error { background: var(--bad); color: #fff; }
.toast.success { background: var(--good); color: #fff; }
.toast.out { opacity: 0; transform: translateY(6px); transition: .3s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(10,12,16,.4); display: flex; align-items: flex-end; }
.sheet { width: 100%; background: var(--surface); border-radius: 16px 16px 0 0; padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; }
.sheet-item { display: flex; align-items: center; gap: 14px; padding: 14px 12px; border: 0; background: transparent; color: var(--text); font-size: 16px; border-radius: 10px; text-align: left; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; box-shadow: var(--shadow-lg); }
.login-card h1 { font-size: 24px; }
.login-card > p { margin: 4px 0 20px; }
.login-logo { display: block; margin-bottom: 14px; }
.input.code { letter-spacing: .3em; font-size: 20px; text-align: center; }
.login-error { color: var(--bad); min-height: 1.2em; margin: 0 0 10px; font-size: 14px; }
.boot-error { padding: 40px; text-align: center; }

/* ---------- Handy ---------- */
@media (max-width: 1000px) {
  .cal-layout { grid-template-columns: 1fr; }
  .agenda { position: static; }
  .doc-detail-grid { grid-template-columns: 1fr; }
  .preview-frame { height: 60vh; }
}
@media (max-width: 760px) {
  body { font-size: 15px; }
  .sidebar { display: none; }
  .mobile-only { display: inline-grid; }
  .hide-sm { display: none; }
  .topbar { padding: calc(10px + env(safe-area-inset-top)) 16px 10px; }
  .topbar h1 { font-size: 20px; }
  main { padding: 4px 16px calc(84px + env(safe-area-inset-bottom)); }
  .bottom-nav { display: flex; position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
  .bn-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; font-size: 11px; color: var(--muted); border: 0; background: transparent; }
  .bn-item.active { color: var(--accent); }
  .cards { grid-template-columns: 1fr; }
  .toolbar { flex-wrap: wrap; }
  .toolbar .search { max-width: none; margin-left: 0; flex: 1 1 100%; order: 10; }
  .file-row { padding-right: 4px; }
  .upload-row { grid-template-columns: 1fr 100px; }
  .day { min-height: 54px; padding: 4px; align-items: center; }
  .day-events { display: none; }
  .day-dots { display: flex; }
  .notes-layout { grid-template-columns: 1fr; height: calc(100vh - 170px); }
  .notes-layout.editing .note-side { display: none; }
  .notes-layout:not(.editing) .note-editor { display: none; }
  .note-title { padding: 14px 16px 4px; font-size: 20px; }
  .note-text, .note-preview { padding: 6px 16px 16px; }
  .modal, .modal.wide { width: calc(100vw - 16px); min-width: 0; max-width: none; }
  .modal-body { padding: 8px 14px 14px; }
  .form { min-width: 0; }
  #toasts { left: 16px; bottom: calc(80px + env(safe-area-inset-bottom)); }
  .today-head h2 { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
