/* ── Morgenwart — calm & minimal (Redesign 2026-07) ───────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Hanken+Grotesk:wght@400;500;600;700&display=swap');

:root {
  /* Surfaces — warm, paper-like */
  --paper:      #F4F3EE;
  --surface:    #FFFFFF;
  --surface-2:  #FAF9F5;
  --tint:       #ECEFEA;

  /* Ink & text */
  --ink-1:      #232824;
  --muted:      #7C877E;
  --faint:      #A6AEA6;
  --line:       #E4E1D9;

  /* Brand — sage */
  --sage:       #6E8579;
  --sage-deep:  #556A5F;
  --sage-soft:  #AEBEB1;
  --sage-tint:  #E5ECE6;

  /* Accents A/B/C/D */
  --a:#DA7460; --a-tint:#F6E5E0;
  --b:#E0A15E; --b-tint:#F7ECDC;
  --c:#7FA089; --c-tint:#E6EEE8;
  --d:#AFAFA6; --d-tint:#ECEBE6;

  --r-sm:8px; --r-md:14px; --r-lg:20px;
  --shadow:0 1px 2px rgba(35,40,36,.05),0 6px 16px -8px rgba(35,40,36,.12);
  --font:'Hanken Grotesk',system-ui,-apple-system,"Segoe UI",sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100%;
  font-family: var(--font);
  background: var(--paper);
  color: var(--ink-1);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── App shell ─────────────────────────────────────────────────────────────── */
#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header (greeting) ─────────────────────────────────────────────────────── */
header {
  padding: 20px 22px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

header .greeting-date { font-size: 13px; color: var(--muted); }
header h1 {
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink-1);
  margin-top: 3px;
}

header .greeting-spruch {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
  font-style: italic;
}

.brand-mark {
  width: 38px; height: 38px;
  border-radius: 12px;
  background: var(--sage);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px;
  flex-shrink: 0;
}

/* ── Segmented tabs ────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--tint);
  border-radius: 12px;
  padding: 4px;
  margin: 16px 22px 0;
}

.tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 600;
  padding: 8px 0;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tab-btn.active {
  background: var(--surface);
  color: var(--ink-1);
  box-shadow: 0 1px 2px rgba(35,40,36,.08);
}

/* ── Focus line ────────────────────────────────────────────────────────────── */
.focus-text {
  margin: 15px 22px 4px;
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.5;
}

/* ── Sections ──────────────────────────────────────────────────────────────── */
.section { margin: 18px 22px 0; }

.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.section-header .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.section-header .label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}
.section-header .count { margin-left: auto; font-size: 12px; color: var(--faint); font-weight: 500; }

.dot-a{background:var(--a)} .dot-b{background:var(--b)} .dot-c{background:var(--c)} .dot-d{background:var(--d)} .dot-unk{background:var(--faint)}

/* ── Item card ─────────────────────────────────────────────────────────────── */
/* Two layers: .item-card (outer, static, positioning context) and
   .card-content (inner, actually slides during a swipe). No overflow:hidden
   on the outer — the prio-picker popover extends below the card's own
   bottom edge and must not get clipped. */
.item-card {
  position: relative;
  border-radius: var(--r-md);
  margin-bottom: 8px;
  touch-action: pan-y; /* we own horizontal gestures, browser keeps vertical scroll */
}

.card-content {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 13px 15px 13px 17px;
  display: flex;
  align-items: flex-start;
  gap: 11px;
  transition: transform 0.22s cubic-bezier(.2,.8,.2,1), opacity 0.22s;
}

.item-card.dragging .card-content { transition: none; }
.item-card.done .card-content { opacity: 0; transform: translateX(8px) !important; pointer-events: none; }

/* Swipe-reveal background — shows the target quadrant while dragging */
.swipe-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}
.swipe-bg.visible { opacity: 1; }
.swipe-bg.dir-left  { justify-content: flex-end;  padding-right: 22px; }
.swipe-bg.dir-right { justify-content: flex-start; padding-left: 22px; }
.swipe-bg.target-A { background: var(--a); }
.swipe-bg.target-B { background: var(--b); }
.swipe-bg.target-C { background: var(--c); }
.swipe-bg.target-D { background: var(--d); }
.swipe-bg.target-none { background: var(--faint); }

/* Left accent bar */
.item-card .accent {
  position: absolute;
  left: 0; top: 11px; bottom: 11px;
  width: 3px;
  border-radius: 0 3px 3px 0;
}
.accent-A{background:var(--a)} .accent-B{background:var(--b)} .accent-C{background:var(--c)} .accent-D{background:var(--d)} .accent-unbekannt{background:var(--faint)} .accent-inbox{background:var(--sage)}

/* Done toggle */
.done-toggle {
  appearance: none;
  width: 20px; height: 20px;
  border: 1.5px solid var(--line);
  border-radius: 6px;
  margin-top: 1px;
  flex-shrink: 0;
  background: var(--surface);
  cursor: pointer;
  color: #fff;
  font-size: 12px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.12s, border-color 0.12s;
}
.done-toggle.checked { background: var(--sage); border-color: var(--sage); }

.item-body { flex: 1; min-width: 0; }
.item-text {
  font-size: 14.5px;
  font-weight: 500;
  line-height: 1.45;
  color: var(--ink-1);
  word-break: break-word;
}

.item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}

.badge {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 7px;
  font-size: 10.5px;
  font-weight: 500;
  white-space: nowrap;
  color: var(--muted);
}

/* Flagged mail — warm accent so it stands out in the meta row */
.badge-flag {
  background: var(--b-tint);
  border-color: var(--b);
  color: var(--b);
}

/* Outlook category chip (Backoffice already filtered out server-side) */
.badge-cat {
  background: var(--sage-tint);
  border-color: var(--sage-soft);
  color: var(--sage-deep);
}

/* "Von: …" provenance line under the item text */
.item-absender {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
  word-break: break-word;
}


/* ── Priority chip + picker ────────────────────────────────────────────────── */
.prio-wrap { position: relative; flex-shrink: 0; }

.prio-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px 3px 7px;
  border-radius: 999px;
  font-family: var(--font);
  font-size: 11.5px;
  font-weight: 600;
  border: none;
  cursor: pointer;
}
.prio-chip .swatch { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.prio-A{background:var(--a-tint);color:var(--a)}
.prio-B{background:var(--b-tint);color:var(--b)}
.prio-C{background:var(--c-tint);color:var(--c)}
.prio-D{background:var(--d-tint);color:#8a8a80}
.prio-unbekannt{background:var(--tint);color:var(--muted)}

/* Picker popover */
.prio-picker {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  display: none;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 5px;
  box-shadow: var(--shadow);
  z-index: 20;
}
.prio-picker.open { display: flex; }

.prio-picker button {
  width: 30px; height: 28px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
}
.prio-picker button.pA{color:var(--a)} .prio-picker button.pB{color:var(--b)}
.prio-picker button.pC{color:var(--c)} .prio-picker button.pD{color:#8a8a80}
.prio-picker button.current { background: var(--sage-tint); border-color: var(--sage-soft); }

/* ── Deadline chip ─────────────────────────────────────────────────────────── */
.deadline-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 7px;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.deadline-chip:hover { background: var(--tint); }
.deadline-chip.set { background: var(--sage-tint); border-color: var(--sage-soft); color: var(--sage-deep); }

.deadline-native {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  opacity: 0; border: none; padding: 0;
  pointer-events: none;
}

/* ── C / D drawers ─────────────────────────────────────────────────────────── */
.drawer-wrap { margin: 18px 22px 0; }
.drawer-btn {
  width: 100%;
  background: none;
  border: 1px dashed var(--line);
  border-radius: var(--r-md);
  color: var(--muted);
  padding: 11px 14px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.12s;
}
.drawer-btn:hover { background: var(--surface-2); }
.drawer-btn .count { margin-left: auto; color: var(--faint); }
.drawer-inner { margin-top: 8px; }

/* ── Refresh button ────────────────────────────────────────────────────────── */
.refresh-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: calc(100% - 44px);
  margin: 20px 22px 28px;
  padding: 14px;
  background: var(--sage);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}
.refresh-btn:hover { background: var(--sage-deep); }
.refresh-btn:disabled { opacity: 0.6; cursor: default; }

/* ── Filter bar (Alle Tasks) ───────────────────────────────────────────────── */
.filter-bar { display: flex; gap: 8px; padding: 15px 22px 4px; flex-wrap: wrap; }
.filter-bar select {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink-1);
  font-family: var(--font);
  font-size: 13px;
  padding: 7px 11px;
  cursor: pointer;
  appearance: none;
}

/* ── Dialog ────────────────────────────────────────────────────────────────── */
.dialog-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(35,40,36,.45);
  backdrop-filter: blur(3px);
  z-index: 100;
  align-items: center; justify-content: center;
}
.dialog-overlay.open { display: flex; }

.dialog {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 28px 24px;
  max-width: 300px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow);
}
.dialog p { margin-bottom: 22px; font-size: 15px; color: var(--ink-1); line-height: 1.5; }
.dialog-btns { display: flex; gap: 10px; }
.dialog-btns button {
  flex: 1; padding: 11px;
  border-radius: 10px; border: none;
  font-family: var(--font); font-size: 14px; font-weight: 600;
  cursor: pointer;
}
.btn-confirm { background: var(--sage); color: #fff; }
.btn-cancel { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }

/* ── Login (numeric keypad) ────────────────────────────────────────────────── */
#login-page {
  min-height: 100vh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 48px 36px 40px;
  text-align: center;
}
.login-mark {
  width: 54px; height: 54px;
  border-radius: 16px;
  background: var(--sage); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 27px; font-weight: 700;
  margin-bottom: 22px;
}
#login-page h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.01em; color: var(--ink-1); }
#login-page .hint { font-size: 14px; color: var(--muted); margin: 6px 0 34px; }

.pin-dots { display: flex; gap: 14px; margin-bottom: 30px; }
.pin-dots span {
  width: 14px; height: 14px; border-radius: 50%;
  border: 1.5px solid var(--sage-soft); background: transparent;
  transition: background 0.12s, border-color 0.12s;
}
.pin-dots span.filled { background: var(--sage); border-color: var(--sage); }

.keypad { display: grid; grid-template-columns: repeat(3, 74px); gap: 14px; }
.keypad button {
  height: 64px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-family: var(--font);
  font-size: 22px;
  font-weight: 500;
  color: var(--ink-1);
  cursor: pointer;
  transition: background 0.1s;
}
.keypad button:active { background: var(--tint); }
.keypad button.key-back { font-size: 18px; font-weight: 600; color: var(--muted); }
.keypad .key-empty { visibility: hidden; }

.error-msg { color: var(--a); font-size: 13px; min-height: 1.2em; margin-top: 16px; }

/* ── Misc ──────────────────────────────────────────────────────────────────── */
.empty { color: var(--faint); font-size: 13px; padding: 4px 0; }
.tab-content { flex: 1; padding-bottom: 40px; }

.spinner {
  display: inline-block;
  width: 15px; height: 15px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }
