:root {
  --bg-main: #0b0f19;
  --bg-card: #131b2e;
  --bg-card-hover: #1b2640;
  --bg-input: #0e1526;
  --border-color: #263352;
  --border-focus: #6366f1;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.3);
  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.25);
  --warning: #f59e0b;
  --danger: #ef4444;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  background-color: rgba(19, 27, 46, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 0.85rem 1.5rem;
}

.header-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #4f46e5, #06b6d4);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.15rem;
  color: white;
  box-shadow: 0 0 15px var(--primary-glow);
}

.logo-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.logo-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.logo-badge {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  background: rgba(99, 102, 241, 0.2);
  color: #818cf8;
  border-radius: 9999px;
  font-weight: 600;
  margin-left: 0.35rem;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 500;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--warning);
}

.status-dot.online {
  background-color: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.status-dot.offline {
  background-color: var(--danger);
  box-shadow: 0 0 8px var(--danger);
}

/* Main Container & Tabs */
main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem;
  width: 100%;
  flex: 1;
}

.tab-nav {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1.5rem;
  overflow-x: auto;
  padding-bottom: 2px;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 0.75rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-content {
  display: none;
  animation: fadeIn 0.25s ease-in-out;
}

.tab-content.active {
  display: block;
}

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

/* Card Elements */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  transition: border-color 0.2s;
}

.card:hover {
  border-color: rgba(99, 102, 241, 0.35);
}

.card-title {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-desc {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}

/* Info Grid */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.info-cell {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
}

.info-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 0.25rem;
}

.info-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

/* Form inputs */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.form-input, .form-textarea, .form-select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-main);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background-color: var(--primary);
  color: white;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 0 15px var(--primary-glow);
}

.btn-secondary {
  background-color: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

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

.btn-danger {
  background-color: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

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

/* Chat Layout */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 650px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
}

.chat-header {
  padding: 0.75rem 1.25rem;
  background-color: var(--bg-input);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.chat-bubble {
  max-width: 85%;
  padding: 0.85rem 1.15rem;
  border-radius: 12px;
  font-size: 0.92rem;
  line-height: 1.5;
  word-break: break-word;
}

.chat-bubble.user {
  align-self: flex-end;
  background-color: var(--primary);
  color: white;
  border-bottom-right-radius: 2px;
}

.chat-bubble.assistant {
  align-self: flex-start;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-bottom-left-radius: 2px;
}

.chat-bubble .reasoning-box {
  background: rgba(0, 0, 0, 0.25);
  border-left: 3px solid #818cf8;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
  border-radius: 4px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.chat-bubble img {
  max-width: 100%;
  border-radius: 8px;
  margin-top: 0.5rem;
}

.chat-input-bar {
  padding: 0.85rem 1.25rem;
  background-color: var(--bg-input);
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

/* Prompt Chips */
.chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip-btn {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: 9999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.chip-btn:hover {
  border-color: var(--primary);
  color: var(--text-main);
  background: rgba(99, 102, 241, 0.1);
}

/* Image Grid & Cards */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
}

.image-card {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  overflow: hidden;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
}

.image-card:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.image-card-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #000;
  overflow: hidden;
  cursor: pointer;
}

.image-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}

.image-card:hover .image-card-thumb img {
  transform: scale(1.04);
}

.image-card-body {
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}

.image-card-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.image-card-meta {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.image-card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: auto;
}

/* Gems Grid */
.gems-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
}

.gem-card {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  transition: all 0.2s;
}

.gem-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.gem-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.gem-card-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
}

.gem-card-prompt {
  background: #070b14;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.65rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  max-height: 100px;
  overflow-y: auto;
  margin-bottom: 1rem;
  white-space: pre-wrap;
}

.gem-badge-custom {
  background: rgba(99, 102, 241, 0.2);
  color: #818cf8;
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 9999px;
  font-weight: 600;
}

.gem-badge-predefined {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 9999px;
  font-weight: 600;
}

/* Deep Research Components */
.research-steps-list {
  list-style: none;
  counter-reset: r-step;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.research-steps-list li {
  counter-increment: r-step;
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  background: var(--bg-input);
  padding: 0.65rem 0.85rem;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  font-size: 0.88rem;
}

.research-steps-list li::before {
  content: counter(r-step);
  width: 22px;
  height: 22px;
  background: rgba(99, 102, 241, 0.2);
  color: #818cf8;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.progress-bar-container {
  width: 100%;
  height: 8px;
  background: var(--bg-input);
  border-radius: 9999px;
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #4f46e5, #06b6d4, #10b981);
  width: 100%;
  animation: progressPulse 2s infinite linear;
}

@keyframes progressPulse {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.report-body {
  background: #070b14;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.5rem;
  font-size: 0.95rem;
  line-height: 1.7;
  color: #e2e8f0;
  max-height: 700px;
  overflow-y: auto;
}

.report-body h1, .report-body h2, .report-body h3 {
  color: #fff;
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
}

.report-body p {
  margin-bottom: 0.85rem;
}

.report-body ul, .report-body ol {
  padding-left: 1.5rem;
  margin-bottom: 0.85rem;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-overlay.active {
  display: flex;
  animation: fadeIn 0.2s ease-in-out;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  width: 100%;
  max-width: 600px;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}

.modal-header {
  padding: 1.25rem;
  background: var(--bg-input);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-main);
}

/* Code & Snippet Blocks */
.code-block {
  background-color: #060911;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  overflow-x: auto;
  position: relative;
  color: #e2e8f0;
}

.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: 4px;
  cursor: pointer;
}

.copy-btn:hover {
  color: var(--text-main);
  background: var(--bg-card-hover);
}

.integration-box {
  background: var(--bg-input);
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

/* Steps list */
.step-list {
  list-style: none;
  counter-reset: step-counter;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 1rem 0;
}

.step-item {
  counter-increment: step-counter;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.step-number {
  width: 28px;
  height: 28px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--primary);
  flex-shrink: 0;
}

/* Session Status Banner */
.session-banner {
  margin-bottom: 1.25rem;
  border-radius: 12px;
  border: 1px solid rgba(239, 68, 68, 0.45);
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.12), rgba(245, 158, 11, 0.06));
  overflow: hidden;
}

.session-banner.warning {
  border-color: rgba(245, 158, 11, 0.5);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.12), rgba(239, 68, 68, 0.04));
}

.session-banner-inner {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  padding: 1rem 1.25rem;
}

.session-banner-icon {
  font-size: 1.4rem;
  line-height: 1.3;
  flex-shrink: 0;
}

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

.session-banner-title {
  font-weight: 700;
  font-size: 1rem;
  color: #fca5a5;
  margin-bottom: 0.35rem;
}

.session-banner.warning .session-banner-title {
  color: #fbbf24;
}

.session-banner-text {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.session-banner-text ol {
  margin: 0.4rem 0 0 1.1rem;
  padding: 0;
}

.session-banner-text li {
  margin-bottom: 0.25rem;
}

.session-banner-text code {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
  font-size: 0.82rem;
  word-break: break-all;
}

.session-banner-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: 6px;
  flex-shrink: 0;
}

.session-banner-close:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.06);
}
