:root {
  --bg: #f4f2ee; --panel: #ffffff; --text: #1d1c1a; --muted: #6b675f;
  --line: #e2ded6; --accent: #2f5d50; --accent-text: #ffffff; --bad: #a33a2a; --ok: #2f6b3a;
  --radius: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161716; --panel: #212321; --text: #ecebe7; --muted: #a29f97;
    --line: #34362f; --accent: #7fb7a4; --accent-text: #0f1a16; --bad: #e0806f; --ok: #8cc795;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { min-height: 100dvh; line-height: 1.5; }
a { color: var(--accent); }

.center { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.card {
  width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 28px 24px;
}
.card h1 { margin: 0 0 4px; font-size: 1.4rem; }
.card p.sub { margin: 0 0 20px; color: var(--muted); font-size: .95rem; }

label { display: block; font-size: .9rem; margin: 14px 0 6px; color: var(--muted); }
input {
  width: 100%; font: inherit; padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
button {
  font: inherit; font-weight: 600; cursor: pointer; border: 0; border-radius: 10px;
  padding: 11px 16px; background: var(--accent); color: var(--accent-text);
}
.card button { width: 100%; margin-top: 20px; }
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.msg { min-height: 1.4em; margin-top: 12px; font-size: .9rem; color: var(--bad); }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.top .brand { font-weight: 700; letter-spacing: .02em; }
main { max-width: 900px; margin: 0 auto; padding: 20px 16px 40px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.tile h2 { margin: 0 0 8px; font-size: 1rem; }
.tile .big { font-size: 1.6rem; font-weight: 700; }
.tile .small { color: var(--muted); font-size: .88rem; }
.ok { color: var(--ok); } .bad { color: var(--bad); }

/* ---- Morgenbriefing ---- */
.tile.briefing { margin-bottom: 14px; }
.briefing-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.briefing-head h2 { margin: 0; }
.small-btn { padding: 6px 12px; font-size: .88rem; }
.briefing-summary { margin: 10px 0 6px; }
.briefing-error {
  margin: 10px 0; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--bad); color: var(--bad); font-size: .92rem;
}
.mail-card { border-top: 1px solid var(--line); padding: 10px 0; }
.mail-card .meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; font-size: .85rem; color: var(--muted); }
.mail-card .subject { font-weight: 600; margin: 2px 0; overflow-wrap: anywhere; }
.mail-card .todo { font-size: .92rem; margin-top: 4px; }
.tag {
  font-size: .75rem; font-weight: 700; padding: 2px 8px; border-radius: 99px;
  background: var(--bg); border: 1px solid var(--line); color: var(--text);
}
.tag.urgent { border-color: var(--bad); color: var(--bad); }

/* ---- App-Rahmen: feste Höhe, jede Ansicht scrollt selbst (Teil 2.5, 2.4) ---- */
body.app { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
body.app .top { flex: none; }
.view { flex: 1; min-height: 0; overflow-y: auto; }
.view[hidden] { display: none; }
.tabs { display: flex; gap: 4px; }
.tabs button, .bottom-tabs button {
  background: transparent; color: var(--muted); padding: 8px 14px; font-weight: 600;
}
.tabs button.active { color: var(--text); background: var(--bg); }
.bottom-tabs { display: none; }

/* ---- Chat ---- */
.view.chat { display: flex; flex-direction: column; overflow: hidden; }
.view.chat[hidden] { display: none; }
.chat-head {
  flex: none; display: flex; gap: 8px; justify-content: space-between; align-items: center;
  max-width: 900px; width: 100%; margin: 0 auto; padding: 10px 16px;
}
select {
  font: inherit; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text);
}
.messages {
  flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 10px;
  max-width: 900px; width: 100%; margin: 0 auto; padding: 8px 16px 16px;
}
.msg-bubble {
  max-width: 85%; padding: 10px 14px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere;
  border: 1px solid var(--line); background: var(--panel);
}
.msg-bubble.user { align-self: flex-end; background: var(--accent); color: var(--accent-text); border-color: transparent; }
.msg-bubble.assistant { align-self: flex-start; }
.msg-bubble.pending { color: var(--muted); }
.msg-bubble.error { color: var(--bad); }
.msg-bubble.hint { align-self: center; color: var(--muted); background: transparent; border: 0; text-align: center; }
.composer {
  flex: none; display: flex; gap: 8px; align-items: flex-end;
  max-width: 900px; width: 100%; margin: 0 auto; padding: 10px 16px 14px;
}
.composer textarea {
  flex: 1; font: inherit; resize: none; padding: 11px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text); max-height: 180px;
}
.composer button:disabled { opacity: .5; cursor: wait; }

/* ---- Handy: Navigation unten im Daumenbereich ---- */
@media (max-width: 700px) {
  .top .tabs { display: none; }
  .bottom-tabs {
    flex: none; display: flex; justify-content: space-around;
    border-top: 1px solid var(--line); background: var(--panel);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-tabs button { flex: 1; padding: 10px; }
  .bottom-tabs button.active { color: var(--accent); }
  .msg-bubble { max-width: 92%; }
}
