:root {
  --bg: #f8f9fa;
  --card: #ffffff;
  --border: #dadce0;
  --text-main: #202124;
  --text-muted: #5f6368;
  --primary: #4285f4;
  --danger: #ea4335;
  --human-color: #0f9d58;
  --neutral-color: #fbbc04;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Noto Sans SC", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text-main);
  line-height: 1.6;
}

.app {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px;
}

.hero {
  background: var(--card);
  padding: 24px;
  border-radius: 12px;
  border: 1px solid var(--border);
  margin-bottom: 24px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.hero h1 {
  margin: 0 0 12px;
  font-size: 24px;
  color: #1a73e8;
}

.hero p {
  margin: 0;
  color: var(--text-muted);
}

.hero strong {
  color: #202124;
}

.dashboard {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.hidden {
  display: none !important;
}

/* Input Section */
.input-panel label {
  display: block;
  font-weight: 600;
  margin-bottom: 12px;
}

textarea {
  width: 100%;
  height: 200px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.7;
  resize: vertical;
}

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

.btn {
  padding: 10px 16px;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 14px;
}

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

.btn.primary:hover {
  background: #1a73e8;
}

.btn.secondary {
  background: #e8eaed;
  color: #3c4043;
}

.btn.secondary:hover {
  background: #dadce0;
}

.btn.outline {
  background: transparent;
  border: 1px solid var(--border);
}

.btn.outline:hover {
  background: #f8f9fa;
}

/* Results Section */
.stats-header {
  display: flex;
  gap: 16px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}

.stat-item {
  flex: 1;
  min-width: 150px;
  background: #f1f3f4;
  padding: 16px;
  border-radius: 8px;
  position: relative;
}

.stat-item.highlight {
  background: #e8f0fe;
  border: 1px solid #8ab4f8;
}

.stat-item.highlight .stat-value {
  color: #1a73e8;
}

.stat-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
  cursor: help;
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
}

.stat-bar {
  height: 6px;
  background: #dadce0;
  border-radius: 3px;
  margin-top: 12px;
  overflow: hidden;
}

.stat-bar .fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.5s ease;
}

/* Tooltip */
.tooltip-container .tooltip {
  visibility: hidden;
  width: 220px;
  background: #202124;
  color: #fff;
  text-align: left;
  border-radius: 6px;
  padding: 8px 12px;
  position: absolute;
  z-index: 10;
  bottom: 120%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  font-weight: normal;
  opacity: 0;
  transition: opacity 0.3s;
}

.tooltip-container:hover .tooltip {
  visibility: visible;
  opacity: 1;
}

.analysis-visualization h3,
.scatter-container h3 {
  margin: 0 0 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  font-size: 18px;
}

.legend {
  margin-bottom: 16px;
  font-size: 13px;
  display: flex;
  gap: 12px;
}

.badge {
  padding: 4px 8px;
  border-radius: 4px;
}

.aihigh {
  background: rgba(234, 67, 53, 0.2);
  border-left: 3px solid var(--danger);
}

.aimid {
  background: transparent;
  border-left: 3px solid var(--border);
}

.humanhigh {
  background: rgba(15, 157, 88, 0.2);
  border-left: 3px solid var(--human-color);
}

.text-canvas {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  max-height: 300px;
  overflow-y: auto;
  line-height: 1.8;
  font-size: 15px;
}

.sent-span {
  transition: background 0.2s;
  border-bottom: 1px solid transparent;
}

.sent-span:hover {
  filter: brightness(0.9);
}

.scatter-container {
  margin-top: 32px;
}

.scatter-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: -8px;
  margin-bottom: 16px;
}

.scatter-plot {
  width: 100%;
  height: 250px;
  background: #fafafa;
  border: 1px solid var(--border);
  border-left: 2px solid #5f6368;
  border-bottom: 2px solid #5f6368;
  border-radius: 4px;
  position: relative;
  overflow: hidden;
}

.axis {
  position: absolute;
  font-size: 11px;
  font-weight: 600;
  color: #5f6368;
}

.x-axis {
  bottom: 8px;
  right: 8px;
}

.y-axis {
  top: 8px;
  left: 8px;
  transform: rotate(-90deg);
  transform-origin: top left;
  margin-top: 100px;
  margin-left: 12px;
}

.quadrant {
  position: absolute;
  font-size: 12px;
  font-weight: bold;
  opacity: 0.3;
}

.ai-zone {
  bottom: 20px;
  left: 20px;
  color: var(--danger);
}

.human-zone {
  top: 20px;
  right: 20px;
  color: var(--human-color);
}

.scatter-point {
  width: 14px;
  height: 14px;
  background: var(--primary);
  border: 2px solid #fff;
  border-radius: 50%;
  position: absolute;
  bottom: 0;
  left: 0;
  transform: translate(-50%, 50%);
  box-shadow: 0 0 0 4px rgba(66, 133, 244, 0.2);
  transition: all 0.8s cubic-bezier(0.25, 1, 0.5, 1);
}

/* === Dark Mode Override (auto-generated) === */
:root[data-theme="dark"] {
  --bg: #1a1a2e;
  --card: #242438;
  --border: #3a3a50;
  --text-main: #e8e8f0;
  --text-muted: #aaa;
  --primary: #9b7bff;
  --danger: #f87171;
  --human-color: #4ade80;
  --neutral-color: #aaa;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
  --bg: #1a1a2e;
  --card: #242438;
  --border: #3a3a50;
  --text-main: #e8e8f0;
  --text-muted: #aaa;
  --primary: #9b7bff;
  --danger: #f87171;
  --human-color: #4ade80;
  --neutral-color: #aaa;
  }
}

/* === CSS Professor Animation Upgrade (Round 22) === */

/* Page entrance */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
.app, main, body > .container { animation: fadeInUp 0.4s ease-out; }

/* Staggered card entrance */
@keyframes cardReveal {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.card, [class*="card"], .mission-card, .module-card, .stat-card {
  animation: cardReveal 0.35s ease-out both;
}
.card:nth-child(2), [class*="card"]:nth-child(2) { animation-delay: 0.05s; }
.card:nth-child(3), [class*="card"]:nth-child(3) { animation-delay: 0.1s; }
.card:nth-child(4), [class*="card"]:nth-child(4) { animation-delay: 0.15s; }
.card:nth-child(5), [class*="card"]:nth-child(5) { animation-delay: 0.2s; }

/* Subtle pulse for primary buttons */
@keyframes btnPulse {
  0%, 100% { box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
  50% { box-shadow: 0 2px 12px rgba(199,73,31,0.25); }
}
button[id*="Btn"]:not(:disabled), .btn-primary {
  animation: btnPulse 3s ease-in-out infinite;
}
button:disabled { animation: none; opacity: 0.6; }

/* Smooth height transitions for collapsible sections */
details { transition: all 0.2s ease; }
details[open] summary { margin-bottom: 8px; }

/* Tooltip fade */
[title] { position: relative; }

/* Progress bar animation */
@keyframes progressFill {
  from { width: 0; }
}
.mc-bar-fill, .mod-progress-fill, .bar-fill, progress::-webkit-progress-value {
  animation: progressFill 0.6s ease-out;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* === Loading & Feedback States === */
@keyframes spin { to { transform: rotate(360deg); } }
.btn-loading { position: relative; pointer-events: none; opacity: 0.7; }
.btn-loading::after {
  content: '';
  position: absolute;
  right: 8px; top: 50%;
  width: 14px; height: 14px;
  margin-top: -7px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.toast-msg {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #333; color: #fff; padding: 10px 20px; border-radius: 8px;
  font-size: 0.9rem; z-index: 9999; opacity: 0;
  transition: opacity 0.3s ease;
}
.toast-msg.show { opacity: 1; }
