:root {
  --bg: #f4f3ef;
  --panel: #ffffff;
  --panel-2: #faf9f6;
  --ink: #14171f;
  --ink-2: #4a4f5c;
  --muted: #8a8f9c;
  --line: #e6e3dc;
  --accent: #ff5a1f;
  --accent-ink: #ffffff;
  --accent-soft: #fff0e8;
  --side: #14171f;
  --side-ink: #c9ccd4;
  --side-hover: #20242f;
  --hoch: #e5372b;
  --mittel: #f0a202;
  --niedrig: #7c8595;
  --ok: #16a34a;
  --shadow: 0 1px 2px rgba(20, 23, 31, .05), 0 6px 24px rgba(20, 23, 31, .06);
  --r: 14px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --display: 'Space Grotesk', var(--font);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1116; --panel: #171a21; --panel-2: #1c2029; --ink: #eceef2; --ink-2: #b4b8c3;
    --muted: #7b8190; --line: #262a34; --accent-soft: #2d1a12; --side: #0b0d11; --side-hover: #171a21;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 15px; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--hoch); min-height: 1.2em; font-size: 14px; margin: 0; }

.logo { font-family: var(--display); font-weight: 700; font-size: 22px; letter-spacing: -.02em; color: #fff; }
.logo span { color: var(--accent); }
.logo.big { font-size: 44px; color: var(--ink); }

/* ---------- Login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 340px; background: var(--panel); padding: 36px 28px; border-radius: 22px; box-shadow: var(--shadow); display: grid; gap: 14px; text-align: center; }
.login-card p { margin: 0 0 8px; }

/* ---------- Inputs & Buttons ---------- */
input:not([type=color]):not([type=checkbox]), select, textarea {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; }
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 9px 16px; font-weight: 600; white-space: nowrap; }
.btn:hover { border-color: var(--ink-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--hoch); }
.btn:disabled { opacity: .6; cursor: wait; }
.icon-btn { border: 0; background: transparent; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; color: var(--ink-2); }
.icon-btn:hover { background: var(--panel-2); color: var(--ink); }
.row-end { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.row-between { display: flex; gap: 8px; justify-content: space-between; align-items: center; flex-wrap: wrap; }

/* ---------- Layout ---------- */
.app { height: 100%; display: grid; grid-template-columns: 250px minmax(0, 1fr) 400px; }
.main { display: contents; }
.sidebar { grid-column: 1; grid-row: 1; background: var(--side); color: var(--side-ink); padding: 22px 14px; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; }
.sidebar .logo { padding: 0 10px 18px; }
.side-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #6b7080; padding: 18px 10px 6px; }
.side-nav { display: grid; gap: 2px; }
.side-link { display: flex; align-items: center; gap: 10px; width: 100%; background: transparent; border: 0; color: inherit; padding: 9px 10px; border-radius: 9px; text-align: left; font-weight: 500; }
.side-link:hover { background: var(--side-hover); color: #fff; }
.side-link.on { background: var(--side-hover); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.side-link .count { margin-left: auto; font-size: 12px; color: #6b7080; font-variant-numeric: tabular-nums; }
.side-link .count.alert { color: #fff; background: var(--hoch); border-radius: 99px; padding: 0 7px; }
.side-link .cdot { width: 9px; height: 9px; border-radius: 3px; flex: none; margin: 0 5px; }
.side-link svg { width: 18px; height: 18px; }
.side-bottom { margin-top: auto; padding-top: 16px; }

.view { min-height: 0; min-width: 0; }
#view-tasks, #view-settings { grid-column: 2; grid-row: 1; display: flex; flex-direction: column; overflow: hidden; }
#view-chat { grid-column: 3; grid-row: 1; }
.app[data-view=settings] #view-tasks, .app[data-view=calendar] #view-tasks { display: none; }
.app:not([data-view=settings]) #view-settings { display: none; }
.app:not([data-view=calendar]) #view-calendar { display: none; }
#view-calendar { grid-column: 2; grid-row: 1; display: flex; flex-direction: column; overflow: hidden; }
.tabbar { display: none; }
.filterbar { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.search { flex: 1; display: flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; }
.search svg { width: 16px; height: 16px; color: var(--muted); }
.search input { border: 0 !important; background: transparent !important; box-shadow: none !important; padding: 9px 0; }
.small-btn { padding: 7px 12px; font-size: 13px; }
.tag.bell { color: var(--accent); }
.day-h { display: flex; align-items: baseline; gap: 8px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 22px 4px 8px; }
.day-h.today { color: var(--accent); }
.event { display: flex; gap: 12px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 11px 12px 11px 14px; margin-bottom: 8px; position: relative; }
.event .ev-time { font-family: var(--display); font-weight: 700; min-width: 92px; font-variant-numeric: tabular-nums; font-size: 14px; }
.event .ev-time small { display: block; font-family: var(--font); font-weight: 500; color: var(--muted); font-size: 12px; }
.event .ev-body { flex: 1; min-width: 0; }
.event .ev-title { font-weight: 600; overflow-wrap: anywhere; }
.event .ev-loc { color: var(--muted); font-size: 13px; }
.event.past { opacity: .5; }
.event .bell-btn.on { color: var(--accent); }
.bell-menu { position: absolute; right: 8px; top: calc(100% - 6px); z-index: 20; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; display: grid; min-width: 190px; }
.bell-menu button { border: 0; background: transparent; text-align: left; padding: 8px 10px; border-radius: 8px; font-size: 14px; }
.bell-menu button:hover { background: var(--panel-2); }
.rem-row { display: flex; gap: 10px; align-items: center; background: var(--accent-soft); border-radius: 12px; padding: 8px 8px 8px 14px; margin-bottom: 6px; font-size: 14px; }
.rem-row b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.rem-row span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.steps code { background: var(--panel-2); padding: 1px 5px; border-radius: 5px; }
.mobile-only { display: none !important; }

/* ---------- Kopf & Schnelleingabe ---------- */
.top { padding: 26px 32px 14px; }
.top-row { display: flex; align-items: center; gap: 16px; }
.top-title { flex: 1; min-width: 0; }
h1 { font-family: var(--display); font-size: 28px; letter-spacing: -.02em; margin: 0; }
h2 { font-family: var(--display); font-size: 17px; margin: 0 0 12px; }
.seg { display: flex; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--ink); color: var(--bg); }
.quick { margin-top: 18px; display: flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 6px 6px 6px 16px; box-shadow: var(--shadow); transition: border-color .15s; }
.quick:focus-within { border-color: var(--accent); }
.quick input { border: 0 !important; background: transparent !important; box-shadow: none !important; padding: 10px 4px; font-size: 16px; }
.quick-spark { color: var(--accent); font-size: 18px; }
.quick.busy .quick-spark { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Liste ---------- */
.list { flex: 1; overflow-y: auto; padding: 4px 32px 40px; }
.group-h { display: flex; align-items: baseline; gap: 8px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 22px 4px 8px; }
.group-h.alert { color: var(--hoch); }
.group-h .n { font-weight: 500; }
.todo { display: flex; gap: 12px; align-items: flex-start; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 13px 14px; margin-bottom: 8px; cursor: pointer; transition: transform .12s, box-shadow .12s, opacity .25s; position: relative; overflow: hidden; }
.todo::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--pc); }
.todo:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.todo.done { opacity: .55; }
.todo.urgent { border-color: color-mix(in srgb, var(--hoch) 45%, var(--line)); background: color-mix(in srgb, var(--hoch) 5%, var(--panel)); }
.todo.urgent::before { width: 6px; background: var(--hoch); }
.bang { display: inline-block; color: #fff; background: var(--hoch); font-weight: 800; letter-spacing: -.02em; font-size: 13px; line-height: 1; padding: 3px 6px 3px 5px; border-radius: 6px; margin-right: 7px; vertical-align: 2px; cursor: pointer; }
.todo.done .bang { display: none; }
.urgent-toggle { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.urgent-toggle .bang { background: var(--line); color: var(--muted); margin: 0; }
.urgent-toggle .switch { margin-left: auto; width: 40px; height: 24px; border-radius: 99px; background: var(--line); position: relative; transition: background .15s; flex: none; }
.urgent-toggle .switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.urgent-toggle.on { border-color: var(--hoch); background: color-mix(in srgb, var(--hoch) 8%, var(--panel)); }
.urgent-toggle.on .bang { background: var(--hoch); color: #fff; }
.urgent-toggle.on .switch { background: var(--hoch); }
.urgent-toggle.on .switch::after { transform: translateX(16px); }
.todo.done .t-title { text-decoration: line-through; }
.todo.flash { animation: flash 1.4s ease; }
@keyframes flash { 0% { background: var(--accent-soft); } 100% { background: var(--panel); } }
.check { flex: none; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); background: transparent; display: grid; place-items: center; margin-top: 1px; transition: all .15s; padding: 0; }
.check:hover { border-color: var(--ok); }
.check svg { width: 14px; height: 14px; stroke-width: 3; opacity: 0; color: #fff; }
.todo.done .check { background: var(--ok); border-color: var(--ok); }
.todo.done .check svg { opacity: 1; }
.t-body { flex: 1; min-width: 0; }
.t-title { font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.t-notes { color: var(--ink-2); font-size: 13.5px; margin-top: 3px; white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.t-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; font-size: 12.5px; }
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--line); color: var(--ink-2); font-weight: 500; }
.tag .cdot { width: 7px; height: 7px; border-radius: 2px; }
.tag.late { background: #fdecea; border-color: #f6c5c0; color: var(--hoch); }
.tag.today { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.tag svg { width: 12px; height: 12px; }
@media (prefers-color-scheme: dark) { .tag.late { background: #3a1714; border-color: #5a221d; } }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 8px; }

/* ---------- Chat ---------- */
.chat { display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--line); min-height: 0; overflow: hidden; }
.chat-head { display: flex; align-items: center; justify-content: space-between; padding: 22px 20px 14px; border-bottom: 1px solid var(--line); }
.chat-title { font-family: var(--display); font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.dot-live { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.messages { flex: 1; overflow-y: auto; padding: 18px 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 86%; padding: 10px 13px; border-radius: 16px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14.5px; }
.msg.user { align-self: flex-end; background: var(--ink); color: var(--bg); border-bottom-right-radius: 5px; }
.msg.assistant { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.msg-btn { display: block; margin-top: 10px; background: var(--accent); color: #fff; text-decoration: none; font-weight: 600; font-size: 14px; padding: 9px 12px; border-radius: 10px; text-align: center; white-space: normal; }
.msg-btn:hover { filter: brightness(1.05); }
.msg .src { display: block; font-size: 11px; opacity: .6; margin-top: 4px; }
.msg.typing { color: var(--muted); }
.msg.typing span { animation: blink 1.2s infinite; }
.msg.typing span:nth-child(2) { animation-delay: .2s; }
.msg.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 50% { opacity: .2; } }
.chat-empty { margin: auto; text-align: center; color: var(--muted); padding: 20px; }
.chat-empty .logo { color: var(--ink); font-size: 32px; margin-bottom: 6px; }
.suggest { display: flex; gap: 6px; padding: 0 14px 8px; overflow-x: auto; scrollbar-width: none; }
.suggest button { flex: none; border: 1px solid var(--line); background: var(--panel); border-radius: 99px; padding: 6px 12px; font-size: 13px; color: var(--ink-2); }
.suggest button:hover { border-color: var(--accent); color: var(--accent); }
.composer { display: flex; gap: 8px; align-items: flex-end; padding: 10px 14px 16px; border-top: 1px solid var(--line); }
.composer textarea { resize: none; max-height: 140px; border-radius: 12px; }
.send { flex: none; width: 42px; height: 42px; border-radius: 12px; border: 0; background: var(--accent); color: #fff; display: grid; place-items: center; }
.send:disabled { opacity: .5; }
.mic { flex: none; height: 42px; min-width: 42px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink-2); display: flex; align-items: center; justify-content: center; gap: 6px; padding: 0 10px; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.mic:hover { color: var(--accent); border-color: var(--accent); }
.mic.rec { background: var(--hoch); border-color: var(--hoch); color: #fff; animation: pulse 1.4s infinite; }
.mic.busy { opacity: .6; cursor: wait; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--hoch) 25%, transparent); } }

/* ---------- Einstellungen ---------- */
.settings-body { flex: 1; overflow-y: auto; padding: 6px 32px 40px; display: grid; gap: 16px; align-content: start; max-width: 820px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 20px; display: grid; gap: 12px; }
.card h2 { margin: 0; }
.card p { margin: 0; }
.stack { display: grid; gap: 8px; }
.cat-row, .pat-row, .add-row { display: flex; gap: 8px; align-items: center; }
.pat-row input { flex: 2; }
.pat-row select { flex: 1; min-width: 0; }
input[type=color] { width: 40px; height: 40px; padding: 2px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); flex: none; cursor: pointer; }
.rules { display: grid; gap: 8px; }
.rule { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; padding: 12px 14px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; }
.rule .when { grid-row: span 2; font-family: var(--display); font-weight: 700; font-size: 18px; color: var(--accent); align-self: center; min-width: 58px; }
.rule .lbl { font-weight: 600; }
.rule .what { font-size: 13px; color: var(--ink-2); }
.summary { background: var(--accent-soft); border-radius: 12px; padding: 12px 14px; font-size: 14px; }
.tg-code { font-family: var(--display); font-size: 26px; font-weight: 700; letter-spacing: .12em; background: var(--panel-2); border: 1px dashed var(--line); border-radius: 12px; padding: 10px 16px; display: inline-block; user-select: all; }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 6px; color: var(--ink-2); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; font-size: 13px; font-weight: 600; }
.pill.ok { background: #e7f7ec; color: var(--ok); }
.pill.off { background: var(--panel-2); color: var(--muted); }
@media (prefers-color-scheme: dark) { .pill.ok { background: #12301c; } }

/* ---------- Sheet ---------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(10, 12, 16, .45); display: grid; place-items: center; z-index: 50; padding: 20px; backdrop-filter: blur(3px); }
.sheet { width: 100%; max-width: 520px; background: var(--panel); border-radius: 20px; padding: 22px; display: grid; gap: 12px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); max-height: 92vh; overflow-y: auto; }
.sheet label { display: grid; gap: 5px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.sheet-grip { display: none; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dl { display: flex; gap: 6px; }
.dl input[type=time] { max-width: 110px; }
.prio-pick { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 6px; }
.prio-pick button { border: 1px solid var(--line); background: var(--panel-2); border-radius: 10px; padding: 9px; font-weight: 600; }
.prio-pick button { box-shadow: inset 0 -3px 0 var(--c); }
.prio-pick button.on { background: var(--c); border-color: var(--c); color: #fff; box-shadow: none; }
.icon-btn:disabled { opacity: .3; cursor: default; background: transparent; }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 12px; font-size: 14px; font-weight: 500; opacity: 0; pointer-events: none; transition: all .25s; z-index: 60; max-width: calc(100vw - 32px); white-space: pre-line; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.chips { display: flex; gap: 6px; overflow-x: auto; margin: 12px -16px 0; padding: 0 16px 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar, .suggest::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); border-radius: 99px; padding: 6px 12px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip .cdot { width: 7px; height: 7px; border-radius: 2px; }
.chip .count { opacity: .6; font-weight: 500; }

/* ---------- Tablet: Chat unten ausblendbar -> als Ansicht ---------- */
@media (max-width: 1180px) {
  .app { grid-template-columns: 230px minmax(0, 1fr) 340px; }
}

/* ---------- Mobil ---------- */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .sidebar { display: none; }
  .mobile-only { display: flex !important; }
  .logo.mobile-only { color: var(--ink); font-size: 20px; }
  #view-tasks, #view-settings, #view-chat, #view-calendar { grid-column: 1; grid-row: 1; }
  .event .ev-time { min-width: 70px; }
  .app:not([data-view=tasks]) #view-tasks { display: none; }
  .app:not([data-view=chat]) #view-chat { display: none; }
  .chat { border-left: 0; }
  .top { padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 10px; }
  .top-row { flex-wrap: wrap; gap: 10px; }
  .top-title { flex-basis: 100%; order: 3; }
  .top-title h1 { font-size: 22px; }
  .seg { margin-left: auto; }
  .seg button { padding: 5px 9px; font-size: 12px; }
  .quick { margin-top: 12px; }
  .list { padding: 0 16px 24px; }
  .settings-body { padding: 0 16px 24px; }
  .chat-head { padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 12px; }
  .composer { padding-bottom: 12px; }
  .tabbar { display: flex; grid-row: 2; background: var(--panel); border-top: 1px solid var(--line); padding: 6px 8px calc(6px + var(--safe-b)); }
  .tabbar button { flex: 1; border: 0; background: transparent; display: grid; justify-items: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--muted); padding: 6px 0; }
  .tabbar button.on { color: var(--accent); }
  .tabbar svg { width: 22px; height: 22px; }
  .sheet-bg { place-items: end stretch; padding: 0; }
  .sheet { border-radius: 22px 22px 0 0; max-width: none; padding: 10px 18px calc(18px + var(--safe-b)); }
  .sheet-grip { display: block; width: 40px; height: 5px; background: var(--line); border-radius: 99px; margin: 0 auto 6px; }
  .grid2 { grid-template-columns: 1fr; }
  .toast { bottom: calc(84px + var(--safe-b)); }
  .pat-row { flex-wrap: wrap; }
  .pat-row input { flex-basis: 100%; }
  input, select, textarea { font-size: 16px !important; } /* kein iOS-Zoom */
}
