:root {
  --night: #0b0820;
  --ink: #f4f0ff;
  --muted: #b3a9d6;
  --glass: rgba(28, 22, 64, 0.72);
  --line: rgba(190, 170, 255, 0.18);
  --violet: #8b5cf6;
  --pink: #f472b6;
  --gold: #fbbf24;
  --cyan: #67e8f9;
  --magic: linear-gradient(120deg, var(--violet), var(--pink) 55%, var(--gold));
  color-scheme: dark;
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(120% 80% at 50% 0%, #1d1450 0%, var(--night) 60%) fixed, var(--night);
  color: var(--ink);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, textarea, input { font: inherit; color: inherit; }
a { color: var(--ink); }
[hidden] { display: none !important; }

#sky { position: fixed; inset: 0; width: 100%; height: 100%; }

/* unscheinbarer Menü-Knopf oben links: Rechtliches + Konto */
.menu-btn {
  position: fixed; z-index: 6; top: calc(env(safe-area-inset-top) + 8px); left: 8px;
  width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: none; cursor: pointer;
  color: var(--muted); opacity: 0.45; fill: currentColor; transition: opacity 0.2s;
}
.menu-btn:active, .menu-btn[aria-expanded="true"] { opacity: 0.9; }
.menu {
  position: fixed; z-index: 6; left: 12px; top: calc(env(safe-area-inset-top) + 52px); min-width: 210px;
  display: grid; padding: 6px; border-radius: 16px; background: rgba(24, 18, 58, 0.97); border: 1px solid var(--line);
  box-shadow: 0 16px 40px rgba(5, 2, 20, 0.6);
}
.menu a, .menu button { display: block; text-align: left; padding: 11px 12px; border-radius: 10px; color: var(--ink); text-decoration: none; font-size: 15px; background: none; border: 0; cursor: pointer; }
.menu a:active, .menu button:active { background: rgba(255, 255, 255, 0.08); }
.link { background: none; border: 0; color: var(--muted); font-size: 15px; padding: 6px 2px; cursor: pointer; }

#home {
  position: fixed; inset: 0; z-index: 1; overflow-y: auto;
  padding: calc(env(safe-area-inset-top) + 28px) 20px 160px;
}
#apps h2 { font-size: 15px; font-weight: 600; color: var(--muted); margin: 0 0 12px; }
.tiles { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 18px 14px; }
.tiles a { display: grid; justify-items: center; gap: 8px; text-decoration: none; font-size: 13px; text-align: center; }
.tiles .icon {
  width: 64px; height: 64px; border-radius: 16px; display: grid; place-items: center;
  font-size: 28px; font-weight: 700; color: white;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.tiles .pending .icon { background: var(--glass); border: 1px dashed var(--line); animation: pulse 2s ease-in-out infinite; }

/* ---------- Orb + Chat darüber (Chat 11; Maße aus dem Regler-Mockup ×1,3 aufs iPhone übertragen) ---------- */
:root { --side: 7px; --orb: 78px; --orb-bottom: calc(env(safe-area-inset-bottom) + 20px); --gap: 18px; }
.orb {
  position: fixed; z-index: 5; left: 50%; bottom: var(--orb-bottom);
  width: var(--orb); height: var(--orb); margin-left: calc(var(--orb) / -2); padding: 0; border: 0; background: none; cursor: pointer;
  border-radius: 50%; transition: transform 0.3s cubic-bezier(0.3, 1.6, 0.5, 1);
}
.orb:active { transform: scale(0.92); }
.orb canvas { width: 100%; height: 100%; display: block; border-radius: 50%; }
.orb canvas.orb-fallback { background: radial-gradient(circle, #fdf4ff 0, #c084fc 5%, #2e1065 16%, #0b0820 30%, #0b0820 58%, #8b5cf6 66%, #f472b6 72%, transparent 76%); }

.sheet {
  position: fixed; z-index: 4; left: var(--side); right: var(--side);
  bottom: calc(var(--orb-bottom) + var(--orb) + var(--gap));
  /* so hoch wie der Inhalt, höchstens bis knapp unter das Logo */
  max-height: calc(100dvh - env(safe-area-inset-top) - 62px - var(--orb-bottom) - var(--orb) - var(--gap));
  display: flex; flex-direction: column;
  background: rgba(22, 16, 52, 0.86);
  backdrop-filter: blur(22px) saturate(140%); -webkit-backdrop-filter: blur(22px) saturate(140%);
  border: 1px solid var(--line); border-radius: 30px;
  box-shadow: 0 20px 60px rgba(5, 2, 20, 0.55);
  transform-origin: 50% calc(100% + 60px);
  transition: transform 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.1), opacity 0.3s;
}
.sheet.closed { transform: scale(0.6) translateY(40px); opacity: 0; pointer-events: none; }
.sheet.away { transform: translateY(140%); opacity: 0; pointer-events: none; }
.msgs { flex: 0 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; padding: 20px 16px 8px; font-size: 17px; line-height: 1.42; }
.msgs { gap: 3px; }
.b { position: relative; max-width: 78%; padding: 9px 14px; border-radius: 20px; font-size: 17px; line-height: 1.35; white-space: pre-wrap; overflow-wrap: anywhere; }
.b.ai { align-self: flex-start; background: #3b2a7a; color: #fff; }
.b.me { align-self: flex-end; background: linear-gradient(135deg, #4c2f9e, #7a45cf); color: #fff; }
.b.ai + .b.me, .b.me + .b.ai, .b + .note, .note + .b { margin-top: 10px; }
.b.ai.end { margin-left: 6px; } .b.me.end { margin-right: 6px; }
.b.ai:not(.end) { margin-left: 6px; } .b.me:not(.end) { margin-right: 6px; }
/* Schwänzchen an der letzten Blase einer Gruppe */
.b.end::before { content: ""; position: absolute; bottom: 0; width: 22px; height: 22px; -webkit-mask-size: 100% 100%; mask-size: 100% 100%; }
.b.ai.end::before { left: -9px; background: #3b2a7a; -webkit-mask-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A//www.w3.org/2000/svg%27%20viewBox%3D%270%200%2022%2022%27%3E%3Cpath%20d%3D%27M9%202%20C9%2012%206%2019.5%200.5%2021.6%20C6%2022.4%2014%2022%2022%2022%20L22%2020.7%20A20%2020%200%200%201%209%202%20Z%27/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A//www.w3.org/2000/svg%27%20viewBox%3D%270%200%2022%2022%27%3E%3Cpath%20d%3D%27M9%202%20C9%2012%206%2019.5%200.5%2021.6%20C6%2022.4%2014%2022%2022%2022%20L22%2020.7%20A20%2020%200%200%201%209%202%20Z%27/%3E%3C/svg%3E"); }
.b.me.end::before { right: -9px; background: #7a45cf; -webkit-mask-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A//www.w3.org/2000/svg%27%20viewBox%3D%270%200%2022%2022%27%3E%3Cpath%20d%3D%27M13%202%20C13%2012%2016%2019.5%2021.5%2021.6%20C16%2022.4%208%2022%200%2022%20L0%2020.7%20A20%2020%200%200%200%2013%202%20Z%27/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A//www.w3.org/2000/svg%27%20viewBox%3D%270%200%2022%2022%27%3E%3Cpath%20d%3D%27M13%202%20C13%2012%2016%2019.5%2021.5%2021.6%20C16%2022.4%208%2022%200%2022%20L0%2020.7%20A20%2020%200%200%200%2013%202%20Z%27/%3E%3C/svg%3E"); }
.b .muted { color: #d6ccff; opacity: 0.85; }
.build { align-self: center; margin-top: 14px; border: 0; border-radius: 999px; padding: 13px 26px; font-size: 17px; font-weight: 700; color: #fff; cursor: pointer;
  background: linear-gradient(120deg, #8b5cf6, #f472b6 55%, #fbbf24); box-shadow: 0 0 24px rgba(244, 114, 182, 0.45); animation: pop 0.5s cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } }
.note { align-self: center; font-size: 13px; color: #b3a9d6; text-align: center; padding: 0 12px; }
.dots { display: inline-flex; gap: 4px; padding: 4px 2px; } .dots b { width: 7px; height: 7px; border-radius: 50%; background: #c4b5fd; animation: dot 1.2s infinite; }
.dots b:nth-child(2) { animation-delay: .15s; } .dots b:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 60%, 100% { opacity: .3; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }
#wish { flex: none; display: flex; gap: 8px; align-items: flex-end; padding: 8px 10px 10px; }
#wish textarea {
  flex: 1; resize: none; max-height: 40vh; min-height: 48px;
  background: rgba(0, 0, 0, 0.28); border: 1px solid var(--line); border-radius: 24px;
  padding: 12px 16px; font-size: 17px; line-height: 1.35; outline: none; min-height: 48px;
}
#wish textarea:focus { border-color: rgba(190, 170, 255, 0.5); }
.send {
  flex: none; width: 48px; height: 48px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--magic); color: white; display: grid; place-items: center;
  box-shadow: 0 0 24px rgba(244, 114, 182, 0.45);
}
.send:disabled { opacity: 0.5; }
.fine { font-size: 12px; color: var(--muted); margin: 10px 4px 0; line-height: 1.4; }
.card .fine { margin: 12px 0 0; }
.fine a { color: var(--muted); }
.error { color: #fda4af; font-size: 14px; margin: 0 18px; min-height: 0; }
.error:empty { display: none; }

/* Desktop: nur Hinweis, dass es eine Handy-App ist */
#desktop { display: none; }
@media (min-width: 820px) and (hover: hover) and (pointer: fine) {
  body > :not(#desktop):not(script) { display: none !important; }
  #desktop {
    display: grid; place-content: center; justify-items: center; gap: 14px; min-height: 100vh;
    text-align: center; padding: 40px; max-width: 34rem; margin: 0 auto;
  }
  #desktop h1 { margin: 6px 0 0; font-size: 30px; line-height: 1.2; text-wrap: balance; }
  #desktop p { margin: 0; color: var(--muted); font-size: 17px; line-height: 1.5; }
  #desktop b { background: var(--magic); -webkit-background-clip: text; background-clip: text; color: transparent; }
}

/* ---------- Magie ---------- */
#magic { position: fixed; inset: 0; z-index: 4; display: flex; flex-direction: column; justify-content: flex-end; pointer-events: none; }
.spell {
  position: absolute; left: 0; right: 0; top: calc(env(safe-area-inset-top) + 9vh);
  text-align: center; font-size: 17px; color: var(--ink); opacity: 0.9; margin: 0; padding: 0 24px;
  text-shadow: 0 0 18px rgba(167, 139, 250, 0.9);
  transition: opacity 0.6s;
}
.spell.fade { opacity: 0; }
.card {
  pointer-events: auto;
  margin: 0 12px calc(env(safe-area-inset-bottom) + 12px);
  padding: 20px 18px 18px;
  background: var(--glass);
  backdrop-filter: blur(22px) saturate(140%); -webkit-backdrop-filter: blur(22px) saturate(140%);
  border: 1px solid var(--line); border-radius: 26px;
  box-shadow: 0 20px 60px rgba(10, 4, 40, 0.6);
  transform: translateY(130%); transition: transform 0.7s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}
.card.in { transform: none; }
.card h2 { margin: 0 0 6px; font-size: 21px; line-height: 1.2; }
.card p { margin: 0 0 12px; color: var(--muted); line-height: 1.4; font-size: 15px; }
.card blockquote { margin: 0 0 12px; padding: 10px 14px; border-radius: 16px; background: rgba(255, 255, 255, 0.06); font-size: 15px; line-height: 1.35; max-height: 18vh; overflow: auto; }
.card .reply { color: var(--ink); background: rgba(139, 92, 246, 0.18); padding: 12px 14px; border-radius: 16px 16px 16px 6px; white-space: pre-wrap; }
.card input, .card textarea {
  width: 100%; background: rgba(0, 0, 0, 0.28); border: 1px solid var(--line); border-radius: 16px;
  padding: 13px 15px; font-size: 17px; outline: none; margin-bottom: 10px; resize: none;
}
.btn {
  width: 100%; border: 0; border-radius: 16px; padding: 15px; font-size: 17px; font-weight: 600; cursor: pointer;
  background: var(--magic); color: white; display: flex; justify-content: center; align-items: center; gap: 8px;
}
.btn.quiet { background: rgba(255, 255, 255, 0.08); font-weight: 500; margin-top: 8px; }
.btn:disabled { opacity: 0.6; }
.card .link { display: block; margin: 10px auto 0; }
.steps { display: flex; gap: 6px; margin: 2px 0 14px; }
.steps i { flex: 1; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.12); overflow: hidden; position: relative; }
.steps i.on::after { content: ""; position: absolute; inset: 0; background: var(--magic); }
.steps i.now::after { content: ""; position: absolute; inset: 0; background: var(--magic); animation: grow 2.4s ease-in-out infinite; transform-origin: left; }
.tag { display: inline-block; font-size: 12px; padding: 3px 9px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); color: var(--muted); margin-bottom: 10px; }

@keyframes pulse { 50% { opacity: 0.55; } }
@keyframes grow { 0% { transform: scaleX(0); } 70%, 100% { transform: scaleX(1); opacity: 0; } }

/* ---------- Textseiten (Datenschutz usw.) ---------- */
body.page { overflow: auto; }
.page main { max-width: 640px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 28px) 20px 60px; line-height: 1.55; }
.page h1 { font-size: 28px; }
.page h2 { font-size: 18px; margin-top: 28px; }
.page p, .page li { color: #ddd5fb; }
.page .back { color: var(--muted); text-decoration: none; }

@media (prefers-reduced-motion: reduce) {
  .sheet, .card { transition: none; }
}
