/* Hedy – Stil nach mockups/: flach, dünne Rahmen, abgerundete Ecken, hell/dunkel über Variablen. */
:root {
  --surface-0: #f5f4f0; --surface-1: #f1efe8; --surface-2: #ffffff;
  --text-primary: #1f1e1c; --text-secondary: #5f5e5a; --text-muted: #888780;
  --text-accent: #185FA5; --bg-accent: #E6F1FB; --text-danger: #A32D2D; --border-danger: #F09595;
  --text-success: #3B6D11; --text-warning: #854F0B;
  --border: rgba(0,0,0,.12); --border-strong: rgba(0,0,0,.2); --border-stronger: rgba(0,0,0,.4);
  --radius: 8px;
  --t-mensch: #7F77DD; --t-kunde: #1D9E75; --t-thema: #D4537E; --t-nachfassen: #888780;
  --t-idee: #BA7517; --t-tagebuch: #B4B2A9; --t-offen: #B4B2A9; --t-sonstiges: #B4B2A9;
  --nav-h: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text-primary); background: var(--surface-0);
  -webkit-text-size-adjust: 100%;
}
@media (prefers-color-scheme: dark) {
  :root {
    --surface-0: #141413; --surface-1: #1f1e1c; --surface-2: #262624;
    --text-primary: #f1efe8; --text-secondary: #b4b2a9; --text-muted: #888780;
    --text-accent: #85B7EB; --bg-accent: #0C447C; --text-danger: #F09595; --border-danger: #A32D2D;
    --text-success: #97C459; --text-warning: #EF9F27;
    --border: rgba(255,255,255,.12); --border-strong: rgba(255,255,255,.22); --border-stronger: rgba(255,255,255,.4);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--surface-0); }
body { font-size: 15px; line-height: 1.45; }
a { color: var(--text-accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.ic { display: block; flex: none; }
.muted { color: var(--text-secondary); }
.small-t { font-size: 12px; }
code { font-size: .92em; background: var(--surface-1); padding: 1px 4px; border-radius: 4px; }

button, .btn {
  font: inherit; font-size: 14px; background: transparent; color: var(--text-primary);
  border: .5px solid var(--border-strong); border-radius: var(--radius); height: 36px; padding: 0 12px;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
}
button:hover, .btn:hover { background: var(--surface-1); text-decoration: none; }
button:disabled, .btn.disabled { opacity: .4; cursor: default; background: transparent; }
button.small, .btn.small { font-size: 12px; height: 28px; padding: 0 10px; }
button.ghost { border-color: transparent; color: var(--text-secondary); }
button.primary, .btn.primary { border-color: var(--text-accent); color: var(--text-accent); height: 44px; padding: 0 18px; font-size: 15px; }
input, textarea {
  font: inherit; font-size: 16px; border: .5px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface-2); color: var(--text-primary); padding: 0 10px;
}
input { height: 36px; }
input:focus, textarea:focus { outline: none; border-color: var(--border-stronger); }

/* Rahmen */
.app { max-width: 560px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; background: var(--surface-2);
       border-left: .5px solid var(--border); border-right: .5px solid var(--border); }
.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
       padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 10px; background: var(--surface-2); }
.top h1 { margin: 0; font-weight: 500; font-size: 18px; }
.icon-btn { color: var(--text-secondary); border: 0; height: 32px; width: 32px; padding: 0; display: inline-flex;
            align-items: center; justify-content: center; border-radius: var(--radius); background: transparent; }
.icon-btn.on { color: var(--text-accent); }
.icon-btn.tiny { height: 22px; width: 22px; }
.content { padding: 4px 16px calc(var(--nav-h) + var(--safe-b) + 24px); }
.nav { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 560px; z-index: 10;
       display: flex; justify-content: space-around; border-top: .5px solid var(--border); background: var(--surface-2);
       padding: 8px 0 calc(6px + var(--safe-b)); height: calc(var(--nav-h) + var(--safe-b)); }
.nav a { color: var(--text-secondary); font-size: 11px; text-align: center; display: flex; flex-direction: column;
         align-items: center; gap: 2px; min-width: 56px; text-decoration: none; }
.nav a.on { color: var(--text-accent); }
.empty { color: var(--text-secondary); text-align: center; padding: 28px 12px; font-size: 14px; }
.empty .ic { display: inline; vertical-align: -3px; }

/* Chat */
.page-chat .content { padding-bottom: calc(var(--nav-h) + var(--safe-b) + 150px); }
.chat { display: flex; flex-direction: column; gap: 10px; }
.chat .older { align-self: center; }
.msg { display: flex; flex-direction: column; max-width: 88%; }
.msg.me { align-self: flex-end; align-items: flex-end; }
.msg.bot { align-self: flex-start; }
.bubble { padding: 8px 12px; border-radius: 14px; font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.me .bubble { background: var(--bg-accent); color: var(--text-primary); border-bottom-right-radius: 4px; }
.msg.bot .bubble { background: var(--surface-1); border-bottom-left-radius: 4px; white-space: normal; }
.msg.error .bubble { border: .5px solid var(--border-danger); background: transparent; }
.msg.proactive .bubble { border-left: 3px solid var(--text-accent); }
.msg-time { font-size: 11px; color: var(--text-muted); margin: 2px 4px 0; }
.msg-tag { font-size: 11px; color: var(--text-accent); display: flex; align-items: center; gap: 4px; margin-bottom: 2px; }
.working .bubble { color: var(--text-secondary); display: flex; align-items: center; gap: 8px; }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--text-muted); animation: blink 1.2s infinite both; }
.dots i:nth-child(2) { animation-delay: .2s; } .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .dots i { animation: none; } }

.composer { position: fixed; left: 50%; transform: translateX(-50%); width: 100%; max-width: 560px; z-index: 9;
            bottom: calc(var(--nav-h) + var(--safe-b)); background: var(--surface-2); border-top: .5px solid var(--border);
            padding: 8px 12px 10px; }
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { flex: 1; resize: none; min-height: 44px; max-height: 40vh; padding: 10px 12px; line-height: 1.35; }
.send { height: 44px; width: 44px; padding: 0; justify-content: center; color: var(--text-accent); border-color: var(--text-accent); }
.composer.busy .send { opacity: .5; }
.quick { display: flex; gap: 6px; margin-bottom: 8px; overflow-x: auto; }
.reply-mode { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-accent);
              background: var(--bg-accent); border-radius: var(--radius); padding: 4px 6px 4px 10px; margin-bottom: 8px; }
.reply-mode span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer.replying textarea { border-color: var(--text-accent); }

/* Rückfrage-Karte */
.card-q { background: var(--bg-accent); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 12px; color: var(--text-accent); font-size: 14px; }
.msg .card-q { margin: 0; }
.card-q ul { margin: 4px 0 0; padding-left: 18px; }
.card-q .q-title { font-size: 12px; opacity: .85; }
.card-q .q-line { font-size: 13px; }
.card-q .q-meta { font-size: 12px; opacity: .75; margin-top: 2px; }
.q-actions { display: flex; gap: 8px; margin-top: 8px; }
.q-actions button, .q-actions .btn { background: var(--surface-2); color: var(--text-primary); }
.card-q.closed { background: var(--surface-1); color: var(--text-secondary); }
.q-state { display: flex; align-items: center; gap: 4px; font-size: 12px; margin-top: 6px; }
.q-state .md p { margin: 0; }

/* Offen */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.kpi { background: var(--surface-1); border-radius: var(--radius); padding: 8px; }
.kpi-l { font-size: 11px; color: var(--text-secondary); }
.kpi-v { font-size: 20px; font-weight: 500; }
.danger { color: var(--text-danger); }
.group-l { font-size: 12px; color: var(--text-secondary); margin: 0 0 6px; }
.group-l.danger { color: var(--text-danger); }
.box { border: .5px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; }
.box.danger-box { border-color: var(--border-danger); }
.row { padding: 10px; display: flex; gap: 10px; align-items: flex-start; border-bottom: .5px solid var(--border); color: inherit; }
a.row:hover { text-decoration: none; background: var(--surface-1); }
.box > .row:last-child, .box > :last-child > .row { border-bottom: 0; }
.danger-box .row { border-bottom: 0; }
.check { border: 0; padding: 0; height: 20px; width: 20px; color: var(--text-secondary); background: transparent; flex: none; }
.check:hover { background: transparent; }
.check.warn { color: var(--text-warning); }
.row-main { flex: 1; min-width: 0; }
.row-title { color: var(--text-primary); display: block; }
.row-meta { font-size: 12px; color: var(--text-secondary); }
.row.done .row-title { color: var(--text-secondary); text-decoration: line-through; }
.row.done .row-meta { color: var(--text-muted); }
.row.done .check { color: var(--text-success); }

/* Markdown */
.md { overflow-wrap: anywhere; }
.md p { margin: 0 0 .5em; } .md p:last-child { margin-bottom: 0; }
.md ul, .md ol { margin: .25em 0 .5em; padding-left: 1.3em; }
.md h1 { font-size: 20px; font-weight: 500; margin: .2em 0 .6em; }
.md h2 { font-size: 16px; font-weight: 500; margin: 1.2em 0 .5em; }
.md h3 { font-size: 14px; font-weight: 600; margin: 1.1em 0 .3em; }
.md blockquote { margin: .4em 0; padding: 2px 10px; border-left: 2px solid var(--border-strong); color: var(--text-secondary); }
.md table { border-collapse: collapse; } .md td, .md th { border: .5px solid var(--border); padding: 3px 6px; }
.md .wl-open { color: var(--text-secondary); border-bottom: 1px dashed var(--border-stronger); }
.note { font-size: 15px; }
.crumb { font-size: 12px; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.props { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; font-size: 13px; margin: 0 0 14px;
         background: var(--surface-1); padding: 8px 10px; border-radius: var(--radius); }
.props dt { color: var(--text-secondary); } .props dd { margin: 0; overflow-wrap: anywhere; }
.props dd p { margin: 0; }

/* Heute */
.daynav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.daynav-l { font-size: 13px; color: var(--text-secondary); }

/* Suche */
.searchbar { position: relative; margin-bottom: 10px; }
.searchbar-i { position: absolute; left: 10px; top: 10px; color: var(--text-muted); }
.searchbar input { width: 100%; padding-left: 32px; }
.hit { display: block; border: .5px solid var(--border); border-radius: var(--radius); padding: 10px; margin-top: 8px; color: inherit; }
.hit:hover { text-decoration: none; background: var(--surface-1); }
.hit-t { font-weight: 500; } .hit-p { font-size: 12px; color: var(--text-muted); }
.hit-s { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.hit-s mark { background: var(--bg-accent); color: var(--text-primary); border-radius: 2px; }

/* Graph */
.seg-wrap { display: flex; gap: 6px; }
.seg-wrap.full { margin-bottom: 10px; }
.seg { font-size: 13px; height: 30px; flex: 1; justify-content: center; }
.seg.on { background: var(--surface-1); border-color: var(--border-stronger); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip { font-size: 12px; height: 28px; padding: 0 10px; display: inline-flex; align-items: center; gap: 6px; border-radius: 14px;
        border: .5px solid var(--border-strong); background: transparent; color: var(--text-primary); white-space: nowrap; }
.chip.off { color: var(--text-muted); border-color: var(--border); }
.chip.off .dot { opacity: .3; }
.chip.sep { margin-left: 4px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.t-mensch { background: var(--t-mensch); } .t-kunde { background: var(--t-kunde); } .t-thema { background: var(--t-thema); }
.t-nachfassen { background: var(--t-nachfassen); } .t-idee { background: var(--t-idee); } .t-tagebuch { background: var(--t-tagebuch); }
.t-offen { background: transparent; border: 1px dashed var(--text-muted); } .t-sonstiges { background: var(--t-sonstiges); }
.cy { height: 60vh; min-height: 360px; border: .5px solid var(--border); border-radius: var(--radius); background: var(--surface-2); touch-action: none; }
.cy-local { height: 300px; min-height: 300px; }
.gcard { margin-top: 10px; border: .5px solid var(--border); border-radius: var(--radius); padding: 10px 12px; min-height: 44px;
         font-size: 13px; color: var(--text-secondary); }
.gcard.active { color: var(--text-primary); }
.gcard-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.gcard-t { font-size: 14px; font-weight: 500; }
.gcard-m { font-size: 12px; color: var(--text-secondary); display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.graph-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.local { margin-top: 20px; }
.local-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.local-head .seg-wrap { width: 170px; }

/* Einstellungen, Login */
.sec { margin-bottom: 24px; }
.sec h2 { font-size: 14px; font-weight: 500; margin: 0 0 8px; }
.sec.center { text-align: center; padding-top: 30px; }
.sec.center button, .sec.center .btn { margin: 8px auto; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.hint { font-size: 12px; color: var(--text-secondary); background: var(--surface-1); padding: 8px 10px; border-radius: var(--radius); }
.pw { display: flex; gap: 8px; justify-content: center; margin-top: 20px; }
[hidden] { display: none !important; }

/* Aufgaben bearbeiten, Kategorien, Karten */
.cat { display: inline-block; font-size: 11px; padding: 0 6px; border-radius: 8px; border: .5px solid var(--border-strong);
       color: var(--text-secondary); margin-left: 2px; }
.kat-hint { margin: -4px 0 12px; }
.linkish { border: 0; height: auto; padding: 0; color: var(--text-accent); font-size: 12px; background: transparent; }
.linkish:hover { background: transparent; text-decoration: underline; }
.danger-btn { color: var(--text-danger); border-color: var(--border-danger); }
.card-gap { margin-top: 6px !important; }
.q-item + .q-item { margin-top: 8px; }
.q-actions.wrap { flex-wrap: wrap; }
.q-more { margin-top: 8px; font-size: 12px; }
.q-more summary { cursor: pointer; }
.taskedit { border: .5px solid var(--border); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 14px;
            display: flex; flex-direction: column; gap: 10px; }
.te-head { display: flex; justify-content: space-between; align-items: center; }
.te-head .group-l { margin: 0; }
.te-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.te-row label { font-size: 13px; color: var(--text-secondary); min-width: 70px; }
.te-row.end { justify-content: flex-end; }
.te-row input[type=date], .te-row select { height: 32px; font-size: 15px; }
select { font: inherit; border: .5px solid var(--border-strong); border-radius: var(--radius); background: var(--surface-2);
         color: var(--text-primary); padding: 0 8px; }
.te-note { display: flex; gap: 8px; align-items: flex-end; }
.te-note textarea { flex: 1; resize: vertical; padding: 8px 10px; font-size: 15px; }
#katfilter { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-right: -16px; padding-right: 16px; }
#katfilter::-webkit-scrollbar { display: none; }
