:root {
  --ink: #1e1b3a;
  --ink-soft: #5a5578;
  --violet: #6c4cf5;
  --violet-2: #8b6bff;
  --pink: #ff5fa2;
  --yellow: #ffc93c;
  --teal: #2ec4b6;
  --mint: #7ff6e6;
  --card: #ffffff;
  --bg-1: #f3efff;
  --bg-2: #ffeef6;
  --radius: 22px;
  --shadow: 0 10px 30px rgba(76, 52, 180, .16);
  --font: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "Nunito", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg-1), var(--bg-2) 60%, #eafff9);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Hintergrund ---------- */
.bg { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.blob { position: absolute; border-radius: 50%; filter: blur(50px); opacity: .45; animation: float 14s ease-in-out infinite; }
.b1 { width: 380px; height: 380px; background: var(--violet-2); top: -120px; left: -100px; }
.b2 { width: 320px; height: 320px; background: var(--pink); bottom: -120px; right: -80px; animation-delay: -5s; }
.b3 { width: 260px; height: 260px; background: var(--teal); top: 40%; left: 60%; opacity: .25; animation-delay: -9s; }
.spark { position: absolute; color: var(--yellow); font-size: 22px; animation: twinkle 3s ease-in-out infinite; }
.s1 { top: 14%; left: 8%; } .s2 { top: 24%; right: 10%; animation-delay: -1s; color: var(--pink); }
.s3 { bottom: 26%; left: 5%; animation-delay: -2s; color: var(--teal); } .s4 { bottom: 14%; right: 18%; animation-delay: -.5s; }
@keyframes float { 50% { transform: translate(30px, 40px) scale(1.08); } }
@keyframes twinkle { 50% { transform: scale(.5) rotate(40deg); opacity: .3; } }

/* ---------- Layout ---------- */
.app {
  position: relative; z-index: 1;
  height: 100dvh; max-width: 860px; margin: 0 auto;
  display: flex; flex-direction: column;
  padding: 0 16px;
}
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 0 10px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { border-radius: 16px; box-shadow: var(--shadow); transform: rotate(-6deg); }
h1 { margin: 0; font-size: 26px; line-height: 1.15; letter-spacing: -.5px; }
h1 { background: linear-gradient(90deg, var(--violet), var(--pink)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tag { margin: 2px 0 0; color: var(--ink-soft); font-size: 14px; }

.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  border: 2px solid rgba(108, 76, 245, .25); background: rgba(255,255,255,.7);
  color: var(--violet); font: 700 15px var(--font);
  padding: 9px 14px; border-radius: 999px; cursor: pointer; transition: .15s;
}
.btn-ghost:hover { background: #fff; transform: translateY(-1px); }
a.btn-ghost { text-decoration: none; }
.top-actions { display: flex; gap: 8px; }
.btn-ghost.light { color: #fff; border-color: rgba(255,255,255,.5); background: rgba(255,255,255,.15); }

/* ---------- Chat ---------- */
.chat {
  flex: 1; overflow-y: auto; padding: 8px 4px 16px;
  scroll-behavior: smooth;
}
.welcome { text-align: center; padding: 18px 8px 8px; animation: pop .5s ease both; }
.mascot svg { animation: bob 3s ease-in-out infinite; filter: drop-shadow(0 12px 16px rgba(108,76,245,.3)); }
@keyframes bob { 50% { transform: translateY(-8px) rotate(3deg); } }
.welcome h2 { font-size: clamp(24px, 4.5vw, 34px); margin: 8px 0 6px; }
.welcome p { color: var(--ink-soft); font-size: 17px; margin: 0 auto 18px; max-width: 520px; line-height: 1.45; }
.ideas { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; text-align: left; }
.idea {
  border: 0; text-align: left; cursor: pointer;
  background: var(--card); border-radius: 18px; padding: 14px 16px;
  font: 600 15px/1.35 var(--font); color: var(--ink);
  box-shadow: 0 4px 0 rgba(108,76,245,.18), var(--shadow);
  transition: transform .15s, box-shadow .15s;
  display: flex; gap: 10px; align-items: flex-start;
}
.idea .em { font-size: 26px; line-height: 1; }
.idea:hover { transform: translateY(-3px) rotate(-.5deg); }
.idea:active { transform: translateY(1px); box-shadow: 0 1px 0 rgba(108,76,245,.18); }

.msg { display: flex; gap: 10px; margin: 14px 0; animation: pop .35s ease both; }
.msg.user { justify-content: flex-end; }
.avatar {
  flex: 0 0 40px; height: 40px; border-radius: 14px;
  background: linear-gradient(135deg, var(--violet-2), var(--pink));
  display: grid; place-items: center; color: #fff; font-size: 20px;
  box-shadow: var(--shadow);
}
.bubble {
  max-width: min(560px, 82%);
  padding: 13px 17px; border-radius: var(--radius);
  font-size: 17px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word;
  box-shadow: var(--shadow);
}
.user .bubble { background: linear-gradient(135deg, var(--violet), #8a5cff); color: #fff; border-bottom-right-radius: 6px; }
.bot .bubble { background: var(--card); border-bottom-left-radius: 6px; }
.bubble .style-tag { display: inline-block; margin-top: 6px; font-size: 13px; background: rgba(255,255,255,.2); padding: 2px 9px; border-radius: 999px; }
.bubble.error { background: #fff4e5; color: #8a4b00; border: 2px dashed #ffb44c; }

.images { display: grid; gap: 12px; margin-top: 10px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.pic { max-width: 460px;
  position: relative; border-radius: 18px; overflow: hidden; background: #eee;
  box-shadow: 0 6px 0 rgba(108,76,245,.15); border: 4px solid #fff;
}
.pic img { display: block; width: 100%; height: auto; cursor: zoom-in; transition: transform .3s; }
.pic img:hover { transform: scale(1.02); }
.pic-actions { display: flex; gap: 8px; padding: 10px; background: #fff; flex-wrap: wrap; }
.chip-btn {
  border: 0; cursor: pointer; text-decoration: none;
  font: 700 14px var(--font); padding: 8px 12px; border-radius: 999px;
  background: var(--bg-1); color: var(--violet); display: inline-flex; gap: 6px; align-items: center;
}
.chip-btn:hover { background: #e6deff; }
.chip-btn.pink { background: #ffe3ef; color: #d6337a; }

/* Lade-Animation */
.painting { display: flex; align-items: center; gap: 14px; }
.palette { width: 46px; height: 46px; position: relative; flex: 0 0 46px; }
.palette span {
  position: absolute; width: 14px; height: 14px; border-radius: 50%;
  animation: orbit 1.4s ease-in-out infinite;
}
.palette span:nth-child(1) { background: var(--pink); }
.palette span:nth-child(2) { background: var(--yellow); animation-delay: -.35s; }
.palette span:nth-child(3) { background: var(--teal); animation-delay: -.7s; }
.palette span:nth-child(4) { background: var(--violet-2); animation-delay: -1.05s; }
@keyframes orbit {
  0%   { top: 0; left: 16px; }
  25%  { top: 16px; left: 32px; }
  50%  { top: 32px; left: 16px; }
  75%  { top: 16px; left: 0; }
  100% { top: 0; left: 16px; }
}
.painting-text { font-weight: 700; color: var(--violet); }
.painting-sub { font-size: 14px; color: var(--ink-soft); }
.progress { height: 8px; border-radius: 99px; background: var(--bg-1); overflow: hidden; margin-top: 8px; width: 220px; max-width: 100%; }
.progress i { display: block; height: 100%; width: 40%; border-radius: 99px; background: linear-gradient(90deg, var(--pink), var(--yellow), var(--teal)); animation: slide 1.6s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }

@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }

/* ---------- Eingabe ---------- */
.composer { padding: 8px 0 calc(12px + env(safe-area-inset-bottom)); }
.styles { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px; scrollbar-width: none; }
.styles::-webkit-scrollbar { display: none; }
.style {
  flex: 0 0 auto; border: 2px solid transparent; cursor: pointer;
  background: rgba(255,255,255,.8); color: var(--ink);
  font: 700 14px var(--font); padding: 8px 13px; border-radius: 999px;
  transition: .15s;
}
.style:hover { background: #fff; }
.style[aria-checked="true"] { background: var(--ink); color: #fff; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(30,27,58,.25); }

.inputbar {
  display: flex; align-items: flex-end; gap: 8px;
  background: #fff; border-radius: 26px; padding: 8px;
  box-shadow: 0 6px 0 rgba(108,76,245,.16), var(--shadow);
  border: 3px solid transparent; transition: border-color .15s;
}
.inputbar:focus-within { border-color: var(--violet-2); }
textarea {
  flex: 1; border: 0; outline: 0; resize: none; background: transparent;
  font: 500 17px/1.4 var(--font); color: var(--ink);
  padding: 10px 10px; max-height: 140px; min-height: 44px;
}
textarea::placeholder { color: #a39fbd; }
.btn-round {
  flex: 0 0 48px; height: 48px; border-radius: 18px; border: 0; cursor: pointer;
  background: linear-gradient(135deg, var(--pink), #ff8a5b); color: #fff;
  display: grid; place-items: center; transition: transform .15s, opacity .15s;
  box-shadow: 0 4px 0 #d6337a;
}
.btn-round:hover { transform: translateY(-2px); }
.btn-round:active { transform: translateY(2px); box-shadow: 0 1px 0 #d6337a; }
.btn-round.alt { background: var(--bg-1); color: var(--violet); box-shadow: 0 4px 0 #d9d0ff; }
.btn-round:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-round.alt.spin svg { animation: roll .5s ease; }
@keyframes roll { to { transform: rotate(360deg); } }
.hint { text-align: center; font-size: 13px; color: var(--ink-soft); margin: 8px 0 0; }

/* ---------- Dialoge ---------- */
dialog { border: 0; padding: 0; background: transparent; max-width: calc(100vw - 32px); }
dialog::backdrop { background: rgba(30, 27, 58, .75); backdrop-filter: blur(4px); }
.lightbox[open] { display: flex; flex-direction: column; align-items: center; gap: 12px; max-width: 96vw; max-height: 96vh; }
.lightbox img { max-width: 92vw; max-height: 82vh; border-radius: 18px; border: 5px solid #fff; }
.codebox form {
  background: #fff; border-radius: 26px; padding: 28px; width: min(380px, calc(100vw - 48px)); text-align: center;
  box-shadow: var(--shadow);
}
.codebox h2 { margin: 0 0 6px; }
.codebox p { color: var(--ink-soft); margin: 0 0 14px; }
.codebox input {
  width: 100%; font: 700 20px var(--font); text-align: center; letter-spacing: 2px;
  padding: 12px; border-radius: 16px; border: 3px solid #e3dcff; outline: 0; margin-bottom: 12px;
}
.codebox input:focus { border-color: var(--violet-2); }
.codebox .err { color: #d6337a; font-weight: 700; }
.btn-big {
  width: 100%; border: 0; cursor: pointer; font: 800 18px var(--font); color: #fff;
  padding: 14px; border-radius: 18px; background: linear-gradient(135deg, var(--violet), var(--pink));
  box-shadow: 0 5px 0 #4a2fc4;
}

/* ---------- Galerie-Seite ---------- */
body.gallery-page { overflow: auto; }
.gallery-page .app { height: auto; min-height: 100dvh; max-width: 1200px; }
.gallery-intro { text-align: center; margin: 6px 0 18px; }
.gallery-intro h2 { margin: 0 0 4px; font-size: 24px; }
.gallery-intro p { margin: 0; color: var(--ink-soft); }
.gallery { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); padding-bottom: 32px; }
.gallery .pic { max-width: none; }
.gallery .pic img { aspect-ratio: 4 / 3; object-fit: cover; }
.gallery .pic-actions { justify-content: space-between; align-items: center; }
.gallery .pic-btns { display: flex; gap: 6px; }
.gallery .pic-date { font-size: 13px; color: var(--ink-soft); }
.gallery-empty { text-align: center; color: var(--ink-soft); padding: 40px 0; }
.chip-btn.danger { background: #ffe3e3; color: #c62828; }
.chip-btn.danger:hover { background: #ffcdcd; }
.btn-ghost.light.danger { background: rgba(198,40,40,.55); border-color: rgba(255,255,255,.5); }
.btn-big.danger { background: linear-gradient(135deg, #e53935, #c62828); box-shadow: 0 5px 0 #8e1c1c; }
.btn-big.ghost { background: var(--bg-1); color: var(--violet); box-shadow: 0 5px 0 #d9d0ff; }
.btn-big:disabled { opacity: .6; cursor: wait; }
.btn-text { border: 0; background: none; color: var(--ink-soft); font: 700 15px var(--font); margin-top: 12px; cursor: pointer; }
.confirm-img { display: block; width: 100%; max-height: 220px; object-fit: cover; border-radius: 16px; margin: 6px 0 12px; }
.confirm-actions { display: flex; gap: 10px; }
.confirm-actions .btn-big { flex: 1; width: auto; min-width: 0; }
.lightbox .lb-bar { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

@media (max-width: 560px) {
  h1 { font-size: 19px; }
  .tag { display: none; }
  .btn-ghost span { display: none; }
  .bubble { max-width: 88%; font-size: 16px; }
  .avatar { flex-basis: 34px; height: 34px; font-size: 17px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Bildbaukasten ---------- */
.builder { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 12px; text-align: left; }
.step {
  background: var(--card); border-radius: 20px; padding: 14px 16px;
  box-shadow: 0 4px 0 rgba(108,76,245,.18), var(--shadow);
}
.step-head { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 10px; }
.step-num {
  flex: 0 0 30px; height: 30px; border-radius: 10px; display: grid; place-items: center;
  font-weight: 800; color: #fff; background: linear-gradient(135deg, var(--violet), var(--pink));
}
.step:nth-child(2) .step-num { background: linear-gradient(135deg, var(--teal), #4aa3ff); }
.step:nth-child(3) .step-num { background: linear-gradient(135deg, #ff8a5b, var(--yellow)); }
.step:nth-child(4) .step-num { background: linear-gradient(135deg, var(--pink), #ff8a5b); }
.step-q { font-weight: 800; font-size: 17px; }
.step-sub { font-size: 13.5px; color: var(--ink-soft); line-height: 1.35; margin-top: 2px; }
.step-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.pick {
  border: 2px solid #e6deff; background: #faf8ff; color: var(--ink); cursor: pointer;
  font: 700 14px var(--font); padding: 7px 11px; border-radius: 999px; transition: .15s;
}
.pick:hover { border-color: var(--violet-2); }
.pick:active { transform: scale(.96); }
.pick.added { animation: pick-added .6s ease; }
@keyframes pick-added { 0% { background: var(--violet); border-color: var(--violet); color: #fff; } 100% { background: #faf8ff; } }
.pick.own { border-style: dashed; color: var(--violet); background: transparent; }

.think { margin-top: 22px; text-align: left; }
.think summary {
  list-style: none; cursor: pointer; display: flex; justify-content: center; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 999px; width: fit-content; margin: 0 auto; background: rgba(255,255,255,.6);
}
.think summary::-webkit-details-marker { display: none; }
.think summary::after { content: '▾'; color: var(--violet); font-size: 18px; transition: transform .2s; }
.think[open] summary { margin-bottom: 10px; }
.think[open] summary::after { transform: rotate(180deg); }
.think summary:hover { background: rgba(255,255,255,.9); }
.think h3 { font-size: 18px; margin: 0; display: inline; }
.themes { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.theme { background: rgba(255,255,255,.75); border-radius: 18px; padding: 12px 14px; border: 2px solid rgba(255,255,255,.9); }
.theme-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.theme-head .em { font-size: 22px; }
.theme-head b { display: block; font-size: 15px; }
.theme-head small { color: var(--ink-soft); font-size: 12.5px; }
.theme-head .next {
  margin-left: auto; border: 0; cursor: pointer; width: 32px; height: 32px; border-radius: 10px;
  background: var(--bg-1); color: var(--violet); font: 800 17px var(--font);
}
.theme-head .next:hover { background: #e6deff; }
.theme-q {
  display: block; width: 100%; text-align: left; border: 0; cursor: pointer; background: transparent;
  font: 600 15px/1.35 var(--font); color: var(--ink); padding: 4px 0;
}
.theme-q:hover { color: var(--violet); }
.theme-q::after { content: '  → antworten'; color: var(--pink); font-size: 13px; font-weight: 700; }
@media (max-width: 560px) {
  .builder { grid-template-columns: 1fr; }
}
