/* ===== DESIGN TOKENS (matches landing page) ===== */
:root {
  --bg: #FAFAF8;
  --bg-alt: #F1F5F4;
  --fg: #1A1A1A;
  --fg-muted: #64748B;
  --fg-subtle: #94A3B8;
  --accent: #0D9488;
  --accent-light: #14B8A6;
  --accent-bg: #F0FDFA;
  --amber: #D97706;
  --amber-bg: #FEF3C7;
  --text-inverse: #FFFFFF;
  --border: #E2E8F0;
  --radius: 12px;
  --radius-lg: 20px;
  --font-display: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 16px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 24px rgba(0,0,0,0.10), 0 1px 6px rgba(0,0,0,0.06);
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== NAV ===== */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  background: rgba(250, 250, 248, 0.90);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav-inner { max-width: 900px; margin: 0 auto; width: 100%; display: flex; align-items: center; justify-content: space-between; }
.nav-logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--fg); }
.nav-logo-icon { width: 32px; height: 32px; background: var(--accent); border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.nav-logo-icon svg { width: 18px; height: 18px; fill: white; }
.nav-logo span { font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; letter-spacing: -0.02em; }
.nav-tagline { font-size: 0.875rem; color: var(--fg-muted); }

/* ===== MAIN ===== */
.main { padding-top: 80px; min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding-bottom: 80px; }

/* ===== HEADER ===== */
.page-header { text-align: center; padding: 48px 24px 32px; max-width: 600px; }
.page-header h1 { font-family: var(--font-display); font-size: 2rem; font-weight: 700; letter-spacing: -0.03em; color: var(--fg); margin-bottom: 8px; }
.page-header p { color: var(--fg-muted); font-size: 1rem; }

/* ===== UPLOAD CARD ===== */
.upload-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 580px;
  box-shadow: var(--shadow);
  margin: 0 24px;
}

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
}
.drop-zone:hover, .drop-zone.drag-over { border-color: var(--accent); background: var(--accent-bg); }
.drop-zone-icon { width: 48px; height: 48px; background: var(--accent-bg); border-radius: 12px; display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; }
.drop-zone-icon svg { width: 24px; height: 24px; stroke: var(--accent); }
.drop-zone h3 { font-family: var(--font-display); font-size: 1rem; font-weight: 600; margin-bottom: 6px; color: var(--fg); }
.drop-zone p { font-size: 0.875rem; color: var(--fg-muted); }
.drop-zone .browse-link { color: var(--accent); font-weight: 500; text-decoration: none; }
.drop-zone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }

/* File preview */
.file-preview { display: none; align-items: center; gap: 12px; padding: 16px; background: var(--bg); border-radius: var(--radius); margin-top: 16px; }
.file-preview.visible { display: flex; }
.file-preview-icon { width: 40px; height: 40px; background: var(--accent-bg); border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.file-preview-icon svg { width: 20px; height: 20px; stroke: var(--accent); }
.file-preview-info { flex: 1; min-width: 0; }
.file-preview-name { font-weight: 500; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-preview-size { font-size: 0.8rem; color: var(--fg-muted); }
.file-preview-remove { background: none; border: none; cursor: pointer; color: var(--fg-muted); padding: 4px; border-radius: 4px; display: flex; align-items: center; }
.file-preview-remove:hover { background: var(--bg-alt); color: var(--fg); }

/* Upload button */
.upload-btn {
  width: 100%;
  margin-top: 16px;
  padding: 14px 24px;
  background: var(--accent);
  color: var(--text-inverse);
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.2s, transform 0.1s;
}
.upload-btn:hover:not(:disabled) { background: var(--accent-light); }
.upload-btn:active:not(:disabled) { transform: scale(0.98); }
.upload-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.upload-btn .spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
}
.upload-btn.loading .spinner { display: block; }
.upload-btn.loading .btn-text { display: none; }
.upload-btn.loading .btn-loading { display: inline; }
.upload-btn .btn-loading { display: none; }

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

/* Error message */
.error-msg { display: none; margin-top: 12px; padding: 12px 16px; background: var(--amber-bg); color: var(--amber); border-radius: var(--radius); font-size: 0.875rem; }
.error-msg.visible { display: block; }

/* ===== EXPLANATION RESULT ===== */
.explanation-card {
  display: none;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 720px;
  margin: 32px 24px 0;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.explanation-card.visible { display: block; }

.explanation-header {
  padding: 20px 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
}
.explanation-header h2 { font-family: var(--font-display); font-size: 1rem; font-weight: 600; color: var(--fg); display: flex; align-items: center; gap: 8px; }
.explanation-header h2 svg { width: 18px; height: 18px; stroke: var(--accent); }
.explanation-badge { background: var(--accent-bg); color: var(--accent); font-size: 0.75rem; font-weight: 600; padding: 4px 10px; border-radius: 20px; }
.explanation-body { padding: 28px; }

/* Markdown rendering */
.explanation-body h2 { font-family: var(--font-display); font-size: 1.1rem; font-weight: 700; color: var(--fg); margin: 24px 0 8px; padding-top: 20px; border-top: 1px solid var(--border); }
.explanation-body h2:first-child { margin-top: 0; padding-top: 0; border-top: none; }
.explanation-body p { color: var(--fg); margin-bottom: 12px; line-height: 1.7; }
.explanation-body ul, .explanation-body ol { padding-left: 20px; margin-bottom: 12px; }
.explanation-body li { color: var(--fg); margin-bottom: 4px; line-height: 1.6; }
.explanation-body strong { color: var(--fg); font-weight: 700; }
.explanation-body code { background: var(--bg-alt); padding: 2px 6px; border-radius: 4px; font-size: 0.875em; font-family: 'Courier New', monospace; }
.explanation-body pre { background: var(--bg-alt); padding: 16px; border-radius: var(--radius); overflow-x: auto; margin-bottom: 12px; }
.explanation-body pre code { background: none; padding: 0; }

/* Try another */
.try-again-wrap { text-align: center; padding: 24px 28px 28px; border-top: 1px solid var(--border); }
.try-again-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px;
  background: var(--bg-alt);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem; font-weight: 500;
  cursor: pointer; text-decoration: none;
  transition: background 0.2s;
}
.try-again-btn:hover { background: var(--bg); }

/* ===== PROCESSING STATE (upload card) ===== */
.processing-overlay { display: none; text-align: center; padding: 40px; }
.processing-overlay.visible { display: block; }
.processing-spinner { width: 48px; height: 48px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto 20px; }
.processing-overlay h3 { font-family: var(--font-display); font-size: 1.1rem; font-weight: 600; margin-bottom: 8px; }
.processing-overlay p { color: var(--fg-muted); font-size: 0.9rem; }