:root {
  --bg-main: #0b0f19;
  --bg-card: rgba(18, 24, 38, 0.85);
  --bg-card-hover: rgba(28, 36, 56, 0.95);
  --bg-subtle: #161e2e;
  --bg-input: #111827;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(99, 102, 241, 0.3);

  --accent-purple: #8b5cf6;
  --accent-cyan: #06b6d4;
  --accent-pink: #ec4899;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  --accent-red: #ef4444;

  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --shadow-card: 0 10px 30px -5px rgba(0, 0, 0, 0.5);
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  background-image: 
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(6, 182, 212, 0.12) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
  background: #374151;
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: #4b5563;
}

/* Container */
.app-container {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 16px 80px;
  width: 100%;
}

/* Navbar / Top Bar */
.top-navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  box-shadow: var(--shadow-card);
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
  cursor: pointer;
}

.brand-badge .icon-logo {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.92rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  color: #fff;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-purple), #6366f1);
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.35);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.5);
}

.btn-success {
  background: linear-gradient(135deg, var(--accent-green), #059669);
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.35);
}
.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
}

.btn-secondary {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-main);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}
.btn-danger:hover {
  background: var(--accent-red);
  color: #fff;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
}

.btn-tts {
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.35);
  color: #c4b5fd;
}

.btn-tts:hover {
  background: rgba(139, 92, 246, 0.3);
  color: #fff;
}

.btn-tts.speaking {
  background: linear-gradient(135deg, var(--accent-pink), var(--accent-purple));
  color: #fff;
  border-color: transparent;
  animation: pulse-audio 1.2s infinite alternate ease-in-out;
}

@keyframes pulse-audio {
  0% {
    box-shadow: 0 0 0 0 rgba(236, 72, 153, 0.4);
    transform: scale(1);
  }
  100% {
    box-shadow: 0 0 12px 3px rgba(236, 72, 153, 0.6);
    transform: scale(1.04);
  }
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-purple { background: rgba(139, 92, 246, 0.2); color: #c4b5fd; border: 1px solid rgba(139, 92, 246, 0.4); }
.badge-cyan { background: rgba(6, 182, 212, 0.2); color: #a5f3fc; border: 1px solid rgba(6, 182, 212, 0.4); }
.badge-amber { background: rgba(245, 158, 11, 0.2); color: #fde68a; border: 1px solid rgba(245, 158, 11, 0.4); }
.badge-green { background: rgba(16, 185, 129, 0.2); color: #a7f3d0; border: 1px solid rgba(16, 185, 129, 0.4); }

/* Linktree Hero Profile */
.linktree-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 30px 24px;
  text-align: center;
  margin-bottom: 28px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}

.linktree-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--accent-purple), var(--accent-cyan), var(--accent-pink));
}

.linktree-avatar {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.4);
}

.linktree-title {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 6px;
  color: #fff;
}

.linktree-subtitle {
  color: var(--accent-cyan);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.linktree-desc {
  max-width: 600px;
  margin: 0 auto 16px;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.detektiv-stats-bar {
  display: inline-flex;
  gap: 16px;
  background: var(--bg-subtle);
  padding: 10px 20px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  font-size: 0.88rem;
  font-weight: 600;
}

/* Linktree Buttons / Source Items */
.source-tree {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.source-item {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.source-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-glow);
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
}

.source-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.source-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.source-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
}

.source-author {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.source-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.finding-pill {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fde68a;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 700;
}

/* Inspector Modal / Overlay */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(5, 7, 13, 0.85);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

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

.inspector-modal {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 1100px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.inspector-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(15, 23, 42, 0.6);
}

.inspector-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

@media (max-width: 800px) {
  .inspector-body {
    grid-template-columns: 1fr;
  }
}

.doc-pane {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
}

.doc-pane-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 10px;
  margin-bottom: 6px;
}

.doc-pane-title {
  font-size: 0.95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.doc-text {
  font-size: 0.93rem;
  line-height: 1.7;
  color: #e5e7eb;
  white-space: pre-wrap;
  user-select: text;
}

.ai-text-container {
  background: rgba(139, 92, 246, 0.05);
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: var(--radius-sm);
  padding: 16px;
  position: relative;
}

/* Highlighting in AI Text */
.ai-highlight {
  background: rgba(245, 158, 11, 0.35);
  border-bottom: 2px solid var(--accent-amber);
  color: #fff;
  border-radius: 4px;
  padding: 2px 4px;
  cursor: pointer;
  position: relative;
  transition: background 0.2s;
}

.ai-highlight:hover {
  background: rgba(245, 158, 11, 0.55);
}

.mark-tag {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 800;
  background: var(--accent-amber);
  color: #000;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
}

/* Selection Popover */
.selection-action-bubble {
  position: absolute;
  background: #1f2937;
  border: 1px solid var(--accent-purple);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  z-index: 100;
  display: none;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  gap: 6px;
  align-items: center;
}

.selection-action-bubble:hover {
  background: var(--accent-purple);
}

/* Findings list inside inspector */
.findings-feed {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.finding-card {
  background: rgba(31, 41, 55, 0.6);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent-amber);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.finding-card-content {
  flex: 1;
}

.finding-card-quote {
  font-style: italic;
  color: #fde68a;
  margin-bottom: 4px;
}

.finding-card-note {
  color: var(--text-main);
}

/* View Section Control */
.view-section {
  display: none;
}
.view-section.active {
  display: block;
}

/* Form Styles for Editor & Feedback */
.form-group {
  margin-bottom: 16px;
}

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

.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.92rem;
  transition: border-color 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

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

/* Scenario Cards (Grid on Home/Selection) */
.scenario-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.scenario-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  cursor: pointer;
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
}

.scenario-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent-cyan);
  box-shadow: 0 12px 30px rgba(6, 182, 212, 0.2);
}

/* Report View / Reflection */
.report-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 30px;
  margin-bottom: 24px;
}

.reveal-box {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-top: 20px;
}

.reveal-error-item {
  background: rgba(31, 41, 55, 0.5);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-top: 10px;
  border-left: 4px solid var(--accent-green);
}

/* Footer */
.app-footer {
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-top: 40px;
}
