/* LifeHub — Oberflaeche.
   Farbwelt aus dem App-Symbol: Petrol als Grund, warmes Bernstein fuer alles,
   was Aufmerksamkeit verlangt, Creme als Papier. Keine Bibliothek, keine
   Web-Fonts von fremden Servern — die App laedt nichts nach. */

:root {
  color-scheme: light dark;

  --deep:   #0D3542;
  --deep-2: #14505F;
  --warm:   #DB7435;
  --warm-2: #F0A24E;

  --bg:      #FBF6EE;
  --surface: #FFFFFF;
  --raised:  #FFFFFF;
  --ink:     #16130F;
  --muted:   #6F675F;
  --faint:   #9C9188;
  --line:    #E7DFD3;
  --line-2:  #F0E9DE;
  --shadow:  0 1px 2px rgba(22,19,15,.06), 0 8px 24px -12px rgba(22,19,15,.18);
  --radius:  15px;
  --tap: 44px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:      #0A1B21;
    --surface: #0F2831;
    --raised:  #143039;
    --ink:     #F2EDE4;
    --muted:   #9DAFB6;
    --faint:   #6E858E;
    --line:    #1D3D48;
    --line-2:  #17323C;
    --deep-2:  #4E97AC;
    --warm:    #F0A24E;
    --warm-2:  #FFC580;
    --shadow:  0 1px 2px rgba(0,0,0,.4), 0 10px 28px -14px rgba(0,0,0,.7);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}
button, input, textarea, select { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- Einrichtung */

.setup { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.setup-card {
  width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px; padding: 26px 24px 22px; box-shadow: var(--shadow);
}
.mark { width: 56px; height: 56px; border-radius: 15px; display: block; margin-bottom: 16px; }
.setup h1 { font-size: 22px; font-weight: 650; letter-spacing: -.01em; }
.lead { color: var(--muted); font-size: 14px; margin: 8px 0 20px; }
.setup label { display: block; font-size: 12px; font-weight: 600; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted); margin: 14px 0 6px; }
.setup input {
  width: 100%; min-height: var(--tap); padding: 10px 13px; background: var(--bg);
  border: 1px solid var(--line); border-radius: 11px; outline: none;
}
.setup input:focus { border-color: var(--deep-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--deep-2) 18%, transparent); }
button.primary {
  width: 100%; min-height: var(--tap); margin-top: 20px; border: 0; border-radius: 11px;
  background: var(--deep); color: #FBF6EE; font-weight: 600; cursor: pointer;
}
@media (prefers-color-scheme: dark) { button.primary { background: var(--deep-2); color: #05161C; } }
button.primary:active { transform: translateY(1px); }
button.primary[disabled] { opacity: .55; cursor: progress; }
.status { font-size: 13.5px; margin-top: 12px; min-height: 20px; }
.status.err { color: var(--warm); }
.status.ok  { color: var(--deep-2); }
.fineprint { color: var(--faint); font-size: 12px; margin-top: 16px; line-height: 1.5; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em;
  background: var(--line-2); padding: 1px 5px; border-radius: 5px; }

/* ---------------------------------------------------------------- Rahmen */

.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 14px) 18px 12px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid transparent;
}
.top.scrolled { border-bottom-color: var(--line); }
.eyebrow { font-size: 11.5px; font-weight: 650; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.top-left { min-width: 0; }
.top h1 {
  font-size: 24px; font-weight: 650; letter-spacing: -.015em; margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
@media (max-width: 390px) { .top h1 { font-size: 21px; } }
.top-right { display: flex; align-items: center; gap: 4px; }
.eyebrow { display: flex; align-items: baseline; gap: 7px; }
.sync { font-size: 11px; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--faint); white-space: nowrap; }
.icon-btn {
  width: var(--tap); height: var(--tap); display: grid; place-items: center;
  background: transparent; border: 0; border-radius: 11px; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--line-2); color: var(--ink); }
.icon-btn.spinning svg { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.banner {
  margin: 0 18px 10px; padding: 9px 13px; border-radius: 11px; font-size: 13.5px;
  background: color-mix(in srgb, var(--warm) 14%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--warm) 35%, transparent);
  color: var(--ink);
}
main { padding: 0 18px calc(env(safe-area-inset-bottom) + 108px); }

/* ---------------------------------------------------------------- Karten */

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px 16px; margin-bottom: 13px; box-shadow: var(--shadow);
}
.card.flat { box-shadow: none; }
.card-title {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  font-size: 11.5px; font-weight: 650; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 11px;
}
.card-title .side { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--faint); font-size: 12.5px; }
.empty { color: var(--faint); font-size: 14.5px; padding: 3px 0; }
.section-head {
  font-size: 11.5px; font-weight: 650; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); margin: 22px 2px 9px;
}

/* Termine */
.ev { display: flex; gap: 13px; padding: 9px 0; border-top: 1px solid var(--line-2); }
.ev:first-child { border-top: 0; padding-top: 2px; }
.ev-time {
  min-width: 52px; font-variant-numeric: tabular-nums; font-weight: 650; font-size: 14px;
  color: var(--deep-2); padding-top: 1px;
}
.ev-time small { display: block; font-weight: 400; color: var(--faint); font-size: 12px; }
.ev-main { flex: 1; min-width: 0; }
.ev-title { font-size: 15.5px; line-height: 1.3; }
.ev-meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.ev.is-now { position: relative; }
.ev.is-now::before {
  content: ""; position: absolute; left: -16px; top: 10px; bottom: 10px; width: 3px;
  border-radius: 2px; background: var(--warm);
}
.ev.declined .ev-title { text-decoration: line-through; color: var(--faint); }

/* Freie Bloecke */
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; font-size: 13.5px;
  background: var(--bg);
}
.chip b { font-variant-numeric: tabular-nums; font-weight: 650; }
.chip span { color: var(--muted); margin-left: 5px; }

/* Aufgaben */
.task { display: flex; align-items: flex-start; gap: 11px; padding: 9px 0; border-top: 1px solid var(--line-2); }
.task:first-child { border-top: 0; }
.box {
  flex: none; width: 21px; height: 21px; margin-top: 1px; border: 1.8px solid var(--faint);
  border-radius: 7px; background: transparent; cursor: pointer; display: grid; place-items: center;
  color: transparent; transition: background .12s, border-color .12s;
}
.box:hover { border-color: var(--deep-2); }
.box.done { background: var(--deep-2); border-color: var(--deep-2); color: var(--surface); }
.task-main { flex: 1; min-width: 0; cursor: pointer; }
.task-title { font-size: 15.5px; line-height: 1.32; overflow-wrap: anywhere; }
.task.done .task-title { text-decoration: line-through; color: var(--faint); }
.task-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; }
.pill { padding: 1px 7px; border-radius: 999px; background: var(--line-2); font-size: 12px; }
.pill.late { background: color-mix(in srgb, var(--warm) 18%, transparent); color: var(--warm); font-weight: 600; }
.pill.today { background: color-mix(in srgb, var(--deep-2) 15%, transparent); color: var(--deep-2); font-weight: 600; }

/* Inbox */
.mail { display: flex; gap: 11px; padding: 11px 0; border-top: 1px solid var(--line-2); }
.mail:first-child { border-top: 0; }
.mail-unread { flex: none; width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; background: var(--warm); }
.mail-unread.read { background: transparent; }
.mail-main { flex: 1; min-width: 0; cursor: pointer; }
.mail-from { font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; gap: 10px; }
.mail-from b { color: var(--ink); font-weight: 600; }
.mail-subj { font-size: 15px; margin-top: 1px; overflow-wrap: anywhere; }
.mail.unread .mail-subj { font-weight: 620; }
.mail-snip { font-size: 13px; color: var(--faint); margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mail-acts { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.mini {
  border: 1px solid var(--line); background: var(--bg); border-radius: 9px; padding: 6px 10px;
  font-size: 12.5px; color: var(--muted); cursor: pointer; min-height: 32px;
}
.mini:hover { border-color: var(--deep-2); color: var(--ink); }
.mini.warn:hover { border-color: var(--warm); color: var(--warm); }

/* Kennzahlen oben auf "Heute" */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-bottom: 13px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: 13px; padding: 11px 12px;
  cursor: pointer;
}
.stat b { display: block; font-size: 23px; font-weight: 650; letter-spacing: -.02em; line-height: 1.1; }
.stat span { font-size: 11.5px; color: var(--muted); }
.stat.alert b { color: var(--warm); }

/* ---------------------------------------------------------------- Navigation */

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 6px 6px calc(env(safe-area-inset-bottom) + 6px);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px);
  border-top: 1px solid var(--line);
}
.tab {
  position: relative; display: grid; justify-items: center; gap: 3px; padding: 7px 2px 5px;
  background: transparent; border: 0; border-radius: 12px; color: var(--faint); cursor: pointer;
}
.tab span { font-size: 10.5px; font-weight: 600; }
.tab.is-active { color: var(--deep-2); }
.tab .dot {
  position: absolute; top: 5px; right: calc(50% - 17px); width: 7px; height: 7px;
  border-radius: 50%; background: var(--warm);
}
.fab {
  position: fixed; right: 18px; z-index: 31;
  bottom: calc(env(safe-area-inset-bottom) + 74px);
  width: 54px; height: 54px; border-radius: 18px; border: 0; cursor: pointer;
  background: var(--deep); color: #FBF6EE; display: grid; place-items: center;
  box-shadow: 0 6px 20px -6px rgba(13,53,66,.55);
}
@media (prefers-color-scheme: dark) { .fab { background: var(--warm); color: #2A1405; } }
.fab:active { transform: translateY(1px); }

/* ---------------------------------------------------------------- Schublade */

.sheet { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(8,20,25,.42); animation: fade .18s ease; }
.sheet-body {
  position: relative; width: 100%; max-width: 520px; max-height: 88dvh; overflow-y: auto;
  background: var(--surface); border-radius: 22px 22px 0 0; padding: 10px 20px calc(env(safe-area-inset-bottom) + 22px);
  animation: rise .22s cubic-bezier(.22,.9,.3,1);
}
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(22px); opacity: .4; } }
.sheet-grip { width: 38px; height: 4px; border-radius: 2px; background: var(--line); margin: 4px auto 14px; }
.sheet h2 { font-size: 19px; font-weight: 650; margin-bottom: 4px; }
.sheet .sub { color: var(--muted); font-size: 13.5px; margin-bottom: 14px; overflow-wrap: anywhere; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; font-weight: 600; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 5px; }
.field input, .field textarea, .field select {
  width: 100%; min-height: var(--tap); padding: 10px 12px; background: var(--bg);
  border: 1px solid var(--line); border-radius: 11px; outline: none;
}
.field textarea { min-height: 78px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--deep-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--deep-2) 18%, transparent);
}
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sheet-actions { display: flex; gap: 9px; margin-top: 18px; }
.sheet-actions button { flex: 1; min-height: var(--tap); border-radius: 11px; cursor: pointer; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.btn-ghost:hover { color: var(--ink); border-color: var(--faint); }
.btn-danger { background: transparent; border: 1px solid color-mix(in srgb, var(--warm) 45%, transparent); color: var(--warm); flex: 0 0 auto; padding: 0 15px; }
.quick { display: flex; gap: 7px; flex-wrap: wrap; margin-top: -4px; margin-bottom: 12px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 80;
  bottom: calc(env(safe-area-inset-bottom) + 92px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px;
  font-size: 14px; box-shadow: var(--shadow); max-width: 88vw; text-align: center;
}

/* ---------------------------------------------------------------- Groessere Fenster */

@media (min-width: 760px) {
  .top, main, .banner { max-width: 860px; margin-left: auto; margin-right: auto; }
  main { padding-bottom: 60px; }
  .tabs {
    position: static; bottom: auto; max-width: 860px; margin: 0 auto 16px;
    grid-template-columns: repeat(4, max-content); gap: 4px; justify-content: start;
    border-top: 0; border-bottom: 1px solid var(--line); padding: 4px 18px 8px; background: transparent;
    backdrop-filter: none;
  }
  .tab { grid-auto-flow: column; justify-items: start; align-items: center; gap: 8px; padding: 8px 14px; }
  .tab span { font-size: 13.5px; }
  .tab.is-active { background: var(--surface); border: 1px solid var(--line); }
  .tab .dot { position: static; margin-left: 2px; }
  .fab { bottom: 26px; right: 26px; }
  .toast { bottom: 26px; }
  .sheet { align-items: center; }
  .sheet-body { border-radius: 20px; padding-bottom: 22px; }
  /* Beide Karten gleich hoch (stretch, nicht start) — sonst enden sie auf
     verschiedener Höhe und die Zeile franst unten aus. Der Abstand nach unten
     wandert von den Karten auf den Zweispalter, sonst klebt die nächste Karte
     ohne Luft daran. */
  .two-col {
    display: grid; grid-template-columns: 1fr 1fr; gap: 13px;
    align-items: stretch; margin-bottom: 13px;
  }
  .two-col > * { margin-bottom: 0; }
}
