/* ARIA - Academic Research Intelligence Assistant */
/* Clean light purple, futuristic yet professional */

:root {
  --primary: #7c3aed;
  --primary-dark: #6d28d9;
  --primary-light: #c4b5fd;
  --primary-bg: #f5f3ff;
  --accent: #a78bfa;
  --accent-light: #ddd6fe;
  --bg-primary: #faf9fe;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f3f1f9;
  --bg-hover: #ebe8f4;
  --text-primary: #1c1527;
  --text-secondary: #4a4458;
  --text-muted: #8e85a3;
  --border: #e8e4f0;
  --border-light: #f3f1f9;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --sidebar-width: 260px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 4px rgba(124, 58, 237, 0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 30px rgba(124, 58, 237, 0.08), 0 4px 12px rgba(0,0,0,0.04);
}

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

html {
  /* Fix iOS 100vh bug — use svh with vh fallback */
  height: 100%;
  height: -webkit-fill-available;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  /* Safe area padding for notch devices */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  min-height: 100vh;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
}

/* Pages */
.page { display: none; min-height: 100vh; min-height: 100dvh; }
.page.active { display: flex; }
#page-app.active { display: block; }

/* Mobile header — hidden on desktop */
.mobile-header { display: none; }
.mobile-bottom-nav { display: none; }

/* ============ LANDING ============ */
.landing { width: 100%; display: flex; flex-direction: column; align-items: center; }
.landing-hero {
  max-width: 1100px;
  margin: 0 auto;
  padding: 60px 24px;
  text-align: center;
}
.landing-logo {
  font-size: 48px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 16px;
  letter-spacing: -1px;
}
.landing-hero h1 {
  font-size: 36px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
  letter-spacing: -0.5px;
}
.landing-subtitle {
  font-size: 18px;
  color: var(--text-secondary);
  max-width: 700px;
  margin: 0 auto 48px;
  line-height: 1.7;
}
.landing-features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-bottom: 48px;
}
.feature-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  text-align: left;
  transition: all 0.2s;
}
.feature-card:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}
.feature-icon { font-size: 32px; margin-bottom: 12px; }
.feature-card h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.feature-card p { font-size: 14px; color: var(--text-secondary); line-height: 1.6; }
.landing-cta { display: flex; gap: 16px; justify-content: center; }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  gap: 6px;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--bg-tertiary); color: var(--text-primary); }
.btn-secondary:hover { background: var(--bg-hover); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-primary); }
.btn-outline:hover { background: var(--bg-tertiary); border-color: var(--primary-light); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { color: var(--text-primary); background: var(--bg-tertiary); }
.btn-lg { padding: 14px 32px; font-size: 16px; border-radius: var(--radius); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============ AUTH ============ */
.auth-container {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary-bg), #faf5ff);
}
.auth-card {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 48px;
  width: 420px;
  box-shadow: var(--shadow-lg);
}
.auth-logo {
  font-size: 36px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-align: center;
  margin-bottom: 8px;
}
.auth-card h2 { text-align: center; margin-bottom: 28px; font-size: 22px; }
.auth-switch { text-align: center; margin-top: 20px; font-size: 14px; color: var(--text-secondary); }
.auth-switch a { color: var(--primary); text-decoration: none; font-weight: 500; }

/* ============ FORMS ============ */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.form-input, input[type="text"], input[type="email"], input[type="password"] {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px; /* Must be >= 16px to prevent iOS Safari auto-zoom on focus */
  font-family: inherit;
  transition: border-color 0.2s;
  background: var(--bg-secondary);
  -webkit-appearance: none;
  appearance: none;
}
.form-input:focus, input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}
.form-textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-family: inherit;
  resize: vertical;
  background: var(--bg-secondary);
  -webkit-appearance: none;
  appearance: none;
}
.form-select, .form-select-sm {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-family: inherit;
  background: var(--bg-secondary);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.form-select-sm { padding: 6px 10px; font-size: 13px; }
.form-row { display: flex; gap: 16px; }
.flex-grow { flex: 1; }
.form-range { width: 100%; }
.error-msg { color: var(--danger); font-size: 13px; margin-bottom: 12px; min-height: 18px; }

/* ============ ONBOARDING ============ */
.onboarding-container {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary-bg), #faf5ff);
  padding: 24px;
}
.onboarding-card {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 48px;
  width: 640px;
  max-width: 100%;
  box-shadow: var(--shadow-lg);
}
.onboarding-progress { margin-bottom: 32px; }
.progress-bar {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 3px;
  transition: width 0.3s;
}
#onboarding-step-label { font-size: 13px; color: var(--text-muted); }
.onboarding-step { display: none; }
.onboarding-step.active { display: block; }
.onboarding-step h2 { font-size: 22px; margin-bottom: 8px; }
.onboarding-step > p { color: var(--text-secondary); margin-bottom: 24px; font-size: 14px; }
.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}
.field-option {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
  background: var(--bg-secondary);
}
.field-option:hover { border-color: var(--primary-light); background: var(--primary-bg); }
.field-option.selected { border-color: var(--primary); background: var(--primary-bg); color: var(--primary-dark); font-weight: 500; }
.onboarding-nav { display: flex; justify-content: space-between; margin-top: 32px; }
.tag-input-container {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  min-height: 44px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.tags-display { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-input-container input {
  border: none !important;
  padding: 4px !important;
  min-width: 120px;
  flex: 1;
  box-shadow: none !important;
}
.tag-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--primary-bg);
  color: var(--primary-dark);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
}
.tag-badge .remove-tag {
  cursor: pointer;
  opacity: 0.6;
  font-size: 16px;
  line-height: 1;
}
.tag-badge .remove-tag:hover { opacity: 1; }

/* ============ SIDEBAR ============ */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  height: 100vh;
  height: 100dvh;
  position: fixed;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
}
.sidebar-logo {
  font-size: 28px;
  font-weight: 700;
  padding: 24px 24px 2px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.sidebar-version {
  font-size: 10px;
  color: var(--text-muted);
  padding: 0 24px 8px;
  letter-spacing: 0.3px;
}
.sidebar-user {
  padding: 8px 24px 20px;
  border-bottom: 1px solid var(--border);
}
.sidebar-username { font-size: 14px; font-weight: 600; }
.sidebar-field { font-size: 12px; color: var(--text-muted); }
.sidebar-nav { flex: 1; padding: 12px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  transition: all 0.2s;
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.nav-item.active { background: var(--primary-bg); color: var(--primary-dark); font-weight: 500; }
.nav-icon { font-size: 18px; width: 24px; text-align: center; }
.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.version { font-size: 11px; color: var(--text-muted); }

/* ============ MAIN CONTENT ============ */
.main-content {
  margin-left: var(--sidebar-width);
  padding: 28px 32px;
  min-height: 100vh;
}
.section { display: none; }
.section.active { display: block; }
.section-header {
  margin-bottom: 20px;
}
.section-header h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.3px; }
.section-subtitle { color: var(--text-secondary); font-size: 14px; margin-top: 4px; }
.section-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
  flex-wrap: wrap;
}

/* ============ STATS ============ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.stat-value { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ============ DASHBOARD ============ */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
}
.dash-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.dash-card h3 { font-size: 16px; font-weight: 600; margin-bottom: 16px; }
.quick-actions { display: flex; flex-direction: column; gap: 10px; }

/* ============ PAPERS ============ */
.search-input {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-family: inherit;
  width: 260px;
  background: var(--bg-secondary);
  -webkit-appearance: none;
}
.papers-list { display: flex; flex-direction: column; gap: 12px; }
.paper-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all 0.2s;
}
.paper-card:hover { border-color: var(--primary-light); box-shadow: var(--shadow); }
.paper-header {
  padding: 16px 20px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.paper-title { font-size: 15px; font-weight: 600; color: var(--text-primary); line-height: 1.4; flex: 1; }
.paper-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
  flex-wrap: wrap;
}
.paper-meta-item { font-size: 12px; color: var(--text-muted); }
.paper-score {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}
.score-high { background: #dcfce7; color: #166534; }
.score-mid { background: #fef9c3; color: #854d0e; }
.score-low { background: #fee2e2; color: #991b1b; }
.paper-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.paper-tag {
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
}
.tag-enriched { background: #dcfce7; color: #166534; }
.tag-pending { background: #fef3c7; color: #92400e; }
.tag-journal { background: var(--primary-bg); color: var(--primary-dark); }
.tag-year { background: #f3e8ff; color: #7c3aed; }
.tag-bookmarked { background: #fce7f3; color: #be185d; }

.paper-expand-arrow {
  width: 20px;
  height: 20px;
  transition: transform 0.2s;
  flex-shrink: 0;
  color: var(--text-muted);
  margin-top: 4px;
}
.paper-expand-arrow.open { transform: rotate(90deg); }

.paper-dropdown {
  display: none;
  padding: 0 20px 20px;
  border-top: 1px solid var(--border-light);
}
.paper-dropdown.open { display: block; }
.dropdown-section {
  margin-bottom: 16px;
}
.dropdown-section h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-dark);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.dropdown-section p, .dropdown-section li {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}
.dropdown-section ul { padding-left: 20px; }
.dropdown-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
}

/* Quantitative results table */
.quant-results { background: #f0fdf4; border-radius: var(--radius-sm); padding: 16px !important; border: 1px solid #bbf7d0; }
.quant-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; }
.quant-table th { text-align: left; font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; padding: 6px 10px; border-bottom: 1px solid #bbf7d0; }
.quant-table td { padding: 6px 10px; border-bottom: 1px solid #dcfce7; color: var(--text-secondary); vertical-align: top; }
.quant-table tr:last-child td { border-bottom: none; }
.quant-value { font-weight: 600; color: #166534; font-family: 'SF Mono', 'Fira Code', monospace; white-space: nowrap; }

.enrichment-bar {
  padding: 10px 16px;
  background: var(--primary-bg);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--primary-dark);
  display: none;
}
.enrichment-bar.visible { display: block; }
.pagination {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 24px;
}

/* ============ READER ============ */
.reader-input-area {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}
.reader-search { flex: 1; width: auto; }
.reader-result {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  line-height: 1.8;
  font-size: 14px;
}
.reader-result:empty { display: none; }
.reader-result h2 { font-size: 18px; margin: 20px 0 8px; color: var(--primary-dark); }
.reader-result h3 { font-size: 15px; margin: 16px 0 6px; }
.reader-result ul { padding-left: 20px; margin: 8px 0; }
.reader-result li { margin-bottom: 4px; }
.reader-history { margin-top: 32px; }
.reader-history h3 { font-size: 16px; margin-bottom: 12px; }

/* ============ CHAT ============ */
.chat-layout { display: flex; gap: 0; height: calc(100vh - 160px); height: calc(100dvh - 160px); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.chat-sidebar {
  width: 240px;
  background: var(--bg-tertiary);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px;
}
.chat-conv-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  transition: all 0.2s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-conv-item:hover { background: var(--bg-hover); }
.chat-conv-item.active { background: var(--primary-bg); color: var(--primary-dark); font-weight: 500; }
.chat-main { flex: 1; display: flex; flex-direction: column; background: var(--bg-secondary); }
.chat-messages { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 24px; }
.chat-empty { text-align: center; padding: 48px 24px; }
.chat-empty h3 { font-size: 18px; margin-bottom: 8px; }
.chat-empty p { color: var(--text-secondary); margin-bottom: 20px; }
.chat-msg {
  margin-bottom: 20px;
  max-width: 85%;
}
.chat-msg.user { margin-left: auto; }
.chat-msg-bubble {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.7;
}
.chat-msg.user .chat-msg-bubble { background: var(--primary); color: white; border-bottom-right-radius: 4px; }
.chat-msg.assistant .chat-msg-bubble { background: var(--bg-tertiary); border-bottom-left-radius: 4px; }
.chat-msg-label { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.chat-input-area {
  display: flex;
  gap: 10px;
  padding: 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}
.chat-textarea {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-family: inherit;
  resize: none;
  min-height: 44px;
  max-height: 120px;
  -webkit-appearance: none;
}
.sample-questions { display: flex; flex-direction: column; gap: 8px; max-width: 500px; margin: 0 auto; }
.sample-q {
  padding: 10px 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all 0.2s;
  text-align: left;
}
.sample-q:hover { background: var(--primary-bg); color: var(--primary-dark); }

/* ============ WRITING ============ */
.writing-form {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}
.writing-output {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  line-height: 1.8;
  font-size: 14px;
  white-space: pre-wrap;
}
.writing-output:empty { display: none; }
.writing-history { margin-top: 32px; }
.writing-history h3 { font-size: 16px; margin-bottom: 12px; }

/* ============ DIGEST ============ */
.digest-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  line-height: 1.8;
  font-size: 14px;
}
.digest-content:empty { display: none; }
.digest-content h2 { font-size: 18px; margin: 20px 0 8px; color: var(--primary-dark); }
.digest-content h3 { font-size: 15px; margin: 16px 0 6px; }
.digest-content a { color: var(--primary); }
.digest-content ul, .digest-content ol { padding-left: 20px; margin: 8px 0; }

/* ============ IDEAS ============ */
.ideas-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.idea-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: all 0.2s;
}
.idea-card:hover { border-color: var(--primary-light); box-shadow: var(--shadow); }
.idea-category {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.cat-experimental { background: #dcfce7; color: #166534; }
.cat-computational { background: #ede9fe; color: #6d28d9; }
.cat-translational { background: #fce7f3; color: #be185d; }
.cat-methodological { background: #fef3c7; color: #92400e; }
.cat-review { background: #f3e8ff; color: #7c3aed; }
.idea-card h4 { font-size: 15px; margin-bottom: 8px; line-height: 1.4; }
.idea-card p { font-size: 13px; color: var(--text-secondary); line-height: 1.6; }

/* ============ LOADING ============ */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px;
  color: var(--text-muted);
}
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ MARKDOWN ============ */
.markdown-body h1 { font-size: 22px; margin: 24px 0 12px; }
.markdown-body h2 { font-size: 18px; margin: 20px 0 8px; color: var(--primary-dark); }
.markdown-body h3 { font-size: 15px; margin: 16px 0 6px; }
.markdown-body p { margin-bottom: 12px; }
.markdown-body ul, .markdown-body ol { padding-left: 20px; margin-bottom: 12px; }
.markdown-body li { margin-bottom: 4px; }
.markdown-body strong { font-weight: 600; }
.markdown-body code { background: var(--bg-tertiary); padding: 2px 6px; border-radius: 4px; font-size: 13px; }
.markdown-body a { color: var(--primary); text-decoration: none; }
.markdown-body a:hover { text-decoration: underline; }

/* ============ TRIAL BANNER ============ */
.trial-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  background: var(--primary-bg);
  color: var(--primary-dark);
  font-size: 14px;
  font-weight: 500;
  border-bottom: 1px solid var(--primary-light);
  z-index: 50;
  gap: 12px;
  flex-wrap: wrap;
}
.trial-banner-urgent {
  background: #fef3c7;
  color: #92400e;
  border-bottom-color: #fcd34d;
}

/* ============ PAYWALL ============ */
.paywall-container {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  background: linear-gradient(135deg, var(--primary-bg), #faf5ff);
  padding: 24px;
}
.paywall-card {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 48px;
  width: 480px;
  max-width: 100%;
  box-shadow: var(--shadow-lg);
}
.pricing-card-paywall {
  background: var(--primary-bg);
  border: 2px solid var(--primary-light);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  margin-bottom: 8px;
}

/* ============ LANDING PRICING ============ */
.landing-pricing {
  margin: 48px 0 32px;
  text-align: center;
}
.landing-pricing h2 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
}
.pricing-highlight {
  background: var(--bg-secondary);
  border: 2px solid var(--primary-light);
  border-radius: var(--radius);
  padding: 40px;
  max-width: 420px;
  margin: 0 auto;
  box-shadow: var(--shadow-lg);
}
.price-tag {
  font-size: 48px;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 4px;
}
.price-tag span {
  font-size: 18px;
  font-weight: 400;
  color: var(--text-muted);
}
.price-trial {
  font-size: 14px;
  color: var(--success);
  font-weight: 600;
  margin-bottom: 20px;
}
.pricing-features-list {
  list-style: none;
  padding: 0;
  margin: 0 0 24px;
  text-align: left;
}
.pricing-features-list li {
  padding: 8px 0;
  font-size: 14px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 8px;
}
.pricing-features-list li::before {
  content: '✓';
  color: var(--success);
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}
.pricing-features-list li:last-child { border-bottom: none; }

/* ============ RESPONSIVE / iOS ============ */
@media (max-width: 900px) {
  .landing-features { grid-template-columns: 1fr; }
  .landing-hero { padding: 40px 20px; }
  .landing-hero h1 { font-size: 26px; }
  .landing-subtitle { font-size: 15px; }
  .landing-cta { flex-direction: column; align-items: center; }
  .auth-card { width: 100%; max-width: 420px; padding: 32px 24px; margin: 0 16px; }

  /* Hide desktop sidebar, show mobile nav */
  .sidebar {
    display: flex;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    width: 280px;
    z-index: 200;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 0 0 40px rgba(0,0,0,0.3);
  }
  /* Overlay when sidebar open */
  .sidebar.mobile-open::after {
    content: '';
    position: fixed;
    top: 0; right: -100vw; bottom: 0;
    width: 100vw;
    background: rgba(0,0,0,0.3);
    z-index: -1;
  }

  .mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    padding-top: calc(12px + env(safe-area-inset-top));
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
  }
  .mobile-logo {
    font-size: 22px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
  }
  .mobile-version {
    font-size: 9px;
    color: var(--text-muted);
    margin-top: -2px;
  }
  .mobile-menu-btn {
    background: none;
    border: none;
    font-size: 24px;
    padding: 8px;
    cursor: pointer;
    color: var(--text-primary);
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0; right: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 6px 0;
    padding-bottom: calc(6px + env(safe-area-inset-bottom));
    z-index: 150;
    justify-content: space-around;
  }
  .mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 8px;
    font-size: 20px;
    text-decoration: none;
    color: var(--text-muted);
    min-width: 44px;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-nav-item span {
    font-size: 10px;
    font-weight: 500;
  }
  .mobile-nav-item.active {
    color: var(--primary);
  }

  .main-content {
    margin-left: 0;
    padding: 20px 16px;
    padding-bottom: calc(80px + env(safe-area-inset-bottom));
  }

  .section-header h1 { font-size: 20px; }
  .section-actions { flex-wrap: wrap; }
  .search-input { width: 100%; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; }
  .ideas-list { grid-template-columns: 1fr; }

  /* Chat — full height on mobile */
  .chat-layout {
    flex-direction: column;
    height: calc(100dvh - 200px);
    border: none;
    border-radius: 0;
    margin: -20px -16px;
    width: calc(100% + 32px);
  }
  .chat-sidebar { width: 100%; max-height: 120px; border-right: none; border-bottom: 1px solid var(--border); }
  .chat-input-area { padding: 10px; }

  /* Paper cards */
  .paper-header { padding: 12px 14px; flex-wrap: wrap; }
  .paper-dropdown { padding: 0 14px 14px; }
  .dropdown-actions { flex-wrap: wrap; }
  .quant-results { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .quant-table { min-width: 400px; }

  /* Reader */
  .reader-input-area { flex-direction: column; }
  .reader-search { width: 100%; }

  /* Touch targets — ensure 44px minimum */
  .btn { min-height: 44px; }
  .btn-sm { min-height: 36px; }
  .nav-item { min-height: 44px; }
  .field-option { min-height: 44px; display: flex; align-items: center; justify-content: center; }
  .onboarding-card { padding: 24px 20px; }
}

/* Profile Section */
.profile-grid {
  display: grid;
  gap: 20px;
  max-width: 700px;
}
.profile-field {
  padding: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 10px;
}
.profile-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.profile-field div {
  font-size: 15px;
  color: var(--text-primary);
  line-height: 1.5;
}
