/* Farben: hell als Standard; dunkel per Systemeinstellung (data-theme=auto) oder fest (data-theme=dark) */
:root {
  --bg: #f6f7f9; --surface: #ffffff; --text: #1d2330; --muted: #667085; --border: #e3e6eb;
  --accent: #2f5bea; --accent-text: #ffffff; --accent-soft: #e8eeff; --danger: #c2372b;
  --ok-bg: #e8f5ec; --ok-text: #1f6b3a; --warn-bg: #fff4e0; --warn-text: #8a5300; --err-bg: #fdecea; --err-text: #a12a1f;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #12151b; --surface: #1b1f27; --text: #e7e9ee; --muted: #9aa3b2; --border: #2c323d;
    --accent: #6b8cff; --accent-text: #0d1020; --accent-soft: #1f2a4a; --danger: #ff7a6e;
    --ok-bg: #16301f; --ok-text: #8fdca8; --warn-bg: #33270f; --warn-text: #f3c77a; --err-bg: #3a1916; --err-text: #ffa59c;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12151b; --surface: #1b1f27; --text: #e7e9ee; --muted: #9aa3b2; --border: #2c323d;
  --accent: #6b8cff; --accent-text: #0d1020; --accent-soft: #1f2a4a; --danger: #ff7a6e;
  --ok-bg: #16301f; --ok-text: #8fdca8; --warn-bg: #33270f; --warn-text: #f3c77a; --err-bg: #3a1916; --err-text: #ffa59c;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* Kopfzeile */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: .5rem 1rem; flex-wrap: wrap;
  padding: .6rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10; }
.topbar nav { display: flex; align-items: center; gap: .9rem; overflow-x: auto; white-space: nowrap;
  scrollbar-width: none; max-width: 100%; }
.topbar nav::-webkit-scrollbar { display: none; }
.topbar a { color: var(--text); text-decoration: none; }
.topbar nav a[aria-current="page"] { color: var(--accent); font-weight: 600; }
.brand { font-weight: 700; letter-spacing: .02em; }

/* Seitenrahmen */
.page { max-width: 760px; margin: 0 auto; padding: 1rem 1rem 3rem; }
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1rem; }
.auth .card { width: 100%; max-width: 380px; }
.logo { font-size: 2rem; font-weight: 750; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; margin: 1rem 0; }

/* Formulare */
form { display: flex; flex-direction: column; gap: .75rem; }
form.inline { display: inline; }
form.row { flex-direction: row; flex-wrap: wrap; align-items: flex-end; }
form.row label { flex: 1 1 180px; }
label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; color: var(--muted); }
input, textarea, select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: .6rem .7rem; width: 100%; }
textarea { resize: vertical; min-height: 4.5rem; line-height: 1.45; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
button { font: inherit; cursor: pointer; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); border-radius: 8px; padding: .5rem .85rem; }
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.danger { color: var(--danger); }
button.link { border: none; background: none; padding: 0; color: var(--text); }
.notice { border-radius: 8px; padding: .7rem .9rem; margin: .75rem 0; }
.notice.ok { background: var(--ok-bg); color: var(--ok-text); }
.notice.warn { background: var(--warn-bg); color: var(--warn-text); }
.notice.error { background: var(--err-bg); color: var(--err-text); }
input.copy { margin-top: .5rem; font-size: .85rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.actions form { flex-direction: row; }

/* Schnell-Eingabe */
.compose { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .75rem; gap: .5rem; margin-bottom: 1rem; }
.compose textarea { border: none; background: transparent; padding: .25rem; min-height: 4rem; }
.compose textarea:focus { outline: none; }
.compose:focus-within { border-color: var(--accent); }
.compose-bar { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
@media (hover: none) { .hint { visibility: hidden; } }

/* Tag-Leiste */
.tagbar { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .25rem; margin-bottom: .5rem; scrollbar-width: thin; }
.chip { flex: none; text-decoration: none; color: var(--text); font-size: .85rem; padding: .25rem .65rem;
  border: 1px solid var(--border); border-radius: 99px; background: var(--surface); }
.chip span { color: var(--muted); font-size: .75rem; }
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* Feed */
.day { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  margin: 1.25rem 0 .5rem; font-weight: 600; }
.note { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .85rem 1rem .6rem; margin-bottom: .6rem; transition: opacity .15s; }
.note.htmx-swapping { opacity: 0; }
.note-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.note-meta { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; margin-top: .5rem; }
.note-meta > a { text-decoration: none; }
.note-actions { display: flex; gap: .3rem; flex-wrap: wrap; }
.note-actions form { flex-direction: row; }
.note-actions button { font-size: .8rem; padding: .25rem .55rem; border-color: transparent; background: transparent; color: var(--muted); }
.note-actions button:hover { border-color: var(--border); color: var(--text); }
.note-actions button.danger { color: var(--danger); }
.note.editing textarea { min-height: 8rem; }
a.hashtag { color: var(--accent); text-decoration: none; }
a.hashtag:hover { text-decoration: underline; }
.more { display: block; width: 100%; margin: 1rem 0; color: var(--muted); }
.empty { text-align: center; padding: 2rem 1rem; }
.details { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; margin-top: 1rem; }
.details dt { font-weight: 600; }
.details dd { margin: 0; }

/* Admin */
.users { list-style: none; padding: 0; margin: 0; }
.users li { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: .75rem 0; border-top: 1px solid var(--border); }
.users li:first-child { border-top: none; }
.tag { font-size: .75rem; padding: .1rem .45rem; border-radius: 99px; background: var(--bg); border: 1px solid var(--border); }
.tag.off { color: var(--danger); }
.tag.wait { color: var(--warn-text); }

/* KI-Analyse (Phase 4) */
:root { --high: #c2372b; --high-bg: #fdecea; --cat-aufgabe: #2f5bea; --cat-idee: #8a4fd6; --cat-wissen: #1f7a5a; --cat-termin: #b4630b; }
:root[data-theme="dark"] { --high: #ff8a7e; --high-bg: #3a1916; --cat-aufgabe: #8aa5ff; --cat-idee: #c39bff; --cat-wissen: #7ad3ae; --cat-termin: #f0b46a; }
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] { --high: #ff8a7e; --high-bg: #3a1916; --cat-aufgabe: #8aa5ff; --cat-idee: #c39bff; --cat-wissen: #7ad3ae; --cat-termin: #f0b46a; }
}
.note-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; margin-bottom: .3rem; }
.note-title { font-size: 1rem; font-weight: 650; margin: 0; }
.badges { display: flex; gap: .3rem; flex: none; }
.badge { font-size: .72rem; font-weight: 600; padding: .1rem .5rem; border-radius: 99px; border: 1px solid currentColor;
  text-decoration: none; white-space: nowrap; }
.badge.high { color: var(--high); background: var(--high-bg); border-color: transparent; }
.badge.cat-aufgabe { color: var(--cat-aufgabe); }
.badge.cat-idee { color: var(--cat-idee); }
.badge.cat-wissen { color: var(--cat-wissen); }
.badge.cat-termin { color: var(--cat-termin); }
.note.prio-high { border-left: 3px solid var(--high); }
.note-body.clamp { display: -webkit-box; -webkit-line-clamp: 8; -webkit-box-orient: vertical; overflow: hidden; }
.todos { list-style: none; margin: .5rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .25rem; }
.todo { flex-direction: row; align-items: center; gap: .5rem; }
.todo .check { width: 1.25rem; height: 1.25rem; padding: 0; border-radius: 5px; border: 1.5px solid var(--muted);
  font-size: .8rem; line-height: 1; display: grid; place-items: center; flex: none; background: transparent; }
.todo.done .check { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.todo.done span { text-decoration: line-through; color: var(--muted); }
.ai-tags { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .45rem; }
.ai-tags a { font-size: .78rem; color: var(--muted); text-decoration: none; border: 1px dashed var(--border);
  border-radius: 99px; padding: .05rem .5rem; }
.ai-tags a:hover { color: var(--accent); border-color: var(--accent); }
.ai-status { color: var(--accent); animation: pulse 1.6s ease-in-out infinite; }
.ai-error { color: var(--danger); cursor: help; }
@keyframes pulse { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .ai-status { animation: none; } }
.catbar { display: flex; gap: 0; margin-bottom: .6rem; border: 1px solid var(--border); border-radius: 8px;
  overflow-x: auto; background: var(--surface); width: max-content; max-width: 100%; }
.seg { padding: .3rem .75rem; font-size: .85rem; color: var(--text); text-decoration: none; white-space: nowrap; border-right: 1px solid var(--border); }
.seg:last-child { border-right: none; }
.seg.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.summary p { margin: 0; }

/* Suche (Phase 5) */
.searchbox { flex-direction: row; gap: .5rem; flex-wrap: wrap; margin-bottom: .5rem; }
.searchbox input[type=search] { flex: 1 1 240px; font-size: 1.05rem; padding: .7rem .8rem; }
.searchbox select { flex: 0 1 180px; width: auto; }
.results { list-style: none; margin: 0 0 1rem; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.result-link { display: flex; flex-direction: column; gap: .2rem; padding: .75rem .9rem; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.result-link:hover { border-color: var(--accent); }
.result-head { display: flex; justify-content: space-between; gap: .5rem; align-items: flex-start; }
.result-snippet { color: var(--text); overflow-wrap: anywhere; }
mark { background: var(--accent-soft); color: var(--accent); border-radius: 3px; padding: 0 .1em; font-weight: 600; }

/* Erinnerungen & Aufgaben (Phase 6) */
.reminder { display: flex; gap: .5rem; align-items: flex-start; margin-top: .55rem; padding: .5rem .6rem;
  border-radius: 8px; background: var(--accent-soft); color: var(--text); font-size: .9rem; }
.reminder .rem-icon { color: var(--accent); flex: none; margin-top: .15rem; }
.reminder.rem-ask { background: var(--warn-bg); }
.reminder.rem-ask .rem-icon { color: var(--warn-text); }
.reminder.rem-gesendet { background: var(--bg); color: var(--muted); }
.reminder.rem-fehler { background: var(--err-bg); }
.rem-main { flex: 1; display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.rem-error { color: var(--err-text); font-size: .85rem; }
.rem-actions { display: flex; gap: .25rem; flex: none; }
.rem-actions form { flex-direction: row; }
.rem-actions button { font-size: .8rem; padding: .15rem .5rem; background: transparent; }
.rem-actions button.icon { font-size: 1rem; line-height: 1; border-color: transparent; color: var(--muted); }
.rem-picker { gap: .4rem; }
.rem-choices { display: flex; flex-wrap: wrap; gap: .3rem; }
.rem-choices button { font-size: .8rem; padding: .25rem .6rem; border-radius: 99px; background: var(--surface); }
.rem-custom { display: flex; gap: .3rem; flex-wrap: wrap; }
.rem-custom input { width: auto; flex: 1 1 180px; padding: .3rem .5rem; font-size: .85rem; }
.rem-custom button { font-size: .8rem; padding: .25rem .6rem; }
.rem-change summary { cursor: pointer; color: var(--accent); font-size: .85rem; width: max-content; }
.rows { list-style: none; margin: 0 0 1rem; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.reminder-row, .todo-row { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .65rem .8rem; }
.reminder-row .row-title { font-weight: 600; text-decoration: none; color: var(--text); }
.todo-row { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; }
.todo-row .from { text-decoration: none; }
