/* Layout: Bühne mit einer Ansicht pro Bereich, darunter die Navigationsleiste */
:root {
  color-scheme: dark;
  --bg: #140b26;
  --bg-2: #1d1138;
  --surface: rgba(255, 255, 255, .06);
  --surface-2: rgba(255, 255, 255, .10);
  --line: rgba(196, 181, 253, .18);
  --text: #f2ecff;
  --muted: #bdb0df;
  --faint: #9486bd;
  --v400: #a78bfa;
  --v500: #8b5cf6;
  --v600: #6d3fe6;
  --lilac: #e4d8ff;
  --ink: #14092b;
  --danger: #f4a9c8;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Noto Serif", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html { height: 100%; background: #120a22; }
body {
  height: 100%; margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.5;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(70% 38% at 12% 0%, rgba(139, 92, 246, .38), transparent 70%),
    radial-gradient(60% 34% at 100% 100%, rgba(109, 63, 230, .30), transparent 70%),
    linear-gradient(180deg, #1a0f33 0%, #120a22 100%);
}
#note, input, select, .entry-text, .preview { -webkit-user-select: text; user-select: text; }

#app { position: fixed; inset: 0; }
.shell { height: 100%; max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; }
#stage { position: relative; flex: 1; min-height: 0; }

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

.view {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; gap: 14px;
  padding: calc(18px + env(safe-area-inset-top, 0px)) 18px 14px;
  overflow: hidden;
  animation: rise .35s ease both;
}
.view.scrolly { overflow-y: auto; }
.scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; gap: 14px; }

/* Buttons */
button {
  font: inherit; cursor: pointer;
  min-height: 48px; padding: 0 22px;
  border-radius: 999px; border: 1px solid transparent;
  color: var(--text); background: none;
  transition: transform .12s ease, background .2s ease, opacity .2s ease;
}
button:active { transform: scale(.97); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--v400); outline-offset: 2px;
}
.primary {
  min-height: 54px; font-weight: 600; font-size: 18px; color: #fff;
  background: linear-gradient(135deg, var(--v500), var(--v600));
  box-shadow: 0 10px 26px rgba(109, 63, 230, .38), inset 0 1px 0 rgba(255, 255, 255, .22);
}
.primary:disabled { opacity: .38; box-shadow: none; cursor: default; }
.secondary { background: var(--surface-2); border-color: var(--line); }
.ghost { color: var(--muted); padding: 0 14px; }
.danger { color: var(--danger); border-color: rgba(244, 169, 200, .35); }
.wide { width: 100%; }

/* Schreiben */
.hero { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.eyebrow { margin: 0; font-size: 13px; letter-spacing: .04em; color: var(--muted); }
.hero h1 { margin: 2px 0 0; font-family: var(--serif); font-weight: 400; font-size: 30px; line-height: 1.15; }
.logo {
  flex: none; width: 42px; height: 42px; border-radius: 50%;
  box-shadow: inset -11px -5px 0 0 var(--lilac);
  filter: drop-shadow(0 0 12px rgba(167, 139, 250, .55));
}
.logo.big { width: 64px; height: 64px; margin: 0 auto 24px; box-shadow: inset -16px -7px 0 0 var(--lilac); }

.mood, .card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 22px; padding: 14px 16px;
}
.mood { display: grid; gap: 4px; padding: 12px 14px 10px; }
.mood-q, .card-title { margin: 0; font-size: 15px; color: var(--muted); }
.card-title { color: var(--text); font-weight: 600; margin-bottom: 10px; }
.opt { font-weight: 400; font-size: 13px; color: var(--faint); margin-left: 6px; }

.scale { display: flex; justify-content: space-between; align-items: center; padding: 2px 4px; }
.dot {
  width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: 50%;
  display: grid; place-items: center;
  border: 1.5px solid var(--line); background: var(--surface);
}
.dot::after {
  content: ""; width: var(--s, 14px); height: var(--s, 14px); border-radius: 50%;
  background: var(--v400); opacity: .5; transition: opacity .2s ease, transform .2s ease;
}
.dot[aria-checked="true"] {
  border-color: var(--v400); background: rgba(139, 92, 246, .32);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, .18);
}
.dot[aria-checked="true"]::after { opacity: 1; transform: scale(1.08); }
.scale-ends { display: flex; justify-content: space-between; padding: 0 10px; font-size: 12.5px; color: var(--faint); }

.paper {
  flex: 1; min-height: 0; display: flex;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 26px; padding: 4px;
}
#note {
  flex: 1; width: 100%; min-height: 0;
  background: transparent; color: var(--text);
  border: 0; outline: 0; resize: none;
  padding: 16px 16px 12px;
  font-family: var(--serif); font-size: 20px; line-height: 1.65;
  caret-color: var(--v400);
}
#note::placeholder { color: #9a8cc4; opacity: 1; }
#note:focus-visible { outline: 0; }
.paper:focus-within { border-color: rgba(167, 139, 250, .5); }

body.kb .hero, body.kb .mood { display: none; }
body.kb .nav { display: none; }

/* Abschluss */
.done-top { text-align: center; padding-top: 4px; }
.breath {
  width: 96px; height: 96px; border-radius: 50%; margin: 0 auto 18px;
  background: radial-gradient(circle at 35% 30%, #d3c4ff, #8b5cf6 70%);
  box-shadow: 0 0 56px rgba(167, 139, 250, .45);
  animation: breathe 8s ease-in-out infinite;
}
.done-title { font-family: var(--serif); font-weight: 400; font-size: 32px; margin: 0 0 8px; }
.lead { max-width: 30ch; margin: 0 auto; color: var(--muted); font-size: 17px; }
.stack { display: flex; flex-direction: column; gap: 10px; padding-bottom: 6px; }

/* Seiten */
.page-head h2 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: 30px; line-height: 1.15; }
.page-head p { margin: 6px 0 0; font-size: 15px; }
.top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin: -6px -6px 0; }
.top > :first-child { justify-self: start; }
.top h2.small { margin: 0; font-size: 14px; font-weight: 500; color: var(--muted); text-align: center; }
.spacer { display: block; }
.center { text-align: center; }

/* Atmen */
.seg {
  display: flex; gap: 4px; padding: 4px; align-self: center;
  border-radius: 999px; background: var(--surface); border: 1px solid var(--line);
}
.seg button { min-height: 40px; padding: 0 18px; color: var(--muted); }
.seg button[aria-checked="true"] { background: rgba(139, 92, 246, .42); color: var(--text); }
.orb-stage { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
.orb-wrap { position: relative; width: min(72vw, 260px); aspect-ratio: 1; display: grid; place-items: center; }
.orb-wrap::before { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 1px dashed var(--line); }
.orb {
  width: 100%; height: 100%; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #d3c4ff, #8b5cf6 70%);
  box-shadow: 0 0 80px rgba(167, 139, 250, .45);
  transform: scale(.62);
  transition: transform 4s ease-in-out;
}
.orb-text { position: absolute; font-family: var(--serif); font-size: 21px; color: var(--ink); font-weight: 600; pointer-events: none; }
.breath-time { margin: 0; font-size: 22px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Rückblick */
.list { display: block; }
.day { margin: 16px 4px 8px; font-size: 14px; font-weight: 500; color: var(--muted); }
.item {
  display: block; width: 100%; text-align: left; margin-bottom: 10px;
  padding: 14px 16px; border-radius: 20px;
  background: var(--surface); border-color: var(--line);
}
.item .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-bottom: 4px; }
.item .time { font-size: 13px; color: var(--muted); }
.item .preview {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; font-family: var(--serif); overflow-wrap: anywhere;
}
.entry-text {
  white-space: pre-wrap; overflow-wrap: anywhere;
  font-family: var(--serif); font-size: 20px; line-height: 1.65; padding: 4px 2px 16px;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.scroll-x { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; flex: none; padding-bottom: 2px; }
.chips.scroll-x::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 40px; padding: 0 16px; font-size: 15px;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
}
.chip[aria-pressed="true"] { background: rgba(139, 92, 246, .38); border-color: var(--v400); color: var(--text); }
.chip.small, .tag {
  min-height: 0; padding: 1px 10px; font-size: 12.5px; border-radius: 999px;
  border: 1px solid var(--line); background: rgba(139, 92, 246, .22); color: var(--lilac);
}
.tag.mood-tag { background: transparent; color: var(--muted); }

.meter { display: grid; grid-template-columns: 62px 1fr 34px; align-items: center; gap: 10px; margin: 8px 0; font-size: 15px; }
.track { height: 10px; border-radius: 99px; background: rgba(255, 255, 255, .09); overflow: hidden; }
.fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--v400), var(--v600)); }
.val { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }

/* Einstellungen */
.settings { padding-bottom: 8px; }
.card h3 { margin: 0 0 6px; font-size: 17px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
input, select {
  display: block; width: 100%; margin: 8px 0; min-height: 48px; padding: 0 14px;
  font: inherit; color: var(--text); background: rgba(0, 0, 0, .25);
  border: 1px solid var(--line); border-radius: 14px;
}
.muted { color: var(--muted); }
.fine { font-size: 14px; margin: 10px 0 0; }
.pad-x { padding: 0 6px; margin-bottom: 16px; }
.msg { min-height: 1.4em; margin: 4px 0; color: var(--danger); font-size: 15px; }

/* Navigation */
.nav {
  display: flex; justify-content: space-around; gap: 4px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
  background: rgba(22, 13, 42, .88);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1; min-width: 0; min-height: 58px; padding: 4px 0 2px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 12px; color: var(--faint); border-radius: 16px;
}
.tab .ico { width: 58px; height: 30px; border-radius: 15px; display: grid; place-items: center; transition: background .2s ease; }
.tab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-current="page"] { color: var(--lilac); font-weight: 600; }
.tab[aria-current="page"] .ico { background: rgba(139, 92, 246, .38); }

/* Sperre */
.lock {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: calc(24px + env(safe-area-inset-top, 0px)) 24px calc(24px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, #1a0f33 0%, #120a22 100%);
}
.lock-box { width: 100%; max-width: 300px; text-align: center; }
.lock-box input { text-align: center; font-size: 22px; letter-spacing: .3em; }

/* Gute Nacht */
.night {
  position: fixed; inset: 0; z-index: 40; width: 100%; height: 100%;
  border: 0; border-radius: 0; background: #07040f; color: #6f609c;
  font-family: var(--serif); font-size: 22px;
  animation: fade 1.2s ease both;
}

.toast {
  position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom, 0px)); z-index: 60;
  transform: translateX(-50%); max-width: 86vw; margin: 0;
  padding: 12px 18px; border-radius: 14px; text-align: center;
  background: #3a2a66; color: var(--text); font-size: 15px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes breathe {
  0%, 100% { transform: scale(.78); opacity: .75; }
  50% { transform: scale(1.08); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .view, .night { animation: none; }
  .breath { animation: none; }
  .orb { transition: none !important; }
  button { transition: none; }
}
