/* mjOS · Bridge — Chat (CH-1 bis CH-5), Neugestaltung H9 nach Handy-Chat.dc.html: helle Blasen, Quellen als Karten, Eingabe als Karte. */
.chat { display: flex; flex-direction: column; gap: 14px; min-height: calc(100dvh - 80px - env(safe-area-inset-top) - 128px - env(safe-area-inset-bottom)); }   /* ohne Kopf (64 + 16), Leiste und Chat-Kreis */
.chat[hidden] { display: none; }

/* Kopf ohne Modellnamen: „Chat“ und der Stift für ein neues Gespräch */
.ch-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ch-new { width: 44px; height: 44px; margin-right: -10px; border: 0; background: transparent; color: var(--ink); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.ch-new svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Zora zu einem Foto: Kopfzeile mit Vorschaubild und „Foto lösen“ */
.ch-focus { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-card); background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow-card); }
.ch-focus[hidden] { display: none; }
.ch-focus img { width: 44px; height: 44px; flex: none; border-radius: 8px; object-fit: cover; background: var(--panel-2); }
.ch-focus img[hidden] { display: none; }
.ch-focus-label { flex: 1; min-width: 0; font: 500 14px var(--font-body); color: var(--text-2); overflow-wrap: anywhere; }
.ch-focus .ch-action { align-self: center; }

/* Verlauf */
.ch-log { flex: 1; display: flex; flex-direction: column; gap: 12px; justify-content: flex-end; }
.ch-user { align-self: flex-end; max-width: 78%; padding: 10px 14px; border-radius: 16px 16px 4px 16px; background: var(--blue); color: var(--on-accent);
  font-size: 15px; line-height: 1.4; overflow-wrap: anywhere; white-space: pre-wrap; }
/* ein abgelegtes Foto: Bild, Bildunterschrift, Balken solange es hochlädt, darunter wo es steht */
.ch-user-photo { align-self: flex-end; max-width: 78%; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.ch-user.photo { max-width: 100%; padding: 4px; display: flex; flex-direction: column; gap: 4px; }
.ch-user.photo img { align-self: center; display: block; max-width: 100%; max-height: 260px; border-radius: 12px; object-fit: cover; background: var(--blue-strong); }
.ch-caption { padding: 4px 10px 2px; }
.ch-upload-bar { display: block; margin: 0 10px 8px; height: 4px; border-radius: var(--radius-pill); background: rgba(255, 255, 255, .3); overflow: hidden; }
.ch-upload-bar span { display: block; height: 4px; width: 40%; background: var(--on-accent); animation: ch-load 1.4s ease-in-out infinite; }
.ch-upload-bar.waiting span { width: 100%; opacity: .45; animation: none; }   /* angehalten: grau, läuft beim nächsten Versuch weiter */
@keyframes ch-load { 0% { transform: translateX(-100%); } 100% { transform: translateX(250%); } }
@media (prefers-reduced-motion: reduce) { .ch-upload-bar span { animation: none; width: 100%; opacity: .7; } }
.ch-upload-note { font-size: 11px; color: var(--ink-2); text-align: right; }
.ch-upload-note.bad { color: var(--attention-text); }
.ch-bot { align-self: flex-start; max-width: 86%; display: flex; flex-direction: column; gap: 8px; }
.ch-who { font-size: var(--text-micro); font-weight: 600; letter-spacing: .06em; color: var(--ink-3); }   /* Iris und Zora gleich: Farbe heisst Zustand, nicht Rechner */
.ch-text { padding: 10px 14px; border-radius: 16px 16px 16px 4px; background: var(--surface); border: 1px solid var(--line);
  font-size: 15px; line-height: 1.45; overflow-wrap: anywhere; white-space: pre-wrap; }
.ch-bot.info .ch-text { color: var(--ink-2); background: var(--ground-soft); }
.ch-bot.local .ch-text { color: var(--muted); }
/* Warten: drei Punkte, die nacheinander aufleuchten; ohne Bewegung bei „weniger Bewegung“ */
.ch-bot.waiting .ch-text { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ch-dots { display: inline-flex; align-items: center; gap: 5px; height: 18px; }
.ch-dots span { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .35; animation: ch-dot 1.2s ease-in-out infinite; }
.ch-dots span:nth-child(2) { animation-delay: .15s; }
.ch-dots span:nth-child(3) { animation-delay: .3s; }
.ch-bot .ch-dots { color: var(--blue); }   /* läuft gerade */
.ch-wait-note { font-size: 13px; }
.ch-wait-note:empty { display: none; }
@keyframes ch-dot { 0%, 60%, 100% { opacity: .35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .ch-dots span { animation: none; opacity: .7; } }
/* Hinweise statt Antworten (besetzt, nicht erreichbar, Fehler): gestrichelt, nicht Teil des Gesprächs */
.ch-bot.notice .ch-text { border-style: dashed; border-color: var(--amber-line); background: var(--amber-soft); box-shadow: none; }
.ch-chip { align-self: flex-start; height: 24px; padding: 0 9px; border-radius: var(--radius-pill); border: 1px solid var(--line);
  font-family: var(--font-mono); font-size: 10px; color: var(--ink-3); display: flex; align-items: center; }
/* Quellen unter jeder Antwort: kleine Karten, Art als Titel, Tag und Zeit darunter; tippen öffnet den Eintrag */
.ch-sources { display: flex; flex-wrap: wrap; gap: 8px; }
.ch-source { min-height: var(--touch); padding: 6px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  text-decoration: none; display: flex; align-items: center; gap: 8px; }
.ch-source-text { display: flex; flex-direction: column; gap: 1px; }
.ch-source-text .t { font-size: 12px; font-weight: 500; }
.ch-source-text .s { font-size: 11px; color: var(--ink-3); }
.ch-source.more { font: 500 12px var(--font-body); color: var(--accent); cursor: pointer; }
.ch-action { align-self: flex-start; min-height: var(--touch); padding: 0 14px; border-radius: var(--radius-pill); border: 1px solid var(--blue-line);
  background: var(--surface); color: var(--accent); font: 500 12px var(--font-body); text-decoration: none; display: flex; align-items: center; cursor: pointer; }
.ch-todo { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border-radius: var(--r-control); border: 1px dashed var(--line-3); font-size: 14px; }
.ch-todo-label { font-family: var(--font-mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* Vorschläge unter einem leeren Gespräch: füllen nur das Feld */
.ch-suggest { display: flex; flex-wrap: wrap; gap: 8px; }
.ch-suggest:empty { display: none; }
.ch-suggestion { position: relative; height: 34px; padding: 0 12px; border-radius: var(--radius-pill); border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--ink); font: 13px var(--font-body); cursor: pointer; }

/* Eingabe (H9) als Karte fest über der Leiste, nur der Verlauf scrollt. --ch-bottom hält unter dem Verlauf so viel frei, wie
   die Eingabe hoch ist (chat.js misst sie, sie wächst mit Text und Bild); 36 px unten für den Chat-Kreis. */
.chat { --ch-bottom: 132px; padding-bottom: var(--ch-bottom); }
.ch-bottom { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 5;
  width: 100%; max-width: 480px; padding: 8px var(--gutter) 36px; background: linear-gradient(to bottom, transparent, var(--hull) 12px); }
.ch-form { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 10px 10px 8px 14px; border-radius: 20px;
  border: 1px solid var(--line-strong); background: var(--surface); box-shadow: 0 2px 8px rgba(22, 25, 29, .06); }
.ch-form:focus-within { border-color: var(--blue-line); }
.ch-form textarea { width: 100%; box-sizing: border-box; border: 0; outline: none; resize: none; background: transparent; color: var(--ink);
  font: 16px/22px var(--font-body); padding: 2px 0; overflow-y: auto; max-height: 158px; }   /* höchstens 7 Zeilen, danach scrollt das Feld */
.ch-form textarea::placeholder { color: var(--ink-3); }
.ch-tools { display: flex; align-items: center; gap: 8px; }
.ch-tools .grow { flex: 1; }
.ch-plus { position: relative; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  display: flex; align-items: center; justify-content: center; cursor: pointer; }
.ch-whom { position: relative; height: 34px; padding: 0 8px 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-2);
  font: 13px var(--font-body); display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.ch-whom[aria-expanded="true"] { background: var(--ground); }
.ch-send { position: relative; width: 34px; height: 34px; border: 0; border-radius: 10px; background: var(--blue); color: var(--on-accent);
  display: flex; align-items: center; justify-content: center; cursor: pointer; }
.ch-send:disabled { background: var(--ink-4); cursor: default; }
.ch-plus::after, .ch-whom::after, .ch-send::after { content: ""; position: absolute; inset: -5px; }   /* Berührfläche 44 px (G-8) */
.ch-suggestion::after { content: ""; position: absolute; inset: -5px 0; }
.ch-tools svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.ch-whom svg { width: 16px; height: 16px; }
/* angehängte Bilder (bis 4) als Raster über dem Feld, jedes mit × */
.ch-attached { display: flex; flex-direction: column; gap: 6px; }
.ch-attached[hidden] { display: none; }
.ch-attached-grid { display: flex; gap: 8px; flex-wrap: wrap; }
.ch-thumb { position: relative; width: 64px; height: 64px; border-radius: 10px; overflow: hidden; background: var(--ground); }
.ch-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ch-thumb-label { position: absolute; left: 4px; bottom: 3px; padding: 0 4px; border-radius: 4px; background: rgba(22, 25, 29, .6); color: #FFFFFF;
  font: 600 9px var(--font-body); }
.ch-unattach { position: absolute; right: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(22, 25, 29, .7);
  color: #FFFFFF; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.ch-unattach::before { content: ""; position: absolute; inset: -11px; }   /* Tippfläche 44 px */
.ch-unattach svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.ch-attached-note { font-size: 12px; color: var(--ink-3); }
.ch-attached-note:empty { display: none; }

/* Bilder einer Nachricht: Raster über dem Text, je mit „Bild n“ (so nennt Zora sie) */
.ch-grid { display: grid; gap: 4px; grid-template-columns: 1fr 1fr; width: 100%; min-width: 0; }
.ch-grid.n1 { grid-template-columns: 1fr; }
.ch-grid.n3 .ch-cell:first-child { grid-column: 1 / -1; }
.ch-user-photo:has(.ch-grid) { width: min(78%, 320px); }
.ch-user.photo:has(.ch-grid) { width: 100%; box-sizing: border-box; }
.ch-cell { position: relative; margin: 0; min-width: 0; }
.ch-cell img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 10px; background: var(--blue-strong); }
.ch-grid.n1 .ch-cell img { aspect-ratio: auto; max-height: 260px; }
.ch-cell figcaption { position: absolute; left: 6px; bottom: 6px; padding: 1px 6px; border-radius: 6px; background: rgba(22, 25, 29, .6);
  color: #FFFFFF; font: 600 10px var(--font-body); }

/* ein von Zora gemaltes Bild mit „Nochmal“, „Speichern“, „Ins Tagebuch übernehmen“ */
.ch-generated { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.ch-generated img { display: block; width: 100%; max-width: 360px; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 14px;
  border: 1px solid var(--line); background: var(--ground-soft); }
.ch-generated figcaption { font: 11px var(--font-mono); color: var(--ink-3); }
.ch-gen-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ch-gen-actions .ch-action:disabled { opacity: .55; cursor: default; }

/* Malen: Palette, Pinsel tupft Kleckse auf die Leinwand, die sich nach der Restzeit füllt; darunter wechselnde Sprüche */
.ch-paint { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.ch-easel { width: 180px; height: 108px; overflow: visible; }
.ch-easel .canvas { fill: #FFFDF7; stroke: var(--line-strong); stroke-width: 1; }
.ch-easel .board { fill: #C9A27A; stroke: #A47E58; stroke-width: 1; }
.ch-easel .dot.c1, .ch-easel .b0, .ch-easel .b4 { fill: #2F6FDB; }
.ch-easel .dot.c2, .ch-easel .b1, .ch-easel .b5 { fill: #E9B321; }
.ch-easel .dot.c3, .ch-easel .b2, .ch-easel .b6 { fill: #D6455B; }
.ch-easel .dot.c4, .ch-easel .b3, .ch-easel .b7 { fill: #3BA374; }
.ch-easel .blob { opacity: 0; transform-box: fill-box; transform-origin: center; transform: scale(.2); transition: opacity .6s ease, transform .6s ease; }
.ch-easel .blob.on { opacity: .9; transform: scale(1); }
.ch-easel .handle { stroke: #6B4A2B; stroke-width: 2.4; stroke-linecap: round; }
.ch-easel .tip { fill: #2F6FDB; }
.ch-easel .brush { animation: ch-dab 2.4s ease-in-out infinite; }
@keyframes ch-dab {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }           /* auf der Palette: Farbe aufnehmen */
  35% { transform: translate(22px, 4px) rotate(-8deg); }
  45% { transform: translate(26px, 10px) rotate(-12deg); }        /* tupf */
  55% { transform: translate(22px, 4px) rotate(-8deg); }
  70% { transform: translate(40px, 22px) rotate(-14deg); }        /* tupf */
}
.ch-paint-say { font-size: 14px; }
.ch-paint-left { font-size: 12px; color: var(--ink-3); }
/* weniger Bewegung: kein Tupfen, kein Aufblühen; die Leinwand füllt sich trotzdem, die Sprüche wechseln seltener */
.ch-paint.calm .brush { animation: none; }
@media (prefers-reduced-motion: reduce) {
  .ch-easel .brush { animation: none; }
  .ch-easel .blob { transition: none; transform: none; }
}

/* Menüs über der Eingabe: „+“ links, Iris/Zora rechts */
.ch-menu { position: absolute; bottom: calc(100% - 28px); width: 236px; padding: 6px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface); box-shadow: var(--shadow-pop); display: flex; flex-direction: column; z-index: 6; }
.ch-menu[hidden] { display: none; }
#ch-attach-menu { left: var(--gutter); }
.ch-who-menu { right: var(--gutter); }
.ch-menu > button, .ch-menu > a { min-height: var(--touch); padding: 8px 10px; border: 0; border-radius: 10px; background: transparent; color: var(--ink);
  font: 14px var(--font-body); text-align: left; text-decoration: none; display: flex; gap: 10px; align-items: center; cursor: pointer; }
.ch-menu > button:hover, .ch-menu > a:hover { background: var(--ground-soft); }
.ch-menu > button[aria-checked="true"] { background: var(--blue-soft); }
.ch-menu > button:disabled { opacity: .45; cursor: default; }
.ch-menu svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ch-menu-text { display: flex; flex-direction: column; gap: 1px; }
.ch-menu-text > span:first-child { font-weight: 500; }
.ch-menu-text .sub { font-size: 12px; color: var(--ink-3); }
