/* Layout: ein Poesiealbum – zartes Rosé-Papier, Beerenrot als Akzent, elegante Serif für Fragen, eine Sache pro Bildschirm, Bereiche unten wie Register. Bewusst nur hell. */
:root {
  --paper: #FBF3F1;
  --surface: #FFFDFC;
  --surface-2: #F6E8E6;
  --ink: #3A2930;
  --muted: #7A646D;
  --line: #EDD8D7;
  --accent: #9A4862;
  --accent-ink: #FFFFFF;
  --accent-soft: #F6E0E5;
  --rec: #B53F5D;
  --rec-soft: #F6D6DF;
  --gold: #B48E57;
  --ok: #5B7D57;
  --ok-soft: #E6EEE0;
  --warn: #93571A;
  --warn-soft: #F8EBD8;
  --hero-a: #F6DDE2;
  --hero-b: #FCEFEA;
  --shadow: 0 1px 2px rgb(90 40 55 / .05), 0 8px 28px rgb(154 72 98 / .09);
  color-scheme: light;

  --font-ui: "Atkinson Hyperlegible", "Verdana", "Segoe UI", system-ui, sans-serif;
  --font-display: "Cormorant Garamond", "Garamond", "Georgia", serif;
  --font-book: "Literata", "Georgia", "Times New Roman", serif;

  --step--1: .9rem;
  --step-0: 1.1875rem;   /* ~19px Grundschrift, gut lesbar auf dem Tablet */
  --step-1: 1.35rem;
  --step-2: 1.85rem;
  --step-3: 2.5rem;
  --radius: 16px;
  --tabs-h: 76px;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 100%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper) radial-gradient(circle at 100% 0%, var(--hero-a), transparent 42rem) no-repeat; color: var(--ink);
  font-family: var(--font-ui); font-size: var(--step-0); line-height: 1.5;
  min-height: 100dvh;
}
[hidden] { display: none !important; }
img { max-width: 100%; display: block; }
button, input, textarea, select { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.2; text-wrap: balance; margin: 0; }
h1 { font-size: var(--step-3); }
h2 { font-size: var(--step-2); }
h3 { font-size: var(--step-1); }
p { margin: 0; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; border-radius: 6px; }

/* ---------- Gerüst ---------- */
.top {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.top-in {
  max-width: 980px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-block: 10px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.brand { background: none; border: 0; padding: 4px 0; font-family: var(--font-display); font-size: 1.55rem; font-style: italic; font-weight: 600; cursor: pointer; color: var(--accent); }
.top-right { display: flex; align-items: center; gap: 10px; }
.backup-state { font-size: var(--step--1); color: var(--muted); }
.backup-state.due { color: var(--warn); font-weight: 700; }
.icon-btn { width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; cursor: pointer; }
.icon-btn svg { width: 24px; height: 24px; }

.main {
  max-width: 980px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 24px calc(var(--tabs-h) + 40px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 28px;
  outline: none;
}

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: max(8px, env(safe-area-inset-left, 0px)); padding-right: max(8px, env(safe-area-inset-right, 0px));
}
.tabs-in { max-width: 720px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); height: var(--tabs-h); }
.tab {
  background: none; border: 0; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: .95rem; color: var(--muted); border-top: 3px solid transparent; min-width: 0;
}
.tab svg { width: 28px; height: 28px; }
.tab[aria-current="page"] { color: var(--accent); border-top-color: var(--accent); font-weight: 700; }
.tab .tab-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* ---------- Bausteine ---------- */
.eyebrow { font-size: var(--step--1); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.lead { font-size: var(--step-1); color: var(--muted); max-width: 40ch; }
.muted { color: var(--muted); }
.small { font-size: var(--step--1); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; display: flex; flex-direction: column; gap: 14px; min-width: 0;
}
.card.flat { box-shadow: none; }
.card.note { background: var(--warn-soft); border-color: transparent; }
.card.note.ok { background: var(--ok-soft); }
.card.hero { position: relative; overflow: hidden; background: linear-gradient(135deg, var(--hero-a), var(--hero-b)); color: var(--ink); border: 1px solid var(--line); box-shadow: var(--shadow); padding: 32px; }
.card.hero > * { position: relative; max-width: 34rem; }
.card.hero .bloom { position: absolute; right: -18px; top: -14px; width: 190px; height: 190px; color: var(--accent); opacity: .22; max-width: none; pointer-events: none; }
.card.hero h2 { font-size: var(--step-3); font-style: italic; color: var(--accent); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 56px; padding: 12px 22px; border-radius: 999px; cursor: pointer;
  border: 2px solid var(--accent); background: var(--surface); color: var(--accent); font-weight: 700; font-size: var(--step-0);
  text-align: center; line-height: 1.2;
}
.btn svg { width: 24px; height: 24px; flex: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.on-hero { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); box-shadow: 0 6px 18px rgb(154 72 98 / .25); }
.btn.ghost { border-color: var(--line); color: var(--ink); background: transparent; }
.btn.danger { border-color: var(--rec); color: var(--rec); background: transparent; }
.btn.big { min-height: 68px; font-size: var(--step-1); padding: 14px 30px; }
.btn.small { min-height: 44px; padding: 8px 16px; font-size: var(--step--1); }
.btn[disabled] { opacity: .5; cursor: default; }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; }
.linkish { background: none; border: 0; padding: 6px 0; color: var(--accent); text-decoration: underline; cursor: pointer; font-weight: 700; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 700; }
.field .hint { font-size: var(--step--1); color: var(--muted); }
input[type="text"], input[type="number"], input[type="password"], textarea, select {
  width: 100%; min-height: 54px; padding: 12px 14px; border-radius: 10px;
  border: 2px solid var(--line); background: var(--surface); color: var(--ink);
}
textarea { min-height: 160px; resize: vertical; line-height: 1.5; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); outline: none; }
.seg { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); border: 2px solid var(--line); border-radius: 14px; padding: 4px; gap: 4px; background: var(--surface); max-width: 100%; }
.seg button { border: 0; background: transparent; padding: 10px 12px; border-radius: 10px; cursor: pointer; min-height: 48px; line-height: 1.2; text-align: center; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 700; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; font-size: var(--step--1); background: var(--surface-2); color: var(--ink); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }

/* ---------- Heute ---------- */
.hello { display: flex; flex-direction: column; gap: 6px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 2px; }
.stat b { font-family: var(--font-display); font-size: 2.2rem !important; color: var(--accent); font-size: var(--step-2); font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: var(--step--1); }
.areas { display: flex; flex-wrap: wrap; gap: 8px; }
.area { cursor: pointer; font-family: inherit; color: var(--ink); min-height: 44px; display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: var(--step--1); }
.area i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--accent); flex: none; }
.area.half i { background: linear-gradient(90deg, var(--accent) 50%, transparent 50%); }
.area.full i { background: var(--accent); }
.legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: var(--step--1); color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.photo-prompt { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 18px; align-items: center; }
.photo-prompt img { width: 140px; height: 140px; object-fit: cover; border-radius: 10px; }

/* ---------- Gespräch ---------- */
.talk { display: flex; flex-direction: column; gap: 22px; align-items: stretch; max-width: 760px; margin: 0 auto; width: 100%; }
.talk-photo { display: flex; gap: 14px; align-items: center; }
.talk-photo img { width: 110px; height: 110px; object-fit: cover; border-radius: 10px; cursor: zoom-in; }
.reaction { font-family: var(--font-display); font-size: 1.5rem !important; font-style: italic; color: var(--muted); font-size: var(--step-1); }
.question { font-family: var(--font-display); font-size: clamp(2rem, 5vw, 2.9rem); line-height: 1.18; font-weight: 600; color: var(--ink); }
.ornament { display: flex; align-items: center; gap: 14px; color: var(--gold); }
.ornament::before, .ornament::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--gold)); }
.ornament::after { background: linear-gradient(90deg, var(--gold), transparent); }
.ornament svg { width: 26px; height: 26px; }
.recorder { display: flex; flex-direction: column; align-items: center; gap: 14px; padding-block: 18px; }
.rec-btn {
  --lvl: 0;
  width: 168px; height: 168px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--rec); color: #fff; display: grid; place-items: center; text-align: center;
  box-shadow: 0 0 0 calc(6px + var(--lvl) * 26px) var(--rec-soft), var(--shadow);
  transition: box-shadow .08s linear, transform .15s ease;
  font-weight: 700; font-size: 1.05rem; line-height: 1.2; padding: 16px;
}
.rec-btn svg { width: 46px; height: 46px; margin: 0 auto 6px; display: block; }
.rec-btn:active { transform: scale(.97); }
.rec-btn.on { background: var(--ink); color: var(--paper); }
.rec-time { font-variant-numeric: tabular-nums; font-size: var(--step-1); font-weight: 700; }
.alt-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.busy { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 40px 0; text-align: center; }
.spinner { width: 54px; height: 54px; border-radius: 50%; border: 5px solid var(--accent-soft); border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.history { border-top: 1px solid var(--line); padding-top: 14px; }
.history summary { cursor: pointer; font-weight: 700; color: var(--accent); min-height: 44px; display: flex; align-items: center; }
.qa { display: flex; flex-direction: column; gap: 6px; padding: 14px 0; border-bottom: 1px dashed var(--line); }
.qa .q { font-weight: 700; }
.qa .a { font-family: var(--font-book); }
.summary-list { margin: 0; padding-left: 1.2em; display: flex; flex-direction: column; gap: 8px; }

/* ---------- Geschichten / Buch ---------- */
.story { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; display: flex; flex-direction: column; gap: 16px; }
.story-text { font-family: var(--font-book); font-size: 1.15rem; line-height: 1.7; max-width: 65ch; }
.story-text p + p { margin-top: .9em; }
.story-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sources { display: flex; flex-wrap: wrap; gap: 8px; }
.play { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px; padding: 6px 14px; min-height: 44px; cursor: pointer; font-size: var(--step--1); }
.play svg { width: 18px; height: 18px; }
.play.playing { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.book-page { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: clamp(22px, 5vw, 56px); box-shadow: var(--shadow); }
.book-page h2 { margin: 1.6em 0 .7em; }
.book-page h2:first-of-type { margin-top: .3em; }
.book-title { font-family: var(--font-display); font-style: italic; font-size: 3rem; text-align: center; margin-bottom: .4em; }

.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.tl { display: grid; grid-template-columns: 110px minmax(0, 1fr) 28px; gap: 16px; padding: 12px 6px; border: 0; border-bottom: 1px solid var(--line); align-items: start; width: 100%; background: none; text-align: left; font: inherit; color: var(--ink); cursor: pointer; border-radius: 8px; }
.tl:hover { background: var(--surface); }
.tl-go { color: var(--muted); opacity: .6; padding-top: 4px; }
.tl-go svg { width: 18px; height: 18px; }
.tl-thumbs { display: flex; gap: 6px; flex-wrap: wrap; }
.tl-thumbs img { width: 56px !important; height: 56px !important; }
.tl .yr { font-family: var(--font-book); font-weight: 600; font-variant-numeric: tabular-nums; font-size: var(--step-1); }
.tl .yr small { display: block; font-family: var(--font-ui); font-weight: 400; font-size: .8rem; color: var(--muted); }
.tl .what { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tl img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; cursor: pointer; }

/* ---------- Fotos ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.ph { position: relative; border: 6px solid var(--surface); box-shadow: var(--shadow); padding: 0; background: var(--surface-2); border-radius: 6px; overflow: hidden; cursor: pointer; aspect-ratio: 1; max-width: 100%; }
.ph img { width: 100%; height: 100%; object-fit: cover; }
.ph .badges { position: absolute; left: 6px; right: 6px; bottom: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
.ph .badges .pill { background: rgb(0 0 0 / .62); color: #fff; font-size: .78rem; padding: 2px 8px; }
.photo-stage { position: relative; border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.photo-stage img { width: 100%; height: auto; }
.facebox { position: absolute; border: 3px solid #fff; border-radius: 8px; box-shadow: 0 0 0 2px rgb(0 0 0 / .45); }
.facebox b { position: absolute; top: -14px; left: -14px; width: 28px; height: 28px; border-radius: 50%; background: var(--gold); color: #fff; display: grid; place-items: center; font-size: .9rem; box-shadow: 0 0 0 2px #fff; }
.facebox.ok { border-color: #8FD3A1; }
.faces { display: flex; flex-direction: column; gap: 10px; }
.face { display: grid; grid-template-columns: 30px 64px minmax(0, 1fr); gap: 12px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.face .num { width: 28px; height: 28px; border-radius: 50%; background: var(--gold); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .9rem; }
.face img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; }
.face .who { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.clues { margin: 0; padding-left: 1.2em; color: var(--muted); font-size: var(--step--1); }
.analysis { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.analysis > div { background: var(--surface-2); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }

/* ---------- Menschen ---------- */
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.person { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; cursor: pointer; min-width: 0; }
.avatar { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-family: var(--font-display); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line); font-size: 2rem; font-weight: 600; flex: none; }
.person b { font-size: var(--step-0); overflow-wrap: anywhere; }
.person span { font-size: var(--step--1); color: var(--muted); }
.crops { display: flex; flex-wrap: wrap; gap: 8px; }
.crops img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; cursor: pointer; }

/* ---------- Ebenen ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 50; background: rgb(10 18 17 / .45);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-panel {
  background: var(--paper); width: 100%; max-width: 860px; max-height: 94dvh; overflow: auto;
  border-radius: 20px 20px 0 0;
  padding-block: 18px calc(28px + env(safe-area-inset-bottom, 0px));
  padding-left: max(18px, env(safe-area-inset-left, 0px)); padding-right: max(18px, env(safe-area-inset-right, 0px));
  display: flex; flex-direction: column; gap: 20px;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; position: sticky; top: -18px; background: var(--paper); padding-block: 8px; z-index: 2; }
.modal { position: fixed; inset: 0; z-index: 60; background: rgb(10 18 17 / .5); display: grid; place-items: center; padding: 16px; }
.modal-panel { background: var(--paper); border-radius: 18px; padding: 24px; width: 100%; max-width: 520px; max-height: 90dvh; overflow: auto; display: flex; flex-direction: column; gap: 16px; box-shadow: var(--shadow); }
.choice-list { display: flex; flex-direction: column; gap: 8px; }
.choice-list button { display: flex; align-items: center; gap: 12px; text-align: left; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; min-height: 56px; }
.choice-list .avatar { width: 40px; height: 40px; font-size: 1.1rem; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 70;
  bottom: calc(var(--tabs-h) + 16px + env(safe-area-inset-bottom, 0px));
  background: var(--ink); color: var(--paper); padding: 12px 20px; border-radius: 999px; max-width: calc(100% - 32px); text-align: center;
  box-shadow: var(--shadow);
}

.onboard { max-width: 620px; margin: 0 auto; width: 100%; display: flex; flex-direction: column; gap: 22px; }
.steps { margin: 0; padding-left: 1.3em; display: flex; flex-direction: column; gap: 6px; }
.key-row { display: flex; gap: 10px; flex-wrap: wrap; }
.key-row input { flex: 1 1 240px; min-width: 0; }

@media (max-width: 560px) {
  :root { --step-3: 2.1rem; --step-2: 1.6rem; --tabs-h: 70px; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .stat { padding: 12px; }
  .photo-prompt { grid-template-columns: 96px minmax(0, 1fr); }
  .photo-prompt img { width: 96px; height: 96px; }
  .tl { grid-template-columns: 76px minmax(0, 1fr) 20px; gap: 10px; }
  .tab { font-size: .8rem; }
  .rec-btn { width: 150px; height: 150px; }
  .backup-state { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 3s; }
  .rec-btn { transition: none; }
}

/* Lebensbereiche sind antippbar */
button.area:hover { border-color: var(--accent); color: var(--accent); }
.area-hint { font-size: var(--step--1); color: var(--muted); }
.setup-link { font-family: ui-monospace, Menlo, monospace; font-size: .8rem; min-height: 90px; word-break: break-all; }

/* Das „Powered by Netlify“-Schild verdeckt sonst die unteren Bereiche */
#nl-badge-frame, #nl-hud-frame { display: none !important; }

/* Einfach plaudern */
.chat { gap: 16px; }
.bubbles { display: flex; flex-direction: column; gap: 12px; }
.bubble { max-width: 88%; padding: 14px 18px; border-radius: 18px; display: flex; flex-direction: column; gap: 8px; min-width: 0; overflow-wrap: anywhere; }
.bubble.ai { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.bubble.ai .story-text { font-size: 1.1rem; }
.bubble.me { align-self: flex-end; background: var(--accent-soft); color: var(--ink); border-bottom-right-radius: 6px; }
.bubble.me p + p, .bubble.ai p + p { margin-top: .6em; }
.composer { position: sticky; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom, 0px)); background: var(--paper); padding-block: 12px; display: flex; gap: 12px; align-items: center; border-top: 1px solid var(--line); z-index: 5; }
.chat-form { flex: 1; display: flex; gap: 10px; align-items: center; min-width: 0; }
.chat-form textarea { min-height: 54px; height: 54px; resize: none; flex: 1; min-width: 0; }
.rec-btn.small-rec { width: 84px; height: 84px; font-size: .85rem; padding: 8px; flex: none; box-shadow: 0 0 0 calc(3px + var(--lvl) * 14px) var(--rec-soft); }
.rec-btn.small-rec svg { width: 28px; height: 28px; margin-bottom: 2px; }
.rec-btn[disabled] { opacity: .5; }
.dots { display: flex; gap: 6px; padding: 6px 0; }
.dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .2s; } .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@media (max-width: 560px) { .chat-form .btn { padding: 10px 14px; } .rec-btn.small-rec { width: 72px; height: 72px; } }

.mode-seg button { font-size: .95rem; padding: 8px 14px; min-height: 44px; }

.orig summary { cursor: pointer; color: var(--accent); font-size: var(--step--1); font-weight: 700; min-height: 36px; display: flex; align-items: center; }

.charpad { display: flex; flex-wrap: wrap; gap: 8px; }
.charbtn { min-width: 48px; min-height: 48px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-size: 1.3rem; font-family: var(--font-book); cursor: pointer; color: var(--ink); }
.charbtn:active { background: var(--accent-soft); }

/* Einstellungen: aufklappbare Bereiche */
.secs { display: flex; flex-direction: column; gap: 10px; }
.sec { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.sec > summary { list-style: none; cursor: pointer; display: grid; grid-template-columns: minmax(0, 1fr) 24px; grid-template-rows: auto auto; column-gap: 12px; padding: 16px 18px; min-height: 64px; align-items: center; }
.sec > summary::-webkit-details-marker { display: none; }
.sec > summary::after { content: ""; grid-column: 2; grid-row: 1 / span 2; width: 10px; height: 10px; border-right: 2.5px solid var(--accent); border-bottom: 2.5px solid var(--accent); transform: rotate(45deg); justify-self: center; transition: transform .2s; }
.sec[open] > summary::after { transform: rotate(-135deg); }
.sec-title { font-family: var(--font-display); font-weight: 600; font-size: 1.35rem; line-height: 1.2; }
.sec-sum { grid-column: 1; font-size: var(--step--1); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sec-alert { color: var(--rec); }
.sec-body { padding: 0 18px 20px; display: flex; flex-direction: column; gap: 16px; border-top: 1px solid var(--line); padding-top: 16px; }
.sec-body > .card { border: 0; padding: 0; background: none; }
.voice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.voice { display: flex; align-items: center; gap: 8px; padding: 12px; min-height: 56px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; text-align: left; font-weight: 700; }
.voice svg { width: 20px; height: 20px; flex: none; color: var(--accent); }
.voice.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.pron-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; background: var(--surface); }
.pron-row.sug { border: 2px solid var(--accent-soft); }
.pron-btns { display: flex; gap: 6px; align-items: center; }
.pron-btns .btn.small { min-height: 40px; padding: 6px 12px; }
.pron-btns .btn svg { width: 18px; height: 18px; }
.play { justify-content: center; }
@media (max-width: 400px) { .voice-grid { grid-template-columns: 1fr; } }
.seg[data-n="2"], .seg[data-n="3"] { grid-template-columns: repeat(var(--n), minmax(0, 1fr)); }
.seg[data-n="3"] button { padding: 10px 6px; font-size: 1rem; }

/* Stil-Kärtchen */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 46px; padding: 8px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); cursor: pointer; font-size: 1rem; color: var(--ink); }
.chip svg { width: 18px; height: 18px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.chip.wish { padding: 0; gap: 0; overflow: hidden; }
.chip.wish > button { border: 0; background: none; color: inherit; font: inherit; display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px 8px 14px; min-height: 44px; cursor: pointer; text-align: left; }
.chip.wish .chip-x { border: 0; border-left: 1px solid currentColor; background: none; color: inherit; opacity: .7; padding: 0 10px; min-height: 44px; cursor: pointer; }
.chip.wish .chip-x svg { width: 16px; height: 16px; }
.seg[data-n="4"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 640px) { .seg[data-n="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* Startseite: zwei große Wege */
.start-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.start-card { position: relative; overflow: hidden; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; text-align: left; padding: 26px 24px; min-height: 210px; border-radius: 20px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; box-shadow: var(--shadow); font: inherit; }
.start-card.speak { background: linear-gradient(135deg, var(--hero-a), var(--hero-b)); }
.start-card .bloom { position: absolute; right: -24px; top: -20px; width: 170px; height: 170px; color: var(--accent); opacity: .18; pointer-events: none; }
.start-icon { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); flex: none; }
.start-card.read .start-icon, .start-card.chat .start-icon, .start-card.diary .start-icon { background: var(--accent-soft); color: var(--accent); }
@media (max-width: 900px) and (min-width: 641px) { .start-title { font-size: 1.45rem; } }
.start-icon svg { width: 30px; height: 30px; }
.start-title { font-family: var(--font-display); font-weight: 600; font-size: 1.75rem; line-height: 1.15; color: var(--accent); text-wrap: balance; }
.start-text { color: var(--muted); font-size: 1.05rem; line-height: 1.45; }
.start-card:active { transform: scale(.99); }
.more-row { display: flex; flex-wrap: wrap; gap: 10px; }
.tally { margin-top: -8px; }
@media (max-width: 640px) {
  .start-grid { grid-template-columns: 1fr; gap: 12px; }
  .start-card { min-height: 0; display: grid; grid-template-columns: 54px minmax(0, 1fr); column-gap: 14px; row-gap: 2px; align-items: center; padding: 16px 18px; border-radius: 16px; }
  .start-icon { width: 54px; height: 54px; grid-row: span 2; }
  .start-icon svg { width: 26px; height: 26px; }
  .start-title { font-size: 1.4rem; }
  .start-text { font-size: .95rem; line-height: 1.35; }
}

.author-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.author { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 10px 12px; min-height: 56px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; color: var(--ink); font: inherit; }
.author b { font-family: var(--font-display); font-size: 1.15rem; }
.author span { font-size: .85rem; color: var(--muted); }
.author.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

/* Hilfe-Leiste über der Navigation */
.help-bar { position: fixed; left: 0; right: 0; z-index: 29; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom, 0px)); padding: 8px max(12px, env(safe-area-inset-right, 0px)) 8px max(12px, env(safe-area-inset-left, 0px)); background: linear-gradient(to top, var(--paper) 70%, transparent); }
.help-btn { max-width: 720px; margin: 0 auto; width: 100%; display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 6px 8px 6px 6px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); cursor: pointer; color: var(--ink); font: inherit; text-align: left; }
.help-ico { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; flex: none; }
.help-ico svg, .help-go svg { width: 20px; height: 20px; }
.help-txt { flex: 1; min-width: 0; color: var(--muted); font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.help-go { color: var(--accent); display: grid; place-items: center; width: 36px; flex: none; }
body.has-help .main { padding-bottom: calc(var(--tabs-h) + 110px + env(safe-area-inset-bottom, 0px)); }
body.has-help .toast { bottom: calc(var(--tabs-h) + 80px + env(safe-area-inset-bottom, 0px)); }
.help-composer { position: sticky; bottom: calc(-28px - env(safe-area-inset-bottom, 0px)); }

.diary-date { margin-top: 8px; }
.pill svg { width: 16px; height: 16px; }

/* Stammbaum */
.tree { display: flex; flex-direction: column; align-items: stretch; }
.gen { display: flex; flex-direction: column; gap: 8px; }
.gen-title { font-family: var(--font-display); font-size: 1.2rem; font-weight: 600; color: var(--muted); text-align: center; }
.gen-row { display: flex; gap: 10px; overflow-x: auto; padding: 6px 4px 10px; justify-content: safe center; scroll-snap-type: x proximity; }
.gen-row.wrap { flex-wrap: wrap; overflow: visible; justify-content: flex-start; }
.gen-link { width: 2px; height: 22px; margin: 0 auto; background: var(--line); border-radius: 2px; }
.node { flex: none; display: flex; align-items: center; gap: 10px; min-width: 170px; max-width: 230px; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); text-align: left; cursor: pointer; font: inherit; color: var(--ink); scroll-snap-align: center; }
.node.me { border: 2px solid var(--accent); background: var(--accent-soft); cursor: default; box-shadow: var(--shadow); }
.node.loose { border-style: dashed; }
.node-txt { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.node-txt b { font-size: 1.02rem; overflow-wrap: anywhere; }
.node-txt span { font-size: .85rem; color: var(--muted); line-height: 1.3; }
.node-years { color: var(--accent) !important; font-weight: 700; font-variant-numeric: tabular-nums; }
.avatar.sm { width: 48px; height: 48px; font-size: 1.3rem; }
.friends { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--line); }
/* Orte */
.place-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.place { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; text-align: left; font: inherit; color: var(--ink); min-width: 0; }
.place-ico { width: 44px; height: 44px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.place-ico svg { width: 22px; height: 22px; }
/* Lebenslauf in Bildern */
.photo-life { display: flex; gap: 12px; overflow-x: auto; padding: 4px 2px 12px; position: relative; }
.life-item { flex: none; display: flex; flex-direction: column; align-items: center; gap: 4px; width: 112px; border: 0; background: none; cursor: pointer; font: inherit; color: var(--ink); }
.life-item img { width: 104px; height: 104px; object-fit: cover; border-radius: 8px; border: 4px solid var(--surface); box-shadow: var(--shadow); }
.life-item b { font-size: .95rem; font-variant-numeric: tabular-nums; }
.life-item span { font-size: .8rem; color: var(--muted); }
/* Auswahl-Raster */
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; max-height: 50dvh; overflow: auto; }
.pick { position: relative; padding: 0; border: 3px solid transparent; border-radius: 10px; overflow: hidden; background: var(--surface-2); cursor: pointer; aspect-ratio: 1; }
.pick img { width: 100%; height: 100%; object-fit: cover; }
.pick.on { border-color: var(--accent); }
.pick span { position: absolute; right: 4px; top: 4px; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.pick span svg { width: 16px; height: 16px; }

.date-row { display: grid; grid-template-columns: 90px minmax(0, 1.4fr) minmax(0, 1fr); gap: 8px; }
.date-row select, .date-row input { min-width: 0; }

/* Wetter und Zeitgeschehen */
.ctx-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); text-align: left; font: inherit; color: var(--ink); cursor: pointer; }
.ctx-item.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.ctx-tag { font-size: .75rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); background: var(--accent-soft); padding: 3px 8px; border-radius: 999px; }
.ctx-text { font-size: .98rem; line-height: 1.4; }
.ctx-pick { font-size: .85rem; color: var(--muted); white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.ctx-item.on .ctx-pick { color: var(--accent); font-weight: 700; }
.ctx-pick svg { width: 16px; height: 16px; }
@media (max-width: 520px) { .ctx-item { grid-template-columns: minmax(0, 1fr) auto; } .ctx-tag { grid-column: 1 / -1; justify-self: start; } }
/* Gesicht entfernen */
.face { grid-template-columns: 30px 64px minmax(0, 1fr) 36px !important; }
.face-del { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--muted); display: grid; place-items: center; cursor: pointer; align-self: start; }
.face-del svg { width: 16px; height: 16px; }

.ai-guess summary { cursor: pointer; font-size: var(--step--1); color: var(--muted); min-height: 32px; display: flex; align-items: center; }

.photo-info { background: var(--surface); }
.saved-hint { display: flex; align-items: center; gap: 6px; font-size: var(--step--1); color: var(--ok); font-weight: 700; }
.saved-hint svg { width: 16px; height: 16px; }
