/* Design System - xAI Storyteller Studio */

:root {
  --bg-color: #000000;
  --bg-workspace: #09090b;
  --card-bg: #18181b;
  --card-border: rgba(255, 255, 255, 0.08);
  --card-hover-border: rgba(255, 255, 255, 0.16);
  --text-main: #f4f4f5;
  --text-muted: #a1a1aa;
  --primary-color: #ffffff;
  --primary-glow: rgba(255, 255, 255, 0.05);
  --accent-color: #19e68c; /* Grok Signature Green */
  --accent-glow: rgba(25, 230, 140, 0.15);
  --gold-color: #eab308; /* solid gold */
  --gold-glow: rgba(234, 179, 8, 0.15);
  --user-msg-bg: #27272a;
  --bot-msg-bg: transparent;
  --font-title: 'Plus Jakarta Sans', sans-serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(99, 91, 137, 0.3) transparent;
}

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font-body);
  height: 100vh;
  overflow: hidden;
  display: flex;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(99, 91, 137, 0.3);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 242, 254, 0.4);
}

/* App Container */
.app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  position: relative;
}

/* Sidebar: Character Manager */
.sidebar {
  width: 320px;
  background-color: var(--bg-color);
  border-right: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 24px;
  border-bottom: 1px solid var(--card-border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-title);
  font-weight: 900;
  font-size: 1.25rem;
  letter-spacing: 1.5px;
  color: var(--text-main);
  text-shadow: 0 0 10px rgba(0, 242, 254, 0.2);
}

.glow-icon {
  color: var(--accent-color);
  filter: drop-shadow(0 0 8px var(--accent-glow));
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.section-title {
  font-family: var(--font-title);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

/* Form Controls */
input[type="text"], select, textarea {
  background: #18181b;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.9rem;
  transition: all 0.2s ease;
  width: 100%;
  outline: none;
}

input[type="text"]:focus, select:focus, textarea:focus {
  border-color: rgba(255, 255, 255, 0.2);
  background: #18181b;
  box-shadow: none;
}

textarea {
  resize: none;
}

/* Buttons */
.btn {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 8px;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-primary {
  background: #ffffff;
  color: #000000;
  font-weight: 700;
}

.btn-primary:hover {
  background: var(--accent-color);
  color: #000000;
  box-shadow: 0 0 15px rgba(25, 230, 140, 0.2);
}

.btn-accent {
  background: rgba(25, 230, 140, 0.1);
  border: 1px solid rgba(25, 230, 140, 0.3);
  color: var(--accent-color);
  font-weight: 700;
}

.btn-accent:hover {
  background: var(--accent-color);
  color: #000000;
  box-shadow: 0 0 15px rgba(25, 230, 140, 0.2);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
}

.mt-4 { margin-top: 1.5rem; }
.mt-3 { margin-top: 1rem; }

/* Character List */
.characters-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.empty-list-message {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
  text-align: center;
  padding: 16px;
  background: rgba(18, 15, 32, 0.3);
  border-radius: 8px;
  border: 1px dashed var(--card-border);
}

.character-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.character-card:hover {
  border-color: var(--accent-color);
  box-shadow: 0 0 10px rgba(0, 242, 254, 0.15);
}

.character-card.active {
  border-color: var(--gold-color);
  box-shadow: 0 0 12px rgba(247, 176, 91, 0.25);
  background: rgba(247, 176, 91, 0.05);
}

.character-card.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--gold-color);
}

.char-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.char-card-name {
  font-family: var(--font-title);
  font-size: 0.9rem;
  font-weight: 700;
}

.char-card-archetype {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.char-card-actions {
  display: flex;
  gap: 8px;
}

.char-btn-delete {
  background: transparent;
  border: none;
  color: #ff4d4d;
  cursor: pointer;
  font-size: 0.8rem;
  opacity: 0.6;
  transition: all 0.2s;
}

.char-btn-delete:hover {
  opacity: 1;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--card-border);
  background: rgba(6, 5, 11, 0.5);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: #2ec4b6;
  border-radius: 50%;
  box-shadow: 0 0 8px #2ec4b6;
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.9); opacity: 0.6; }
  50% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.6; }
}

/* Main Workspace Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-workspace);
}

/* App Header & Navigation */
.app-header {
  height: 64px;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
  background: rgba(11, 9, 20, 0.8);
  backdrop-filter: blur(10px);
}

.nav-tabs {
  display: flex;
  gap: 8px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.15rem;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
  color: var(--accent-color);
  background: rgba(25, 230, 140, 0.1);
  box-shadow: inset 0 0 0 1px rgba(25, 230, 140, 0.25);
}

.btn-voice {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
}

/* Tab Content */
.tab-container {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.tab-content {
  display: none;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
}

.tab-content.active {
  display: flex;
  flex-direction: column;
}

/* Chat Area Layout */
.chat-area {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Grok Landing / Welcome Layout */
.grok-welcome-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex: 1;
  padding: 40px 20px;
  max-width: 600px;
  margin: 10% auto 0 auto;
  animation: messageIn 0.4s cubic-bezier(0.1, 0.9, 0.2, 1) forwards;
}

.grok-slash-logo {
  font-family: var(--font-body);
  font-size: 6rem;
  font-weight: 800;
  color: var(--accent-color);
  line-height: 1;
  text-shadow: 0 0 25px rgba(25, 230, 140, 0.2);
  margin-bottom: 16px;
  user-select: none;
  font-style: italic;
}

.grok-welcome-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.5px;
  margin-bottom: 12px;
}

.grok-welcome-subtitle {
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 32px;
}

.grok-quick-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  width: 100%;
}

.quick-action-btn {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 10px 20px;
  color: var(--text-main);
  font-size: 0.82rem;
  font-family: var(--font-body);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.quick-action-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

/* Chat Message Bubbles */
.message {
  display: flex;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  gap: 16px;
  padding: 18px 0;
  animation: messageIn 0.3s cubic-bezier(0.1, 0.9, 0.2, 1) forwards;
}

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

.message.user {
  flex-direction: row-reverse;
}

.message-content {
  line-height: 1.6;
  font-size: 0.96rem;
  flex: 1;
}

.message.user .message-content {
  background-color: var(--user-msg-bg);
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 18px;
  border-top-right-radius: 4px;
  padding: 12px 18px;
  max-width: 70%;
  flex-grow: 0;
}

.message.bot .message-content {
  background-color: transparent;
  color: var(--text-main);
  border: none;
  box-shadow: none;
  padding: 0;
  max-width: 100%;
}

/* Grok Avatar Icon for Bot responses */
.message.bot::before {
  content: '/';
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(25, 230, 140, 0.08);
  border: 1px solid rgba(25, 230, 140, 0.2);
  color: var(--accent-color);
  font-family: var(--font-body);
  font-style: italic;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
  user-select: none;
}

.message-content h3 {
  font-family: var(--font-body);
  font-size: 1.1rem;
  margin-bottom: 8px;
  color: var(--accent-color);
}

.message-content p {
  margin-bottom: 12px;
}
.message-content p:last-child {
  margin-bottom: 0;
}

.message-actions {
  display: flex;
  gap: 12px;
  margin-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  padding-top: 8px;
}

.btn-msg-action {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.72rem;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-msg-action:hover {
  color: var(--accent-color);
}

/* Chat Input Bar */
.chat-input-wrapper {
  padding: 16px 24px 28px 24px;
  border-top: none;
  background: linear-gradient(to top, var(--bg-workspace) 80%, transparent 100%);
  width: 100%;
}

.attachment-preview {
  display: inline-flex;
  position: relative;
  margin-bottom: 12px;
  margin-left: calc(50% - 380px); /* Align with centered composer */
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--accent-color);
  box-shadow: 0 0 10px var(--accent-glow);
}

@media (max-width: 800px) {
  .attachment-preview {
    margin-left: 0;
  }
}

.attachment-preview img {
  max-height: 80px;
  max-width: 140px;
  object-fit: cover;
}

.btn-close-attachment {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  border: none;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.7rem;
}

.chat-form {
  background: #121214;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  display: flex;
  align-items: center;
  padding: 10px 16px;
  gap: 12px;
  max-width: 760px;
  margin: 0 auto;
  transition: border-color 0.25s, box-shadow 0.25s;
}

.chat-form:focus-within {
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.03);
}

.chat-form textarea {
  flex: 1;
  background: transparent;
  border: none;
  padding: 8px 4px;
  min-height: 24px;
  max-height: 120px;
  box-shadow: none;
  outline: none;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.96rem;
  line-height: 1.5;
  resize: none;
}

.btn-attach-image, .btn-mic {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-muted);
  border: none;
  background: transparent;
}

.btn-attach-image:hover, .btn-mic:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

.btn-mic.recording {
  color: #ff4d4d;
  background: rgba(255, 77, 77, 0.1);
  animation: heartbeat 1.5s infinite;
}

@keyframes heartbeat {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

.btn-send {
  background: #ffffff;
  color: #000000;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  transition: transform 0.2s, background 0.2s;
  flex-shrink: 0;
}

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

.hidden { display: none !important; }

/* Split Layout for Labs */
.split-layout {
  display: flex;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.card {
  flex: 1;
  background-color: var(--bg-workspace);
  border-right: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  padding: 24px;
  overflow-y: auto;
}

.card:last-child {
  border-right: none;
}

.card h3 {
  font-family: var(--font-title);
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 1px;
}

.card-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

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

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

/* Suggestion Tags */
.prompt-suggestions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.suggestion-tag {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: rgba(99, 91, 137, 0.15);
  border: 1px solid var(--card-border);
  padding: 4px 10px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
}

.suggestion-tag:hover {
  color: var(--accent-color);
  border-color: var(--accent-color);
  background: rgba(0, 242, 254, 0.05);
}

/* Character Injector Style */
.character-injector-box {
  background: rgba(18, 15, 32, 0.4);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 12px;
}

.checkbox-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox-wrapper input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-color);
}

.checkbox-wrapper label {
  color: var(--text-main);
  font-size: 0.85rem;
  cursor: pointer;
}

.inject-info {
  font-size: 0.75rem;
  margin-top: 6px;
  color: var(--gold-color);
  padding-left: 26px;
}

/* Output Display Cards */
.output-card {
  background: #09080f;
}

.output-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.output-preview {
  flex: 1;
  background: rgba(11, 9, 20, 0.6);
  border: 2px dashed var(--card-border);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  min-height: 300px;
}

.preview-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--text-muted);
  text-align: center;
  padding: 24px;
}

.placeholder-icon {
  font-size: 3rem;
  color: rgba(99, 91, 137, 0.4);
}

.output-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.output-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

/* Image Uploader Card-box */
.image-uploader, .video-uploader {
  height: 180px;
  border: 2px dashed var(--card-border);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.25s;
  background: rgba(18, 15, 32, 0.2);
}

.image-uploader:hover, .video-uploader:hover {
  border-color: var(--accent-color);
  background: rgba(0, 242, 254, 0.03);
}

.uploader-content {
  text-align: center;
  color: var(--text-muted);
}

.uploader-content i {
  font-size: 2rem;
  margin-bottom: 8px;
}

.uploaded-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
}

.file-input-hidden {
  position: absolute;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 3;
}

/* Video Frame Extraction display */
.extracted-frames-panel {
  margin-top: 16px;
  border-top: 1px solid var(--card-border);
  padding-top: 16px;
}

.frames-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.frame-thumb {
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: 4px;
  border: 1px solid var(--card-border);
  object-fit: cover;
}

.card-dark {
  background: rgba(11, 9, 20, 0.6);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 16px;
}

.analysis-output {
  max-height: 250px;
  overflow-y: auto;
}

.analysis-text {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-main);
  margin-top: 8px;
}

/* Voice companion overlay */
.voice-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at center, rgba(16, 12, 33, 0.98) 0%, rgba(6, 5, 11, 0.99) 100%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 40px;
  backdrop-filter: blur(12px);
  animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.voice-overlay-header {
  display: flex;
  justify-content: flex-end;
}

.btn-close-overlay {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  font-family: var(--font-title);
  font-size: 0.8rem;
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.25s;
}

.btn-close-overlay:hover {
  color: var(--text-main);
  background: rgba(255, 77, 77, 0.1);
  border-color: #ff4d4d;
}

.voice-overlay-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 30px;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

/* Orb Canvas & animations */
.orb-container {
  position: relative;
  width: 320px;
  height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#orb-canvas {
  width: 100%;
  height: 100%;
  z-index: 5;
  filter: filter(url(#organic-blob));
}

.orb-backdrop-glow {
  position: absolute;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-color) 0%, var(--primary-color) 60%, transparent 100%);
  filter: blur(40px);
  opacity: 0.35;
  z-index: 2;
  transition: all 0.4s;
}

.voice-status-box {
  text-align: center;
}

.voice-status-box h2 {
  font-family: var(--font-title);
  font-size: 2rem;
  letter-spacing: 2px;
  color: var(--text-main);
  text-shadow: 0 0 15px rgba(255, 255, 255, 0.1);
  text-transform: uppercase;
}

.voice-subtext {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Real-time speech transcription bubbles */
.transcription-container {
  width: 100%;
  min-height: 100px;
  max-height: 200px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 10px 24px;
}

.voice-bubble {
  padding: 10px 16px;
  border-radius: 20px;
  max-width: 80%;
  font-size: 0.95rem;
  line-height: 1.4;
  animation: bubbleIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes bubbleIn {
  from { opacity: 0; transform: scale(0.8) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.voice-bubble.user-bubble {
  background: rgba(0, 242, 254, 0.1);
  border: 1px solid rgba(0, 242, 254, 0.25);
  color: var(--accent-color);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.voice-bubble.bot-bubble {
  background: rgba(123, 44, 191, 0.12);
  border: 1px solid rgba(123, 44, 191, 0.35);
  color: var(--text-main);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

/* Control buttons below orb */
.voice-controls {
  display: flex;
  gap: 20px;
  margin-top: 10px;
}

.btn-voice-ctrl {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s;
}

.btn-voice-ctrl:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
}

.btn-voice-ctrl.active {
  background: rgba(0, 242, 254, 0.08);
  border-color: var(--accent-color);
  color: var(--accent-color);
  box-shadow: 0 0 10px var(--accent-glow);
}

.btn-voice-ctrl.active:nth-child(2) {
  background: rgba(247, 176, 91, 0.08);
  border-color: var(--gold-color);
  color: var(--gold-color);
  box-shadow: 0 0 10px var(--gold-glow);
}

.btn-voice-ctrl.muted {
  border-color: #ff4d4d;
  color: #ff4d4d;
  background: rgba(255, 77, 77, 0.05);
}

/* inline styling image */
.inline-image {
  max-width: 100%;
  border-radius: 8px;
  margin-top: 10px;
  border: 1px solid var(--card-border);
}
.inline-video {
  max-width: 100%;
  border-radius: 8px;
  margin-top: 10px;
  border: 1px solid var(--card-border);
}

/* ----------------------------------------------------
   iOS Web App & Mobile Layout Optimizations
   ---------------------------------------------------- */
:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

/* Base resets for iOS standalone application view */
html, body {
  position: fixed;
  width: 100%;
  height: 100%;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
}

/* Disable drag selects to feel native */
.sidebar-header, 
.nav-tabs, 
.btn, 
.tab-btn, 
.btn-mode,
.voice-overlay-header, 
.btn-voice-ctrl, 
.logo {
  -webkit-user-select: none;
  user-select: none;
}

/* Page boundaries offset for notches and virtual home indicator */
.app-container {
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

.sidebar {
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

.app-header {
  padding-top: calc(var(--safe-top) + 8px);
  height: auto !important;
  min-height: calc(64px + var(--safe-top));
}

.chat-input-wrapper {
  padding-bottom: calc(var(--safe-bottom) + 16px);
}

.voice-overlay {
  padding-top: calc(var(--safe-top) + 24px);
  padding-bottom: calc(var(--safe-bottom) + 24px);
  padding-left: calc(var(--safe-left) + 24px);
  padding-right: calc(var(--safe-right) + 24px);
}

/* Smooth kinetic scrolling for lists */
.sidebar-content, 
.chat-messages, 
.card, 
.transcription-container, 
.analysis-output {
  -webkit-overflow-scrolling: touch;
}

/* Hide desktop-only UI or toggle button by default */
.mobile-only {
  display: none !important;
}

/* Chat Mode Switcher styling */
.chat-mode-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.mode-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--font-title);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-right: 4px;
}

.btn-mode {
  background: rgba(99, 91, 137, 0.12);
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-family: var(--font-title);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-mode:hover {
  color: var(--text-main);
  background: rgba(99, 91, 137, 0.25);
}

.btn-mode.active {
  background: rgba(0, 242, 254, 0.08);
  border-color: var(--accent-color);
  color: var(--accent-color);
  box-shadow: 0 0 10px rgba(0, 242, 254, 0.15);
}

/* ----------------------------------------------------
   Responsive Layout overrides for Mobile & Tablet
   ---------------------------------------------------- */
@media (max-width: 768px) {
  .mobile-only {
    display: inline-flex !important;
  }

  .app-container {
    flex-direction: column;
    overflow: hidden;
  }

  /* Slide-out Sidebar Drawer */
  .sidebar {
    position: absolute;
    top: 0;
    left: -100%;
    width: 85%;
    max-width: 320px;
    height: 100%;
    z-index: 120;
    box-shadow: 5px 0 25px rgba(0, 0, 0, 0.9);
    transition: left 0.3s cubic-bezier(0.1, 0.9, 0.2, 1);
    background-color: #000000;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
  }

  .app-container.sidebar-open .sidebar {
    left: 0;
  }

  /* Dark Overlay for mobile slide-out */
  .sidebar-overlay {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(5px);
    z-index: 110;
  }

  .app-container.sidebar-open .sidebar-overlay {
    display: block;
  }

  /* Compact layout for mobile header and navigation tabs */
  .app-header {
    padding-left: 16px;
    padding-right: 16px;
    gap: 12px;
  }

  .nav-tabs {
    gap: 4px;
    overflow-x: auto;
    mask-image: linear-gradient(to right, black 85%, transparent 100%);
    -webkit-mask-image: linear-gradient(to right, black 85%, transparent 100%);
    padding-bottom: 4px;
    scrollbar-width: none;
    flex: 1;
  }
  
  .nav-tabs::-webkit-scrollbar {
    display: none;
  }

  .tab-btn {
    width: 38px;
    height: 38px;
    font-size: 1.1rem;
  }

  .btn-voice {
    width: 38px;
    height: 38px;
    font-size: 1.1rem;
  }

  /* Workspace card splits stack vertically */
  .split-layout {
    flex-direction: column;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    height: 100%;
  }

  .card {
    border-right: none !important;
    border-bottom: 1px solid var(--card-border);
    overflow-y: visible;
    flex-shrink: 0;
    padding: 18px;
    min-height: auto;
  }

  .card:last-child {
    border-bottom: none;
  }

  /* Responsive image previews */
  .output-preview {
    min-height: 200px;
  }

  .frames-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .voice-overlay-content {
    gap: 16px;
  }

  .orb-container {
    width: 260px;
    height: 260px;
  }

  .orb-backdrop-glow {
    width: 180px;
    height: 180px;
  }

  .voice-status-box h2 {
    font-size: 1.6rem;
  }
}

/* Glassmorphic hover overlay for images/video preview actions */
.output-preview {
  position: relative;
  background: #0d0d10;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  overflow: hidden;
}

.output-actions-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.3) 60%, rgba(0, 0, 0, 0) 100%);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px;
  opacity: 0;
  transform: translateY(15px);
  transition: all 0.3s cubic-bezier(0.1, 0.9, 0.2, 1);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 10;
}

.output-preview:hover .output-actions-overlay,
.output-actions-overlay:hover,
.output-preview:active .output-actions-overlay {
  opacity: 1;
  transform: translateY(0);
}

.output-actions-overlay.hidden {
  display: none !important;
}

.output-actions-overlay .btn {
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 0.76rem;
}

/* Collapsible sidebar form */
.sidebar-form {
  transition: max-height 0.3s cubic-bezier(0.1, 0.9, 0.2, 1), opacity 0.2s ease, margin 0.3s cubic-bezier(0.1, 0.9, 0.2, 1), padding 0.3s cubic-bezier(0.1, 0.9, 0.2, 1);
  max-height: 500px;
  opacity: 1;
  overflow: hidden;
  margin-top: 12px;
}

.sidebar-form.collapsed {
  max-height: 0 !important;
  opacity: 0 !important;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  pointer-events: none;
}

/* Collapsible icon animation */
.collapsible-trigger .toggle-icon {
  transition: transform 0.2s cubic-bezier(0.1, 0.9, 0.2, 1);
}

/* Chat History elements styling */
.chat-history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
  max-height: 240px;
  overflow-y: auto;
  scrollbar-width: none;
}

.chat-history-list::-webkit-scrollbar {
  display: none;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.history-item:hover, .history-item.active {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.history-item .history-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-right: 8px;
}

.history-item .btn-delete-history {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.15s;
}

.history-item .btn-delete-history:hover {
  color: #ff4d4d;
  background: rgba(255, 77, 77, 0.12);
}

/* Security password gateway overlay */
.password-gateway {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #000000;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 0.5s cubic-bezier(0.1, 0.9, 0.2, 1);
}

.password-gateway.fade-out {
  opacity: 0;
  pointer-events: none;
}

.gateway-content {
  background: #09090b;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 40px;
  width: 90%;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9);
}

.gateway-logo {
  font-family: var(--font-title);
  font-size: 3rem;
  font-weight: 850;
  color: var(--accent-color);
  margin-bottom: 20px;
  user-select: none;
}

.gateway-content h2 {
  font-family: var(--font-title);
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 8px;
}

.gateway-content p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.gateway-content input[type="password"] {
  background: #18181b;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 12px 16px;
  color: #fff;
  font-size: 1rem;
  width: 100%;
  text-align: center;
  outline: none;
  transition: all 0.2s;
}

.gateway-content input[type="password"]:focus {
  border-color: rgba(255, 255, 255, 0.2);
}

.gateway-error {
  color: #ff4d4d;
  font-size: 0.85rem;
  margin-top: 16px;
  font-weight: 600;
}

/* Creations Gallery tab styles */
.gallery-container {
  padding: 24px;
  max-width: 1200px;
  margin: 0 auto;
  height: 100%;
  overflow-y: auto;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  margin-top: 20px;
  padding-bottom: 40px;
}

.gallery-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.2s ease;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.gallery-card:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 255, 255, 0.2);
}

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

.gallery-card-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.4) 70%, transparent 100%);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.gallery-card:hover .gallery-card-overlay {
  opacity: 1;
  transform: translateY(0);
}

.gallery-card-prompt {
  font-size: 0.75rem;
  color: #e4e4e7;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.4;
}

.gallery-card-actions {
  display: flex;
  gap: 8px;
}

.gallery-card-actions .btn {
  padding: 6px 10px;
  font-size: 0.75rem;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.gallery-card-actions a.btn {
  color: #fff;
  text-decoration: none;
}

.gallery-empty i {
  color: rgba(255, 255, 255, 0.15) !important;
}

/* Imagine Mode Active State */
.btn-attach-image.active {
  color: var(--accent-color) !important;
  background: rgba(168, 85, 247, 0.15) !important;
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.4);
}

/* 4-Image Grid in Chat */
.chat-image-grid-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
  max-width: 100%;
}

.chat-image-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  width: 100%;
}

.chat-grid-card {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
  background: var(--bg-card);
}

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

.chat-grid-card-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 8px 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.grid-card-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255,255,255,0.15);
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.85rem;
}

.grid-card-btn:hover {
  background: var(--accent-color);
  border-color: var(--accent-color);
  transform: scale(1.1);
}

.grid-card-btn.liked {
  color: #ff4d4d;
  background: rgba(255, 77, 77, 0.15);
  border-color: #ff4d4d;
}

.grid-card-btn.liked i {
  font-weight: 900;
}

.chat-grid-controls {
  display: flex;
  gap: 8px;
  justify-content: flex-start;
  margin-top: 4px;
}

.chat-grid-controls .btn {
  padding: 6px 12px;
  font-size: 0.75rem;
  border-radius: 20px;
}
