/* CSS Variables - Ropilot Theme */
:root {
  /* Backgrounds - Dark theme with transparency for blur effect */
  /* These values work with system-level blur (Windows acrylic, macOS vibrancy) */
  --bg-primary: rgba(9, 9, 11, 0.75);
  --bg-secondary: rgba(24, 24, 27, 0.70);
  --bg-tertiary: rgba(28, 28, 31, 0.65);
  --bg-hover: rgba(39, 39, 42, 0.65);
  --bg-active: rgba(52, 52, 56, 0.65);

  /* Text colors */
  --text-primary: #fafafa;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;

  /* Accent colors - Orange theme */
  --accent: #f97316;
  --accent-hover: #ea580c;
  --accent-light: #fb923c;
  --accent-glow: rgba(249, 115, 22, 0.25);
  --accent-gradient: linear-gradient(135deg, #f97316 0%, #eab308 100%);

  /* Borders */
  --border: rgba(255, 255, 255, 0.06);
  --border-light: rgba(255, 255, 255, 0.1);
  --border-focus: rgba(249, 115, 22, 0.5);
  --border-accent: rgba(249, 115, 22, 0.3);

  /* Status colors */
  --success: #22c55e;
  --warning: #eab308;
  --error: #ef4444;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-accent: 0 8px 30px -8px rgba(249, 115, 22, 0.5);

  /* Border radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  /* Layout */
  --titlebar-height: 44px;
  --sidebar-width: 280px;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Monaco', monospace;
}

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

/* Base */
html, body {
  height: 100%;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: transparent;
  overflow: hidden;
  /* Allow text selection globally - Electron apps sometimes block it */
  -webkit-user-select: text;
  user-select: text;
}

/* Allow text selection in messages - nuclear option for Electron */
.messages,
.messages *,
.message,
.message *,
.message-wrapper,
.message-wrapper *,
.message-content,
.message-content *,
.message.user,
.message.user * {
  -webkit-user-select: text !important;
  user-select: text !important;
  -webkit-user-drag: none !important;
}

.message-content {
  cursor: text;
}

/* Buttons should not be selectable */
.message-edit-btn,
.message-edit-btn *,
button,
button * {
  -webkit-user-select: none !important;
  user-select: none !important;
}

/* App Container */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--bg-primary);
  border-radius: 0;
  border: 1px solid var(--border);
  overflow: hidden;
  position: relative;
  -webkit-user-select: text;
  user-select: text;
}

/* Windows 11: Acrylic blur is handled by Electron's backgroundMaterial
   The semi-transparent bg-primary allows the blur to show through */
body.win11-acrylic .app {
  background: var(--bg-primary);
}

/* Windows 10: Use CSS backdrop-filter as fallback */
body.win10-fallback .app {
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
}

/* macOS: Vibrancy is handled by Electron, just need transparent backgrounds */
body.platform-darwin .app {
  background: var(--bg-primary);
}

/* Linux: Use CSS backdrop-filter (depends on compositor support) */
body.platform-linux .app {
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
}

/* Subtle background glow - matches website aesthetic */
.app::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -25%;
  width: 50%;
  height: 100%;
  background: radial-gradient(circle, rgba(249, 115, 22, 0.08) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

.app::after {
  content: '';
  position: absolute;
  bottom: -30%;
  right: -20%;
  width: 40%;
  height: 80%;
  background: radial-gradient(circle, rgba(234, 179, 8, 0.05) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

.app > * {
  position: relative;
  z-index: 1;
}

/* Title Bar */
.titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--titlebar-height);
  padding: 0 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  -webkit-app-region: drag;
}

.titlebar-drag {
  flex: 1;
  display: flex;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 70px; /* Space for traffic lights on macOS */
}

.logo-icon {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  box-shadow:
    0 0 12px 2px rgba(249, 115, 22, 0.15),
    0 0 24px 4px rgba(249, 115, 22, 0.06);
  object-fit: contain;
}

.logo-text {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.logo-text .logo-accent {
  color: var(--accent);
}

/* Gradient text - matches website branding */
.logo-text .gradient-text {
  color: #f97316; /* Fallback for unsupported browsers */
  background: linear-gradient(135deg, #f97316 0%, #eab308 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: inline-block;
}

.titlebar-controls {
  display: flex;
  gap: 8px;
  -webkit-app-region: no-drag;
}

.titlebar-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.titlebar-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.titlebar-btn.btn-close:hover {
  background: var(--error);
  color: white;
}

.titlebar-btn svg {
  width: 12px;
  height: 12px;
  fill: currentColor;
}

/* Main Content */
.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
  -webkit-app-region: no-drag;
  -webkit-user-select: text;
  user-select: text;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  transition: width 0.25s ease, min-width 0.25s ease, opacity 0.25s ease;
  overflow: hidden;
}

.sidebar.collapsed {
  width: 0;
  min-width: 0;
  border-right: none;
}

.sidebar.collapsed .sidebar-header,
.sidebar.collapsed .chat-list,
.sidebar.collapsed .sidebar-footer {
  opacity: 0;
  pointer-events: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  padding: 12px 12px 12px 16px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}

.sidebar-header .sidebar-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  flex: 1;
}

.sidebar-header .btn-icon {
  width: 32px;
  height: 32px;
}

.sidebar-header .btn-icon svg {
  width: 16px;
  height: 16px;
}

.btn-collapse {
  flex-shrink: 0;
}

.btn-collapse svg {
  transition: transform 0.2s ease;
}

/* Expand sidebar button (floating) */
.btn-expand-sidebar {
  position: fixed;
  left: 12px;
  top: calc(var(--titlebar-height) + 12px);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  z-index: 50;
}

.btn-expand-sidebar:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-accent);
}

.btn-expand-sidebar svg {
  width: 18px;
  height: 18px;
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

/* Project Folders */
.project-folder {
  margin-bottom: 4px;
}

.project-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.project-header:hover {
  background: var(--bg-hover);
}

.project-header.active {
  background: var(--bg-active);
  border-color: var(--border-accent);
}

.project-expand-btn {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.project-expand-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.project-expand-btn svg {
  width: 14px;
  height: 14px;
  transition: transform 0.2s ease;
}

.project-folder.expanded .project-expand-btn svg {
  transform: rotate(90deg);
}

.project-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(249, 115, 22, 0.1);
  border-radius: var(--radius-sm);
  color: var(--accent);
  flex-shrink: 0;
}

.project-icon svg {
  width: 16px;
  height: 16px;
}

.project-name {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-name-input {
  flex: 1;
  min-width: 0;
  padding: 4px 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  outline: none;
}

.project-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.project-header:hover .project-actions {
  opacity: 1;
}

.project-add-chat-btn,
.project-menu-btn {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.project-add-chat-btn:hover,
.project-menu-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.project-add-chat-btn svg,
.project-menu-btn svg {
  width: 14px;
  height: 14px;
}

.project-chats {
  display: none;
  padding-left: 20px;
}

.project-folder.expanded .project-chats {
  display: block;
}

.project-empty {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

/* Project Context Menu */
.project-context-menu {
  min-width: 140px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 4px;
  z-index: 200;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}

.menu-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.menu-item svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.menu-item-danger:hover {
  background: rgba(239, 68, 68, 0.15);
  color: var(--error);
}

/* Chat Items (within projects) */
.chat-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin: 2px 0;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chat-item:hover {
  background: var(--bg-hover);
  border-color: var(--border-accent);
}

.chat-item.active {
  background: var(--bg-active);
  border-color: var(--border-accent);
}

.chat-item-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(249, 115, 22, 0.08);
  border-radius: var(--radius-sm);
  color: var(--accent-light);
  flex-shrink: 0;
}

.chat-item-icon svg {
  width: 16px;
  height: 16px;
}

.chat-item-content {
  flex: 1;
  min-width: 0;
}

.chat-item-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-preview {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-delete {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.chat-item:hover .chat-item-delete {
  opacity: 1;
}

.chat-item-delete:hover {
  background: var(--error);
  color: white;
}

.chat-item-delete svg {
  width: 12px;
  height: 12px;
}

/* Chat name editing */
.chat-item.editing {
  background: var(--bg-active);
}

.chat-name-input {
  width: 100%;
  padding: 4px 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  outline: none;
  box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.15);
}

.chat-item-title {
  cursor: default;
}

/* Double-click hint on hover */
.chat-item:hover .chat-item-title {
  cursor: text;
}

/* Chat item processing spinner */
.chat-item-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(249, 115, 22, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

.chat-item.processing .chat-item-delete {
  display: none;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}

/* Chat Area */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  -webkit-user-select: text;
  user-select: text;
}

/* Setup Screen */
.setup-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.setup-content {
  text-align: center;
  max-width: 500px;
}

.setup-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
}

.setup-icon.warning {
  background: rgba(234, 179, 8, 0.15);
  color: var(--warning);
  border: 1px solid rgba(234, 179, 8, 0.3);
}

.setup-icon svg {
  width: 36px;
  height: 36px;
}

.setup-content h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.setup-content > p {
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.setup-steps {
  text-align: left;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 24px;
}

.setup-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
}

.setup-step:not(:last-child) {
  border-bottom: 1px solid var(--border);
}

.step-number {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
  box-shadow: 0 0 12px rgba(249, 115, 22, 0.3);
}

.step-content {
  flex: 1;
}

.step-content strong {
  display: block;
  margin-bottom: 4px;
}

.step-content code {
  display: block;
  background: rgba(0, 0, 0, 0.3);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-secondary);
  user-select: all;
}

.setup-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.setup-actions .btn-primary {
  min-width: 160px;
  position: relative;
}

.setup-actions .btn-spinner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.setup-actions .btn-spinner.hidden {
  display: none;
}

.setup-actions .btn-text.hidden {
  display: none;
}

.setup-actions .spinner {
  width: 18px;
  height: 18px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Setup prereq notice */
.setup-prereq {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 16px;
}

.setup-prereq .prereq-label {
  display: inline-block;
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 4px;
  margin-bottom: 8px;
}

.setup-prereq p {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
}

.setup-prereq a {
  color: #60a5fa;
  text-decoration: none;
}

.setup-prereq a:hover {
  text-decoration: underline;
}

/* Step description */
.step-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 2px 0 8px 0;
}

/* Setup status indicators */
.setup-status {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-bottom: 24px;
  padding: 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
}

.setup-status.hidden {
  display: none;
}

.setup-status-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.status-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.status-icon svg {
  width: 16px;
  height: 16px;
}

.status-icon.pending {
  color: var(--text-secondary);
}

.status-icon.checking {
  color: var(--accent);
  animation: pulse 1s ease-in-out infinite;
}

.status-icon.success {
  color: #22c55e;
}

.status-icon.error {
  color: #ef4444;
}

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

.status-label {
  font-weight: 500;
}

.status-result {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 12px;
}

/* Setup help link */
.setup-help {
  margin-top: 24px;
  text-align: center;
}

.setup-help p {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
}

.setup-help a {
  color: var(--accent);
  text-decoration: none;
}

.setup-help a:hover {
  text-decoration: underline;
}

.setup-help .relaunch-note {
  font-size: 12px;
  color: var(--text-tertiary);
  font-style: italic;
}

.download-link {
  color: var(--accent);
  font-weight: 500;
  text-decoration: none;
}

.download-link:hover {
  text-decoration: underline;
}

/* Setup success state */
.setup-icon.success {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

/* Welcome Screen */
.welcome-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.welcome-content {
  text-align: center;
  max-width: 400px;
}

.welcome-logo {
  width: 80px;
  height: 80px;
  margin: 0 auto 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(249, 115, 22, 0.12);
  border: 1.5px solid rgba(249, 115, 22, 0.4);
  border-radius: var(--radius-lg);
  color: var(--accent);
  box-shadow:
    0 0 24px 4px rgba(249, 115, 22, 0.15),
    0 0 48px 8px rgba(249, 115, 22, 0.06),
    inset 0 0 12px rgba(249, 115, 22, 0.08);
}

.welcome-logo svg,
.welcome-logo img {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: contain;
}

.welcome-content h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.03em;
}

.welcome-content h1 .gradient-text {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome-content p {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.welcome-actions {
  display: flex;
  justify-content: center;
}

/* Chat View */
.chat-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0; /* Critical: allows flex child to shrink below content size */
  overflow: hidden;
}

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

/* Message Styles */
.message {
  max-width: 80%;
  animation: fadeIn 0.2s ease;
}

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

/* Subtle fade-up animation for streaming assistant responses */
@keyframes fadeUpStream {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.assistant.streaming .message-content {
  animation: fadeUpStream 0.25s ease-out forwards;
}

.message.user {
  align-self: flex-end;
  margin-left: auto;
}

.message.assistant {
  align-self: flex-start;
}

.message-content {
  font-size: 15px;
  line-height: 1.7;
}

.message.user .message-content {
  background: rgba(180, 80, 20, 0.85);
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 16px -4px rgba(180, 80, 20, 0.5);
  -webkit-user-select: text !important;
  user-select: text !important;
  cursor: text;
  pointer-events: auto;
}

/* Ensure all elements inside user message content are selectable */
.message.user .message-content,
.message.user .message-content * {
  -webkit-user-select: text !important;
  user-select: text !important;
}

/* Assistant messages - completely seamless, no visual container */
.message.assistant .message-content,
.message.emit .message-content,
.message.assistant.emit .message-content {
  background: none !important;
  background-color: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  outline: none !important;
  padding: 0 !important;
  margin: 0;
  color: var(--text-primary);
  user-select: text;
  cursor: text;
}

/* Status history messages - compact stacked hints */
.message-status {
  padding: 0;
  margin: 0;
}

.message-status + .message-status {
  margin-top: -4px; /* Reduce space between consecutive status items */
}

.message-status .message-content {
  padding: 4px 12px;
  background: transparent;
}

.status-content {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-secondary);
}

.status-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

.message-status.status-done .status-content {
  color: var(--text-secondary);
  opacity: 0.8;
}

.message-status.status-done .status-text {
  font-style: italic;
}

/* Status Bar (legacy) */
.status-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  background: var(--bg-tertiary);
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 13px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Input Area */
.input-area {
  padding: 10px 16px 12px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  position: relative;
  /* Subtle gradient overlay for depth */
  background-image: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.01) 0%,
    transparent 100%
  );
}

/* Input Options Row (Model + Auto Playtest) */
.input-options-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding-left: 2px;
  padding-right: 2px;
}

/* Model Selector */
.model-selector {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Auto Playtest Toggle */
.auto-playtest-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
}

.auto-playtest-toggle .toggle-label {
  font-size: 9px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.7;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 28px;
  height: 16px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 16px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 10px;
  width: 10px;
  left: 2px;
  bottom: 2px;
  background-color: var(--text-muted);
  border-radius: 50%;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--accent);
  border-color: var(--accent);
}

.toggle-switch input:checked + .toggle-slider:before {
  background-color: white;
  transform: translateX(12px);
}

.toggle-switch:hover .toggle-slider {
  border-color: var(--border-light);
}

.model-selector label {
  font-size: 9px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.7;
}

.model-selector select {
  padding: 4px 24px 4px 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 11px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
}

.model-selector select:hover {
  border-color: var(--border-light);
  color: var(--text-primary);
  background-color: var(--bg-hover);
  transform: translateY(-1px);
}

.model-selector select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.12);
  color: var(--text-primary);
  background-color: var(--bg-hover);
}

.model-selector select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
  padding: 10px;
}

.input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.input-wrapper {
  flex: 1;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  box-shadow:
    0 1px 4px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.input-wrapper::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: calc(var(--radius-md) + 1px);
  background: linear-gradient(135deg, rgba(249, 115, 22, 0) 0%, rgba(249, 115, 22, 0) 100%);
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
  z-index: -1;
}

.input-wrapper:hover {
  border-color: var(--border-light);
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow:
    0 0 0 2px rgba(249, 115, 22, 0.12),
    0 2px 8px rgba(0, 0, 0, 0.2);
  background: rgba(28, 28, 31, 0.9);
}

.input-wrapper:focus-within::before {
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.08) 0%, rgba(234, 179, 8, 0.04) 100%);
  opacity: 1;
}

textarea {
  width: 100%;
  height: 32px;
  min-height: 32px;
  max-height: 160px;
  padding: 6px 12px;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  line-height: 20px;
  resize: none;
  transition: height 0.2s ease;
  box-sizing: border-box;
}

textarea::placeholder {
  color: var(--text-muted);
  transition: all 0.2s ease;
  font-weight: 400;
}

.input-wrapper:hover textarea::placeholder {
  color: rgba(161, 161, 170, 0.8);
}

.input-wrapper:focus-within textarea::placeholder {
  color: var(--text-secondary);
}

/* Expanded textarea state */
textarea.expanded {
  padding-bottom: 10px;
}

/* Character count indicator (optional, for future use) */
.input-char-count {
  position: absolute;
  bottom: 8px;
  right: 12px;
  font-size: 10px;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.input-wrapper:focus-within .input-char-count {
  opacity: 0.6;
}

.input-char-count.warning {
  color: var(--warning);
}

.input-char-count.error {
  color: var(--error);
}

.input-info {
  margin-top: 6px;
  padding: 0 2px;
  font-size: 10px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.input-area:hover .input-info,
.input-area:focus-within .input-info {
  opacity: 1;
}

.input-info #project-dir-display {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.15s ease;
}

.input-info #project-dir-display:hover {
  color: var(--text-secondary);
}

.input-info #project-dir-display::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--success);
  opacity: 0.7;
  flex-shrink: 0;
  box-shadow: 0 0 4px rgba(34, 197, 94, 0.4);
}

.input-info #project-dir-display.no-project::before {
  background: var(--text-muted);
  box-shadow: none;
}

.input-hint {
  font-size: 9px;
  color: var(--text-muted);
  opacity: 0.6;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: opacity 0.2s ease;
}

.input-wrapper:focus-within ~ .input-info .input-hint {
  opacity: 1;
}

.input-hint kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 4px;
  min-width: 16px;
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 500;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: 3px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
  transition: all 0.15s ease;
}

.input-wrapper:focus-within ~ .input-info .input-hint kbd {
  background: var(--bg-hover);
  border-color: var(--border-accent);
}

.input-hint .hint-divider {
  color: var(--border-light);
  margin: 0 2px;
}

/* Buttons */
/* Input area icon button (folder select) */
.input-row .btn-icon {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.input-row .btn-icon::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(249, 115, 22, 0.1) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.input-row .btn-icon:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-light);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.input-row .btn-icon:hover::before {
  opacity: 1;
}

.input-row .btn-icon:active {
  background: var(--bg-active);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.input-row .btn-icon svg {
  width: 16px;
  height: 16px;
  transition: transform 0.2s ease;
}

/* Generic btn-icon (used elsewhere) */
.btn-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-icon svg {
  width: 20px;
  height: 20px;
}

/* Send button */
.btn-send {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-md);
  color: #fff;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  box-shadow:
    0 2px 6px rgba(249, 115, 22, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.btn-send::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 50%);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.btn-send::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.15) 0%, transparent 50%);
  opacity: 1;
}

.btn-send:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow:
    0 3px 10px rgba(249, 115, 22, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.btn-send:hover:not(:disabled)::before {
  opacity: 1;
}

.btn-send:active:not(:disabled) {
  box-shadow:
    0 1px 4px rgba(249, 115, 22, 0.3),
    inset 0 1px 2px rgba(0, 0, 0, 0.1);
  transition-duration: 0.1s;
}

.btn-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--bg-hover);
  color: var(--text-muted);
  box-shadow: none;
  transform: none;
}

.btn-send:disabled::before,
.btn-send:disabled::after {
  display: none;
}

/* Subtle pulse animation for enabled send button - disabled for compact mode */

.btn-send svg {
  width: 16px;
  height: 16px;
  transition: transform 0.2s ease;
  position: relative;
  z-index: 1;
}

/* Send button processing state */
.btn-send.processing {
  pointer-events: none;
  background: var(--accent);
  opacity: 0.85;
  animation: none;
}

.btn-send.processing svg {
  animation: sendPulse 1s ease-in-out infinite;
}

@keyframes sendPulse {
  0%, 100% {
    opacity: 0.6;
    transform: scale(0.92);
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
}

/* Ripple effect for send button click */
.btn-send .ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  transform: scale(0);
  animation: rippleEffect 0.5s ease-out forwards;
  pointer-events: none;
}

@keyframes rippleEffect {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

/* Focus visible state for keyboard navigation */
.btn-send:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 2px rgba(249, 115, 22, 0.3),
    0 2px 8px rgba(249, 115, 22, 0.25);
}

.input-row .btn-icon:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.15);
}

/* Stop button mode */
.btn-send.stop-mode {
  background: var(--accent);
  box-shadow:
    0 2px 6px rgba(249, 115, 22, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.btn-send.stop-mode:hover {
  background: var(--accent-hover);
  box-shadow:
    0 3px 10px rgba(249, 115, 22, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.btn-send.stop-mode svg {
  width: 14px;
  height: 14px;
}

.btn-primary {
  padding: 12px 24px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-accent);
}

.btn-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-secondary:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-secondary svg {
  width: 18px;
  height: 18px;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
}

.modal-content {
  position: relative;
  width: 90%;
  max-width: 420px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg), 0 0 60px -20px rgba(249, 115, 22, 0.15);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* Form Elements */
.form-group {
  margin-bottom: 16px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease;
}

.form-group input:focus {
  border-color: var(--border-focus);
  background: rgba(249, 115, 22, 0.05);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
}

.form-group input::placeholder {
  color: var(--text-muted);
}

.form-group small {
  display: block;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.form-group a {
  color: var(--accent-light);
  text-decoration: none;
  transition: color 0.15s ease;
}

.form-group a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* Plugin Status */
.plugin-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 13px;
}

.plugin-status.installed {
  color: #22c55e;
}

.plugin-status.not-installed {
  color: var(--text-muted);
}

.plugin-status.update-available {
  color: #f59e0b;
}

.btn-full-width {
  width: 100%;
  justify-content: center;
}

.btn-full-width svg {
  width: 16px;
  height: 16px;
  margin-right: 8px;
}

.btn-full-width.loading {
  pointer-events: none;
  opacity: 0.7;
}

/* Utility Classes */
.hidden {
  display: none !important;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--bg-hover);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--bg-active);
}

/* Selection */
::selection {
  background: rgba(249, 115, 22, 0.3);
  color: var(--text-primary);
}

/* Selection on user messages needs contrast - white highlight on orange background */
.message.user .message-content::selection,
.message.user .message-content *::selection {
  background: rgba(255, 255, 255, 0.4);
  color: #000;
}

/* ===========================================
   Markdown Rendering Styles
   =========================================== */

/* Headers */
.message-content h1 {
  font-size: 1.5em;
  font-weight: 700;
  margin: 16px 0 8px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.02em;
}

.message-content h2 {
  font-size: 1.3em;
  font-weight: 600;
  margin: 14px 0 6px 0;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.01em;
}

.message-content h3 {
  font-size: 1.15em;
  font-weight: 600;
  margin: 12px 0 6px 0;
}

.message-content h4 {
  font-size: 1.05em;
  font-weight: 600;
  margin: 10px 0 4px 0;
}

.message-content h5,
.message-content h6 {
  font-size: 1em;
  font-weight: 600;
  margin: 8px 0 4px 0;
  color: var(--text-secondary);
}

/* First element shouldn't have top margin */
.message-content > *:first-child {
  margin-top: 0;
}

/* Last element shouldn't have bottom margin */
.message-content > *:last-child {
  margin-bottom: 0;
}

/* Paragraphs */
.message-content p {
  margin: 8px 0;
  line-height: 1.6;
}

/* Bold and Italic */
.message-content strong {
  font-weight: 600;
}

.message-content em {
  font-style: italic;
}

/* Links */
.message-content a {
  color: var(--accent-light);
  text-decoration: none;
  transition: color 0.15s ease;
}

.message-content a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* Lists */
.message-content ul,
.message-content ol {
  margin: 8px 0;
  padding-left: 24px;
}

.message-content li {
  margin: 4px 0;
  line-height: 1.5;
}

.message-content li > ul,
.message-content li > ol {
  margin: 4px 0;
}

/* Nested list styling */
.message-content ul {
  list-style-type: disc;
}

.message-content ul ul {
  list-style-type: circle;
}

.message-content ul ul ul {
  list-style-type: square;
}

/* Checkboxes in task lists */
.message-content input[type="checkbox"] {
  margin-right: 8px;
  accent-color: var(--accent);
}

/* Blockquotes */
.message-content blockquote {
  margin: 12px 0;
  padding: 8px 16px;
  border-left: 3px solid var(--accent);
  background: rgba(249, 115, 22, 0.05);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
}

.message-content blockquote p {
  margin: 4px 0;
}

/* Code blocks */
.message-content pre {
  background: #282c34;
  border-radius: var(--radius-md);
  padding: 16px;
  margin: 12px 0;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.5;
  border: 1px solid var(--border);
}

.message-content pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: 13px;
  color: #abb2bf;
}

/* Inline code */
.message-content code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent-light);
}

/* Tables */
.message-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13px;
  overflow-x: auto;
  display: block;
}

.message-content thead {
  background: rgba(255, 255, 255, 0.05);
}

.message-content th {
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  border: 1px solid var(--border-light);
  color: var(--text-primary);
}

.message-content td {
  padding: 8px 12px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.message-content tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

.message-content tr:hover {
  background: rgba(255, 255, 255, 0.04);
}

/* Horizontal rules */
.message-content hr {
  border: none;
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

/* Images */
.message-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  margin: 8px 0;
}

/* Strikethrough */
.message-content del {
  text-decoration: line-through;
  color: var(--text-muted);
}

/* Keyboard input */
.message-content kbd {
  display: inline-block;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Subscript and Superscript */
.message-content sub,
.message-content sup {
  font-size: 0.75em;
}

/* Definition lists */
.message-content dl {
  margin: 8px 0;
}

.message-content dt {
  font-weight: 600;
  margin-top: 8px;
}

.message-content dd {
  margin-left: 24px;
  color: var(--text-secondary);
}

/* User messages - adjust markdown styles for orange background */
.message.user .message-content h1,
.message.user .message-content h2,
.message.user .message-content h3,
.message.user .message-content h4,
.message.user .message-content h5,
.message.user .message-content h6 {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}

.message.user .message-content a {
  color: #fff;
  text-decoration: underline;
}

.message.user .message-content code {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.message.user .message-content pre {
  background: rgba(0, 0, 0, 0.2);
  border-color: rgba(255, 255, 255, 0.1);
}

.message.user .message-content pre code {
  color: #fff;
}

.message.user .message-content blockquote {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.3);
  color: rgba(255, 255, 255, 0.9);
}

.message.user .message-content th,
.message.user .message-content td {
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.message.user .message-content thead {
  background: rgba(255, 255, 255, 0.1);
}

.message.user .message-content tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.05);
}

.message.user .message-content tr:hover {
  background: rgba(255, 255, 255, 0.1);
}

.message.user .message-content hr {
  background: rgba(255, 255, 255, 0.2);
}

/* ===========================================
   End Markdown Styles
   =========================================== */

/* Connection status indicator */
.connection-status {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--error);
}

.connection-dot.connected {
  background: var(--success);
}

/* Platform-specific adjustments */
body.platform-win32 .logo,
body.platform-linux .logo {
  padding-left: 0; /* No traffic lights on Windows/Linux - titlebar padding is sufficient */
}

body.platform-darwin .titlebar-controls {
  display: none; /* Use native traffic lights on macOS */
}

/* Message editing */
.message {
  position: relative;
}

.message-wrapper {
  position: relative;
  display: inline-block;
  max-width: 100%;
  -webkit-user-select: text !important;
  user-select: text !important;
}

.message.user .message-wrapper {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  -webkit-user-select: text !important;
  user-select: text !important;
}

.message-edit-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  z-index: 10;
  pointer-events: none;
  flex-shrink: 0;
  order: -1; /* Place before the message content */
}

/* Show edit button on hover of the wrapper (includes both button and bubble) */
.message.user .message-wrapper:hover .message-edit-btn {
  opacity: 1;
  pointer-events: auto;
}

/* Keep edit button visible when hovering the button itself */
.message-edit-btn:hover {
  opacity: 1;
  pointer-events: auto;
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-accent);
}

.message-edit-btn svg {
  width: 14px;
  height: 14px;
}

/* Message in edit mode */
.message.editing .message-content {
  display: none;
}

.message-edit-textarea {
  width: 100%;
  min-width: 300px;
  max-width: 100%;
  min-height: 60px;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border: 2px solid var(--accent);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.15);
}

.message-edit-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  justify-content: flex-end;
}

.message-edit-actions button {
  padding: 6px 14px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-edit-cancel {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.btn-edit-cancel:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-edit-save {
  background: var(--accent);
  border: none;
  color: #fff;
}

.btn-edit-save:hover {
  background: var(--accent-hover);
}

/* Modal small variant */
.modal-content.modal-small {
  max-width: 360px;
}

.modal-warning {
  color: var(--text-secondary);
  line-height: 1.6;
}

.btn-danger {
  padding: 10px 20px;
  background: var(--error);
  border: none;
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-danger:hover {
  background: #dc2626;
  transform: translateY(-1px);
}

.btn-small {
  width: auto;
  padding: 10px 20px;
}

.modal-footer .btn-secondary {
  width: auto;
}

/* Queue Container - shows queued messages above input */
.queue-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 16px;
  border-top: 1px solid var(--border-light);
  animation: fadeIn 0.2s ease;
}

.queue-message {
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.4;
  opacity: 0.7;
}

/* Pending Message - shows user message before it's confirmed */
.pending-message-container {
  display: flex;
  flex-direction: column;
  padding: 12px 16px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-secondary);
  animation: fadeIn 0.2s ease;
}

.pending-message-content {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  max-height: 150px;
  overflow-y: auto;
}

.pending-message-text {
  flex: 1;
  white-space: pre-wrap;
  word-break: break-word;
}

.pending-message-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.pending-message-content:hover .pending-message-actions {
  opacity: 1;
}

.pending-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.pending-action-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.pending-action-btn svg {
  flex-shrink: 0;
}

.pending-edit-btn:hover {
  color: var(--accent);
}

.pending-delete-btn:hover {
  color: #ef4444;
}

/* Diff Modal - kept for legacy but hidden */
.modal-content.modal-diff {
  max-width: 800px;
  width: 95%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.diff-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.diff-status {
  background: var(--accent);
  color: white;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.diff-filename {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-secondary);
}

.diff-container {
  background: #1e1e1e;
  border-radius: var(--radius-md);
  overflow-y: auto;
  max-height: 60vh;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
}

.diff-line {
  display: flex;
  padding: 0;
  border-left: 3px solid transparent;
}

.diff-linenum {
  width: 40px;
  padding: 2px 8px;
  text-align: right;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.2);
  user-select: none;
  flex-shrink: 0;
}

.diff-prefix {
  width: 20px;
  padding: 2px 4px;
  text-align: center;
  user-select: none;
  flex-shrink: 0;
}

.diff-code {
  flex: 1;
  padding: 2px 12px 2px 4px;
  white-space: pre-wrap;
  word-break: break-word;
}

.diff-line.diff-added {
  background: rgba(34, 197, 94, 0.1);
  border-left-color: #22c55e;
}

.diff-line.diff-added .diff-prefix {
  color: #22c55e;
}

.diff-line.diff-removed {
  background: rgba(239, 68, 68, 0.1);
  border-left-color: #ef4444;
}

.diff-line.diff-removed .diff-prefix {
  color: #ef4444;
}

.diff-line.diff-unchanged {
  background: transparent;
}

.diff-line.diff-unchanged .diff-prefix {
  color: var(--text-muted);
}

.diff-line.diff-separator {
  background: rgba(255, 255, 255, 0.03);
  border-left-color: transparent;
  justify-content: center;
}

.diff-line.diff-separator .diff-code {
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  padding: 4px 12px;
}

/* ===========================================
   Inline Diff Preview (Cursor-style)
   =========================================== */

.inline-diff {
  margin: 12px 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  background: #1a1a1d;
  overflow: hidden;
  max-width: 100%;
  animation: fadeIn 0.2s ease;
}

.inline-diff-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid var(--border);
}

.inline-diff-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-diff-badge {
  background: var(--accent);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.inline-diff-filename {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
}

/* Clickable filename - opens script in Studio */
.inline-diff-filename.clickable {
  cursor: pointer;
  /* Override the global user-select: text rule to ensure clicks work properly */
  -webkit-user-select: none !important;
  user-select: none !important;
}

.inline-diff-filename.clickable:hover {
  color: var(--accent-light);
  text-decoration: underline;
}

/* Script type colored accents */
.inline-diff[data-script-type="Script"] {
  border-color: rgba(59, 130, 246, 0.3);
}

.inline-diff[data-script-type="LocalScript"] {
  border-color: rgba(34, 197, 94, 0.3);
}

.inline-diff[data-script-type="ModuleScript"] {
  border-color: rgba(168, 85, 247, 0.3);
}

.inline-diff-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.inline-diff-toggle {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.inline-diff-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.inline-diff-toggle svg {
  width: 14px;
  height: 14px;
  transition: transform 0.2s ease;
}

.inline-diff.collapsed .inline-diff-toggle svg {
  transform: rotate(-90deg);
}

.inline-diff-body {
  max-height: 200px; /* ~10 lines at 12px font with 1.5 line-height */
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
}

.inline-diff.collapsed .inline-diff-body {
  display: none;
}

/* Inline diff lines - more compact */
.inline-diff .diff-line {
  padding: 0;
  border-left-width: 2px;
}

.inline-diff .diff-linenum {
  width: 32px;
  padding: 1px 6px;
  font-size: 11px;
}

.inline-diff .diff-prefix {
  width: 16px;
  padding: 1px 2px;
  font-size: 11px;
}

.inline-diff .diff-code {
  padding: 1px 8px 1px 4px;
  font-size: 11px;
}

/* Stats summary in header */
.inline-diff-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

.inline-diff-stats .stat-added {
  color: #22c55e;
}

.inline-diff-stats .stat-removed {
  color: #ef4444;
}

/* Script type icons in diff header */
.script-icon {
  flex-shrink: 0;
  vertical-align: middle;
}

.inline-diff-info .script-icon {
  margin-right: 2px;
}

/* Rewind Modal */
.modal-content.modal-rewind {
  max-width: 440px;
}

.modal-description {
  color: var(--text-secondary);
  margin-bottom: 16px;
  font-size: 14px;
}

.rewind-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rewind-option {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
  width: 100%;
}

.rewind-option:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
}

.rewind-option:active {
  background: var(--bg-active);
}

.rewind-option-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(249, 115, 22, 0.1);
  border-radius: var(--radius-sm);
  color: var(--accent);
  flex-shrink: 0;
}

.rewind-option-icon svg {
  width: 18px;
  height: 18px;
}

.rewind-option-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.rewind-option-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.rewind-option-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Revert option is the primary/default action - styled more prominently */
.rewind-option-revert {
  background: rgba(249, 115, 22, 0.08);
  border-color: var(--accent);
  border-width: 2px;
}

.rewind-option-revert .rewind-option-icon {
  background: rgba(249, 115, 22, 0.15);
  color: var(--accent);
}

.rewind-option-revert:hover {
  background: rgba(249, 115, 22, 0.12);
  border-color: var(--accent-hover);
}

.rewind-option-revert:hover .rewind-option-icon {
  background: rgba(249, 115, 22, 0.2);
}

/* Focus state for keyboard navigation */
.rewind-option:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.2);
}

.rewind-option:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.3);
}

/* Keyboard hint for revert button */
.rewind-option-revert .rewind-option-desc::after {
  content: " (Enter)";
  color: var(--accent-light);
  font-weight: 500;
}

/* Loading state for rewind buttons */
.rewind-option.loading {
  pointer-events: none;
  opacity: 0.7;
}

.rewind-option.loading .rewind-option-icon svg {
  animation: spin 0.8s linear infinite;
}

/* ===========================================
   Syntax Highlighting in Inline Diffs
   =========================================== */

/* Ensure highlight.js syntax colors show through diff backgrounds */
.inline-diff .diff-code {
  /* Use transparent background so diff line colors show through */
  background: transparent !important;
}

/* Override highlight.js background to be transparent in diffs */
.inline-diff .diff-code .hljs,
.inline-diff .diff-code code {
  background: transparent !important;
  padding: 0;
}

/* Syntax highlighting token colors - slightly adjusted for visibility on diff backgrounds */
/* These work with atom-one-dark theme */

/* Unchanged lines - use standard syntax colors */
.inline-diff .diff-unchanged .diff-code .hljs-keyword,
.inline-diff .diff-unchanged .diff-code .hljs-selector-tag,
.inline-diff .diff-unchanged .diff-code .hljs-literal,
.inline-diff .diff-unchanged .diff-code .hljs-section,
.inline-diff .diff-unchanged .diff-code .hljs-link {
  color: #c678dd;
}

.inline-diff .diff-unchanged .diff-code .hljs-string,
.inline-diff .diff-unchanged .diff-code .hljs-title,
.inline-diff .diff-unchanged .diff-code .hljs-name,
.inline-diff .diff-unchanged .diff-code .hljs-type,
.inline-diff .diff-unchanged .diff-code .hljs-attribute,
.inline-diff .diff-unchanged .diff-code .hljs-symbol,
.inline-diff .diff-unchanged .diff-code .hljs-bullet,
.inline-diff .diff-unchanged .diff-code .hljs-addition,
.inline-diff .diff-unchanged .diff-code .hljs-variable,
.inline-diff .diff-unchanged .diff-code .hljs-template-tag,
.inline-diff .diff-unchanged .diff-code .hljs-template-variable {
  color: #98c379;
}

.inline-diff .diff-unchanged .diff-code .hljs-comment,
.inline-diff .diff-unchanged .diff-code .hljs-quote,
.inline-diff .diff-unchanged .diff-code .hljs-deletion,
.inline-diff .diff-unchanged .diff-code .hljs-meta {
  color: #5c6370;
}

.inline-diff .diff-unchanged .diff-code .hljs-number,
.inline-diff .diff-unchanged .diff-code .hljs-regexp,
.inline-diff .diff-unchanged .diff-code .hljs-literal,
.inline-diff .diff-unchanged .diff-code .hljs-params {
  color: #d19a66;
}

.inline-diff .diff-unchanged .diff-code .hljs-built_in,
.inline-diff .diff-unchanged .diff-code .hljs-builtin-name {
  color: #e6c07b;
}

.inline-diff .diff-unchanged .diff-code .hljs-function .hljs-keyword {
  color: #c678dd;
}

.inline-diff .diff-unchanged .diff-code .hljs-function .hljs-title {
  color: #61afef;
}

/* Added lines - brighter colors for visibility on green background */
.inline-diff .diff-added .diff-code .hljs-keyword,
.inline-diff .diff-added .diff-code .hljs-selector-tag,
.inline-diff .diff-added .diff-code .hljs-literal,
.inline-diff .diff-added .diff-code .hljs-section,
.inline-diff .diff-added .diff-code .hljs-link {
  color: #d19de8;
}

.inline-diff .diff-added .diff-code .hljs-string,
.inline-diff .diff-added .diff-code .hljs-title,
.inline-diff .diff-added .diff-code .hljs-name,
.inline-diff .diff-added .diff-code .hljs-type,
.inline-diff .diff-added .diff-code .hljs-attribute,
.inline-diff .diff-added .diff-code .hljs-symbol,
.inline-diff .diff-added .diff-code .hljs-bullet,
.inline-diff .diff-added .diff-code .hljs-addition,
.inline-diff .diff-added .diff-code .hljs-variable,
.inline-diff .diff-added .diff-code .hljs-template-tag,
.inline-diff .diff-added .diff-code .hljs-template-variable {
  color: #b5e890;
}

.inline-diff .diff-added .diff-code .hljs-comment,
.inline-diff .diff-added .diff-code .hljs-quote,
.inline-diff .diff-added .diff-code .hljs-deletion,
.inline-diff .diff-added .diff-code .hljs-meta {
  color: #7a8590;
}

.inline-diff .diff-added .diff-code .hljs-number,
.inline-diff .diff-added .diff-code .hljs-regexp,
.inline-diff .diff-added .diff-code .hljs-literal,
.inline-diff .diff-added .diff-code .hljs-params {
  color: #e5b070;
}

.inline-diff .diff-added .diff-code .hljs-built_in,
.inline-diff .diff-added .diff-code .hljs-builtin-name {
  color: #f0d080;
}

.inline-diff .diff-added .diff-code .hljs-function .hljs-title {
  color: #7cc5f5;
}

/* Removed lines - adjusted colors for visibility on red background */
.inline-diff .diff-removed .diff-code .hljs-keyword,
.inline-diff .diff-removed .diff-code .hljs-selector-tag,
.inline-diff .diff-removed .diff-code .hljs-literal,
.inline-diff .diff-removed .diff-code .hljs-section,
.inline-diff .diff-removed .diff-code .hljs-link {
  color: #d8a5e5;
}

.inline-diff .diff-removed .diff-code .hljs-string,
.inline-diff .diff-removed .diff-code .hljs-title,
.inline-diff .diff-removed .diff-code .hljs-name,
.inline-diff .diff-removed .diff-code .hljs-type,
.inline-diff .diff-removed .diff-code .hljs-attribute,
.inline-diff .diff-removed .diff-code .hljs-symbol,
.inline-diff .diff-removed .diff-code .hljs-bullet,
.inline-diff .diff-removed .diff-code .hljs-addition,
.inline-diff .diff-removed .diff-code .hljs-variable,
.inline-diff .diff-removed .diff-code .hljs-template-tag,
.inline-diff .diff-removed .diff-code .hljs-template-variable {
  color: #a8d480;
}

.inline-diff .diff-removed .diff-code .hljs-comment,
.inline-diff .diff-removed .diff-code .hljs-quote,
.inline-diff .diff-removed .diff-code .hljs-deletion,
.inline-diff .diff-removed .diff-code .hljs-meta {
  color: #8a8a95;
}

.inline-diff .diff-removed .diff-code .hljs-number,
.inline-diff .diff-removed .diff-code .hljs-regexp,
.inline-diff .diff-removed .diff-code .hljs-literal,
.inline-diff .diff-removed .diff-code .hljs-params {
  color: #e8b575;
}

.inline-diff .diff-removed .diff-code .hljs-built_in,
.inline-diff .diff-removed .diff-code .hljs-builtin-name {
  color: #f5d590;
}

.inline-diff .diff-removed .diff-code .hljs-function .hljs-title {
  color: #85c8f5;
}

/* Base text color for diff lines */
.inline-diff .diff-unchanged .diff-code {
  color: #abb2bf;
}

.inline-diff .diff-added .diff-code {
  color: #d0e8c0;
}

.inline-diff .diff-removed .diff-code {
  color: #e8d0d0;
}

/* ==================== Playtest Panel ==================== */

.playtest-panel {
  margin: 12px 0;
  border-radius: var(--radius-md);
  border: 1px solid rgba(34, 197, 94, 0.3);
  background: #1a1a1d;
  max-width: 100%;
  animation: fadeIn 0.2s ease;
}

.playtest-panel.stopped {
  border-color: var(--border-light);
}

.playtest-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  min-height: 40px;
  background: rgba(0, 0, 0, 0.8);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  position: sticky;
  top: 0;
  z-index: 10;
  flex-shrink: 0;
}

.playtest-panel.collapsed .playtest-header {
  border-bottom: none;
}

.playtest-header:hover {
  background: rgba(0, 0, 0, 0.4);
}

.playtest-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.playtest-badge {
  background: var(--success);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.playtest-panel.stopped .playtest-badge {
  background: var(--text-muted);
}

.playtest-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
}

.playtest-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(34, 197, 94, 0.2);
  border-top-color: var(--success);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

.playtest-panel.stopped .playtest-spinner {
  display: none;
}

.playtest-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.playtest-toggle {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.playtest-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.playtest-toggle svg {
  width: 12px;
  height: 12px;
  transition: transform 0.15s ease;
}

.playtest-panel.collapsed .playtest-toggle svg {
  transform: rotate(-90deg);
}

.playtest-body {
  min-height: 150px;
  max-height: 500px;
  overflow-y: auto;
}

.playtest-panel.collapsed .playtest-body {
  display: none;
}

.playtest-scripts {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
}

/* Script entry - styled like inline-diff modal */
.playtest-script-entry {
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  background: #1a1a1d;
  overflow: hidden;
}

.playtest-script-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid var(--border);
}

.playtest-script-header:hover {
  background: rgba(0, 0, 0, 0.4);
}

.playtest-context-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
}

/* Badge style for run context */
.playtest-script-badge {
  background: var(--accent);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.playtest-script-badge.server {
  background: #8b5cf6;
}

.playtest-script-badge.client {
  background: #3b82f6;
}

.playtest-script-label {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  flex: 1;
}

.playtest-script-toggle {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.playtest-script-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.playtest-script-toggle svg {
  width: 14px;
  height: 14px;
  transition: transform 0.2s ease;
}

.playtest-script-entry:not(.expanded) .playtest-script-toggle svg {
  transform: rotate(-90deg);
}

.playtest-script-code {
  display: none;
  background: rgba(0, 0, 0, 0.2);
  max-height: 200px;
  overflow-y: auto;
}

.playtest-script-entry.expanded .playtest-script-code {
  display: block;
}

.playtest-script-code pre {
  margin: 0;
  padding: 10px 12px;
  overflow-x: auto;
}

.playtest-script-code code {
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;
  color: #abb2bf;
}

.playtest-empty {
  padding: 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  font-style: italic;
}

.playtest-result {
  padding: 12px;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.1);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-primary);
}

.playtest-result p {
  margin: 0 0 8px 0;
}

.playtest-result p:last-child {
  margin-bottom: 0;
}

.playtest-result code {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 12px;
}

.playtest-result pre {
  background: rgba(0, 0, 0, 0.2);
  padding: 10px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 8px 0;
}

.playtest-result pre code {
  background: transparent;
  padding: 0;
}

/* ===========================================
   New Project Modal
   =========================================== */

.modal-content.modal-new-project {
  max-width: 560px;
}

.project-type-cards {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
}

.project-type-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 20px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.project-type-card:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
  transform: translateY(-2px);
}

.project-type-card:active {
  transform: translateY(0);
}

.project-type-card:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.2);
}

.project-type-icon {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(113, 113, 122, 0.15);
  border-radius: var(--radius-md);
  color: var(--text-muted);
}

.project-type-icon svg {
  width: 28px;
  height: 28px;
}

.project-type-icon-recommended {
  background: rgba(249, 115, 22, 0.12);
  color: var(--accent);
}

.project-type-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.project-type-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.project-type-benefits {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.project-type-benefits li {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.project-type-benefits li::before {
  content: "";
  width: 4px;
  height: 4px;
  background: var(--text-muted);
  border-radius: 50%;
  opacity: 0.5;
}

.project-api-key-section {
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.label-optional {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 12px;
}

/* Enhanced context menu for project actions */
.menu-item-separator {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.menu-item.menu-item-has-value {
  position: relative;
}

.menu-item-badge {
  margin-left: auto;
  padding: 2px 6px;
  background: rgba(249, 115, 22, 0.15);
  color: var(--accent);
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
}

/* ===========================================
   Connection Error Modal
   =========================================== */

.modal-content.modal-connection-error {
  max-width: 380px;
}

.modal-backdrop.no-close {
  cursor: default;
}

.connection-error-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(239, 68, 68, 0.15);
  border-radius: 50%;
  color: #ef4444;
}

.connection-error-icon svg {
  width: 32px;
  height: 32px;
}

#btn-connection-retry {
  min-width: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

#btn-connection-retry .retry-spinner {
  display: none;
}

#btn-connection-retry .retry-spinner.visible {
  display: inline-flex;
}

#btn-connection-retry .retry-text.hidden {
  display: none;
}

#btn-connection-retry .spinner {
  width: 16px;
  height: 16px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
