/* === D&D App — Globales Styling === */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-card: #1e2a47;
  --accent: #e94560;
  --accent-hover: #d13550;
  --gold: #d4a574;
  --gold-dim: #a07850;
  --text: #eee;
  --text-muted: #888;
  --danger: #e94560;
  --success: #4caf50;
  --radius: 8px;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

html, body { height: 100%; }

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
}

h1, h2, h3, h4 { font-family: Georgia, serif; color: var(--gold); }
a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--text); }
.text-muted { color: var(--text-muted); font-size: 0.85rem; }

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 20px; border: none; border-radius: var(--radius);
  font-size: 1rem; font-weight: 600; cursor: pointer;
  transition: background-color 0.2s, opacity 0.2s; text-decoration: none;
  min-height: 44px;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background-color: var(--accent); color: white; }
.btn-primary:hover:not(:disabled) { background-color: var(--accent-hover); }
.btn-secondary { background-color: var(--bg-card); color: var(--text); border: 1px solid var(--gold-dim); }
.btn-secondary:hover:not(:disabled) { background-color: var(--bg-secondary); border-color: var(--gold); }
.btn-danger { background-color: #c0392b; color: white; }
.btn-danger:hover:not(:disabled) { background-color: #a93226; }
.btn-small { padding: 6px 14px; font-size: 0.85rem; min-height: 36px; }
.btn-full { width: 100%; }

/* --- Header & Navigation --- */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px; background-color: var(--bg-secondary);
  border-bottom: 2px solid var(--gold-dim); flex-shrink: 0;
}
.header-left { display: flex; align-items: center; gap: 16px; min-width: 0; }
.header-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }

.header-logo {
  display: flex; align-items: center; gap: 8px;
  font-family: Georgia, serif; font-size: 1.2rem; font-weight: 700;
  color: var(--gold); white-space: nowrap;
}
.header-logo:hover { color: var(--text); }
.header-logo-img { height: 36px; width: auto; border-radius: 4px; }

.header-title {
  font-size: 1.2rem; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; max-width: 400px;
}

.main-nav { display: flex; gap: 4px; }
.nav-link {
  padding: 6px 14px; border-radius: var(--radius); color: var(--text-muted);
  font-size: 0.9rem; font-weight: 600; transition: background-color 0.2s, color 0.2s;
  min-height: 44px; display: flex; align-items: center;
}
.nav-link:hover { color: var(--text); background-color: rgba(255,255,255,0.05); }
.nav-link.active { color: var(--gold); background-color: rgba(212, 165, 116, 0.1); }

.nav-burger {
  display: none; background: none; border: 1px solid var(--gold-dim);
  color: var(--gold); font-size: 1.3rem; padding: 4px 10px;
  border-radius: var(--radius); cursor: pointer; min-height: 44px;
}

.mobile-nav {
  display: none; flex-direction: column; gap: 4px;
  padding: 12px 24px; background: var(--bg-secondary);
  border-bottom: 1px solid var(--gold-dim);
}
.mobile-nav .nav-link { padding: 10px 14px; }

.version-badge { color: var(--text-muted); font-size: 0.7rem; opacity: 0.5; font-weight: 400; }
.username-badge { color: var(--gold); font-weight: 600; font-size: 0.9rem; }

.mode-badge {
  padding: 4px 10px; border-radius: 12px; font-size: 0.8rem;
  font-weight: 600; text-transform: uppercase;
}
.mode-badge.player { background-color: rgba(76, 175, 80, 0.2); color: #4caf50; border: 1px solid #4caf50; }
.mode-badge.dm { background-color: rgba(233, 69, 96, 0.2); color: var(--accent); border: 1px solid var(--accent); }

/* --- Auth-Seite --- */
.auth-container {
  display: flex; align-items: center; justify-content: center;
  flex-direction: column;
  min-height: 100vh; padding: 20px;
}
.auth-card {
  background: var(--bg-secondary); border: 2px solid var(--gold-dim);
  border-radius: 12px; padding: 40px; width: 100%; max-width: 420px;
  box-shadow: var(--shadow), 0 0 40px rgba(212, 165, 116, 0.08);
}
.auth-logo { text-align: center; margin-bottom: 12px; }
.auth-logo-img { height: 80px; width: auto; border-radius: 8px; }
.auth-title { text-align: center; font-size: 1.8rem; margin-bottom: 4px; }
.auth-subtitle { text-align: center; color: var(--text-muted); margin-bottom: 24px; }

.auth-tabs {
  display: flex; margin-bottom: 24px; border-radius: var(--radius);
  overflow: hidden; border: 1px solid var(--gold-dim);
}
.auth-tab {
  flex: 1; padding: 10px; background: transparent; color: var(--text-muted);
  border: none; cursor: pointer; font-size: 0.95rem; font-weight: 600;
  transition: background-color 0.2s, color 0.2s; min-height: 44px;
}
.auth-tab.active { background-color: var(--gold-dim); color: white; }
.auth-tab:hover:not(.active) { color: var(--text); }

/* --- Formulare --- */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; margin-bottom: 6px; font-size: 0.9rem;
  color: var(--gold); font-weight: 600;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 10px 14px; background-color: var(--bg-primary);
  color: var(--text); border: 1px solid var(--gold-dim);
  border-radius: var(--radius); font-size: 1rem; font-family: inherit;
  transition: border-color 0.2s; min-height: 44px;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--gold);
}
.form-group textarea { resize: vertical; min-height: auto; }
.form-error { color: var(--accent); font-size: 0.85rem; margin-bottom: 12px; min-height: 20px; }
.form-success { color: var(--success); font-size: 0.85rem; margin-bottom: 12px; padding: 8px 12px; background: rgba(76,175,80,0.1); border-radius: var(--radius); }
.form-warning {
  background: rgba(233, 69, 96, 0.1); border: 1px solid var(--accent);
  color: var(--accent); padding: 8px 12px; border-radius: var(--radius);
  font-size: 0.85rem; margin-top: 8px;
}
.form-hint { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 8px; }
.size-hint { margin-top: 4px; display: block; }

.form-section {
  margin-bottom: 28px; padding-bottom: 20px;
  border-bottom: 1px solid rgba(212, 165, 116, 0.15);
}
.form-section:last-of-type { border-bottom: none; }
.form-section-title { font-size: 1rem; margin-bottom: 16px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-actions { display: flex; gap: 12px; justify-content: flex-end; padding-top: 16px; }
.page-title { margin-bottom: 20px; }

.radio-group { display: flex; flex-direction: column; gap: 8px; }
.radio-label {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border-radius: var(--radius); cursor: pointer; transition: background-color 0.2s;
  min-height: 44px;
}
.radio-label:hover { background-color: rgba(255,255,255,0.03); }
.radio-label input[type="radio"] { width: auto; accent-color: var(--gold); min-height: auto; }

.character-preview { margin-top: 8px; }
.char-preview-card {
  background: var(--bg-card); border: 1px solid var(--gold-dim);
  border-radius: var(--radius); padding: 10px 14px; font-size: 0.9rem;
}
.char-checkbox-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.char-checkbox-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border-radius: var(--radius); cursor: pointer; transition: background-color 0.2s;
  min-height: 44px;
}
.char-checkbox-item:hover { background-color: rgba(255,255,255,0.03); }
.char-checkbox-item input[type="checkbox"] { width: auto; accent-color: var(--gold); min-height: auto; }

/* --- Dashboard --- */
.dashboard-container { max-width: 1000px; margin: 0 auto; padding: 32px 24px; }
.dashboard-header {
  display: flex; flex-direction: column; align-items: flex-start; gap: 12px; margin-bottom: 24px;
}
.dashboard-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.campaigns-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;
}
.campaign-card {
  background: var(--bg-card); border: 1px solid var(--gold-dim);
  border-radius: var(--radius); padding: 20px;
  transition: border-color 0.2s, box-shadow 0.2s; cursor: pointer;
}
.campaign-card:hover { border-color: var(--gold); box-shadow: 0 4px 20px rgba(212, 165, 116, 0.15); }
.campaign-card-header { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.campaign-card h3 { font-size: 1.1rem; margin-right: 8px; }
.campaign-card-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.campaign-tag {
  padding: 3px 8px; border-radius: 4px; font-size: 0.75rem; font-weight: 600;
  background: rgba(212, 165, 116, 0.15); color: var(--gold);
}
.campaign-characters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.char-mini {
  padding: 2px 8px; border-radius: 4px; font-size: 0.75rem;
  background: rgba(76, 175, 80, 0.15); color: #4caf50;
}
.campaign-card-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 12px; border-top: 1px solid rgba(212, 165, 116, 0.15);
}
.campaign-date { font-size: 0.8rem; color: var(--text-muted); }
.campaign-delete-btn {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  padding: 4px 8px; font-size: 0.85rem; border-radius: 4px;
  transition: color 0.2s, background-color 0.2s; min-height: 44px;
}
.campaign-delete-btn:hover { color: var(--danger); background-color: rgba(233, 69, 96, 0.1); }

.char-personality-preview { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 12px; font-style: italic; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-icon { font-size: 4rem; margin-bottom: 16px; }
.empty-state .btn { margin-top: 20px; }

/* --- Formular-Container --- */
.form-container { max-width: 600px; margin: 0 auto; padding: 32px 24px; }
.form-container-wide { max-width: 750px; }
.campaign-form {
  background: var(--bg-secondary); border: 1px solid var(--gold-dim);
  border-radius: var(--radius); padding: 32px;
}

/* --- Detail-Modus Toggle --- */
.detail-toggle {
  display: flex; align-items: center; gap: 12px; margin-bottom: 24px;
  padding-bottom: 16px; border-bottom: 1px solid rgba(212, 165, 116, 0.15);
}
.toggle-label { color: var(--gold); font-weight: 600; font-size: 0.9rem; }
.toggle-switch { display: flex; border: 1px solid var(--gold-dim); border-radius: var(--radius); overflow: hidden; }
.toggle-btn {
  padding: 6px 16px; border: none; background: transparent; color: var(--text-muted);
  font-size: 0.85rem; font-weight: 600; cursor: pointer; transition: background-color 0.2s, color 0.2s;
  min-height: 36px;
}
.toggle-btn.active { background: var(--gold-dim); color: white; }
.toggle-btn:hover:not(.active) { color: var(--text); }

.detailed-section { animation: slideDown 0.3s ease; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* --- Attribute Circles --- */
.attributes-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.attribute-circle {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: var(--bg-primary); border: 2px solid var(--gold-dim);
  border-radius: 12px; padding: 12px 8px; transition: border-color 0.2s;
}
.attribute-circle:hover { border-color: var(--gold); }
.attribute-circle label { font-size: 0.75rem; font-weight: 700; color: var(--gold); letter-spacing: 1px; }
.attribute-circle input {
  width: 48px; text-align: center; padding: 4px; background: var(--bg-secondary);
  border: 1px solid var(--gold-dim); border-radius: 6px; color: var(--text);
  font-size: 1.1rem; font-weight: 700; min-height: auto;
}
.attribute-circle input:focus { outline: none; border-color: var(--gold); }
.attr-mod { font-size: 0.85rem; color: var(--text-muted); font-weight: 600; }

.combat-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.combat-stats .form-group input { text-align: center; }

.saves-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.save-item { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.save-item label { font-size: 0.75rem; font-weight: 700; color: var(--gold); }
.save-item input {
  width: 48px; text-align: center; padding: 4px; background: var(--bg-primary);
  border: 1px solid var(--gold-dim); border-radius: 6px; color: var(--text);
  font-size: 0.9rem; min-height: auto;
}
.save-item input:focus { outline: none; border-color: var(--gold); }

.skills-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; }
.skill-item { padding: 4px 0; }
.skill-label {
  display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 0.9rem;
  padding: 4px 8px; border-radius: 4px; transition: background-color 0.2s; min-height: 44px;
}
.skill-label:hover { background-color: rgba(255,255,255,0.03); }
.skill-label input[type="checkbox"] { width: auto; accent-color: var(--gold); min-height: auto; }
.skill-attr { color: var(--text-muted); font-size: 0.8rem; }

/* --- Modal --- */
.modal {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
}
.modal-content {
  background: var(--bg-secondary); border: 1px solid var(--gold-dim);
  border-radius: var(--radius); padding: 28px; max-width: 440px; width: 100%;
}
.modal-content h3 { margin-bottom: 12px; }
.modal-content p { margin-bottom: 20px; color: var(--text-muted); line-height: 1.5; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; }

/* --- Chat-Seite --- */
.chat-page { display: flex; flex-direction: column; height: 100vh; }
.chat-layout { flex: 1; display: flex; overflow: hidden; }
.chat-container { flex: 1; overflow-y: auto; padding: 20px 24px; display: flex; flex-direction: column; }
.chat-messages { flex: 1; display: flex; flex-direction: column; gap: 16px; max-width: 800px; width: 100%; margin: 0 auto; }

.chat-message { display: flex; gap: 10px; max-width: 85%; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.chat-message.user { align-self: flex-end; flex-direction: row-reverse; }
.chat-message.assistant { align-self: flex-start; }

.chat-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; flex-shrink: 0;
}
.chat-message.user .chat-avatar { background: rgba(170, 130, 200, 0.3); border: 1px solid rgba(170, 130, 200, 0.5); }
.chat-message.assistant .chat-avatar { background: var(--bg-card); border: 1px solid var(--gold-dim); }

.chat-bubble { padding: 12px 16px; border-radius: 12px; line-height: 1.6; word-wrap: break-word; overflow-wrap: break-word; }
.chat-message.user .chat-bubble { background: rgba(160, 130, 100, 0.18); color: var(--text); border: 1px solid rgba(170, 130, 200, 0.5); border-bottom-right-radius: 4px; }
.chat-message.assistant .chat-bubble { background: var(--bg-card); border: 1px solid var(--gold-dim); border-bottom-left-radius: 4px; }

/* Markdown in Chat */
.chat-message.assistant .chat-bubble h1, .chat-message.assistant .chat-bubble h2, .chat-message.assistant .chat-bubble h3 { font-size: 1.1rem; margin: 12px 0 6px; color: var(--gold); }
.chat-message.assistant .chat-bubble h1:first-child, .chat-message.assistant .chat-bubble h2:first-child, .chat-message.assistant .chat-bubble h3:first-child { margin-top: 0; }
.chat-message.assistant .chat-bubble h4, .chat-message.assistant .chat-bubble h5, .chat-message.assistant .chat-bubble h6 { font-size: 1rem; margin: 10px 0 4px; color: var(--gold); }
.chat-message.assistant .chat-bubble p { margin-bottom: 8px; }
.chat-message.assistant .chat-bubble p:last-child { margin-bottom: 0; }
.chat-message.assistant .chat-bubble strong { color: var(--gold); }
.chat-message.assistant .chat-bubble em { color: #ccc; }
.chat-message.assistant .chat-bubble hr { border: none; border-top: 1px solid var(--gold-dim); margin: 12px 0; opacity: 0.5; }
.chat-message.assistant .chat-bubble ul, .chat-message.assistant .chat-bubble ol { margin: 8px 0; padding-left: 20px; }
.chat-message.assistant .chat-bubble li { margin-bottom: 4px; }
.chat-message.assistant .chat-bubble blockquote { border-left: 3px solid var(--gold-dim); padding-left: 12px; margin: 8px 0; color: var(--text-muted); font-style: italic; }
.chat-message.assistant .chat-bubble code { background: rgba(0,0,0,0.3); padding: 2px 6px; border-radius: 4px; font-size: 0.9em; }
.chat-message.assistant .chat-bubble pre { background: rgba(0,0,0,0.3); padding: 10px; border-radius: var(--radius); overflow-x: auto; margin: 8px 0; }
.chat-message.assistant .chat-bubble pre code { background: none; padding: 0; }

/* Markdown in User-Nachrichten */
.chat-message.user .chat-bubble p { margin-bottom: 8px; }
.chat-message.user .chat-bubble p:last-child { margin-bottom: 0; }
.chat-message.user .chat-bubble strong { color: rgba(200, 170, 230, 1); }
.chat-message.user .chat-bubble em { color: #ccc; }
.chat-message.user .chat-bubble ul, .chat-message.user .chat-bubble ol { margin: 8px 0; padding-left: 20px; }
.chat-message.user .chat-bubble li { margin-bottom: 4px; }
.chat-message.user .chat-bubble blockquote { border-left: 3px solid rgba(170, 130, 200, 0.5); padding-left: 12px; margin: 8px 0; color: var(--text-muted); font-style: italic; }
.chat-message.user .chat-bubble hr { border: none; border-top: 1px solid rgba(170, 130, 200, 0.3); margin: 12px 0; opacity: 0.5; }

.dice-result { display: inline-block; background: rgba(212, 165, 116, 0.2); border: 1px solid var(--gold-dim); border-radius: 4px; padding: 2px 8px; font-weight: 600; color: var(--gold); }

.retry-btn { margin-top: 8px; display: block; }

/* Typing */
.typing-indicator { display: flex; align-items: center; gap: 10px; padding: 0 24px 12px; max-width: 800px; width: 100%; margin: 0 auto; flex-wrap: wrap; }
.typing-avatar { font-size: 1.2rem; }
.typing-dots { display: flex; gap: 4px; }
.typing-dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); animation: pulse 1.4s infinite ease-in-out; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
.typing-hint { color: var(--text-muted); font-size: 0.8rem; }

@keyframes pulse { 0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }

/* Chat-Eingabe */
.chat-input-area { background: var(--bg-secondary); border-top: 2px solid var(--gold-dim); padding: 12px 24px 16px; flex-shrink: 0; }
.chat-form { display: flex; gap: 12px; max-width: 800px; margin: 0 auto; align-items: flex-end; }

/* Modell-Auswahl */
.model-selector-row { display: flex; align-items: center; gap: 10px; max-width: 800px; margin: 0 auto 10px; }
.model-selector-label { font-size: 0.78rem; color: var(--text-muted); font-weight: 600; flex-shrink: 0; }
.model-dropdown {
  background: var(--bg-card); color: var(--text); border: 1px solid var(--gold-dim);
  border-radius: var(--radius); padding: 4px 10px; font-size: 0.78rem; font-weight: 600;
  cursor: pointer; min-height: 28px; line-height: 1; outline: none;
  appearance: auto; -webkit-appearance: auto; max-width: 200px;
}
.model-dropdown:focus { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(212,175,55,0.2); }
.model-dropdown optgroup { font-weight: 700; color: var(--text-muted); }
.model-dropdown option { font-weight: 400; color: var(--text); background: var(--bg-card); }
.model-info-btn {
  background: none; border: none; cursor: pointer; font-size: 1rem;
  padding: 2px 6px; border-radius: 4px; transition: background-color 0.2s;
  min-height: 28px; line-height: 1;
}
.model-info-btn:hover { background: rgba(255,255,255,0.08); }

/* Modell-Info Modal */
.model-info-modal-content { max-width: 620px; max-height: 80vh; overflow-y: auto; }
.model-info-list { display: flex; flex-direction: column; gap: 16px; margin-bottom: 20px; }
.model-info-item { padding: 14px; background: var(--bg-primary); border: 1px solid var(--gold-dim); border-radius: var(--radius); }
.model-info-item.unavailable { opacity: 0.5; }
.model-info-item h4 { font-size: 0.95rem; margin-bottom: 8px; color: var(--gold); }
.model-info-item p { font-size: 0.85rem; color: var(--text-muted); line-height: 1.6; margin: 0; }

/* Denkvorgang (einklappbar) */
.thinking-block {
  margin-bottom: 10px; border-radius: var(--radius); overflow: hidden;
  border: 1px solid rgba(160, 120, 80, 0.35);
}
.thinking-block summary {
  padding: 5px 10px; cursor: pointer; color: var(--text-muted); font-size: 0.78rem;
  font-weight: 600; background: rgba(0,0,0,0.2); user-select: none;
  list-style: none; display: flex; align-items: center; gap: 6px;
}
.thinking-block summary::-webkit-details-marker { display: none; }
.thinking-block summary::before { content: '▶'; font-size: 0.65rem; transition: transform 0.2s; }
.thinking-block[open] summary::before { transform: rotate(90deg); }
.thinking-content {
  padding: 10px 12px; font-size: 0.8rem; color: var(--text-muted);
  white-space: pre-wrap; background: rgba(0,0,0,0.12); line-height: 1.55;
  max-height: 280px; overflow-y: auto;
}

/* KI-Gedächtnis (einklappbar, violetter Ton) */
.memory-block {
  margin-top: 10px; border-radius: var(--radius); overflow: hidden;
  border: 1px solid rgba(130, 90, 180, 0.35);
}
.memory-block summary {
  padding: 5px 10px; cursor: pointer; color: #b89ae0; font-size: 0.78rem;
  font-weight: 600; background: rgba(90, 50, 140, 0.15); user-select: none;
  list-style: none; display: flex; align-items: center; gap: 6px;
}
.memory-block summary::-webkit-details-marker { display: none; }
.memory-block summary::before { content: '▶'; font-size: 0.65rem; transition: transform 0.2s; }
.memory-block[open] summary::before { transform: rotate(90deg); }
.memory-content {
  padding: 10px 12px; font-size: 0.8rem; color: #c4a8e0;
  white-space: pre-wrap; background: rgba(90, 50, 140, 0.08); line-height: 1.55;
  max-height: 280px; overflow-y: auto;
}

/* Debug-Prompt (einklappbar, unter User-Nachrichten, grauer Ton) */
.debug-prompt-block {
  margin-top: 8px; border-radius: var(--radius); overflow: hidden;
  border: 1px solid rgba(100, 100, 120, 0.35);
}
.debug-prompt-block summary {
  padding: 5px 10px; cursor: pointer; color: var(--text-muted); font-size: 0.75rem;
  font-weight: 600; background: rgba(0,0,0,0.15); user-select: none;
  list-style: none; display: flex; align-items: center; gap: 6px;
}
.debug-prompt-block summary::-webkit-details-marker { display: none; }
.debug-prompt-block summary::before { content: '▶'; font-size: 0.65rem; transition: transform 0.2s; }
.debug-prompt-block[open] summary::before { transform: rotate(90deg); }
.debug-prompt-content {
  padding: 10px 12px; font-size: 0.72rem; color: var(--text-muted);
  white-space: pre-wrap; background: rgba(0,0,0,0.1); line-height: 1.5;
  max-height: 400px; overflow-y: auto; font-family: 'Consolas', 'Monaco', monospace;
}

/* Notizen-Panel */
.notes-panel {
  position: fixed; top: 0; right: 0; height: 100vh; width: 370px; max-width: 85vw;
  background: var(--bg-secondary); border-left: 2px solid var(--gold-dim);
  z-index: 1001; flex-direction: column; padding: 0;
  transform: none; box-shadow: -4px 0 20px rgba(0,0,0,0.5);
}
.notes-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; border-bottom: 1px solid var(--gold-dim); flex-shrink: 0;
}
.notes-panel-header h3 { font-size: 1rem; margin: 0; }
.notes-panel-scroll {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column;
}
.notes-section { padding: 0 0 8px; }
.notes-section-title {
  font-size: 0.9rem; color: var(--gold); margin: 0; padding: 12px 16px 0;
  font-family: Georgia, serif;
}
.ai-memory-section {
  border-top: 1px solid rgba(130, 90, 180, 0.3);
}
.ai-memory-section .notes-section-title { color: #b89ae0; }
.ai-memory-section textarea { border-color: rgba(130, 90, 180, 0.35); }
.ai-memory-section textarea:focus { border-color: #b89ae0; }
.notes-hint {
  padding: 8px 16px 0; font-size: 0.78rem; color: var(--text-muted); line-height: 1.4;
}
.notes-panel textarea {
  margin: 8px 16px; padding: 10px 12px; background: var(--bg-primary);
  color: var(--text); border: 1px solid var(--gold-dim); border-radius: var(--radius);
  font-size: 0.85rem; font-family: inherit; resize: none; line-height: 1.5;
  min-height: 120px; width: calc(100% - 32px); box-sizing: border-box;
}
.notes-panel textarea:focus { outline: none; border-color: var(--gold); }
.notes-counter {
  padding: 0 16px 4px; font-size: 0.78rem; color: var(--text-muted); text-align: right;
}
.notes-status {
  padding: 0 16px 8px; font-size: 0.78rem; text-align: right; min-height: 18px;
}
.notes-status.saved { color: var(--success); }
.notes-status.error { color: var(--accent); }

/* Modell-Hinweis unter KI-Nachrichten */
.message-model-hint {
  margin-top: 8px; font-size: 0.7rem; color: var(--text-muted);
  opacity: 0.6; text-align: right; font-style: italic;
}

/* Settings Toggle Row */
.settings-toggle-row { display: flex; flex-direction: column; gap: 4px; }

.chat-form textarea {
  flex: 1; padding: 12px 16px; background: var(--bg-primary); color: var(--text);
  border: 1px solid var(--gold-dim); border-radius: var(--radius);
  font-size: 1rem; font-family: inherit; resize: none;
  min-height: 44px; max-height: 150px; line-height: 1.5; transition: border-color 0.2s;
}
.chat-form textarea:focus { outline: none; border-color: var(--gold); }
.btn-send { height: 44px; padding: 0 24px; flex-shrink: 0; }

/* --- Charakter-Sidebar --- */
.char-sidebar {
  position: fixed; top: 0; right: 0; height: 100vh; width: 320px; max-width: 85vw;
  background: var(--bg-secondary); border-left: 2px solid var(--gold-dim);
  overflow-y: auto; flex-shrink: 0;
  z-index: 1001; /* ÜBER dem Overlay */
  transform: translateX(100%);
  transition: transform 0.3s ease;
  pointer-events: auto;
  display: flex; flex-direction: column;
}
.char-sidebar.open { transform: translateX(0); }

.sidebar-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 1000; /* unter der Sidebar */
  pointer-events: auto;
}

.sidebar-header { display: flex; align-items: center; justify-content: space-between; padding: 16px; border-bottom: 1px solid var(--gold-dim); }
.sidebar-header h3 { font-size: 1rem; }
.sidebar-close-btn { background: none; border: none; color: var(--text-muted); font-size: 1.2rem; cursor: pointer; padding: 4px; min-height: 44px; min-width: 44px; }
.sidebar-close-btn:hover { color: var(--text); }
.sidebar-characters { padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.sidebar-char { background: var(--bg-card); border: 1px solid var(--gold-dim); border-radius: var(--radius); overflow: hidden; }
.sidebar-char-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; cursor: pointer; transition: background-color 0.2s; min-height: 44px; }
.sidebar-char-header:hover { background: rgba(255,255,255,0.03); }
.sidebar-char-name { display: flex; flex-direction: column; gap: 2px; }
.sidebar-char-name strong { color: var(--gold); font-size: 0.95rem; }
.sidebar-char-hp { text-align: center; }
.hp-display { display: block; font-weight: 700; color: var(--success); font-size: 0.95rem; }
.hp-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; }
.sidebar-char-detail { padding: 12px; border-top: 1px solid rgba(212, 165, 116, 0.15); animation: fadeIn 0.2s ease; }
.sidebar-attrs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-bottom: 12px; }
.sidebar-attrs span { font-size: 0.8rem; color: var(--text-muted); text-align: center; padding: 3px; background: var(--bg-primary); border-radius: 4px; }
.sidebar-edit-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.sidebar-edit-row label { font-size: 0.8rem; color: var(--gold); font-weight: 600; white-space: nowrap; }
.sidebar-edit-col { flex-direction: column; align-items: stretch; }
.sidebar-edit-col .btn { align-self: flex-end; margin-top: 4px; }
.sidebar-input { width: 60px; padding: 4px 6px; background: var(--bg-primary); border: 1px solid var(--gold-dim); border-radius: 4px; color: var(--text); font-size: 0.9rem; text-align: center; min-height: auto; }
.sidebar-input:focus { outline: none; border-color: var(--gold); }
.sidebar-textarea { width: 100%; padding: 6px 8px; background: var(--bg-primary); border: 1px solid var(--gold-dim); border-radius: 4px; color: var(--text); font-size: 0.8rem; font-family: inherit; resize: vertical; min-height: auto; }
.sidebar-textarea:focus { outline: none; border-color: var(--gold); }
.sidebar-info { font-size: 0.8rem; margin-bottom: 6px; color: var(--text-muted); }
.sidebar-info strong { color: var(--gold); }

/* --- Admin-Panel --- */
.admin-container { max-width: 1400px; }
.admin-table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.admin-table th, .admin-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid rgba(212, 165, 116, 0.15); white-space: nowrap; }
.admin-table th { color: var(--gold); font-weight: 700; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px; position: sticky; top: 0; background: var(--bg-secondary); }
.admin-table th.sortable { cursor: pointer; user-select: none; }
.admin-table th.sortable:hover { color: var(--text); }
.admin-table tbody tr:nth-child(even) { background: rgba(255,255,255,0.02); }
.admin-table tbody tr:hover { background: rgba(212, 165, 116, 0.05); }
.admin-table .row-inactive { opacity: 0.5; }
.actions-cell { white-space: nowrap; display: flex; gap: 4px; flex-wrap: nowrap; }
.admin-badge { background: var(--gold-dim); color: white; padding: 2px 6px; border-radius: 4px; font-size: 0.7rem; font-weight: 700; }
.status-active { color: var(--success); font-weight: 600; }
.status-inactive { color: var(--accent); font-weight: 600; }
.admin-section-title { color: var(--gold); font-size: 1rem; font-weight: 600; margin: 1rem 0 0.5rem; }
.sort-arrow { font-size: 0.75rem; margin-left: 2px; }
.coins-cell { white-space: nowrap; }
.btn-tiny { padding: 1px 6px; font-size: 0.7rem; min-width: auto; margin-left: 2px; line-height: 1.4; cursor: pointer; border: 1px solid var(--gold-dim); background: transparent; color: var(--gold); border-radius: 3px; }
.btn-tiny:hover { background: var(--gold-dim); color: white; }
.role-select { background: var(--bg-primary); color: var(--text); border: 1px solid var(--gold-dim); border-radius: 4px; padding: 3px 6px; font-size: 0.8rem; cursor: pointer; }
.role-select:disabled { opacity: 0.5; cursor: not-allowed; }
.usage-total-row td { border-top: 2px solid var(--gold-dim); }

/* --- Portraits --- */
.portrait-section {
  display: flex; align-items: center; gap: 20px;
  margin-bottom: 24px; padding-bottom: 20px;
  border-bottom: 1px solid rgba(212, 165, 116, 0.15);
}
.portrait-preview {
  width: 120px; height: 120px; border-radius: 12px;
  background: var(--bg-primary); border: 2px solid var(--gold-dim);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0;
}
.portrait-preview img { width: 100%; height: 100%; object-fit: cover; }
.portrait-fallback { font-size: 3rem; display: flex; align-items: center; justify-content: center; }
.portrait-actions { display: flex; flex-direction: column; gap: 8px; }
.portrait-upload-btn { cursor: pointer; }
.portrait-ai-btn { cursor: pointer; }
.portrait-modal-content { max-width: 520px; }
.portrait-modal-content textarea { width: 100%; min-height: 120px; margin-bottom: 12px; }
.portrait-modal-hint { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 12px; }

/* Chat-Avatare mit Portraits */
.chat-avatar { position: relative; }
.chat-avatar-img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }

/* Charakter-Card Portraits */
.char-card-name-row { display: flex; align-items: center; gap: 10px; }
.char-card-portrait { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; flex-shrink: 0; border: 2px solid var(--gold-dim); }
.char-card-portrait-fallback {
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-primary); font-size: 1.2rem;
}

/* Dashboard Campaign-Card Portraits */
.campaign-char-portraits { display: flex; align-items: center; margin-bottom: 12px; }
.char-portrait-mini {
  width: 32px; height: 32px; border-radius: 50%; object-fit: cover;
  border: 2px solid var(--bg-card); margin-left: -8px;
}
.char-portrait-mini:first-child { margin-left: 0; }
.char-portrait-fallback {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-primary); font-size: 0.8rem;
}
.char-portrait-more {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--gold-dim); color: white; font-size: 0.7rem; font-weight: 700;
}

/* Sidebar Portraits */
.sidebar-char-info { display: flex; align-items: center; gap: 8px; }
.sidebar-portrait { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex-shrink: 0; border: 1px solid var(--gold-dim); }
.sidebar-portrait-fallback { width: 36px; height: 36px; border-radius: 50%; background: var(--bg-primary); border: 1px solid var(--gold-dim); display: flex; align-items: center; justify-content: center; font-size: 1rem; flex-shrink: 0; }

/* Campaign-new preview portrait */
.char-preview-card { display: flex; align-items: center; gap: 12px; background: var(--bg-card); border: 1px solid var(--gold-dim); border-radius: var(--radius); padding: 10px 14px; font-size: 0.9rem; }
.char-preview-portrait { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.char-preview-portrait-fallback { width: 44px; height: 44px; border-radius: 50%; background: var(--bg-primary); border: 1px solid var(--gold-dim); display: flex; align-items: center; justify-content: center; font-size: 1.3rem; flex-shrink: 0; }

/* --- KI-Portrait Loading Overlay --- */
.ai-loading-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0, 0, 0, 0.75); display: flex;
  align-items: center; justify-content: center;
}
.ai-loading-box {
  text-align: center; padding: 40px 48px; border-radius: 16px;
  background: var(--bg-secondary); border: 1px solid var(--gold-dim);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5); max-width: 360px;
}
.ai-spinner {
  width: 48px; height: 48px; margin: 0 auto 20px;
  border: 4px solid rgba(212, 165, 116, 0.2);
  border-top-color: var(--gold); border-radius: 50%;
  animation: aiSpin 0.9s linear infinite;
}
@keyframes aiSpin { to { transform: rotate(360deg); } }
.ai-loading-title {
  font-family: Georgia, serif; color: var(--gold);
  font-size: 1.05rem; font-weight: 700; margin-bottom: 8px;
}
.ai-loading-hint {
  color: var(--text-muted); font-size: 0.82rem; line-height: 1.5;
}

/* --- Legal Pages (Impressum, Datenschutz) --- */
.legal-container {
  min-height: 100vh; padding: 40px 20px;
  display: flex; justify-content: center; align-items: flex-start;
}
.legal-card {
  background: var(--bg-secondary); border: 1px solid var(--gold-dim);
  border-radius: 12px; padding: 40px; max-width: 780px; width: 100%;
  box-shadow: var(--shadow); line-height: 1.75;
}
.legal-card h1 { font-size: 1.6rem; margin-bottom: 24px; }
.legal-card h3 { font-size: 1rem; margin: 24px 0 8px; }
.legal-card p { margin-bottom: 12px; color: var(--text); font-size: 0.92rem; }
.legal-card ul { margin: 8px 0 12px 20px; font-size: 0.92rem; }
.legal-card li { margin-bottom: 4px; }
.legal-card code { background: rgba(0,0,0,0.3); padding: 1px 5px; border-radius: 3px; font-size: 0.85em; }
.legal-card a { color: var(--gold); }
.legal-card a:hover { color: var(--text); }
.legal-back {
  display: inline-block; margin-bottom: 16px; font-size: 0.9rem;
  color: var(--text-muted); text-decoration: none;
}
.legal-back:hover { color: var(--gold); }
.legal-footer-links { margin-top: 32px; padding-top: 16px; border-top: 1px solid rgba(212, 165, 116, 0.15); }

/* Site Footer Links */
.site-footer {
  text-align: center; padding: 16px 24px; color: var(--text-muted);
  font-size: 0.78rem;
}
.site-footer a { color: var(--text-muted); text-decoration: none; margin: 0 8px; }
.site-footer a:hover { color: var(--gold); }

/* Auth Footer (Login-Seite) */
.auth-footer { text-align: center; margin-top: 20px; }
.auth-footer a { color: var(--text-muted); font-size: 0.8rem; text-decoration: none; margin: 0 8px; }
.auth-footer a:hover { color: var(--gold); }
.btn-link { background: none; border: none; color: var(--gold-dim); cursor: pointer; text-decoration: underline; display: block; text-align: center; width: 100%; }
.btn-link:hover { color: var(--gold); }
.form-success { color: #4caf50; font-size: 0.85rem; margin-bottom: 8px; padding: 8px; background: rgba(76,175,80,0.1); border-radius: var(--radius); }

/* --- Responsive --- */
@media (max-width: 768px) {
  .portrait-section { flex-direction: column; align-items: center; }
  .portrait-preview { width: 100px; height: 100px; }
  .app-header { padding: 10px 16px; gap: 8px; }
  .header-title { font-size: 1rem; max-width: 150px; }
  .header-logo { font-size: 0; gap: 0; }
  .header-logo-img { height: 32px; }
  .main-nav { display: none; }
  .nav-burger { display: block; }
  .version-badge { display: none; }

  .dashboard-container { padding: 20px 16px; }
  .dashboard-header { flex-direction: column; gap: 12px; align-items: stretch; }
  .dashboard-actions { flex-direction: column; }
  .campaigns-grid { grid-template-columns: 1fr; }

  .form-container { padding: 20px 16px; }
  .campaign-form { padding: 20px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .attributes-grid { grid-template-columns: repeat(3, 1fr); }
  .saves-grid { grid-template-columns: repeat(3, 1fr); }
  .skills-grid { grid-template-columns: 1fr; }
  .combat-stats { grid-template-columns: repeat(2, 1fr); }
  .form-actions { flex-direction: column-reverse; }

  .auth-card { padding: 24px 16px; }
  .legal-card { padding: 24px 16px; }
  .legal-container { padding: 20px 12px; }

  .chat-container { padding: 12px 12px; }
  .chat-input-area { padding: 10px 12px; }
  .chat-form { gap: 8px; }
  .chat-message { max-width: 92%; }
  .chat-bubble { padding: 10px 12px; }

  .username-badge { display: none; }

  /* Sidebar: schon fixed, nur Schatten auf Mobile */
  .char-sidebar { box-shadow: -4px 0 20px rgba(0,0,0,0.5); }

  /* Admin-Tabelle auf Mobile */
  .admin-table { font-size: 0.8rem; }
  .admin-table th, .admin-table td { padding: 8px 6px; }
  .actions-cell { flex-direction: column; gap: 4px; }
}

@media (max-width: 480px) {
  .attributes-grid { grid-template-columns: repeat(2, 1fr); }
  .saves-grid { grid-template-columns: repeat(2, 1fr); }
  .combat-stats { grid-template-columns: 1fr; }
  .chat-message { max-width: 95%; }
}

/* === Navigation Dropdown === */
.nav-dropdown { position: relative; }
.nav-dropdown-trigger {
  background: none; border: none; cursor: pointer; font-family: inherit;
}
.nav-dropdown-menu {
  display: none; position: absolute; top: 100%; left: 0; z-index: 100;
  background: var(--bg-secondary); border: 1px solid var(--gold-dim);
  border-radius: var(--radius); min-width: 200px; padding: 8px 0;
  box-shadow: var(--shadow);
}
.nav-dropdown:hover .nav-dropdown-menu { display: block; }
.nav-dropdown-item {
  display: block; padding: 8px 16px; color: var(--text-muted);
  font-size: 0.85rem; transition: background 0.2s, color 0.2s;
}
.nav-dropdown-item:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.nav-dropdown-item.active { color: var(--gold); }
.nav-dropdown-divider { height: 1px; background: rgba(212,165,116,0.15); margin: 4px 0; }

/* Mobile nav groups */
.mobile-nav-group { display: flex; flex-direction: column; }
.mobile-nav-group-title {
  padding: 10px 14px 4px; color: var(--gold-dim); font-size: 0.75rem;
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
}
.nav-link-indent { padding-left: 28px !important; }

/* === World Element Type Tabs === */
.world-type-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.world-type-tab {
  padding: 6px 12px; border-radius: var(--radius); font-size: 0.8rem;
  color: var(--text-muted); background: var(--bg-card); border: 1px solid transparent;
  transition: all 0.2s; text-decoration: none;
}
.world-type-tab:hover { color: var(--text); border-color: var(--gold-dim); }
.world-type-tab.active { color: var(--gold); border-color: var(--gold); background: rgba(212, 165, 116, 0.1); }

/* === Worldbuilding Selection (Campaign Creation + Chat Modal) === */
.worldbuilding-select-container { overflow-y: visible; }
.worldbuilding-section { margin-top: 8px; }
.wb-type-group { margin-bottom: 16px; }
.wb-type-title {
  font-size: 0.9rem; color: var(--gold); margin-bottom: 8px;
  font-family: Georgia, serif;
}
.wb-limit { color: var(--text-muted); font-size: 0.75rem; font-family: 'Segoe UI', sans-serif; }
.wb-type-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: nowrap; }
.wb-type-header .wb-type-title { margin-bottom: 0; flex: 1; min-width: 0; }
.wb-checkbox-list { display: flex; flex-direction: column; gap: 6px; }
.wb-checkbox-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  background: var(--bg-card); border: 1px solid rgba(255,255,255,0.05);
  border-radius: var(--radius); cursor: pointer; transition: border-color 0.2s;
}
.wb-checkbox-item:hover { border-color: var(--gold-dim); }
.wb-checkbox-item input[type="checkbox"] {
  width: 18px; height: 18px; accent-color: var(--gold); flex-shrink: 0;
}
.wb-thumb {
  width: 40px; height: 40px; border-radius: 6px; object-fit: cover; flex-shrink: 0;
}
.wb-thumb-fallback {
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-secondary); font-size: 1.2rem;
}
.wb-item-info { display: flex; flex-direction: column; min-width: 0; }
.wb-item-info strong { font-size: 0.85rem; color: var(--text); }
.wb-item-info .text-muted { font-size: 0.75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wb-count { font-size: 0.8rem; color: var(--gold-dim); margin-top: 4px; }

/* === Modal Wide (for worldbuilding) === */
.modal-content-wide { max-width: 600px; width: 95%; max-height: 80vh; overflow-y: auto; }

/* === Worldbuilding Hierarchy Info === */
.wb-hierarchy-info {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px; margin: 4px 0 2px;
}
.wb-hierarchy-tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.75rem; color: var(--gold); background: rgba(212,165,116,0.1);
  padding: 2px 8px; border-radius: 10px; border: 1px solid rgba(212,165,116,0.2);
}
.wb-children-tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.75rem; color: var(--text-muted); background: rgba(255,255,255,0.03);
  padding: 2px 8px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.05);
}

/* === Worldbuilding Cascading Selection === */
.wb-world-group { margin-bottom: 12px; border: 1px solid rgba(212,165,116,0.15); border-radius: var(--radius); padding: 10px; background: rgba(0,0,0,0.15); }
.wb-world-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: nowrap; }
.wb-world-header label { font-weight: bold; color: var(--gold); font-size: 0.9rem; display: flex; align-items: center; gap: 8px; cursor: pointer; flex: 1; min-width: 0; }
.wb-select-all-btn { font-size: 0.7rem; padding: 2px 8px; background: rgba(212,165,116,0.15); color: var(--gold); border: 1px solid rgba(212,165,116,0.3); border-radius: 4px; cursor: pointer; transition: background 0.2s; white-space: nowrap; flex-shrink: 0; }
.wb-select-all-btn:hover { background: rgba(212,165,116,0.3); }
.wb-children-indent { margin-left: 20px; border-left: 2px solid rgba(212,165,116,0.15); padding-left: 10px; }
.wb-children-indent .wb-checkbox-item { background: rgba(0,0,0,0.1); }

/* --- Nav Dropdown Group Titles --- */
.nav-dropdown-group-title {
  display: block;
  padding: 4px 14px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gold-dim);
  pointer-events: none;
}
.nav-dropdown-group-title:not(:first-child) {
  margin-top: 4px;
  border-top: 1px solid rgba(212, 165, 116, 0.15);
  padding-top: 6px;
}

/* --- Wizard Progress --- */
.wizard-progress {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 28px;
}
.wizard-step {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid transparent;
  transition: all 0.2s;
}
.wizard-step span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg-secondary);
  font-size: 0.75rem;
}
.wizard-step.active {
  color: var(--gold);
  border-color: var(--gold-dim);
}
.wizard-step.active span {
  background: var(--gold);
  color: var(--bg-primary);
}
.wizard-step.completed {
  color: var(--success);
}
.wizard-step.completed span {
  background: var(--success);
  color: white;
}
.wizard-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 20px;
}

/* --- Spielbau Cards --- */
.spielbau-select-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
}
.spielbau-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 2px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.spielbau-card:hover {
  border-color: var(--gold-dim);
}
.spielbau-card.selected {
  border-color: var(--gold);
  background: rgba(212, 165, 116, 0.08);
}
.spielbau-card-main {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
}
.spielbau-card-portrait {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.spielbau-card-portrait-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  font-size: 1.2rem;
}
.spielbau-card-info {
  flex: 1;
  min-width: 0;
}
.spielbau-card-info strong {
  color: var(--text);
  font-size: 0.95rem;
}
.spielbau-card-desc {
  padding: 0 14px 10px;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* --- Card Select (Volk/Klasse) --- */
.card-search {
  margin-bottom: 8px;
}
.card-select-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--gold-dim);
  border-radius: var(--radius);
  padding: 8px;
  background: var(--bg-secondary);
}
.card-select-list.collapsed {
  max-height: 200px;
}
.card-select-item {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 2px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.2s;
}
.card-select-item:hover {
  border-color: var(--gold-dim);
}
.card-select-item.selected {
  border-color: var(--gold);
  background: rgba(212, 165, 116, 0.08);
}
.card-select-main {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
}
.card-select-portrait {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.card-select-portrait-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  font-size: 1rem;
}
.card-select-info {
  flex: 1;
  min-width: 0;
}
.card-select-info strong {
  color: var(--text);
  font-size: 0.9rem;
}
.card-select-info-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 4px;
  opacity: 0.6;
  transition: opacity 0.2s;
}
.card-select-info-btn:hover {
  opacity: 1;
}
.card-select-desc {
  padding: 0 12px 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* --- System/Custom Badges --- */
.wb-system-badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 4px;
  background: rgba(212, 165, 116, 0.15);
  color: var(--gold);
  margin-left: 6px;
}
.wb-custom-badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 4px;
  background: rgba(76, 175, 80, 0.15);
  color: var(--success);
  margin-left: 6px;
}

/* --- World Type Tab Separator --- */
.world-type-tab-separator {
  width: 2px;
  height: 20px;
  background: var(--gold-dim);
  opacity: 0.4;
  margin: 0 4px;
  align-self: center;
}

/* --- Character Select Dropdown (Campaign Wizard) --- */
#char-select-single {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--gold-dim);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.95rem;
  font-family: 'Segoe UI', system-ui, sans-serif;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23d4a574' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
  cursor: pointer;
  min-height: 44px;
}
#char-select-single:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(212, 165, 116, 0.2);
}
#char-select-single option {
  background: var(--bg-secondary);
  color: var(--text);
  padding: 8px;
}

/* --- Button Height Fix: Align all header buttons --- */
.dashboard-header .btn {
  padding: 8px 16px;
  font-size: 0.85rem;
  min-height: 36px;
}

@media (max-width: 768px) {
  .nav-dropdown { display: none; }
  .world-type-tabs { display: none; }
  .dashboard-actions { flex-direction: column; gap: 8px; }
}

/* ===================================================================
   TAFELRUNDE — Styles
   =================================================================== */

:root {
  --tr-accent: #e6a53c;
  --tr-accent-hover: #cc8c28;
  --tr-npc: #4caf50;
  --tr-assistant: #42a5f5;
  --tr-chronicler: #ab47bc;
}

/* --- Tafelrunde Buttons --- */
.btn-tr-primary { background-color: var(--tr-accent); color: #1a1a2e; font-weight: 700; }
.btn-tr-primary:hover:not(:disabled) { background-color: var(--tr-accent-hover); }

/* --- Tafelrunde Card --- */
.tr-card { border-left: 3px solid var(--tr-accent); }

.tr-roles { display: flex; gap: 4px; flex-wrap: wrap; }

.tr-role-badge {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 2px 8px; border-radius: 12px; font-size: 0.75rem; font-weight: 600;
}
.tr-role-npc { background: rgba(76, 175, 80, 0.2); color: var(--tr-npc); }
.tr-role-assistant { background: rgba(66, 165, 245, 0.2); color: var(--tr-assistant); }
.tr-role-chronicler { background: rgba(171, 71, 188, 0.2); color: var(--tr-chronicler); }

.tr-card-actions { display: flex; gap: 8px; align-items: center; }

/* --- Rollen-Tabs im Chat --- */
.tr-role-tabs {
  display: flex; gap: 0; background: var(--bg-secondary);
  border-bottom: 1px solid var(--gold-dim);
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  padding: 0 16px;
}

.tr-tab {
  padding: 10px 20px; border: none; background: none;
  color: var(--text-muted); font-size: 0.9rem; font-weight: 600;
  cursor: pointer; white-space: nowrap; border-bottom: 3px solid transparent;
  transition: all 0.2s; min-height: 44px;
}
.tr-tab:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.tr-tab.active { color: var(--text); }
.tr-tab-npc.active { border-bottom-color: var(--tr-npc); color: var(--tr-npc); }
.tr-tab-assistant.active { border-bottom-color: var(--tr-assistant); color: var(--tr-assistant); }
.tr-tab-chronicler.active { border-bottom-color: var(--tr-chronicler); color: var(--tr-chronicler); }

/* --- NPC-Auswahl-Leiste --- */
.tr-npc-bar {
  background: var(--bg-secondary); border-bottom: 1px solid rgba(255,255,255,0.05);
  padding: 8px 16px;
}

.tr-npc-list {
  display: flex; gap: 12px; overflow-x: auto;
  -webkit-overflow-scrolling: touch; padding-bottom: 4px;
}

.tr-npc-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 6px 10px; border: 2px solid transparent; border-radius: var(--radius);
  background: none; cursor: pointer; transition: all 0.2s; min-width: 70px;
  color: var(--text-muted);
}
.tr-npc-item:hover { border-color: rgba(76, 175, 80, 0.3); color: var(--text); }
.tr-npc-item.active {
  border-color: var(--tr-npc); color: var(--text);
  box-shadow: 0 0 8px rgba(76, 175, 80, 0.3);
}

.tr-npc-portrait {
  width: 44px; height: 44px; border-radius: 50%; object-fit: cover;
  border: 2px solid var(--gold-dim);
}
.tr-npc-portrait-fallback {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--bg-card); font-size: 1.2rem; border: 2px solid var(--gold-dim);
}
.tr-npc-item.active .tr-npc-portrait { border-color: var(--tr-npc); }
.tr-npc-name { font-size: 0.7rem; text-align: center; max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Session-Leiste --- */
.tr-session-bar {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-secondary); border-bottom: 1px solid rgba(255,255,255,0.05);
  padding: 8px 16px;
}
.tr-session-start { background: rgba(76, 175, 80, 0.2); color: var(--tr-npc); border: 1px solid var(--tr-npc); }
.tr-session-start:hover { background: rgba(76, 175, 80, 0.3); }
.tr-session-end { background: rgba(233, 69, 96, 0.2); color: var(--danger); border: 1px solid var(--danger); }
.tr-session-end:hover { background: rgba(233, 69, 96, 0.3); }
.tr-session-info { font-size: 0.85rem; color: var(--text-muted); }

/* --- Schnellaktions-Leiste --- */
.tr-quick-actions {
  display: flex; gap: 6px; padding: 6px 0;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tr-quick-actions::-webkit-scrollbar { display: none; }

.tr-quick-btn {
  flex-shrink: 0; padding: 6px 12px; border: 1px solid var(--gold-dim);
  border-radius: 20px; background: var(--bg-card); color: var(--text);
  font-size: 0.8rem; cursor: pointer; white-space: nowrap;
  transition: all 0.2s; min-height: 36px;
}
.tr-quick-btn:hover { border-color: var(--tr-accent); background: rgba(230, 165, 60, 0.1); color: var(--tr-accent); }
.tr-quick-btn:active { transform: scale(0.95); }

/* --- Input-Hint --- */
.tr-input-hint {
  font-size: 0.8rem; color: var(--text-muted); padding: 2px 0; margin: 0;
}

/* --- Nachrichten-Styling nach Rolle --- */
.tr-msg-npc .message-content { border-left: 3px solid var(--tr-npc); padding-left: 12px; }
.tr-msg-chronicler .message-content { border-left: 3px solid var(--tr-chronicler); padding-left: 12px; opacity: 0.9; }
.tr-msg-assistant .message-content { border-left: 3px solid var(--tr-assistant); padding-left: 12px; }

.message-avatar {
  width: 36px; height: 36px; border-radius: 50%; display: flex;
  align-items: center; justify-content: center; font-size: 1.2rem;
  flex-shrink: 0; background: var(--bg-card);
}
.tr-avatar-npc { background: rgba(76, 175, 80, 0.15); }
.tr-avatar-assistant { background: rgba(66, 165, 245, 0.15); }
.tr-avatar-chronicler { background: rgba(171, 71, 188, 0.15); }

.message-body { flex: 1; min-width: 0; }

.message-sender {
  display: block; font-size: 0.75rem; font-weight: 600; margin-bottom: 2px;
}
.tr-sender-npc { color: var(--tr-npc); }
.tr-sender-assistant { color: var(--tr-assistant); }
.tr-sender-chronicler { color: var(--tr-chronicler); }

.assistant-message {
  display: flex; gap: 10px; align-items: flex-start;
}

.system-message {
  text-align: center; padding: 4px 12px;
}
.system-message .message-content {
  display: inline-block; padding: 4px 12px; border-radius: 12px;
  background: rgba(255,255,255,0.05); font-size: 0.8rem; color: var(--text-muted);
}

/* --- Rollen-Auswahl im Erstellungs-Wizard --- */
.tr-role-select {
  display: flex; flex-direction: column; gap: 8px;
}

.tr-role-option {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border: 2px solid var(--bg-card);
  border-radius: var(--radius); cursor: pointer;
  transition: all 0.2s; background: var(--bg-card);
}
.tr-role-option:hover { border-color: var(--tr-accent); }
.tr-role-option:has(input:checked) { border-color: var(--tr-accent); background: rgba(230, 165, 60, 0.08); }

.tr-role-option input[type="checkbox"] { width: 20px; height: 20px; flex-shrink: 0; accent-color: var(--tr-accent); }

.tr-role-option-content {
  display: flex; flex-direction: column; gap: 2px;
}
.tr-role-option-emoji { font-size: 1.5rem; }
.tr-role-option-content strong { color: var(--text); }
.tr-role-option-content .text-muted { font-size: 0.8rem; }

/* --- Wizard Progress Amber --- */
.tr-wizard-progress .wizard-step.active span { background: var(--tr-accent); }
.tr-wizard-progress .wizard-step.completed span { background: var(--tr-accent); }

/* --- Sessions im Übersicht-Modal --- */
.sessions-list { display: flex; flex-direction: column; gap: 16px; max-height: 60vh; overflow-y: auto; }

.session-item {
  padding: 12px; background: var(--bg-card); border-radius: var(--radius);
  border-left: 3px solid var(--tr-chronicler);
}
.session-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.session-summary { font-size: 0.9rem; line-height: 1.5; white-space: pre-wrap; }

/* --- AI Memory Block in Chat --- */
.ai-memory-block { margin-top: 8px; }
.ai-memory-block summary {
  cursor: pointer; font-size: 0.8rem; color: var(--text-muted);
  padding: 4px 0;
}
.ai-memory-content {
  padding: 8px 12px; margin-top: 4px; background: rgba(255,255,255,0.03);
  border-radius: var(--radius); font-size: 0.8rem; color: var(--text-muted);
  white-space: pre-wrap; max-height: 200px; overflow-y: auto;
}

/* --- Chat Settings Sidebar (Mobile) --- */
.chat-settings-toggle {
  display: none; border: none; background: transparent; color: var(--gold);
  font-size: 1.2rem; cursor: pointer; padding: 4px; min-height: 36px;
}
.chat-settings-sidebar {
  display: none; position: fixed; top: 0; right: 0; z-index: 200;
  width: 220px; height: 100vh; background: var(--bg-secondary);
  border-left: 1px solid var(--gold-dim); box-shadow: -4px 0 20px rgba(0,0,0,0.5);
  flex-direction: column; padding: 16px; gap: 10px;
  transform: translateX(100%); transition: transform 0.25s ease;
}
.chat-settings-sidebar.open {
  display: flex; transform: translateX(0);
}
.chat-settings-sidebar .sidebar-close-btn {
  align-self: flex-end; margin-bottom: 8px;
}
.chat-settings-sidebar .btn { justify-content: flex-start; width: 100%; }

/* --- Mobile Responsive --- */
@media (max-width: 768px) {
  .tr-role-tabs { padding: 0 8px; }
  .tr-tab { padding: 8px 14px; font-size: 0.85rem; }
  .tr-npc-bar { padding: 6px 8px; }
  .tr-npc-list { gap: 8px; }
  .tr-quick-actions { padding: 4px 0; }
  .tr-quick-btn { padding: 8px 14px; font-size: 0.78rem; min-height: 40px; }
  .tr-session-bar { padding: 6px 8px; flex-wrap: wrap; }
  .tr-input-hint { font-size: 0.75rem; }

  .tr-role-select { gap: 6px; }
  .tr-role-option { padding: 10px 12px; }

  .message-avatar { width: 30px; height: 30px; font-size: 1rem; }

  /* Chat header: collapse buttons into settings sidebar */
  .chat-page .header-right .btn-secondary:not(.chat-settings-toggle) { display: none; }
  .chat-page .header-right .mode-badge { display: none; }
  .chat-settings-toggle { display: inline-flex; align-items: center; }
  .chat-settings-sidebar { display: flex; }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   COIN SYSTEM (v2.3)
   ═══════════════════════════════════════════════════════════════════════════════ */

/* --- Header Coin Display --- */
.coin-header-link {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--gold); font-weight: bold; font-size: 0.85rem;
  text-decoration: none; padding: 4px 10px; border-radius: var(--radius);
  background: rgba(212,165,116,0.1); border: 1px solid rgba(212,165,116,0.25);
  transition: background 0.2s, border-color 0.2s;
}
.coin-header-link:hover { background: rgba(212,165,116,0.2); border-color: rgba(212,165,116,0.4); }

/* --- Coin Shop Page --- */
.coins-container { max-width: 900px; margin: 90px auto 40px; padding: 0 20px; }
.coin-balance-hero {
  text-align: center; padding: 32px 20px; margin-bottom: 24px;
  background: rgba(212,165,116,0.05); border: 1px solid rgba(212,165,116,0.15);
  border-radius: var(--radius);
}
.coin-balance-hero-icon { font-size: 3rem; margin-bottom: 8px; }
.coin-balance-hero-amount { font-size: 2rem; font-weight: bold; color: var(--gold); font-family: Georgia, serif; }
.coin-balance-hero-sub { color: var(--text-muted); font-size: 0.85rem; margin-top: 6px; }

.section-title { color: var(--gold); font-family: Georgia, serif; margin-bottom: 16px; }

/* --- Package Grid --- */
.coin-packages-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.coin-package {
  background: var(--card-bg); border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius); padding: 20px; text-align: center;
  transition: border-color 0.2s, transform 0.15s; position: relative;
}
.coin-package:hover { border-color: rgba(212,165,116,0.3); transform: translateY(-2px); }
.coin-package.featured { border-color: var(--gold); box-shadow: 0 0 20px rgba(212,165,116,0.15); }
.coin-package-badge {
  position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
  background: var(--gold); color: #1a1a2e; font-size: 0.7rem; font-weight: bold;
  padding: 2px 12px; border-radius: 10px; white-space: nowrap;
}
.coin-package-name { font-weight: bold; color: var(--gold); font-size: 1.1rem; margin-bottom: 8px; }
.coin-package-coins { font-size: 1.5rem; margin-bottom: 4px; }
.coin-package-price { font-size: 1.2rem; font-weight: bold; color: var(--text-primary); margin-bottom: 4px; }
.coin-package-perunit { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 12px; }
.coin-package-buy { width: 100%; }

/* --- Price Table --- */
.coin-price-details { margin-bottom: 24px; }
.coin-price-summary {
  cursor: pointer; padding: 10px 16px; color: var(--gold); font-weight: bold;
  background: rgba(212,165,116,0.05); border: 1px solid rgba(212,165,116,0.15);
  border-radius: var(--radius); list-style: none;
}
.coin-price-summary::-webkit-details-marker { display: none; }
.coin-price-summary::before { content: '▸ '; }
.coin-price-details[open] .coin-price-summary::before { content: '▾ '; }
.coin-cost-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 0.85rem; }
.coin-cost-table th { text-align: left; color: var(--gold); padding: 6px 12px; border-bottom: 1px solid rgba(212,165,116,0.2); }
.coin-cost-table td { padding: 5px 12px; border-bottom: 1px solid rgba(255,255,255,0.04); }
.coin-cost-section td { color: var(--gold); font-weight: bold; padding-top: 12px; background: rgba(212,165,116,0.03); }

/* --- Donation Box --- */
.coin-donation-box {
  background: rgba(212,165,116,0.04); border: 1px solid rgba(212,165,116,0.12);
  border-radius: var(--radius); padding: 16px 20px; margin-bottom: 24px;
}
.coin-donation-box h3 { color: var(--gold); margin-bottom: 8px; font-size: 1rem; }
.coin-donation-box p { font-size: 0.85rem; color: var(--text-muted); margin: 4px 0; }

/* --- Tabs --- */
.coin-tabs { display: flex; gap: 0; margin-bottom: 16px; border-bottom: 1px solid rgba(212,165,116,0.15); }
.coin-tab {
  padding: 8px 16px; background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 0.9rem; border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}
.coin-tab:hover { color: var(--text-primary); }
.coin-tab.active { color: var(--gold); border-bottom-color: var(--gold); }

/* --- Orders Table --- */
.coin-orders-table, .coin-history-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.coin-orders-table th, .coin-history-table th { text-align: left; color: var(--gold); padding: 6px 8px; border-bottom: 1px solid rgba(212,165,116,0.2); }
.coin-orders-table td, .coin-history-table td { padding: 6px 8px; border-bottom: 1px solid rgba(255,255,255,0.04); }

/* --- Spending Summary --- */
.coin-summary-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 0.85rem; }
.coin-summary-total { display: flex; justify-content: space-between; padding: 6px 0; font-weight: bold; border-top: 1px solid rgba(212,165,116,0.15); margin-top: 6px; }
.coin-spent { color: var(--accent); }
.coin-earned { color: #4caf50; }
.coin-history-filter { margin-bottom: 12px; }
.coin-history-filter select { background: var(--card-bg); color: var(--text-primary); border: 1px solid rgba(255,255,255,0.1); border-radius: 4px; padding: 4px 8px; }
.coin-pagination { margin-top: 12px; display: flex; gap: 4px; flex-wrap: wrap; }

/* --- Purchase Modal --- */
.coin-purchase-modal { max-width: 480px; }
.coin-modal-price { font-size: 1.3rem; font-weight: bold; color: var(--gold); text-align: center; margin-bottom: 16px; }
.coin-payment-options { display: flex; gap: 8px; }
.coin-payment-options .btn { flex: 1; }
.coin-payment-options .btn.active { border-color: var(--gold); background: rgba(212,165,116,0.15); }
.coin-prepayment-form .form-group { margin-bottom: 10px; }
.coin-prepayment-form .form-row { display: flex; gap: 8px; }
.coin-prepayment-form .form-row .form-group { flex: 1; }
.coin-prepayment-form input { width: 100%; padding: 8px 10px; background: var(--bg-primary); color: var(--text-primary); border: 1px solid rgba(255,255,255,0.1); border-radius: var(--radius); font-size: 0.85rem; }
.coin-prepayment-form label { font-size: 0.8rem; color: var(--text-muted); display: block; margin-bottom: 3px; }
.coin-checkbox-label { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; margin: 8px 0; cursor: pointer; }
.coin-total { padding: 10px; background: rgba(212,165,116,0.05); border-radius: var(--radius); margin: 12px 0; text-align: center; }
.coin-info-box { padding: 16px; background: rgba(212,165,116,0.05); border-radius: var(--radius); text-align: center; }
.coin-success-box { padding: 16px; background: rgba(76,175,80,0.05); border: 1px solid rgba(76,175,80,0.15); border-radius: var(--radius); }
.coin-success-box h4 { color: #4caf50; margin-bottom: 8px; }

/* --- Insufficient Coins Popup --- */
.coin-popup-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 9999;
  background: rgba(0,0,0,0.7); display: flex; align-items: center; justify-content: center;
}
.coin-popup {
  background: var(--card-bg); border: 1px solid rgba(212,165,116,0.25);
  border-radius: var(--radius); padding: 32px; text-align: center; max-width: 380px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}
.coin-popup-icon { font-size: 3rem; margin-bottom: 12px; }
.coin-popup h3 { color: var(--accent); margin-bottom: 12px; }
.coin-popup p { font-size: 0.9rem; margin-bottom: 16px; }
.coin-popup-actions { display: flex; gap: 8px; justify-content: center; }

/* --- Chat Cost Indicator --- */
.chat-cost-indicator { font-size: 0.75rem; color: var(--text-muted); padding: 2px 8px; }
.chat-cost-indicator.insufficient { color: var(--accent); }

/* --- Creation Cost Badge --- */
.create-cost-badge { font-size: 0.75rem; color: var(--gold); margin-left: 6px; }
.create-cost-badge.free { color: #4caf50; }

/* --- Role-based visibility --- */
body[data-role="user"] .thinking-block,
body[data-role="user"] .debug-prompt-block { display: none !important; }
body[data-role="user"] .ai-memory-block { display: none !important; }

/* Image model selector in portrait modals */
.image-model-selector { margin: 10px 0; display: flex; gap: 8px; align-items: center; }
.image-model-selector label { font-size: 0.85rem; color: var(--text-muted); }
.image-model-selector select { background: var(--bg-primary); color: var(--text-primary); border: 1px solid rgba(255,255,255,0.1); border-radius: 4px; padding: 4px 8px; font-size: 0.85rem; }
.image-model-cost { font-size: 0.75rem; color: var(--gold); margin-left: 6px; }

@media (max-width: 768px) {
  .coin-packages-grid { grid-template-columns: repeat(2, 1fr); }
  .coin-header-link { font-size: 0.75rem; padding: 3px 6px; }
  .coin-orders-table, .coin-history-table { font-size: 0.7rem; }
  .coin-payment-options { flex-direction: column; }
}
