@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Inter:wght@400;500;600&display=swap');

:root {
  --bg-dark: #0a0c10;
  --bg-surface: #12161f;
  --bg-glass: rgba(18, 22, 31, 0.85);
  --bg-bubble-char: #1a202c;
  --bg-bubble-user: linear-gradient(135deg, #d97706 0%, #b45309 100%);
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-gold: rgba(245, 158, 11, 0.35);
  
  --accent-gold: #f59e0b;
  --accent-gold-hover: #fbbf24;
  --accent-gold-glow: rgba(245, 158, 11, 0.25);
  
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dialogue: #fcd34d;
  --text-action: #a78bfa;
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --shadow-glow: 0 0 20px rgba(245, 158, 11, 0.2);
  --shadow-bubble: 0 4px 14px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-image: 
    radial-gradient(circle at 10% 15%, rgba(245, 158, 11, 0.07) 0%, transparent 45%),
    radial-gradient(circle at 90% 85%, rgba(139, 92, 246, 0.05) 0%, transparent 50%);
}

/* App Container */
#app-container {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  position: relative;
  background: var(--bg-surface);
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.8);
  border-left: 1px solid var(--border-glass);
  border-right: 1px solid var(--border-glass);
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-glass);
  z-index: 20;
  position: sticky;
  top: 0;
}

.char-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.avatar-wrapper {
  position: relative;
  width: 44px;
  height: 44px;
}

.avatar-img {
  width: 100%;
  height: 100%;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 2px solid var(--accent-gold);
  box-shadow: 0 0 10px var(--accent-gold-glow);
}

.online-badge {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  background: #10b981;
  border: 2px solid var(--bg-surface);
  border-radius: var(--radius-full);
}

.char-meta h1 {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.gold-tooth-icon {
  font-size: 0.8rem;
  color: var(--accent-gold);
}

.char-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  display: inline-block;
}

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

.btn-icon {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-icon:hover, .btn-icon:active {
  background: rgba(245, 158, 11, 0.2);
  border-color: var(--accent-gold);
  color: var(--accent-gold-hover);
  transform: scale(1.05);
}

.credit-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid var(--border-gold);
  color: var(--accent-gold);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  letter-spacing: 0.02em;
}

/* Control Toolbar */
.control-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: rgba(14, 18, 25, 0.95);
  border-bottom: 1px solid var(--border-glass);
  font-size: 0.82rem;
  gap: 10px;
}

.length-selector {
  display: flex;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-full);
  padding: 2px;
}

.length-opt {
  padding: 4px 10px;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.2s;
  user-select: none;
}

.length-opt.active {
  background: var(--accent-gold);
  color: #000;
  font-weight: 700;
  box-shadow: 0 0 10px var(--accent-gold-glow);
}

.model-tag-select {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 0.75rem;
  font-family: inherit;
  outline: none;
  cursor: pointer;
}

.model-tag-select:focus {
  border-color: var(--accent-gold);
}

/* Chat Message Area */
#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

#chat-messages::-webkit-scrollbar {
  width: 5px;
}

#chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

/* Message Styles */
.message-row {
  display: flex;
  gap: 10px;
  max-width: 90%;
  animation: fadeInMsg 0.25s ease-out forwards;
}

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

.message-row.user, .message-row.user-row {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-row.char, .message-row.char-row {
  align-self: flex-start;
}

.msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  object-fit: cover;
  flex-shrink: 0;
  margin-top: 4px;
}

.char .msg-avatar, .char-row .msg-avatar {
  border: 1.5px solid var(--accent-gold);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.25);
}

.user .msg-avatar, .user-row .msg-avatar {
  border: 1.5px solid rgba(255, 255, 255, 0.2);
}

.msg-body-wrapper, .message-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 100%;
}

.user .msg-body-wrapper, .user-row .message-content {
  align-items: flex-end;
}

.char .msg-body-wrapper, .char-row .message-content {
  align-items: flex-start;
}

.msg-bubble, .message-bubble {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  line-height: 1.58;
  letter-spacing: -0.01em;
  word-break: break-word;
  position: relative;
  box-shadow: var(--shadow-bubble);
}

.char .msg-bubble, .char-row .message-bubble, .char-bubble {
  background: var(--bg-bubble-char);
  border: 1px solid var(--border-glass);
  border-top-left-radius: 4px;
  color: #e5e7eb;
}

.user .msg-bubble, .user-row .message-bubble, .user-bubble {
  background: var(--bg-bubble-user);
  border-top-right-radius: 4px;
  color: #fff;
  font-weight: 400;
  box-shadow: 0 4px 16px rgba(217, 119, 6, 0.25);
}

/* Dialogue and Action styling in RP */
.msg-bubble em, .msg-bubble i, .message-bubble em, .message-bubble i {
  color: var(--text-action);
  font-style: italic;
}

.msg-bubble .dialogue-text, .message-bubble .dialogue-text {
  color: var(--text-dialogue);
  font-weight: 500;
}

.msg-bubble .inner-thought, .message-bubble .inner-thought {
  display: inline-block;
  color: #c4b5fd;
  font-style: italic;
  font-size: 0.9em;
  line-height: 1.45;
  padding: 4px 10px;
  margin: 4px 0;
  background: rgba(196, 181, 253, 0.08);
  border-left: 2px solid rgba(196, 181, 253, 0.6);
  border-radius: 4px;
}

.msg-bubble .inner-thought em, .message-bubble .inner-thought em {
  color: #ddd6fe;
}

.msg-bubble p, .message-bubble p {
  margin-bottom: 8px;
}

.msg-bubble p:last-child, .message-bubble p:last-child {
  margin-bottom: 0;
}

/* Action toolbar on messages */
.msg-actions, .message-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0.85;
  transition: opacity 0.2s;
  padding: 2px 4px;
  flex-wrap: wrap;
}

.msg-actions:hover, .message-actions:hover {
  opacity: 1;
}

.msg-action-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  user-select: none;
}

.msg-action-btn:hover {
  color: var(--accent-gold);
  border-color: var(--accent-gold-glow);
  background: rgba(245, 158, 11, 0.12);
}

.msg-action-btn.retry-btn {
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.3);
  background: rgba(251, 191, 36, 0.08);
  font-weight: 500;
}

.msg-action-btn.retry-btn:hover {
  background: rgba(251, 191, 36, 0.2);
  color: #fff;
}

.msg-action-btn:disabled, .msg-action-btn.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
  border-color: rgba(255, 255, 255, 0.05);
  background: transparent;
  color: #64748b;
}

/* Swipe Navigation Controls */
.swipe-container {
  display: inline-flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-full);
  padding: 2px 6px;
  gap: 4px;
}

.swipe-btn {
  background: transparent;
  border: none;
  color: var(--accent-gold);
  cursor: pointer;
  font-size: 0.72rem;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  line-height: 1;
  transition: all 0.15s ease;
  user-select: none;
}

.swipe-btn:hover:not(:disabled) {
  background: rgba(245, 158, 11, 0.25);
  color: #fff;
}

.swipe-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
  color: var(--text-muted);
}

.swipe-indicator {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-main);
  padding: 0 4px;
  user-select: none;
  letter-spacing: 0.05em;
}

.max-retry-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(148, 163, 184, 0.12);
  border: 1px solid rgba(148, 163, 184, 0.25);
  color: #94a3b8;
  font-size: 0.72rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.msg-action-btn:hover {
  color: var(--accent-gold);
  background: rgba(255, 255, 255, 0.05);
}

/* Streaming indicator */
.typing-cursor {
  display: inline-block;
  width: 7px;
  height: 15px;
  background: var(--accent-gold);
  margin-left: 4px;
  vertical-align: middle;
  animation: blink 0.8s infinite;
}

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

.error-banner {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  margin-top: 4px;
}

.error-retry-btn {
  background: rgba(245, 158, 11, 0.15) !important;
  color: var(--accent-gold) !important;
  border: 1px solid var(--accent-gold) !important;
  padding: 6px 14px !important;
  border-radius: var(--radius-md) !important;
  font-weight: 500 !important;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.error-retry-btn:hover {
  background: var(--accent-gold) !important;
  color: #000 !important;
}

/* Quick Bar above input */
.quick-action-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  background: rgba(14, 18, 25, 0.7);
  overflow-x: auto;
  scrollbar-width: none;
}

.quick-action-bar::-webkit-scrollbar {
  display: none;
}

.quick-chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  color: var(--text-muted);
  font-size: 0.76rem;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
}

.quick-chip:hover, .quick-chip:active {
  background: rgba(245, 158, 11, 0.15);
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

/* Chat Input Bar */
.chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-glass);
  position: sticky;
  bottom: 0;
  z-index: 20;
}

.input-box-wrapper {
  flex: 1;
  position: relative;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 8px 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-box-wrapper:focus-within {
  border-color: var(--accent-gold);
  box-shadow: 0 0 12px var(--accent-gold-glow);
}

#user-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-family: inherit;
  font-size: 0.95rem;
  resize: none;
  max-height: 120px;
  min-height: 24px;
  line-height: 1.4;
}

#user-input::placeholder {
  color: #6b7280;
}

.send-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: var(--accent-gold);
  border: none;
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  box-shadow: 0 0 12px var(--accent-gold-glow);
}

.send-btn:hover {
  background: var(--accent-gold-hover);
  transform: scale(1.05);
}

.send-btn:disabled {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #fff;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.84rem;
  color: var(--text-muted);
  font-weight: 500;
}

.form-input {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
}

.form-input:focus {
  border-color: var(--accent-gold);
}

.btn-primary {
  background: var(--accent-gold);
  color: #000;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover {
  background: var(--accent-gold-hover);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-weight: 500;
  cursor: pointer;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-weight: 500;
  cursor: pointer;
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

.greeting-option {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 10px;
  cursor: pointer;
  font-size: 0.85rem;
  color: #d1d5db;
  line-height: 1.45;
  transition: all 0.2s;
}

.greeting-option:hover {
  border-color: var(--accent-gold);
  background: rgba(245, 158, 11, 0.05);
}

/* Character Profile Modal & Tabs */
.char-profile {
  transition: transform 0.15s ease;
  user-select: none;
}

.char-profile:hover .avatar-img {
  transform: scale(1.08);
  box-shadow: 0 0 16px var(--accent-gold-glow);
}

.char-profile:hover #char-name {
  color: var(--accent-gold);
}

.avatar-img {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.profile-modal-card {
  max-width: 720px;
  width: 95vw;
  height: 88vh;
  max-height: 88vh;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden; /* Lock outer modal scroll so tabs stay pinned */
}

.profile-modal-card .modal-header {
  flex-shrink: 0;
  padding-bottom: 2px;
}

.profile-hero {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-glass);
}

.profile-hero-avatar {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-full);
  border: 2px solid var(--accent-gold);
  object-fit: cover;
  box-shadow: 0 0 12px var(--accent-gold-glow);
  flex-shrink: 0;
}

.profile-hero-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.profile-hero-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.profile-hero-meta {
  font-size: 0.78rem;
  color: var(--accent-gold);
  font-weight: 500;
  line-height: 1.3;
}

.profile-tags-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 3px;
  max-height: 48px;
  overflow-y: auto;
}

.profile-tags-wrap::-webkit-scrollbar {
  width: 3px;
}
.profile-tags-wrap::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.profile-tag-pill {
  font-size: 0.68rem;
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.25);
  padding: 1px 7px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

/* Tabs Navigation - Prominent, Unshrinkable, Clear Buttons */
.profile-tabs-nav {
  flex-shrink: 0; /* CRITICAL: Never collapse */
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 4px 0 10px 0;
  border-bottom: 1px solid var(--border-glass);
  min-height: 48px;
}

@media (max-width: 600px) {
  .profile-tabs-nav {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    padding-bottom: 8px;
  }
}

.profile-tab-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #d1d5db;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  font-family: inherit;
  min-height: 40px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.profile-tab-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.profile-tab-btn.active {
  color: #000;
  background: var(--accent-gold);
  border-color: var(--accent-gold);
  font-weight: 700;
  box-shadow: 0 0 14px var(--accent-gold-glow);
  transform: none;
}

/* Tab Panes - Only Pane Scrolls */
.profile-tab-pane {
  display: none;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  flex-direction: column;
  gap: 14px;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(245, 158, 11, 0.3) rgba(255, 255, 255, 0.03);
}

.profile-tab-pane::-webkit-scrollbar {
  width: 5px;
}

.profile-tab-pane::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 4px;
}

.profile-tab-pane::-webkit-scrollbar-thumb {
  background: var(--accent-gold);
  border-radius: 4px;
}

.profile-tab-pane.active {
  display: flex;
}

/* Lore Cards */
.lore-section-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lore-section-title {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--accent-gold);
  display: flex;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.lore-text {
  font-size: 0.85rem;
  line-height: 1.65;
  color: #d1d5db;
  white-space: pre-wrap;
  word-break: break-word;
}

.code-block-box {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.78rem;
  line-height: 1.5;
  color: #93c5fd;
  white-space: pre-wrap;
  overflow-x: auto;
  user-select: text;
  max-height: 400px;
}


/* ---- v4 additions: toasts, scroll pill, swipe, safe-area ---- */
.toast-host { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 1000; width: min(92vw, 420px); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: rgba(15, 23, 42, 0.96); color: #f8fafc; border: 1px solid rgba(255,255,255,0.15); border-radius: 12px; padding: 10px 14px; font-size: 0.88rem; box-shadow: 0 8px 24px rgba(0,0,0,0.4); }
.toast button { background: none; border: none; color: #fbbf24; font-weight: 600; cursor: pointer; font-size: 0.88rem; }
.scroll-pill { position: absolute; left: 50%; bottom: 150px; transform: translateX(-50%); z-index: 20; background: #f59e0b; color: #0f172a; border: none; border-radius: 999px; padding: 6px 14px; font-weight: 600; font-size: 0.82rem; cursor: pointer; box-shadow: 0 4px 14px rgba(0,0,0,0.4); }
.send-btn.stop { background: #ef4444; }
.chat-input-bar { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
.swipe-bar { display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: 6px; }
.swipe-bar .swipe-btn { width: 32px; height: 28px; font-size: 0.95rem; }
.msg-bubble.char-bubble { touch-action: pan-y; }

/* ---- v4.1 mobile fixes: no horizontal page scroll ---- */
html, body { overflow-x: hidden; max-width: 100vw; }
#app-container { min-width: 0; overflow: hidden; }
#app-container > * { min-width: 0; max-width: 100%; }
.quick-action-bar { max-width: 100%; flex-shrink: 0; }
.control-bar { gap: 8px; }
.control-bar .length-selector { flex-shrink: 0; }
.control-bar .model-tag-select { flex: 1 1 0; min-width: 0; max-width: 100%; text-overflow: ellipsis; }

/* ---- v4.2 smoothness ---- */
* { -webkit-tap-highlight-color: transparent; }
button, .quick-chip, .length-opt, select { touch-action: manipulation; }
.message-row.enter { animation: rowIn 0.22s ease-out; }
.toast { animation: rowIn 0.2s ease-out; }
.modal-overlay { transition: opacity 0.18s ease; }
.msg-action-btn, .swipe-btn, .quick-chip, .send-btn { transition: background-color 0.15s ease, transform 0.12s ease, opacity 0.15s ease; }
.msg-action-btn:active, .swipe-btn:active, .quick-chip:active, .send-btn:active { transform: scale(0.95); }
#chat-messages { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
#user-input, .form-input { font-size: 16px; }
@keyframes rowIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---- Home / character selection ---- */
.home-screen {
  min-height: 100vh;
  padding: 48px 16px 32px;
  max-width: 720px;
  margin: 0 auto;
}
.home-title { font-size: 1.7rem; font-weight: 600; text-align: center; }
.home-sub { color: var(--text-muted); text-align: center; margin: 6px 0 28px; font-size: 0.92rem; }
.home-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .home-grid { grid-template-columns: 1fr 1fr; } }
.home-card {
  display: flex; gap: 14px; align-items: center; text-align: left;
  background: var(--bg-surface); color: var(--text-main);
  border: 1px solid var(--border-glass); border-radius: var(--radius-lg);
  padding: 14px; cursor: pointer; font-family: inherit;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.home-card:hover, .home-card:focus-visible { border-color: var(--border-gold); transform: translateY(-1px); outline: none; }
.home-card-avatar { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; flex: none; border: 2px solid var(--border-gold); background: var(--bg-dark); }
.home-card-body { min-width: 0; }
.home-card-name { font-size: 1.1rem; font-weight: 600; }
.home-card-tagline { color: var(--text-muted); font-size: 0.82rem; margin: 3px 0 6px; }
.home-card-status { color: var(--accent-gold); font-size: 0.78rem; }
#home-btn { margin-right: 6px; font-size: 1.15rem; line-height: 1; }
