/* JAMES — Web. Light-only Theme als 1:1-Replikat der iOS-App. */

:root {
  --bg: #ffffff;
  --bg-soft: #f4f4f6;
  --bg-soft-2: #ebebef;
  --border: #e6e6ea;
  --border-strong: #d1d1d8;
  --text: #0c0c0f;
  --text-dim: #6b6b75;
  --text-muted: #94949e;
  --accent: #BF0002;        /* iOS rgb(0.75, 0.00, 0.01) */
  --accent-soft: rgba(191, 0, 2, 0.10);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.04);
  /* iOS bubble shadow: offset (6, 6), opacity 0.13, radius 3pt */
  --shadow-bubble-r: 6px 6px 3px rgba(0,0,0,0.13);
  --shadow-bubble-l: -6px 6px 3px rgba(0,0,0,0.13);
  --radius: 18px;
  --radius-sm: 12px;
  --radius-pill: 999px;
  /* Höhe der Bottom-Tab-Bar (inkl. Safe-Area) — global verwendbar. */
  --tabbar-h: calc(58px + env(safe-area-inset-bottom));
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Body als Flex-Spalte: Topbar oben, Main flex:1 (scrollbarer Bereich
     intern), Tabbar unten. So muss .chat keine Pixel-Höhe berechnen. */
  display: flex;
  flex-direction: column;
  height: 100vh;        /* Fallback */
  height: 100svh;       /* Small viewport — niemals zu groß */
  height: 100dvh;       /* Dynamic — passt sich an Browser-Chrome an */
  overflow: hidden;
}

.hidden { display: none !important; }

/* ───────────────────── Topbar ───────────────────── */

.topbar {
  flex-shrink: 0;
  z-index: 20;
  display: grid;
  /* Beide Seiten 1fr → Brand sitzt garantiert in der optischen Mitte,
     unabhängig davon ob rechts gerade chat-only-Buttons sichtbar sind. */
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-left {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-self: start;
}
.topbar-right {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-self: end;
}
.brand {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 1.6px;
  color: var(--accent);
  text-align: center;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s ease, transform 0.1s ease;
}
.icon-btn:hover { background: var(--bg-soft); }
.icon-btn:active { transform: scale(0.95); }

.lang-select {
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
}

#app {
  flex: 1;
  min-height: 0;        /* unverzichtbar damit Kinder mit overflow:auto greifen */
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
}
#app > section { flex: 1; min-height: 0; }

/* ───────────────────── Picker ───────────────────── */

.picker {
  padding: 28px 4px 64px;
}
.picker-title {
  margin: 6px 8px 22px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: var(--accent);
}
.character-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 16px;
}
.character-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 22px 14px 18px;
  border-radius: var(--radius);
  background: #fff;
  border: 1.5px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}
.character-card:hover {
  transform: translateY(-2px);
  border-color: var(--card-accent, var(--accent));
  box-shadow: var(--shadow-md);
}
.character-avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
  box-shadow: 0 0 0 3px var(--card-accent, var(--accent));
  margin-bottom: 14px;
}
.character-name {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--accent);
  line-height: 1.2;
}
.character-hashtags {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.35;
  min-height: 28px;
}
.character-card.is-current {
  border-color: var(--card-accent, var(--accent));
  box-shadow: 0 0 0 2px var(--card-accent, var(--accent)), 0 4px 14px rgba(0,0,0,0.08);
}
.character-card.is-locked .character-avatar { filter: grayscale(0.6) opacity(0.85); }
.lock-overlay {
  position: absolute;
  top: 56px;
  left: 50%;
  transform: translateX(-50%);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(12,12,15,0.78);
  color: #fff;
  border-radius: 50%;
  font-size: 14px;
  pointer-events: none;
}
.premium-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 9.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, #f5d36c, #b48a17);
  color: #1a1300;
  box-shadow: var(--shadow-sm);
}

/* ───────────────────── Archive ───────────────────── */

.archive {
  padding: 28px 4px 24px;
  overflow-y: auto;
  min-height: 0;
}
.archive-empty {
  margin: 18px 8px;
  color: var(--text-dim);
  font-size: 14px;
}
.archive-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.archive-item {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  transition: transform 0.1s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}
.archive-item:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}
.archive-item-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 2px var(--card-accent, var(--accent));
}
.archive-item-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.archive-item-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}
.archive-item-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  text-transform: none;
  letter-spacing: 0.1px;
}
.archive-item-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
}
.archive-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.archive-item-preview {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.archive-item-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}
.archive-action {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.archive-action:hover { background: var(--bg-soft); color: var(--text); }
.archive-action.is-fav { color: #d4a017; }
.archive-action.is-danger:hover { background: rgba(191,0,2,0.10); color: var(--accent); }

/* Bottom-Tab aktiv-State */
.tab.is-active { color: var(--accent); }
.tab.is-active svg { color: var(--accent); }

/* ───────────────────── Chat ───────────────────── */

.chat {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding-top: 10px;
  overflow: hidden;
}
/* Scroll-Bereich = Hero + Messages. Composer ist NICHT drin, bleibt unten fix.
   So kann der User immer scrollen wenn Inhalt+Composer mehr Höhe brauchen
   als der Viewport hergibt, ohne dass der Composer überdeckt wird. */
.chat-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
}
.chat-hero {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 10px 12px 6px;
  gap: 12px;
  transition: padding 0.25s ease;
}
.chat-hero-avatar {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.08));
  transition: width 0.25s ease, height 0.25s ease, transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.2), opacity 0.18s ease;
  cursor: grab;
  user-select: none;
  -webkit-user-drag: none;
  touch-action: pan-y;
}
.chat-hero-avatar.is-swiping { transition: none; cursor: grabbing; }
.chat-hero-avatar.fly-out-left  { transform: translateX(-180px) scale(0.6); opacity: 0; }
.chat-hero-avatar.fly-out-right { transform: translateX( 180px) scale(0.6); opacity: 0; }
.chat-hero-avatar.fly-in-left   { transform: translateX(-180px) scale(0.6); opacity: 0; }
.chat-hero-avatar.fly-in-right  { transform: translateX( 180px) scale(0.6); opacity: 0; }

/* Swipe-Hint: kleine Indikatoren links/rechts neben dem Avatar */
.chat-hero-swipe-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: -6px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  user-select: none;
}
.chat-hero-swipe-hint .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-muted);
  opacity: 0.35;
  transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease;
}
.chat-hero-swipe-hint .dot.is-active {
  opacity: 1;
  background: var(--accent);
  transform: scale(1.4);
}
.chat-hero.is-collapsed .chat-hero-swipe-hint { display: none; }
.chat-hero-name {
  font-size: 14px;
  font-weight: 700;
  margin: 0;
  color: var(--text-dim);
  letter-spacing: 0.2px;
}
.chat-hookline {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  margin: 4px 0 0;
  line-height: 1.22;
  max-width: 720px;
  letter-spacing: -0.4px;
}

/* Mode-Pills (Liquid-Glass-Look wie iOS 26) */
.mode-pills {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px;
  border-radius: var(--radius-pill);
  background: rgba(255,255,255,0.55);
  border: 1px solid rgba(255,255,255,0.65);
  box-shadow: 0 1px 1px rgba(0,0,0,0.04), inset 0 1px 0 rgba(255,255,255,0.8), 0 6px 18px rgba(0,0,0,0.06);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
}
.mode-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, transform 0.1s ease;
}
.mode-pill:hover { color: var(--text); }
.mode-pill:active { transform: scale(0.97); }
.mode-pill.is-active {
  color: var(--text);
  background: linear-gradient(180deg, #ffffff 0%, #f7f7f7 70%, #efefef 100%);
  box-shadow: 0 1px 1px rgba(0,0,0,0.06), inset 0 1px 0 rgba(255,255,255,0.9);
}
.mode-pill-label { line-height: 1; }

/* Suggestions ("💡 Nur für dich") */
.suggestions {
  width: 100%;
  max-width: 640px;
  margin: 14px auto 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.suggestions-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 auto;
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 500;
}
.suggestions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.suggestion-chip {
  text-align: center;
  padding: 12px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.35;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.1s ease;
}
.suggestion-chip:hover { background: #fff; border-color: var(--border-strong); }
.suggestion-chip:active { transform: scale(0.98); }

/* Compact-Hero (kollabiert nach erster User-Message) */
.chat-hero.is-collapsed {
  flex-direction: row;
  justify-content: flex-start;
  text-align: left;
  gap: 10px;
  padding: 6px 4px 8px;
  border-bottom: 1px solid var(--border);
}
.chat-hero.is-collapsed .chat-hero-avatar { width: 36px; height: 36px; filter: none; }
.chat-hero.is-collapsed .chat-hero-name { font-size: 13px; color: var(--text-dim); }
.chat-hero.is-collapsed .chat-hookline,
.chat-hero.is-collapsed .mode-pills,
.chat-hero.is-collapsed .suggestions {
  display: none;
}

/* ───────────────────── Messages ───────────────────── */

.messages {
  /* Messages laufen jetzt INNERHALB von .chat-scroll mit, kein eigenes
     Scrolling mehr — der äußere Container scrollt Hero + Messages zusammen. */
  flex: 1 0 auto;
  padding: 14px 4px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.date-separator {
  align-self: center;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 4px 12px;
  margin: 4px 0 6px;
}

.message {
  display: flex;
  align-items: flex-end;
  max-width: 92%;
  animation: bubbleIn 0.18s ease-out;
}
@keyframes bubbleIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.message.from-user {
  align-self: flex-end;
  justify-content: flex-end;
  max-width: 80%;
}
.message.from-character {
  align-self: flex-start;
  padding-left: 18px;
  position: relative;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
  background: #fff;
  position: absolute;
  left: 0;
  bottom: -2px;
  box-shadow: 0 0 0 2px var(--bubble-color, var(--accent)), 0 1px 2px rgba(0,0,0,0.12);
  z-index: 1;
}

.bubble {
  padding: 11px 16px 12px;
  border-radius: var(--radius);
  line-height: 1.45;
  font-size: 15px;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.message.from-user .bubble {
  background: #0c0c0f;
  color: #ffffff;
  border-bottom-right-radius: 6px;
  box-shadow: var(--shadow-bubble-l);
}
.message.from-character .bubble {
  background: #ffffff;
  color: var(--text);
  border: 1.5px solid var(--bubble-color, rgba(0,0,0,0.10));
  border-bottom-left-radius: 6px;
  margin-left: 22px;
  box-shadow: var(--shadow-bubble-r);
}
.bubble.streaming::after {
  content: "▍";
  display: inline-block;
  margin-left: 2px;
  color: var(--bubble-color, var(--accent));
  animation: blink 1s steps(2) infinite;
}

/* Markdown-Elemente innerhalb der KI-Bubble */
.message.from-character .bubble > *:first-child { margin-top: 0; }
.message.from-character .bubble > *:last-child  { margin-bottom: 0; }
.message.from-character .bubble p { margin: 0 0 8px; }
.message.from-character .bubble strong { font-weight: 700; }
.message.from-character .bubble em { font-style: italic; }
.message.from-character .bubble h1,
.message.from-character .bubble h2,
.message.from-character .bubble h3,
.message.from-character .bubble h4 {
  margin: 12px 0 6px;
  font-weight: 700;
  letter-spacing: -0.2px;
  line-height: 1.25;
}
.message.from-character .bubble h1 { font-size: 18px; }
.message.from-character .bubble h2 { font-size: 17px; }
.message.from-character .bubble h3 { font-size: 16px; }
.message.from-character .bubble h4 { font-size: 15px; }
.message.from-character .bubble ul,
.message.from-character .bubble ol {
  margin: 6px 0 8px;
  padding-left: 20px;
}
.message.from-character .bubble li { margin: 2px 0; }
.message.from-character .bubble li > p { margin: 0; }
.message.from-character .bubble code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.92em;
  background: rgba(0,0,0,0.06);
  padding: 1px 6px;
  border-radius: 5px;
}
.message.from-character .bubble pre {
  margin: 8px 0;
  padding: 10px 12px;
  background: #f4f4f6;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.45;
}
.message.from-character .bubble pre code {
  background: transparent;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}
.message.from-character .bubble blockquote {
  margin: 8px 0;
  padding: 6px 12px;
  border-left: 3px solid var(--bubble-color, var(--accent));
  background: rgba(0,0,0,0.03);
  border-radius: 0 8px 8px 0;
  color: var(--text-dim);
}
.message.from-character .bubble a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.message.from-character .bubble a:hover { text-decoration-thickness: 2px; }
.message.from-character .bubble hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 12px 0;
}
.message.from-character .bubble table {
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 14px;
}
.message.from-character .bubble th,
.message.from-character .bubble td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}
.message.from-character .bubble th {
  background: var(--bg-soft);
  font-weight: 700;
}

@keyframes blink { to { visibility: hidden; } }
.bubble.error {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(191,0,2,0.35);
}

/* ───────────────────── Composer ───────────────────── */

.composer {
  flex-shrink: 0;
  /* Harte Obergrenze, damit ein langer Composer (Textarea wächst bis 200px)
     den Scroll-Bereich nicht weiter zusammendrückt als sinnvoll und nicht
     unter die Tabbar rutscht. */
  max-height: 50vh;
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding: 12px 4px;
  padding-bottom: 14px;
  background: #fff;
  border-top: 1px solid var(--border);
}
.composer-pill {
  flex: 1;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-soft);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  padding: 4px 6px 4px 14px;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.composer-pill:focus-within {
  border-color: rgba(0,0,0,0.10);
  background: #fff;
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.composer-leading {
  display: inline-flex;
  align-items: center;
  color: var(--text-muted);
  padding: 8px 0;
}
.composer-input {
  flex: 1;
  resize: none;
  min-height: 40px;
  max-height: 200px;
  background: transparent;
  color: var(--text);
  border: none;
  padding: 9px 0;
  font: inherit;
  font-size: 15px;
  line-height: 1.4;
  outline: none;
}
.composer-input::placeholder { color: var(--text-muted); }
.composer-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-soft-2);
  border: none;
  color: var(--text-dim);
  cursor: not-allowed;
  margin: 2px;
}

.send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #0c0c0f;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s ease, background 0.15s ease, opacity 0.15s ease;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}
.send-btn:hover { transform: scale(1.05); }
.send-btn:disabled {
  background: var(--bg-soft-2);
  color: var(--text-muted);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ───────────────────── Bottom Tab Bar ───────────────────── */

.tabbar {
  flex-shrink: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: #ffffff;
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
  /* Padding-bottom für Home-Indicator + explizite min-height, damit der
     Flex-Container den Platz auch tatsächlich reserviert. Ohne die min-height
     hat iOS Safari den Composer manchmal in die Tabbar geschoben. */
  padding-bottom: env(safe-area-inset-bottom);
  min-height: calc(58px + env(safe-area-inset-bottom));
}
.tab {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px 6px;
  background: transparent;
  border: 0;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 10px;
  font-weight: 500;
  transition: color 0.12s ease, transform 0.1s ease;
}
.tab:active { transform: scale(0.96); }
.tab.is-active {
  color: var(--text);
  font-weight: 600;
}
.tab-label { line-height: 1.1; }

/* ───────────────────── Toast ───────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 14px);
  transform: translate(-50%, 12px);
  background: rgba(12, 12, 15, 0.95);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 100;
}
.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ───────────────────── Auth Modal ───────────────────── */

.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(12,12,15,0.45);
  backdrop-filter: blur(2px);
}
.modal-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 24px;
  padding: 28px 24px 24px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
  animation: modalIn 0.18s ease-out;
  max-height: 90dvh;
  overflow-y: auto;
}
.modal-card--wide {
  max-width: 760px;
  padding: 24px 22px 22px;
}
.modal-card--wide .character-grid {
  margin-top: 4px;
}
.modal-card--wide .picker-title {
  margin: 0 0 16px;
  text-align: left;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: transparent;
  border: 0;
  font-size: 26px;
  color: var(--text-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
}
.modal-close:hover { background: var(--bg-soft); color: var(--text); }
.modal-title {
  margin: 0 0 16px;
  font-size: 20px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.2px;
}
.modal-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-soft);
  border-radius: var(--radius-pill);
  margin-bottom: 18px;
}
.modal-tab {
  flex: 1;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.modal-tab.is-active {
  background: #fff;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.modal-form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 12px; font-weight: 600; color: var(--text-dim); }
.field input {
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  font: inherit;
  font-size: 15px;
  color: var(--text);
  outline: none;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.field input:focus {
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-error {
  margin: 0;
  min-height: 18px;
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: var(--radius-pill);
  padding: 12px 18px;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.15s ease;
}
.btn-primary:hover { opacity: 0.92; }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary {
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 11px 18px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-secondary:hover { background: var(--bg-soft-2); }
.btn-ghost-text {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  align-self: center;
  margin-top: 4px;
}
.btn-ghost-text:hover { color: var(--text); }

.account-email {
  margin: 0 0 6px;
  font-size: 14px;
  color: var(--text-dim);
}
.account-status {
  margin: 8px 0 18px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--bg-soft);
  font-size: 13px;
  color: var(--text);
}
.account-status.is-premium {
  background: linear-gradient(135deg, rgba(245,211,108,0.25), rgba(180,138,23,0.15));
  border: 1px solid rgba(180,138,23,0.4);
  color: #5b4400;
  font-weight: 600;
}
.account-actions { display: flex; flex-direction: column; gap: 10px; }

/* Account-Button im Topbar – aktiver Style wenn eingeloggt */
.icon-btn.is-logged-in {
  color: var(--accent);
  background: var(--accent-soft);
}

/* ───────────────────── Mobile ───────────────────── */

@media (max-width: 540px) {
  .character-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
  .character-avatar { width: 76px; height: 76px; }
  .picker-title { font-size: 20px; }
  .chat-hero-avatar { width: 92px; height: 92px; }
  .chat-hookline { font-size: 19px; }
  .brand { font-size: 16px; letter-spacing: 1.2px; }
  .icon-btn { width: 34px; height: 34px; }
}
