@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,400;0,9..144,500;0,9..144,600;1,9..144,500&family=Figtree:wght@400;500;600;700&display=swap');

/* ---------- Design tokens ---------- */
:root {
  --bg:        #FAF7F1;   /* warmes Elfenbein */
  --surface:   #FFFFFF;
  --surface-2: #FBFAF7;

  --sage:      #B9D2B2;   /* Wichtiges */
  --sage-ink:  #4C6B49;
  --sky:       #AECBDD;   /* Checklisten */
  --sky-ink:   #3E6478;
  --sand:      #F0D2A6;   /* Anleitungen */
  --sand-ink:  #92642F;

  --ink:       #3A352E;   /* Haupttext */
  --ink-soft:  #7C7466;   /* Sekundärtext */
  --ink-faint: #ACA495;

  --accent:    #8C7A9E;   /* Plum – Links, Fokus, Buttons */
  --accent-ink:#FFFFFF;

  --line:      #EAE3D6;
  --shadow:    0 8px 24px rgba(58, 53, 46, 0.08);
  --shadow-sm: 0 2px 8px rgba(58, 53, 46, 0.06);

  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 10px;

  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Figtree', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  color-scheme: light;
}

/* ---------- Reset ---------- */
* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
body {
  min-height: 100dvh;
}
h1, h2, h3 { font-family: var(--font-display); margin: 0; font-weight: 600; }
p { margin: 0 0 0.85em; line-height: 1.55; }
p:last-child { margin-bottom: 0; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
ul { margin: 0; padding: 0; list-style: none; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

:focus-visible {
  outline: 2.5px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- App shell ---------- */
.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
}

.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: max(14px, env(safe-area-inset-top)) 8px 12px;
  background: rgba(250, 247, 241, 0.88);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.appbar-title {
  flex: 1;
  text-align: center;
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ink);
}
.appbar-back, .appbar-logout, .appbar-spacer {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--ink-soft);
  flex-shrink: 0;
}
.appbar-back:active, .appbar-logout:active {
  background: var(--line);
}

.content {
  flex: 1;
  padding: 18px 18px calc(40px + env(safe-area-inset-bottom));
}

/* ---------- Home: Kacheln ---------- */
.hero {
  text-align: center;
  padding: 10px 6px 26px;
}
.hero-eyebrow {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 6px;
}
.hero-title {
  font-size: 1.6rem;
  font-style: italic;
  font-weight: 500;
  color: var(--ink);
}

.tiles {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tile {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 22px 20px;
  border-radius: var(--radius-lg);
  border: none;
  width: 100%;
  text-align: left;
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.tile:active { transform: scale(0.98); box-shadow: var(--shadow-sm); }

.tile-icon {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  border-radius: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tile--wichtiges .tile-icon { background: var(--sage); color: var(--sage-ink); }
.tile--checklisten .tile-icon { background: var(--sky); color: var(--sky-ink); }
.tile--anleitungen .tile-icon { background: var(--sand); color: var(--sand-ink); }

.tile-text { flex: 1; }
.tile-title {
  font-family: var(--font-display);
  font-size: 1.18rem;
  font-weight: 600;
  color: var(--ink);
}
.tile-sub {
  font-size: 0.86rem;
  color: var(--ink-soft);
  margin-top: 2px;
}
.tile-chevron { color: var(--ink-faint); flex-shrink: 0; }

/* ---------- Listen-Unterseiten mit A–Z Index ---------- */
.list-wrap {
  position: relative;
  padding-right: 26px;
}

.letter-group { margin-bottom: 4px; }
.letter-heading {
  position: sticky;
  top: 68px;
  z-index: 5;
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
  background: var(--bg);
  padding: 14px 4px 6px;
}

.item-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: var(--surface);
  border: none;
  padding: 15px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s ease;
}
.item-card:active { transform: scale(0.985); background: var(--surface-2); }

.item-dot {
  width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0;
}
.item--wichtiges .item-dot { background: var(--sage); }
.item--checklisten .item-dot { background: var(--sky); }
.item--anleitungen .item-dot { background: var(--sand); }

.item-title { flex: 1; font-weight: 500; font-size: 1rem; }
.item-meta { font-size: 0.78rem; color: var(--ink-faint); }
.item-chevron { color: var(--ink-faint); flex-shrink: 0; }

.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--ink-soft);
}

/* A-Z Schnellwahl-Leiste (rechter Rand, wie in Kontakte) */
.az-rail {
  position: fixed;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 15;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 3px;
  border-radius: 12px;
}
.az-rail button {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1.35;
  padding: 0 4px;
  opacity: 0.55;
}
.az-rail button:disabled { color: var(--ink-faint); opacity: 0.3; }

/* ---------- Bottom Sheet ---------- */
.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(58, 53, 46, 0.32);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease;
  z-index: 30;
}
.sheet-backdrop.is-open { opacity: 1; visibility: visible; }

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-width: 480px;
  margin: 0 auto;
  max-height: 82dvh;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -10px 40px rgba(58,53,46,0.18);
  transform: translateY(105%);
  transition: transform 0.32s cubic-bezier(.32,.72,0,1);
  z-index: 31;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet.is-open { transform: translateY(0); }

.sheet-handle {
  width: 38px; height: 5px;
  background: var(--line);
  border-radius: 3px;
  margin: 10px auto 4px;
  flex-shrink: 0;
}
.sheet-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 20px 14px;
  flex-shrink: 0;
}
.sheet-title {
  flex: 1;
  font-size: 1.28rem;
  font-style: italic;
}
.sheet-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--surface-2);
  border: none;
  color: var(--ink-soft);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sheet-body {
  overflow-y: auto;
  padding: 0 22px 28px;
  color: var(--ink);
  font-size: 0.98rem;
}
.sheet-body p { line-height: 1.6; }
.sheet-body .steps {
  margin: 6px 0 0;
  padding-left: 22px;
}
.sheet-body .steps li {
  line-height: 1.55;
  margin-bottom: 8px;
  padding-left: 4px;
}

/* Checklisten im Sheet */
.checklist-group { margin-bottom: 20px; }
.checklist-group:last-child { margin-bottom: 0; }
.checklist-label {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--sky-ink);
  margin-bottom: 8px;
}
.check-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 2px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.check-item:last-child { border-bottom: none; }
.check-box {
  width: 21px; height: 21px;
  border-radius: 7px;
  border: 1.8px solid var(--ink-faint);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, border-color 0.15s;
}
.check-item.is-checked .check-box {
  background: var(--sky-ink);
  border-color: var(--sky-ink);
}
.check-box svg { opacity: 0; transform: scale(0.6); transition: opacity 0.12s, transform 0.12s; }
.check-item.is-checked .check-box svg { opacity: 1; transform: scale(1); }
.check-text { font-size: 0.96rem; }
.check-item.is-checked .check-text { color: var(--ink-faint); text-decoration: line-through; }

/* ---------- Login ---------- */
.login-body {
  background: linear-gradient(180deg, #FAF7F1 0%, #F1EADC 100%);
  min-height: 100dvh;
}
.login-wrap {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 34px 26px 28px;
  text-align: center;
}
.login-icon {
  width: 54px; height: 54px;
  margin: 0 auto 16px;
  border-radius: 16px;
  background: var(--sage);
  color: var(--sage-ink);
  display: flex; align-items: center; justify-content: center;
}
.login-card h1 {
  font-size: 1.4rem;
  font-style: italic;
  margin-bottom: 4px;
}
.login-sub {
  color: var(--ink-soft);
  font-size: 0.9rem;
  margin-bottom: 22px;
}
.login-note {
  background: var(--surface-2);
  color: var(--ink-soft);
  font-size: 0.85rem;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
}
.login-error {
  background: #F7E3DC;
  color: #9A4A2E;
  font-size: 0.85rem;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
}
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card input[type="password"] {
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--line);
  background: var(--surface-2);
  font-size: 1rem;
  color: var(--ink);
}
.login-card input[type="password"]:focus {
  border-color: var(--accent);
  outline: none;
}
.login-card button[type="submit"] {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: none;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}
.login-card button[type="submit"]:active { opacity: 0.85; }

/* ---------- Responsive: iPad ---------- */
@media (min-width: 620px) {
  .app { max-width: 560px; }
  .content { padding: 24px 26px 50px; }
}
