:root {
    --bg: #f5f6f8;
    --card: #ffffff;
    --border: #e0e2e6;
    --text-main: #202124;
    --text-muted: #5f6368;
    --primary: #5c35d4;
    --sun: #fbbc04;
    --shadow: #3c4043;
    --obs: #ea4335;
    --success: #0f9d58;
    --input-bg: #fafafa;
    --report-bg: #f8f9fa;
    --article-bg: #fff3e0;
    --article-border: #ffe0b2;
    --article-heading: #ef6c00;
    --val-copy-bg: #ffe0b2;
    --val-copy-bg-hover: #ffcc80;
    --val-copy-text: #d84315;
    --hint-color: #8d6e63;
    --compass-bg: radial-gradient(circle, #fafafa 60%, #fff 100%);
    --text-btn-hover-bg: #f0ebf8;
    --val-fail-bg: #fce8e6;
    --val-fail-text: #c5221f;
}

/* Dark mode overrides */
:root[data-theme="dark"] {
    --bg: #1a1a2e;
    --card: #242438;
    --border: #3a3a50;
    --text-main: #e8e8f0;
    --text-muted: #aaa;
    --primary: #9b7bff;
    --shadow: #8a8a9a;
    --success: #4ade80;
    --input-bg: #2e2e44;
    --report-bg: #2e2e44;
    --article-bg: #2e2a22;
    --article-border: #5a4a30;
    --article-heading: #ffb74d;
    --val-copy-bg: #5a4a30;
    --val-copy-bg-hover: #7a6a40;
    --val-copy-text: #ffab91;
    --hint-color: #d7a98a;
    --compass-bg: radial-gradient(circle, #2e2e44 60%, #242438 100%);
    --text-btn-hover-bg: rgba(155, 123, 255, 0.12);
    --val-fail-bg: rgba(248, 113, 113, 0.12);
    --val-fail-text: #f87171;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #1a1a2e;
        --card: #242438;
        --border: #3a3a50;
        --text-main: #e8e8f0;
        --text-muted: #aaa;
        --primary: #9b7bff;
        --shadow: #8a8a9a;
        --success: #4ade80;
        --input-bg: #2e2e44;
        --report-bg: #2e2e44;
        --article-bg: #2e2a22;
        --article-border: #5a4a30;
        --article-heading: #ffb74d;
        --val-copy-bg: #5a4a30;
        --val-copy-bg-hover: #7a6a40;
        --val-copy-text: #ffab91;
        --hint-color: #d7a98a;
        --compass-bg: radial-gradient(circle, #2e2e44 60%, #242438 100%);
        --text-btn-hover-bg: rgba(155, 123, 255, 0.12);
        --val-fail-bg: rgba(248, 113, 113, 0.12);
        --val-fail-text: #f87171;
    }
}

* {
    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: 1000px;
    margin: 0 auto;
    padding: 24px 16px;
}

.hero {
    background: var(--card);
    padding: 24px;
    border-radius: 12px;
    border: 1px solid var(--border);
    margin-bottom: 24px;
}

.hero h1 {
    margin: 0 0 12px;
    font-size: 26px;
    color: var(--primary);
}

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

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

@media (min-width: 800px) {
    .dashboard {
        flex-direction: row;
    }

    .calculator {
        flex: 1;
    }

    .visualizer {
        flex: 1;
    }
}

.panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
}

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

.panel-header h2 {
    margin: 0;
    font-size: 18px;
}

.panel h2 {
    margin: 0 0 20px 0;
    font-size: 18px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 14px;
}

.help-text {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

input[type="number"],
input[type="datetime-local"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
    background: var(--input-bg);
    color: var(--text-main);
}

.coord-inputs {
    display: flex;
    gap: 12px;
}

.coord-inputs input {
    width: 50%;
}

.btn {
    padding: 12px 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: #4a29af;
}

.btn.full-width {
    width: 100%;
    margin-top: 10px;
}

.text-btn {
    background: transparent;
    color: var(--primary);
    padding: 4px 8px;
}

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

.hidden {
    display: none !important;
}

/* Compass rendering */
.compass-container {
    display: flex;
    justify-content: center;
    margin: 30px 0;
}

.compass-rose {
    width: 200px;
    height: 200px;
    border: 2px solid var(--border);
    border-radius: 50%;
    position: relative;
    background: var(--compass-bg);
}

.mark {
    position: absolute;
    font-size: 12px;
    font-weight: bold;
    color: var(--text-muted);
}

.m-n {
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
}

.m-e {
    right: -40px;
    top: 50%;
    transform: translateY(-50%);
}

.m-s {
    bottom: -24px;
    left: 50%;
    transform: translateX(-50%);
}

.m-w {
    left: -40px;
    top: 50%;
    transform: translateY(-50%);
}

.center-dot {
    width: 12px;
    height: 12px;
    background: #aaa;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 5;
}

.needle {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 4px;
    height: 90px;
    transform-origin: 50% 0px;
    /* Pivots from the center (which is the top of the needle div) */
    transition: transform 1s cubic-bezier(0.25, 1, 0.5, 1);
    pointer-events: none;
}

/* Needles point "up" towards 0 degrees initially. But we want the line to grow from center outward. 
   So top:50%, left:50%, transform-origin: top center. 
   The div itself draws downward initially. So rotation 0 points South by default in CSS if we draw downwards.
   We need to initially rotate 180 so it points North.
*/
.needle .line {
    width: 100%;
    height: 100%;
    border-radius: 2px;
}

.needle .label {
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    white-space: nowrap;
    font-weight: bold;
}

/* Sun is yellow */
.sun-needle .line {
    background: var(--sun);
    box-shadow: 0 0 10px var(--sun);
}

.sun-needle .label {
    color: #d69e00;
}

/* Shadow is dark grey, goes opposite to sun */
.shadow-needle .line {
    background: rgba(60, 64, 67, 0.6);
}

.shadow-needle .label {
    color: var(--shadow);
}

/* Observed Shadow is red dashed (actually we just use a different color) */
.obs-needle .line {
    background: var(--obs);
    width: 2px;
}

.obs-needle .label {
    color: var(--obs);
}

.results-report {
    display: flex;
    gap: 12px;
    flex-direction: column;
}

.report-box {
    background: var(--report-bg);
    padding: 16px;
    border-radius: 8px;
    border-left: 4px solid var(--primary);
}

.report-box h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
}

.report-box p {
    margin: 0 0 5px 0;
    font-size: 13px;
    color: var(--text-muted);
}

.report-box strong {
    color: var(--text-main);
    font-size: 15px;
}

.r-val {
    border-left-color: var(--success);
}

.r-val.fail {
    border-left-color: var(--obs);
    background: var(--val-fail-bg);
}

.r-val.fail #valMessage {
    color: var(--val-fail-text);
    font-weight: bold;
}

.article-panel {
    background: var(--article-bg);
    border: 1px solid var(--article-border);
    border-radius: 12px;
    padding: 24px;
    margin-top: 24px;
    font-size: 14.5px;
}

.article-panel h3 {
    margin: 0 0 16px;
    color: var(--article-heading);
}

.val-copy {
    background: var(--val-copy-bg);
    padding: 2px 6px;
    border-radius: 4px;
    cursor: pointer;
    color: var(--val-copy-text);
    font-weight: bold;
}

.val-copy:hover {
    background: var(--val-copy-bg-hover);
}

.hint {
    font-size: 13px;
    color: var(--hint-color);
    font-weight: 600;
    margin-top: 16px;
}
/* === 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; }


/* === Onboarding Pulse Dot === */
@keyframes onboardPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.6; }
}
.onboard-dot {
  display: inline-block;
  width: 8px; height: 8px;
  background: var(--accent, #c7491f);
  border-radius: 50%;
  animation: onboardPulse 1.5s ease-in-out infinite;
  margin-right: 4px;
  vertical-align: middle;
}
