/* =============================================================================
   Morgenblatt — Basis-Styles (Phase 0)
   Mobile-first. Farben + Typografie aus dem Klickdummy in _design/.
   Self-hosted webfonts (DSGVO) — füge die Dateien in /assets/fonts/ ein,
   siehe assets/fonts/README.md. Solange die Dateien fehlen, fallen die
   Stacks auf Systemschriften zurück und das Layout funktioniert weiter.
   ========================================================================== */

/* --- Webfonts (Self-Hosting) ------------------------------------------------ */
@font-face {
  font-family: 'Instrument Serif';
  src: local('Instrument Serif'),
       url('/assets/fonts/instrument-serif-regular.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Instrument Serif';
  src: local('Instrument Serif Italic'),
       url('/assets/fonts/instrument-serif-italic.woff2') format('woff2');
  font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
  font-family: 'DM Sans';
  src: local('DM Sans'),
       url('/assets/fonts/dm-sans-variable.woff2') format('woff2-variations');
  font-weight: 300 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: local('JetBrains Mono'),
       url('/assets/fonts/jetbrains-mono-variable.woff2') format('woff2-variations');
  font-weight: 400 600; font-style: normal; font-display: swap;
}

/* --- Tokens ---------------------------------------------------------------- */
:root {
  --bg: #EFE8DA;
  --surface: #FAF6EE;
  --surface-alt: #E8E0CE;
  --ink: #1A1612;
  --ink-2: #564A3E;
  --ink-3: #8B7E6C;
  --rule: #D9CFB9;
  --rust: #B8543F;
  --moss: #5A7A4F;
  --rust-soft: #E8C9BD;
  --moss-soft: #C9D7C2;

  --font-serif: 'Instrument Serif', Georgia, 'Times New Roman', serif;
  --font-sans: 'DM Sans', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* --- Reset ----------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

/* --- Page wrapper ---------------------------------------------------------- */
.page, .login-page {
  max-width: 480px;
  margin: 0 auto;
  padding: 28px 22px 80px;
}

/* --- Masthead -------------------------------------------------------------- */
.masthead {
  text-align: center;
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  padding: 14px 0 10px;
  margin-bottom: 18px;
}
.masthead-edition {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 4px;
}
.masthead-title {
  font-family: var(--font-serif);
  font-size: 44px;
  line-height: 1;
  font-weight: 400;
  letter-spacing: -0.01em;
}
.masthead-title em {
  font-style: italic;
  color: var(--rust);
}
.masthead-meta {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-top: 8px;
  padding: 0 4px;
}

/* --- Greeting -------------------------------------------------------------- */
.greeting { text-align: center; margin: 26px 0 18px; }
.greeting-line {
  font-family: var(--font-serif);
  font-size: 28px;
  font-style: italic;
  line-height: 1.15;
}
.greeting-sub { font-size: 14px; color: var(--ink-2); margin-top: 6px; }

/* --- Sections -------------------------------------------------------------- */
.section { margin-top: 28px; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid var(--ink);
  padding-bottom: 6px;
  margin-bottom: 12px;
}
.section-title {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 400;
  line-height: 1;
}
.section-count {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* --- Banner (Verbindungs-/Status-Hinweise) -------------------------------- */
.banner {
  margin: 18px 0 8px;
  padding: 12px 14px;
  border-radius: 4px;
  font-size: 13px;
  line-height: 1.45;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.banner code {
  font-family: var(--font-mono);
  font-size: 11px;
  background: rgba(0,0,0,0.06);
  padding: 1px 5px;
  border-radius: 2px;
}
.banner-ok {
  background: var(--moss-soft);
  color: var(--moss);
  border-left: 3px solid var(--moss);
}
.banner-warn {
  background: var(--rust-soft);
  color: var(--rust);
  border-left: 3px solid var(--rust);
}
.banner-cta {
  margin-left: auto;
  color: inherit;
  font-weight: 500;
  text-decoration: underline;
  white-space: nowrap;
}

/* --- Placeholder (Phase-0-Stub) ------------------------------------------- */
.placeholder {
  padding: 18px 16px;
  background: var(--surface);
  border: 1px dashed var(--rule);
  border-radius: 4px;
  font-size: 13px;
  color: var(--ink-3);
  font-style: italic;
}
.placeholder-error {
  background: var(--rust-soft);
  color: var(--rust);
  border-color: var(--rust);
  font-style: normal;
}

/* --- Tile body (live data) ------------------------------------------------ */
.tile-body .empty {
  font-size: 13px;
  color: var(--ink-3);
  font-style: italic;
  padding: 8px 0;
}

/* --- Calendar items ------------------------------------------------------- */
.cal-item {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--rule);
}
.cal-item:last-child { border-bottom: none; }
.cal-time {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink);
  line-height: 1.3;
}
.cal-time small {
  display: block;
  color: var(--ink-3);
  font-size: 10px;
  margin-top: 2px;
}
.cal-body { padding-top: 1px; min-width: 0; }
.cal-title { font-weight: 500; font-size: 15px; }
.cal-meta {
  font-size: 12px;
  color: var(--ink-2);
  margin-top: 2px;
}
.cal-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 6px;
  margin-left: 6px;
  background: var(--surface-alt);
  color: var(--ink-2);
  border-radius: 2px;
}
.cal-tag.now { background: var(--rust); color: var(--surface); }

/* --- Inbox buckets / mail items ------------------------------------------- */
.inbox-bucket { margin-bottom: 16px; }
.inbox-bucket:last-child { margin-bottom: 0; }
.inbox-bucket-muted { opacity: 0.78; }
.inbox-bucket-muted .mail-item { padding: 6px 0; }
.inbox-bucket-muted .mail-from { font-weight: 400; }

.inbox-bucket-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 6px;
}
.inbox-bucket-label .dot {
  width: 6px; height: 6px; border-radius: 50%;
}
.dot.urgent  { background: var(--rust); }
.dot.waiting { background: #C5A572; }
.dot.unread  { background: var(--ink-3); }

.mail-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px;
  padding: 8px 0;
  border-bottom: 1px solid var(--rule);
  align-items: baseline;
  color: inherit;
  text-decoration: none;
  position: relative;
}
.mail-item:last-child { border-bottom: none; }
.mail-item-main-link {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: baseline;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: background-color 0.12s ease;
  margin: 0 -6px;
  padding: 0 6px;
  border-radius: 3px;
  min-width: 0;
}
.mail-item-main-link:hover { background: var(--surface-alt); }
.mail-item-main-link:active { background: var(--rule); }
.mail-hide {
  background: none;
  border: none;
  color: var(--ink-3);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
  margin-left: 2px;
  border-radius: 3px;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}
.mail-item:hover .mail-hide { opacity: 0.7; }
.mail-hide:hover { color: var(--rust); opacity: 1; }

.mail-item-main { min-width: 0; }
.mail-from {
  font-weight: 500;
  font-size: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
}
.mail-subject {
  font-size: 12px;
  color: var(--ink-2);
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mail-time {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-3);
  white-space: nowrap;
}
.mail-tag {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 2px;
  background: var(--surface-alt);
  color: var(--ink-2);
}
.mail-tag-pay { background: var(--rust-soft); color: var(--rust); }

/* --- Eingang heute -------------------------------------------------------- */
.eingang-group { margin-bottom: 16px; }
.eingang-group:last-child { margin-bottom: 0; }
.eingang-group-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 8px;
}
.eingang-group-label .badge {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--ink-3);
  margin-left: auto;
  letter-spacing: 0.1em;
}
.eingang-item {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 4px;
  margin-bottom: 6px;
}
.eingang-item:last-child { margin-bottom: 0; }
.eingang-item-link {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.eingang-item-link:hover {
  border-color: var(--ink-2);
  background: var(--surface-alt);
}
.eingang-item-link:active { background: var(--rule); }
.eingang-icon {
  width: 36px; height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: -0.05em;
}
.eingang-icon.dhl    { background: #FFCC00; color: #D40511; }
.eingang-icon.parcel { background: var(--surface-alt); color: var(--ink); }
.eingang-icon.cash   { background: var(--moss-soft); color: var(--moss); font-size: 16px; }
.eingang-icon.bill   { background: var(--rust-soft); color: var(--rust); font-size: 16px; }
.eingang-icon.bday   { background: #F4E4D0; color: #B8543F; font-size: 16px; }
.eingang-icon.remind { background: var(--surface-alt); color: var(--ink); font-size: 16px; }
.eingang-info { min-width: 0; }
.eingang-title { font-size: 14px; font-weight: 500; line-height: 1.3; }
.eingang-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-3);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.eingang-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
  text-align: right;
  white-space: nowrap;
}
.eingang-tag.due { color: var(--rust); font-weight: 500; }
.eingang-tag.ok  { color: var(--moss); }

/* --- Tracking quick-add --------------------------------------------------- */
.tracking-add {
  display: flex;
  gap: 6px;
  margin-top: 14px;
}
.tracking-add input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--rule);
  padding: 9px 12px;
  font-size: 13px;
  color: var(--ink);
  border-radius: 4px;
  outline: none;
  transition: border-color 0.15s;
}
.tracking-add input:focus { border-color: var(--ink-2); }
.tracking-add button {
  background: var(--ink);
  color: var(--surface);
  border: none;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 4px;
}
.tracking-add button:active { background: var(--rust); }
.tracking-add button[disabled] { opacity: 0.5; cursor: progress; }

/* --- Familie -------------------------------------------------------------- */
.fam-grid { display: grid; gap: 10px; }
.fam-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 4px;
}
.fam-icon { font-size: 18px; text-align: center; }
.fam-name { font-weight: 500; font-size: 14px; }
.fam-detail { font-size: 12px; color: var(--ink-2); font-family: var(--font-mono); }
.fam-status {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 2px;
}
.fam-status.home { background: var(--moss-soft); color: var(--moss); }
.fam-status.away { background: var(--rust-soft); color: var(--rust); }
.fam-note {
  margin-top: 4px;
  padding: 10px 12px;
  background: var(--surface-alt);
  border-left: 3px solid var(--rust);
  font-size: 13px;
  font-style: italic;
  color: var(--ink-2);
}
.fam-note strong { font-style: normal; color: var(--ink); }
.fam-actions { margin-top: 6px; text-align: right; }
.fam-link {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  text-decoration: none;
}
.fam-link:hover { color: var(--rust); }

/* --- Todos ---------------------------------------------------------------- */
.todo-add { display: flex; gap: 6px; margin-bottom: 12px; }
.todo-add input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--rule);
  padding: 10px 12px;
  font-size: 14px;
  color: var(--ink);
  border-radius: 4px;
  outline: none;
  transition: border-color 0.15s;
}
.todo-add input:focus { border-color: var(--ink-2); }
.todo-add button {
  background: var(--ink);
  color: var(--surface);
  border: none;
  padding: 0 18px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 4px;
}
.todo-add button:active { background: var(--rust); }
.todo-add button[disabled] { opacity: 0.5; cursor: progress; }

.todo-list { list-style: none; margin: 0; padding: 0; }
.todo-item {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
}
.todo-item:last-child { border-bottom: none; }
.todo-check {
  width: 20px; height: 20px;
  border: 1.5px solid var(--ink-2);
  border-radius: 50%;
  display: grid;
  place-items: center;
  transition: all 0.15s;
}
.todo-check svg { opacity: 0; transition: opacity 0.15s; }
.todo-item.done .todo-check { background: var(--moss); border-color: var(--moss); }
.todo-item.done .todo-check svg { opacity: 1; }
.todo-text { font-size: 14px; }
.todo-item.done .todo-text { text-decoration: line-through; color: var(--ink-3); }
.todo-del {
  background: none;
  border: none;
  color: var(--ink-3);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  opacity: 0;
  transition: opacity 0.15s;
}
.todo-item:hover .todo-del,
.todo-item.done .todo-del { opacity: 1; }

.todo-connect-btn {
  display: inline-block;
  margin-top: 8px;
  background: var(--ink);
  color: var(--surface);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.todo-connect-btn:hover { background: var(--rust); }

/* --- Weather pill --------------------------------------------------------- */
.weather-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 12px;
  padding: 6px 14px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-2);
}
.weather-pill strong {
  font-weight: 500;
  color: var(--ink);
  font-size: 13px;
}
.weather-cond { color: var(--ink-2); }

/* --- News tabs / items ---------------------------------------------------- */
.news-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}
.news-tab {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--rule);
  padding: 7px 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
  text-align: center;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.news-tab:hover { border-color: var(--ink-2); }
.news-tab.active {
  background: var(--ink);
  color: var(--surface);
  border-color: var(--ink);
}
.news-item {
  display: block;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
  text-decoration: none;
  color: inherit;
}
.news-item:last-child { border-bottom: none; }
.news-item:hover .news-headline { color: var(--rust); }
.news-headline {
  font-family: var(--font-serif);
  font-size: 17px;
  line-height: 1.25;
  color: var(--ink);
  transition: color 0.15s ease;
}
.news-source {
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 4px;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

/* --- Footer ---------------------------------------------------------------- */
.colophon {
  text-align: center;
  margin-top: 40px;
  padding-top: 16px;
  border-top: 1px solid var(--ink);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.colophon em {
  font-family: var(--font-serif);
  font-style: italic;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink-2);
}

/* --- Logout button --------------------------------------------------------- */
.logout-btn {
  background: none;
  border: 1px solid var(--rule);
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 6px 10px;
  border-radius: 3px;
  transition: border-color 0.15s, color 0.15s;
}
.logout-btn:hover { border-color: var(--rust); color: var(--rust); }

/* --- Login ----------------------------------------------------------------- */
.login-card {
  margin-top: 32px;
  padding: 24px 22px 22px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 4px;
}
.login-title {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 400;
  text-align: center;
  margin-bottom: 18px;
}
.login-form { display: flex; flex-direction: column; gap: 14px; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.field input {
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 10px 12px;
  font-size: 15px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s;
}
.field input:focus { border-color: var(--ink-2); }

.login-btn {
  margin-top: 6px;
  background: var(--ink);
  color: var(--surface);
  border: none;
  padding: 12px 16px;
  border-radius: 3px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.04em;
}
.login-btn:active { background: var(--rust); }
.login-btn[disabled] { opacity: 0.5; cursor: progress; }

.login-error {
  margin-top: 4px;
  padding: 10px 12px;
  background: var(--rust-soft);
  border-left: 3px solid var(--rust);
  color: var(--rust);
  font-size: 13px;
}

/* --- Page-load stagger ----------------------------------------------------- */
.section, .greeting, .masthead, .login-card {
  animation: fadeUp 0.5s ease both;
}
.greeting { animation-delay: 0.05s; }
.section:nth-of-type(1) { animation-delay: 0.10s; }
.section:nth-of-type(2) { animation-delay: 0.14s; }
.section:nth-of-type(3) { animation-delay: 0.18s; }
.section:nth-of-type(4) { animation-delay: 0.22s; }
.section:nth-of-type(5) { animation-delay: 0.26s; }
.section:nth-of-type(6) { animation-delay: 0.30s; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Reduced motion -------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* --- Wider viewports (tablet+) -------------------------------------------- */
@media (min-width: 768px) {
  .page, .login-page { max-width: 560px; padding: 40px 32px 100px; }
  .masthead-title { font-size: 56px; }
  .greeting-line { font-size: 32px; }
}
