/* Main container */
.cvr-main {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px 40px;
}

/* Hero */
.cvr-hero {
  text-align: center;
  padding: 8px 0 20px;
}

.cvr-hero h1,
.main-heading {
  font-size: clamp(1.5rem, 5vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: 8px;
  line-height: 1.2;
}

.cvr-hero p,
.sub-heading {
  font-size: 14px;
  color: var(--sub);
  max-width: 560px;
  margin: 0 auto;
  line-height: 1.6;
}

/* Upload section card */
.upload-section {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

/* Drop zone */
.upload-area {
  border: 2px dashed var(--line);
  border-radius: 14px;
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
  background: var(--bg);
}
.upload-area:hover,
.upload-area.dragover {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 4%, var(--bg));
}

.upload-icon {
  width: 48px;
  height: 48px;
  color: var(--brand);
  margin: 0 auto 14px;
  stroke-width: 1.5;
  display: block;
}

.upload-area h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}

.upload-area p {
  color: var(--sub);
  font-size: 13px;
  margin-bottom: 18px;
}

.file-input { display: none; }

.upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--brand);
  color: #fff;
  border: none;
  padding: 11px 24px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  font-family: "Poppins", sans-serif;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--brand) 25%, transparent);
}
.upload-btn:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
}

/* Preview area */
.preview-area {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.file-info {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg);
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
}

.file-icon {
  width: 30px;
  height: 30px;
  color: var(--brand);
  flex-shrink: 0;
}

.file-details { flex: 1; min-width: 0; }

.file-details h4 {
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-details p { color: var(--sub); font-size: 12px; }

.preview-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.file-info .preview-actions { margin-top: 0; }

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: "Poppins", sans-serif;
  transition: background 0.2s ease, transform 0.15s ease;
}
.action-btn svg { width: 16px; height: 16px; }

.delete-btn {
  background: color-mix(in srgb, #dc2626 8%, var(--card));
  color: #dc2626;
  border: 1px solid color-mix(in srgb, #dc2626 15%, transparent);
}
.delete-btn:hover {
  background: color-mix(in srgb, #dc2626 14%, var(--card));
  transform: translateY(-1px);
}

.analyze-btn {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 4px 10px color-mix(in srgb, var(--brand) 22%, transparent);
}
.analyze-btn:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}
.analyze-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.preview-thumbnail {
  width: 100%;
  max-height: 360px;
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 12px;
}
.preview-thumbnail img,
.preview-thumbnail canvas {
  max-height: 340px;
  max-width: 100%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.10);
}

/* Loading */
.loading-section {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  padding: 60px 20px;
  text-align: center;
  margin-bottom: 16px;
}

.loading-content { max-width: 420px; margin: 0 auto; }

.loading-spinner {
  width: 52px;
  height: 52px;
  border: 3px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  margin: 0 auto 20px;
}

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

.loading-section h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}
.loading-section p { color: var(--sub); font-size: 14px; min-height: 2.4em; }

/* Results section */
.results-section {
  background: transparent;
  padding: 0;
  margin-bottom: 32px;
}

.results-section .flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab-btn {
  flex-shrink: 0;
  padding: 10px 20px;
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  color: var(--sub);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  font-family: "Poppins", sans-serif;
  border-radius: 8px 8px 0 0;
  transition: color 0.15s ease, background 0.15s ease;
  white-space: nowrap;
}
.tab-btn:hover {
  color: var(--brand);
  background: color-mix(in srgb, var(--brand) 5%, transparent);
}
.tab-btn.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 5%, transparent);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* Results layout */
.results-grid {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 16px;
}

/* Score sidebar */
.results-sidebar {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  padding: 20px;
  align-self: start;
  position: sticky;
  top: calc(var(--header-h) + 12px);
}

.results-sidebar h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  margin-bottom: 14px;
}

/* Score ring */
.score-card {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.score-circle {
  width: 110px;
  height: 110px;
  filter: drop-shadow(0 4px 10px color-mix(in srgb, var(--brand) 18%, transparent));
}

.score-chart {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.score-bg {
  fill: none;
  stroke: var(--line);
  stroke-width: 3.5;
}

.score-progress {
  fill: none;
  stroke: url(#scoreGradient);
  stroke-width: 3.5;
  stroke-linecap: round;
  transition: stroke-dasharray 1.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.score-text {
  font-size: 14px;
  font-weight: 800;
  fill: var(--brand);
  transform: rotate(90deg);
  transform-origin: 18px 18px;
  text-anchor: middle;
  dominant-baseline: middle;
  letter-spacing: -0.02em;
}

/* Score breakdown */
.breakdown-categories { display: grid; gap: 12px; }

.category-item { border-radius: 10px; }

.category-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.category-header h4 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.points {
  font-size: 12px;
  font-weight: 700;
  color: var(--brand);
}

.category-bar {
  height: 6px;
  background: var(--line);
  border-radius: 99px;
  overflow: hidden;
}

.category-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--brand2));
  border-radius: 99px;
  transition: width 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Score justification */
.results-sidebar .border-t {
  border-top: 1px solid var(--line);
  margin-top: 14px;
  padding-top: 14px;
}

#scoreJustification {
  font-size: 12px;
  color: var(--sub);
  line-height: 1.5;
}

/* Feedback sections */
.feedback-section {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: var(--shadow2);
  margin-bottom: 12px;
  transition: box-shadow 0.2s ease;
}
.feedback-section:hover { box-shadow: var(--shadow); }

.feedback-section .section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  user-select: none;
}

.feedback-section .section-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  margin: 0;
}

.feedback-section .section-header .toggle-icon {
  width: 20px;
  height: 20px;
  color: var(--sub);
  transition: transform 0.25s ease;
  flex-shrink: 0;
}

.feedback-section .section-header .toggle-icon.collapsed {
  transform: rotate(-90deg);
}

.feedback-section .content-area {
  padding: 0 20px 14px;
}

/* Give first child controlled top breathing room via padding, not margin.
   This beats Tailwind JIT margin utilities (mt-4 etc.) which can't override padding. */
.feedback-section .content-area > *:first-child {
  margin-top: 0 !important;
  padding-top: 10px;
}

/* Tailwind mt-* class override for any first child */
.feedback-section .content-area > [class*="mt-"]:first-child {
  margin-top: 0 !important;
}

.feedback-section .content-area.collapsed { display: none; }

/* Feedback content typography */
.content-area {
  font-size: 13px;
  color: var(--text);
  line-height: 1.65;
}

.content-area p { color: var(--sub); margin-bottom: 8px; }

.content-area ul {
  list-style: disc;
  margin-left: 1.5rem;
  margin-top: 8px;
  margin-bottom: 8px;
}
.content-area ol {
  list-style: decimal;
  margin-left: 1.5rem;
  margin-top: 8px;
  margin-bottom: 8px;
}
.content-area li {
  margin-bottom: 5px;
  line-height: 1.6;
  color: var(--sub);
}
.content-area strong { font-weight: 700; color: var(--text); }
.content-area em { font-style: italic; }
.content-area code {
  background: var(--chip);
  color: var(--text);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 0.85em;
}
.content-area h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--brand);
  margin-top: 16px;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

/* Feedback bullets injected by JS */
.content-area .feedback-bullet {
  display: block;
  padding-left: 1.75rem;
  position: relative;
  line-height: 1.5;
  margin-bottom: 4px;
}
.content-area .feedback-bullet::before {
  content: "•";
  position: absolute;
  left: 0.75rem;
  color: var(--brand);
  font-weight: 700;
}
.content-area .feedback-numbered {
  display: block;
  padding-left: 1.25rem;
  line-height: 1.6;
  margin: 4px 0;
}

.feedback-label {
  display: block;
  margin: 4px 0 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--brand);
}
.content-area h4.feedback-label {
  border-bottom: 1px solid color-mix(in srgb, var(--brand) 20%, transparent);
  padding-bottom: 4px;
  margin-left: 0;
}

/* Feedback point */
.feedback-point {
  margin-bottom: 14px;
}
.feedback-point h4 {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  font-size: 14px;
}
.feedback-point p,
.feedback-point ul {
  color: var(--sub);
  font-size: 13px;
  line-height: 1.65;
}
.feedback-point ul li {
  margin-bottom: 4px;
  list-style: disc;
  margin-left: 1.5rem;
}

/* Rewrite suggestions */
.rewrite-suggestion {
  margin: 10px 0 0 8px;
  border-left: 3px solid var(--brand);
  padding: 8px 12px;
  font-style: italic;
  background: color-mix(in srgb, var(--brand) 4%, var(--card));
  border-radius: 0 8px 8px 0;
  font-size: 13px;
  color: var(--text);
}

.rewrite-btn {
  display: inline-flex;
  align-items: center;
  background: color-mix(in srgb, var(--brand) 10%, var(--chip));
  color: var(--brand);
  border: none;
  padding: 4px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  margin-left: 8px;
  cursor: pointer;
  font-family: "Poppins", sans-serif;
  transition: background 0.15s ease;
}
.rewrite-btn:hover {
  background: color-mix(in srgb, var(--brand) 18%, var(--chip));
}

/* Highlights */
.highlight-good {
  color: var(--success);
  font-weight: 700;
  display: inline-block;
  margin-left: 3px;
}
.highlight-issue {
  color: var(--danger);
  font-weight: 700;
  display: inline-block;
  margin-left: 3px;
}

/* Grammar corrections */
.grammar-correction {
  background: color-mix(in srgb, #dc2626 5%, var(--card));
  padding: 10px 14px;
  border-radius: 10px;
  border-left: 3px solid var(--danger);
  margin-bottom: 8px;
}

.original-text {
  text-decoration: line-through;
  color: var(--danger);
  margin-right: 6px;
}
.corrected-text {
  color: var(--success);
  font-weight: 600;
}

/* Severity badges */
.severity-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-left: 5px;
  vertical-align: middle;
}

.severity-critical { background: color-mix(in srgb, #dc2626 12%, var(--card)); color: #dc2626; border: 1px solid color-mix(in srgb, #dc2626 25%, transparent); }
.severity-high     { background: color-mix(in srgb, #ea580c 12%, var(--card)); color: #ea580c; border: 1px solid color-mix(in srgb, #ea580c 25%, transparent); }
.severity-moderate { background: color-mix(in srgb, #ca8a04 12%, var(--card)); color: #ca8a04; border: 1px solid color-mix(in srgb, #ca8a04 25%, transparent); }
.severity-low      { background: color-mix(in srgb, #64748b 10%, var(--card)); color: #64748b; border: 1px solid color-mix(in srgb, #64748b 20%, transparent); }

/* Tooltip */
.tooltip {
  position: relative;
  display: inline-block;
  cursor: help;
  border-bottom: 1px dotted var(--sub);
}
.tooltip .tooltiptext {
  visibility: hidden;
  width: 200px;
  background: #1e293b;
  color: #f8fafc;
  text-align: center;
  border-radius: 8px;
  padding: 6px 10px;
  position: absolute;
  z-index: 10;
  bottom: 130%;
  left: 50%;
  margin-left: -100px;
  opacity: 0;
  transition: opacity 0.2s ease;
  font-size: 12px;
  font-weight: 400;
}
.tooltip:hover .tooltiptext { visibility: visible; opacity: 1; }

/* Action buttons row */
.action-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 24px;
  flex-wrap: wrap;
}

.primary-btn,
.secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  font-family: "Poppins", sans-serif;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
  border: 1.5px solid transparent;
}
.primary-btn svg,
.secondary-btn svg { width: 18px; height: 18px; }

.primary-btn {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--brand) 22%, transparent);
}
.primary-btn:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--brand) 28%, transparent);
}

.secondary-btn {
  background: var(--card);
  color: var(--brand);
  border-color: var(--line);
}
.secondary-btn:hover {
  background: var(--chip);
  border-color: var(--brand2);
  transform: translateY(-2px);
}

/* Leaderboard / History rows injected by JS */
.p-3.rounded-lg.border { border-color: var(--line) !important; }
.hover\:bg-gray-50:hover { background: var(--chip) !important; }

.history-item {
  background: var(--card);
  border: 1px solid var(--line) !important;
  border-radius: 14px !important;
  cursor: pointer;
  transition: background 0.15s ease;
}
.history-item:hover { background: var(--chip) !important; }

/* Tips section */
.tips-section {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  padding: 28px 24px;
  margin-top: 12px;
}

.tips-section h2 {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  text-align: center;
  margin-bottom: 20px;
  letter-spacing: -0.025em;
}

.tips-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.tip-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.tip-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }

.tip-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--brand), var(--brand2));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 10px color-mix(in srgb, var(--brand) 22%, transparent);
}
.tip-icon svg { width: 20px; height: 20px; color: #fff; }

.tip-card h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.tip-card p {
  font-size: 13px;
  color: var(--sub);
  line-height: 1.55;
}

/* Form group (domain section) */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
  font-family: "Poppins", sans-serif;
  font-size: 13px;
  transition: border-color 0.2s ease;
}
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--brand);
}

.submit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--brand);
  color: #fff;
  border: none;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  font-family: "Poppins", sans-serif;
  cursor: pointer;
  width: 100%;
  margin-top: 8px;
  transition: background 0.2s ease, transform 0.15s ease;
}
.submit-btn:hover { background: var(--primary-dark); transform: translateY(-2px); }
.submit-btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

/* PDF preview modal overrides */
#pdfPreviewModal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(15, 27, 45, 0.55);
  backdrop-filter: blur(4px);
}

.cvr-modal-shell {
  max-width: 860px;
  width: 92%;
  margin: 5vh auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: 0 24px 48px rgba(0,0,0,0.18);
  overflow: hidden;
}

.cvr-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.cvr-modal-head h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.cvr-modal-close {
  border: none;
  background: var(--chip);
  color: var(--sub);
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  font-family: "Poppins", sans-serif;
  transition: background 0.15s ease;
}
.cvr-modal-close:hover { background: var(--line); }

.cvr-modal-body {
  max-height: 62vh;
  overflow-y: auto;
  padding: 20px;
}

.cvr-modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
}

.cvr-modal-download {
  background: var(--brand);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  font-family: "Poppins", sans-serif;
  cursor: pointer;
  transition: background 0.2s ease;
}
.cvr-modal-download:hover { background: var(--primary-dark); }

/* ── Responsive ── */
@media (max-width: 768px) {
  .cvr-main { padding: 16px 16px 40px; }

  .results-grid {
    grid-template-columns: 1fr;
  }
  .results-sidebar {
    position: static;
  }

  .tabs { gap: 2px; }
  .tab-btn {
    padding: 9px 14px;
    font-size: 13px;
    border-radius: 8px;
    border-bottom-color: transparent;
  }
  .tab-btn.active {
    border-bottom-color: transparent;
    background: color-mix(in srgb, var(--brand) 9%, transparent);
  }

  .file-info { flex-wrap: wrap; }
  .file-info .preview-actions {
    width: 100%;
    margin-top: 8px;
  }
  .file-info .action-btn { flex: 1; justify-content: center; }

  .action-buttons { flex-direction: column; }
  .primary-btn,
  .secondary-btn { width: 100%; }

  .tips-grid { grid-template-columns: 1fr; }
}

@media (min-width: 769px) and (max-width: 1023px) {
  .cvr-main { max-width: 860px; }
  .results-grid { grid-template-columns: 240px 1fr; }
}

@media (min-width: 1024px) {
  .cvr-main { max-width: 1100px; }
  .results-grid { grid-template-columns: 280px 1fr; gap: 20px; }
}

@media (min-width: 1400px) {
  .cvr-main { max-width: 1280px; }
  .results-grid { grid-template-columns: 320px 1fr; gap: 24px; }
  .results-sidebar { padding: 24px; }
  .feedback-section .content-area { padding: 0 24px 20px; }
  .feedback-section .section-header { padding: 18px 24px; }
}
