/* Refugium Atelier — App-Stylesheet
   Ziel: ein alter Herr soll sich nicht ueberfordert fuehlen.
   Drei Knoepfe. Atmender Avatar. Hanseatisch hell. Newsreader/Manrope.
*/

:root {
  --paper: #faf7f1;
  --paper-warm: #f4efe6;
  --line: rgba(28, 36, 44, 0.12);
  --line-strong: rgba(28, 36, 44, 0.22);
  --ink: #1a1814;
  --ink-soft: #4a4640;
  --ink-mute: #797268;
  --deep: #1f3a4a;
  --deep-soft: #2c5469;
  --water: #4a7488;
  --water-light: #c5d6dd;
  --sand: #c9b491;
  --good: #2a6049;
  --bad: #7b332f;
  --shadow-soft: 0 1px 3px rgba(28, 36, 44, 0.06), 0 8px 30px rgba(28, 36, 44, 0.08);
  --shadow-deep: 0 4px 14px rgba(28, 36, 44, 0.10), 0 30px 80px rgba(28, 36, 44, 0.18);
  --serif: "Newsreader", Georgia, serif;
  --sans: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --max: 760px;
  --safe-bottom: max(16px, env(safe-area-inset-bottom));
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

button { font: inherit; cursor: pointer; }

a {
  color: var(--deep);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

/* ==== App-Bar ==== */
.appbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px clamp(16px, 4vw, 28px);
  background: rgba(250, 247, 241, 0.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--ink);
  min-width: 0;
}

.brand .mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--deep);
  color: var(--paper);
  font-family: var(--serif);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.brand-text strong {
  display: block;
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 500;
  line-height: 1.1;
}

.brand-text small {
  display: block;
  margin-top: 2px;
  color: var(--ink-mute);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.03em;
}

.favoriten-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 600;
}

.favoriten-toggle .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--sand);
}

.favoriten-toggle .fav-count {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--deep);
}

.favoriten-toggle:hover { background: var(--paper-warm); }
.favoriten-toggle.is-active { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.favoriten-toggle.is-active .fav-count { color: var(--paper); }

/* ==== Atelier (main) ==== */
.atelier {
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(24px, 5vw, 48px) clamp(16px, 4vw, 28px) 240px;
}

/* ==== Avatar greeting ==== */
.avatar-greeting {
  text-align: center;
  padding: clamp(24px, 5vw, 56px) 0 clamp(20px, 3vw, 32px);
}

.avatar {
  position: relative;
  width: clamp(120px, 28vw, 180px);
  aspect-ratio: 1 / 1;
  margin: 0 auto 24px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--deep) 0%, var(--deep-soft) 80%);
  display: grid;
  place-items: center;
  color: var(--paper);
  box-shadow: var(--shadow-deep);
}

.avatar-letter {
  position: relative;
  z-index: 2;
  font-family: var(--serif);
  font-size: clamp(2.6rem, 7vw, 4rem);
  font-weight: 400;
  letter-spacing: -0.02em;
}

.avatar-pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(74, 116, 136, 0.5);
  animation: avatar-pulse 4s ease-in-out infinite;
}

.avatar-pulse.pulse-2 {
  animation-delay: 2s;
}

@keyframes avatar-pulse {
  0%   { transform: scale(1); opacity: 0.6; }
  60%  { transform: scale(1.18); opacity: 0; }
  100% { transform: scale(1.18); opacity: 0; }
}

.avatar[data-status="listening"] {
  background: linear-gradient(145deg, #7b332f 0%, #9a4540 80%);
}

.avatar[data-status="thinking"] .avatar-pulse {
  animation-duration: 1.4s;
  border-color: rgba(201, 180, 145, 0.8);
}

.avatar[data-status="speaking"] {
  background: linear-gradient(145deg, var(--good) 0%, #347a5c 80%);
}

.status-text {
  margin: 0 0 18px;
  color: var(--ink-mute);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.greeting {
  margin: 0 0 14px;
  font-family: var(--serif);
  font-size: clamp(1.7rem, 4.4vw, 2.4rem);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.01em;
}

.greeting-sub {
  margin: 0 auto;
  max-width: 480px;
  color: var(--ink-soft);
  font-size: 1rem;
  line-height: 1.55;
}

/* ==== Chat-Stream ==== */
.stream {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 24px;
}

.bubble {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 92%;
  padding: 16px 18px;
  border-radius: 18px;
  font-size: 1rem;
  line-height: 1.55;
  animation: bubble-in 0.35s ease-out;
}

@keyframes bubble-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.bubble.from-hermes {
  align-self: flex-start;
  background: var(--paper-warm);
  border: 1px solid var(--line);
  color: var(--ink);
  border-bottom-left-radius: 6px;
}

.bubble.from-user {
  align-self: flex-end;
  background: var(--deep);
  color: var(--paper);
  border-bottom-right-radius: 6px;
}

.bubble.from-user a { color: rgba(250, 247, 241, 0.9); }

.bubble .meta {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin: 0;
}

.bubble.from-user .meta { color: rgba(250, 247, 241, 0.6); }

.bubble p { margin: 0; }

.bubble figure {
  margin: 0;
  border-radius: 10px;
  overflow: hidden;
}

.bubble img {
  width: 100%;
  max-height: 480px;
  object-fit: cover;
  display: block;
}

.bubble .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.bubble .chip {
  padding: 7px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.bubble .chip:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.bubble .chip.is-good { background: var(--good); color: var(--paper); border-color: var(--good); }
.bubble .chip.is-bad { background: var(--bad); color: var(--paper); border-color: var(--bad); }

.bubble.is-thinking {
  align-self: flex-start;
  background: transparent;
  border: 0;
  padding-left: 0;
  color: var(--ink-mute);
}

.bubble.is-thinking .dots {
  display: inline-flex;
  gap: 4px;
}

.bubble.is-thinking .dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-mute);
  animation: dot 1.2s ease-in-out infinite;
}

.bubble.is-thinking .dots span:nth-child(2) { animation-delay: 0.2s; }
.bubble.is-thinking .dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dot {
  0%, 100% { opacity: 0.3; transform: translateY(0); }
  50%      { opacity: 1; transform: translateY(-3px); }
}

/* ==== Quick prompts ==== */
.quick-prompts {
  margin-top: 8px;
  padding: 24px 0 0;
  border-top: 1px dashed var(--line);
}

.quick-prompts.is-hidden { display: none; }

.quick-label {
  margin: 0 0 14px;
  color: var(--ink-mute);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.quick-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 480px) {
  .quick-grid { grid-template-columns: 1fr; }
}

.quick-grid button {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  color: var(--ink);
  text-align: left;
  font-family: var(--serif);
  font-size: 0.98rem;
  font-weight: 400;
  line-height: 1.3;
  transition: border-color 0.2s, transform 0.2s;
}

.quick-grid button:hover {
  border-color: var(--deep);
  transform: translateY(-1px);
}

/* ==== Favoriten ==== */
.favoriten {
  margin-top: 32px;
  padding: 24px;
  background: var(--paper-warm);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.fav-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}

.favoriten h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 500;
}

.fav-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.fav-card {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: var(--paper);
  box-shadow: var(--shadow-soft);
  aspect-ratio: 4 / 3;
}

.fav-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.fav-card .caption {
  position: absolute;
  inset: auto 0 0 0;
  padding: 8px 10px;
  background: linear-gradient(to top, rgba(26, 24, 20, 0.85), transparent);
  color: var(--paper);
  font-size: 0.74rem;
  font-weight: 500;
}

.fav-empty {
  margin: 0;
  padding: 8px 0;
  color: var(--ink-mute);
  font-size: 0.92rem;
  font-style: italic;
}

.fav-empty.is-hidden { display: none; }

.link {
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--deep);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ==== Composer (sticky bottom) ==== */
.composer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  padding: 12px clamp(12px, 4vw, 24px) var(--safe-bottom);
  background: rgba(250, 247, 241, 0.96);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 30px rgba(28, 36, 44, 0.06);
}

.composer-inner {
  max-width: var(--max);
  margin: 0 auto;
}

.pending {
  margin-bottom: 8px;
  padding: 10px 12px;
  background: var(--paper-warm);
  border: 1px solid var(--line);
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.pending img {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 6px;
}

.pending button.remove {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: var(--ink-mute);
  font-size: 1.2rem;
  cursor: pointer;
  line-height: 1;
}

.prompt {
  width: 100%;
  min-height: 56px;
  max-height: 180px;
  padding: 14px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  resize: none;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.prompt:focus {
  border-color: var(--deep);
  box-shadow: 0 0 0 3px rgba(31, 58, 74, 0.12);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

@media (max-width: 480px) {
  .actions {
    grid-template-columns: 1fr 1fr 1fr;
  }
  .actions .btn-image { grid-column: 1 / -1; }
}

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--paper);
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.1s;
}

.btn:hover { background: var(--paper-warm); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn .ico {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 0.95rem;
  background: var(--paper-warm);
  color: var(--deep);
}

.btn-mic.is-active {
  background: var(--bad);
  border-color: var(--bad);
  color: var(--paper);
  animation: btn-mic-pulse 1.4s ease-in-out infinite;
}

.btn-mic.is-active .ico {
  background: var(--paper);
  color: var(--bad);
  animation: dot-blink 0.8s ease-in-out infinite;
}

@keyframes btn-mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(123, 51, 47, 0.4); }
  50%      { box-shadow: 0 0 0 8px rgba(123, 51, 47, 0); }
}

@keyframes dot-blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

.btn-photo {
  position: relative;
}

.btn-image .ico { color: var(--sand); }

.btn-send {
  background: var(--deep);
  border-color: var(--deep);
  color: var(--paper);
}

.btn-send:hover { background: var(--ink); border-color: var(--ink); }

.btn-send .ico,
.btn-send .arrow {
  background: rgba(250, 247, 241, 0.18);
  color: var(--paper);
}

.btn-send .arrow {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 0.9rem;
}

.footer-meta {
  margin: 12px 0 0;
  font-size: 0.78rem;
  color: var(--ink-mute);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.footer-meta a { color: var(--ink-soft); text-decoration: none; }
.footer-meta a:hover { color: var(--ink); }
.footer-meta .sep { opacity: 0.5; }

[data-backend-status].is-online::before {
  content: "● ";
  color: var(--good);
}

[data-backend-status].is-offline::before {
  content: "○ ";
  color: var(--ink-mute);
}

/* Hide on mobile when label is too tight */
@media (max-width: 380px) {
  .btn .label { font-size: 0.85rem; }
}

/* ==== Appbar Actions (icon-btns) ==== */
.appbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.icon-btn:hover { background: var(--paper-warm); }
.icon-btn.is-active { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.icon-btn .ico-voice { font-family: var(--serif); font-size: 1.2rem; line-height: 1; }
.icon-btn[data-voice-toggle].is-active .ico-voice { color: var(--paper); }

/* ==== Mood Cards (Initial-Inspirator) ==== */
.mood-cards {
  margin-top: 8px;
  padding: 24px 0 0;
  border-top: 1px dashed var(--line);
}

.mood-cards.is-hidden { display: none; }

.mood-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
}

@media (max-width: 540px) {
  .mood-grid { grid-template-columns: 1fr; }
}

.mood-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
  transition: transform 0.4s ease, opacity 0.4s ease;
}

.mood-card.is-rated-yes { border-color: var(--good); }
.mood-card.is-rated-no { opacity: 0.45; transform: scale(0.97); }
.mood-card.is-removing { opacity: 0; transform: translateY(-12px) scale(0.94); }

.mood-card figure {
  margin: 0;
  aspect-ratio: 4 / 3;
  overflow: hidden;
}

.mood-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.mood-text {
  padding: 16px 16px 8px;
}

.mood-text h3 {
  margin: 0 0 6px;
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 500;
  line-height: 1.15;
}

.mood-text p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink-soft);
  line-height: 1.45;
}

.mood-actions {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  padding: 10px 14px 14px;
}

.chip-bad,
.chip-good {
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.chip-bad { color: var(--bad); }
.chip-bad:hover { background: var(--bad); color: var(--paper); border-color: var(--bad); }

.chip-good {
  background: var(--deep);
  color: var(--paper);
  border-color: var(--deep);
}
.chip-good:hover { background: var(--good); border-color: var(--good); }

/* ==== Tool-Bubble (was Hermes gerade tut) ==== */
.bubble.kind-tool {
  align-self: flex-start;
  background: rgba(74, 116, 136, 0.08);
  border: 1px solid rgba(74, 116, 136, 0.24);
  color: var(--deep);
  font-size: 0.88rem;
  padding: 10px 14px;
}

.bubble.kind-tool .tool-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--deep);
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: none;
}

.bubble.kind-tool .tool-icon {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--water);
  color: var(--paper);
  font-size: 0.85rem;
}

.bubble.kind-tool .tool-status {
  margin-left: auto;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink-mute);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.bubble.kind-tool .tool-text {
  margin: 6px 0 0;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, monospace;
  font-size: 0.78rem;
  color: var(--ink-soft);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ==== Request-Bubble (Angelo bittet um Upload) ==== */
.bubble.kind-request {
  align-self: stretch;
  max-width: 100%;
  background: linear-gradient(145deg, #fff8e6, #fdefcd);
  border: 1px solid rgba(189, 152, 79, 0.4);
}

.bubble.kind-request .meta {
  color: #8c6a25;
}

.request-card {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 12px 0 16px;
}

.request-icon {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--paper);
  color: var(--deep);
  font-size: 1.3rem;
}

.request-body { flex: 1; min-width: 0; }
.request-what {
  margin: 0 0 4px;
  font-family: var(--serif);
  font-size: 1.08rem;
  font-weight: 500;
  line-height: 1.3;
  color: var(--ink);
}

.request-why {
  margin: 0;
  font-size: 0.86rem;
  color: var(--ink-soft);
  font-style: italic;
}

.chip-primary {
  background: var(--deep);
  color: var(--paper);
  border-color: var(--deep);
  cursor: pointer;
  position: relative;
}

.chip-primary:hover { background: var(--ink); border-color: var(--ink); }

/* ==== Note-Bubbles (Go/No-Go/Frage/Todo) ==== */
.bubble.kind-note {
  align-self: flex-start;
  max-width: 90%;
  padding: 10px 14px;
  border-left-width: 4px;
  border-left-style: solid;
}

.bubble.kind-note .meta {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 0 0 4px;
}

.bubble.kind-note .note-text {
  margin: 0;
  font-size: 0.95rem;
}

.bubble.note-go {
  background: rgba(42, 96, 73, 0.1);
  border-color: var(--good);
  border-left-color: var(--good);
}
.bubble.note-go .meta { color: var(--good); }

.bubble.note-no_go {
  background: rgba(123, 51, 47, 0.1);
  border-color: var(--bad);
  border-left-color: var(--bad);
}
.bubble.note-no_go .meta { color: var(--bad); }

.bubble.note-frage {
  background: rgba(74, 116, 136, 0.1);
  border-color: var(--water);
  border-left-color: var(--water);
}
.bubble.note-frage .meta { color: var(--water); }

.bubble.note-todo {
  background: rgba(189, 152, 79, 0.12);
  border-color: var(--sand);
  border-left-color: var(--sand);
}
.bubble.note-todo .meta { color: #8c6a25; }

/* ==== Research-Bubble (Web-Recherche-Ergebnis) ==== */
.bubble.kind-research {
  align-self: stretch;
  max-width: 100%;
  background: var(--paper-warm);
  border: 1px solid var(--line);
}

.research-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.research-link {
  display: block;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  text-decoration: none;
  color: var(--deep);
  font-size: 0.92rem;
  line-height: 1.4;
  transition: border-color 0.2s, transform 0.15s;
}

.research-link:hover {
  border-color: var(--deep);
  transform: translateY(-1px);
}

.research-line {
  margin: 0;
  padding: 6px 0;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

/* ==== Artefakt-Bubble (Webseite, Praesentation, Dokument, E-Mail) ==== */
.bubble.kind-artifact {
  align-self: stretch;
  max-width: 100%;
  background: var(--paper);
  border: 1px solid var(--line-strong);
}

.artifact-preview {
  display: block;
  width: 100%;
  height: 420px;
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper-warm);
}

@media (max-width: 540px) {
  .artifact-preview { height: 360px; }
}

.artifact-text {
  margin: 12px 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper-warm);
  max-height: 360px;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ==== Referenz-Bubble (Look-Recherche pro Vorbild) ==== */
.bubble.kind-reference {
  align-self: stretch;
  max-width: 100%;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  padding: 16px;
}

.bubble.kind-reference .meta {
  margin: 0 0 8px;
  color: var(--ink-mute);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
}

.bubble.kind-reference .ref-figure {
  margin: 0 0 12px;
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  background: var(--paper-warm);
}

.bubble.kind-reference .ref-figure img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.bubble.kind-reference .ref-name {
  margin: 0 0 12px;
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 500;
  line-height: 1.15;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
}

.bubble.kind-reference .ref-name small {
  font-size: 0.78rem;
  color: var(--ink-mute);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.bubble.kind-reference .ref-look {
  margin: 0 0 14px;
  padding: 0 0 0 18px;
  color: var(--ink-soft);
  font-size: 0.92rem;
  line-height: 1.55;
}

.bubble.kind-reference .ref-look li { padding: 2px 0; }

.bubble.kind-reference .ref-take,
.bubble.kind-reference .ref-leave,
.bubble.kind-reference .ref-translate {
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: 8px;
  font-size: 0.92rem;
  line-height: 1.5;
}

.bubble.kind-reference .ref-take {
  background: rgba(42, 96, 73, 0.08);
  border-left: 3px solid var(--good);
}
.bubble.kind-reference .ref-take strong { color: var(--good); }

.bubble.kind-reference .ref-leave {
  background: rgba(123, 51, 47, 0.08);
  border-left: 3px solid var(--bad);
}
.bubble.kind-reference .ref-leave strong { color: var(--bad); }

.bubble.kind-reference .ref-translate {
  background: rgba(74, 116, 136, 0.08);
  border-left: 3px solid var(--water);
  margin-bottom: 12px;
}
.bubble.kind-reference .ref-translate strong { color: var(--deep); }

.bubble.kind-reference .chip {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--paper-warm);
  color: var(--deep);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
}

.bubble.kind-reference .chip:hover {
  background: var(--deep);
  color: var(--paper);
  border-color: var(--deep);
}

/* ==== Resonanz-Bubble (MiroFish-Style) ==== */
.bubble.kind-resonance {
  align-self: stretch;
  max-width: 100%;
  background: var(--paper-warm);
  border: 1px solid var(--line);
  padding: 18px;
}

.resonance-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

@media (max-width: 480px) {
  .resonance-grid { grid-template-columns: 1fr; }
}

.resonance-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
}

.resonance-row strong {
  display: block;
  font-family: var(--serif);
  font-size: 0.95rem;
  color: var(--deep);
}

.resonance-row p {
  margin: 4px 0 0;
  font-size: 0.8rem;
  color: var(--ink-soft);
  line-height: 1.4;
}

.resonance-row .score {
  font-family: var(--serif);
  font-size: 1.4rem;
  font-weight: 500;
  color: var(--deep);
  align-self: center;
  font-variant-numeric: tabular-nums;
}

.resonance-row.is-low .score { color: var(--bad); }
.resonance-row.is-high .score { color: var(--good); }

/* ==== Mappe ==== */
.mappe {
  position: fixed;
  inset: 70px 0 0 0;
  z-index: 80;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.mappe[hidden] { display: none; }

.mappe-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 18px clamp(16px, 4vw, 28px) 12px;
}

.mappe-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.6rem;
  font-weight: 500;
}

.mappe-tabs {
  display: flex;
  gap: 8px;
  padding: 0 clamp(16px, 4vw, 28px) 12px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
}

.mappe-tab {
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--paper-warm);
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.mappe-tab.is-active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.mappe-content {
  flex: 1;
  overflow-y: auto;
  padding: 18px clamp(16px, 4vw, 28px);
}

.mappe-entry {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  margin-bottom: 10px;
}

.mappe-entry .entry-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 0 0 6px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-mute);
}

.mappe-entry .entry-meta .who {
  color: var(--deep);
}

.mappe-entry .entry-text {
  margin: 0;
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.5;
}

.mappe-entry img {
  margin-top: 8px;
  width: 100%;
  max-width: 280px;
  border-radius: 8px;
}

.mappe-foot {
  display: flex;
  justify-content: space-between;
  padding: 12px clamp(16px, 4vw, 28px) var(--safe-bottom);
  border-top: 1px solid var(--line);
}

.link-warn { color: var(--bad); }

/* hidden-Attribut soll auch an display:flex/grid Elementen wirken */
[hidden] { display: none !important; }

/* Hauptaktion im Composer: Anrufen wenn idle, Auflegen-Stack wenn calling */
.primary-action { padding: 4px 0 8px; }

body.is-calling .btn-call-fixed { display: none !important; }
body:not(.is-calling) .call-controls { display: none !important; }
body.is-calling .composer-standard { display: none; }

.btn-call-fixed {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px 22px;
  border: 0;
  border-radius: 18px;
  background: linear-gradient(145deg, var(--good) 0%, #347a5c 100%);
  color: var(--paper);
  font-family: var(--sans);
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(42, 96, 73, 0.32);
  transition: transform 0.1s, box-shadow 0.2s;
}

.btn-call-fixed:hover { transform: translateY(-1px); }
.btn-call-fixed:active { transform: translateY(1px); }
.btn-call-fixed:disabled { opacity: 0.55; cursor: progress; }

.btn-call-fixed .call-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(250, 247, 241, 0.2);
  font-size: 0.9rem;
}

.btn-call-fixed .call-label {
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 500;
  text-align: left;
  line-height: 1.05;
}

.btn-call-fixed .call-sub {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.8;
  text-align: right;
}

.call-secondary {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 8px;
}

.call-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 4px 0 6px;
}

.btn-hangup-big {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 18px 22px;
  border: 0;
  border-radius: 18px;
  background: linear-gradient(145deg, #7b332f 0%, #9a4540 100%);
  color: var(--paper);
  font-family: var(--sans);
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(123, 51, 47, 0.42);
  transition: transform 0.1s, box-shadow 0.2s;
}

.btn-hangup-big:hover { transform: translateY(-1px); }
.btn-hangup-big:active { transform: translateY(1px); }

.hangup-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(250, 247, 241, 0.18);
  font-size: 1.1rem;
}

.hangup-text {
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 500;
  text-align: left;
}

.hangup-timer {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  opacity: 0.92;
}

.btn-ptt {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 18px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--paper);
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.btn-ptt.is-talking {
  background: var(--good);
  border-color: var(--good);
  color: var(--paper);
  animation: btn-mic-pulse 1.4s ease-in-out infinite;
}

.btn-ptt .ptt-icon {
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: var(--bad);
  color: var(--paper);
  font-size: 0.7rem;
}

.btn-ptt.is-talking .ptt-icon {
  background: var(--paper);
  color: var(--good);
}

.btn-mute-big {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: transparent;
  font-size: 0.9rem;
  cursor: pointer;
}

.btn-mute-big.is-muted {
  background: var(--bad);
  color: var(--paper);
  border-color: var(--bad);
}

/* ==== Call-Bar (Telefonat) ==== */
.call-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 28px;
  flex-wrap: wrap;
}

.btn-call,
.btn-hangup {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px 32px;
  border: 0;
  border-radius: 22px;
  font-family: var(--sans);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s;
  min-width: 200px;
}

.btn-call {
  background: linear-gradient(145deg, var(--good) 0%, #347a5c 100%);
  color: var(--paper);
  box-shadow: 0 6px 18px rgba(42, 96, 73, 0.32), 0 1px 2px rgba(28, 36, 44, 0.2);
}

.btn-call:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(42, 96, 73, 0.44), 0 2px 4px rgba(28, 36, 44, 0.2);
}

.btn-call:active { transform: translateY(1px); }
.btn-call:disabled { opacity: 0.55; cursor: progress; }

.btn-hangup {
  background: linear-gradient(145deg, #7b332f 0%, #9a4540 100%);
  color: var(--paper);
  box-shadow: 0 6px 18px rgba(123, 51, 47, 0.36);
}

.btn-hangup:hover { transform: translateY(-1px); }

.btn-call .call-icon,
.btn-hangup .call-icon {
  font-size: 1.3rem;
  line-height: 1;
}

.btn-call .call-label,
.btn-hangup .call-label {
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 500;
  line-height: 1.05;
}

.btn-call .call-sub {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.78;
}

.btn-hangup .call-timer {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  opacity: 0.92;
}

.btn-mute {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--ink);
  font-size: 1.2rem;
  cursor: pointer;
}

.btn-mute.is-muted {
  background: var(--bad);
  color: var(--paper);
  border-color: var(--bad);
}

.call-status {
  margin: 16px 0 0;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--paper-warm);
  color: var(--ink-soft);
  font-size: 0.84rem;
  font-weight: 600;
  display: inline-block;
}

.call-status.is-error { background: rgba(123, 51, 47, 0.12); color: var(--bad); }
.call-status.is-success { background: rgba(42, 96, 73, 0.12); color: var(--good); }

/* Avatar wenn im Call: konstant pulsierend, voll deep */
body.is-calling .avatar {
  background: linear-gradient(145deg, var(--good) 0%, #347a5c 80%);
  animation: avatar-call-pulse 2.4s ease-in-out infinite;
}

body.is-calling .avatar[data-status="listening"] {
  background: linear-gradient(145deg, #c5a352 0%, var(--sand) 80%);
}

body.is-calling .avatar[data-status="speaking"] {
  background: linear-gradient(145deg, var(--water) 0%, var(--deep-soft) 80%);
}

@keyframes avatar-call-pulse {
  0%, 100% { box-shadow: var(--shadow-deep), 0 0 0 0 rgba(42, 96, 73, 0.45); }
  50%      { box-shadow: var(--shadow-deep), 0 0 0 18px rgba(42, 96, 73, 0); }
}

/* Live-Transkript-Bubbles im Chat (waehrend Call) */
.bubble.is-streaming {
  position: relative;
}

.bubble.is-streaming::after {
  content: "▋";
  display: inline-block;
  margin-left: 2px;
  animation: cursor-blink 0.9s steps(2) infinite;
  color: var(--ink-mute);
}

@keyframes cursor-blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* Favoriten card text-only fallback */
.fav-card.text-only {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding: 14px 16px;
  background: linear-gradient(145deg, var(--deep), var(--deep-soft));
  color: var(--paper);
  font-family: var(--serif);
  font-size: 0.88rem;
  line-height: 1.4;
}

.fav-card.text-only p {
  margin: 0;
  z-index: 1;
}

.fav-card.text-only .caption {
  display: none;
}
