/* ─────────────────────────────────────────────────────────────────────────────
   Project ASR — UI stylesheet
   Palette: slate-based neutrals, blue primary, amber diff highlight
   Premium visual design with micro-animations and gradient accents.
   No external CDN dependencies.
───────────────────────────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

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

:root {
  --blue-600:    #2563eb;
  --blue-700:    #1d4ed8;
  --blue-50:     #eff6ff;
  --green-600:   #16a34a;
  --green-100:   #dcfce7;
  --green-700:   #15803d;
  --amber-500:   #f59e0b;
  --amber-100:   #fef3c7;
  --amber-800:   #92400e;
  --red-600:     #dc2626;
  --red-100:     #fee2e2;
  --red-700:     #b91c1c;
  --slate-900:   #0f172a;
  --slate-800:   #1e293b;
  --slate-700:   #334155;
  --slate-600:   #475569;
  --slate-500:   #64748b;
  --slate-400:   #94a3b8;
  --slate-200:   #e2e8f0;
  --slate-100:   #f1f5f9;
  --slate-50:    #f8fafc;
  --white:       #ffffff;

  --radius-sm:   4px;
  --radius:      8px;
  --radius-lg:   12px;

  --shadow-sm:   0 1px 3px rgba(0,0,0,.08);
  --shadow:      0 2px 8px rgba(0,0,0,.10);
  --shadow-lg:   0 4px 16px rgba(0,0,0,.12);

  --font:        'Inter', system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono:   "SF Mono", "Fira Code", Consolas, "Courier New", monospace;

  /* Extended palette for premium feel */
  --indigo-500:  #6366f1;
  --indigo-600:  #4f46e5;
  --violet-500:  #8b5cf6;
  --blue-500:    #3b82f6;
  --blue-800:    #1e40af;
  --green-50:    #f0fdf4;
  --red-50:      #fef2f2;
  --blue-100:    #dbeafe;
  --blue-200:    #bfdbfe;
  --blue-300:    #93c5fd;
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--slate-100);
  color: var(--slate-800);
  font-size: 14px;
  line-height: 1.6;
}

/* ── Header ──────────────────────────────────────────────────────────────── */

.site-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
  color: var(--white);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 16px rgba(0,0,0,.25), 0 0 1px rgba(99,102,241,.15);
  border-bottom: 1px solid rgba(99, 102, 241, .15);
}

.header-inner {
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  background: linear-gradient(135deg, var(--blue-600), var(--indigo-500));
  color: var(--white);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: .08em;
  padding: 5px 10px;
  border-radius: 6px;
  box-shadow: 0 1px 8px rgba(99, 102, 241, .3);
  text-shadow: 0 1px 2px rgba(0,0,0,.2);
}

.brand-name { font-weight: 700; font-size: 15px; letter-spacing: .02em; }
.brand-sub  { font-size: 11px; color: var(--slate-400); letter-spacing: .04em; }

.header-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--slate-400);
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--slate-500);
}
.status-dot--idle    { background: var(--slate-500); }
.status-dot--busy    { background: var(--amber-500); animation: pulse .8s ease-in-out infinite alternate; }
.status-dot--ok      { background: var(--green-600); }
.status-dot--error   { background: var(--red-600); }

@keyframes pulse { from { opacity: .4; } to { opacity: 1; } }

/* ── Header controls ──────────────────────────────────────────────────── */

.header-controls {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Profile selector */
.profile-selector {
  display: flex;
  align-items: center;
  gap: 6px;
}

.profile-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--slate-400);
  font-weight: 600;
  white-space: nowrap;
}

.profile-dropdown {
  background: var(--slate-800);
  color: var(--white);
  border: 1px solid var(--slate-700);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 12px;
  font-family: var(--font);
  min-width: 140px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2394a3b8'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 24px;
}

.profile-dropdown:hover {
  border-color: var(--slate-500);
}

.profile-dropdown:focus {
  outline: 2px solid var(--blue-600);
  outline-offset: 1px;
}

.profile-dropdown option {
  background: var(--slate-800);
  color: var(--white);
}

/* Mode toggle */
.mode-toggle {
  display: flex;
  background: var(--slate-800);
  border-radius: var(--radius);
  border: 1px solid var(--slate-700);
  overflow: hidden;
}

.mode-btn {
  background: transparent;
  color: var(--slate-400);
  border: none;
  padding: 4px 14px;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: all .2s ease;
  white-space: nowrap;
}

.mode-btn:hover {
  color: var(--slate-200);
  background: rgba(255, 255, 255, .05);
}

.mode-btn--active {
  background: linear-gradient(135deg, var(--blue-600), var(--indigo-500));
  color: var(--white);
  font-weight: 600;
  box-shadow: 0 1px 6px rgba(99,102,241,.25);
}

.mode-btn--active:hover {
  background: linear-gradient(135deg, var(--blue-700), var(--indigo-600));
  color: var(--white);
}

/* ── Production mode ─────────────────────────────────────────────────── */

body.mode-production .panel--calibration {
  display: none;
}

body.mode-production .calib-form {
  display: none;
}

/* Style-match verdict */
.verdict-badge--style-match {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: var(--white);
  padding: 4px 12px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: .02em;
}

.style-match-info {
  margin-top: 8px;
  padding: 8px 12px;
  background: rgba(99, 102, 241, .06);
  border: 1px solid rgba(99, 102, 241, .15);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--slate-600);
}

.style-match-info strong {
  color: #6366f1;
}

/* ── Layout grid ─────────────────────────────────────────────────────────── */

.main-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto auto auto auto;
  grid-template-areas:
    "input   output"
    "editlog editlog"
    "scores  calibration"
    "scan    scan";
  gap: 18px;
  padding: 24px;
  max-width: 1600px;
  margin: 0 auto;
}

/* ── Panels ──────────────────────────────────────────────────────────────── */

.panel {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 0 0 1px rgba(0,0,0,.03);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: box-shadow .25s ease, transform .25s ease;
  border: 1px solid rgba(226, 232, 240, .6);
}

.panel:hover {
  box-shadow: 0 4px 20px rgba(0,0,0,.08), 0 0 0 1px rgba(99,102,241,.06);
  transform: translateY(-1px);
}

[hidden] { display: none !important; }

.panel--input       { grid-area: input; min-height: 420px; }
.panel--output      { grid-area: output; min-height: 420px; }
.panel--editlog     { grid-area: editlog; }
.panel--scores      { grid-area: scores; }
.panel--calibration { grid-area: calibration; }
.panel--scan        { grid-area: scan; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--slate-200);
  flex-shrink: 0;
  background: linear-gradient(180deg, rgba(248,250,252,.8) 0%, rgba(255,255,255,0) 100%);
}

.panel-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--slate-700);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px 14px;
  border-top: 1px solid var(--slate-200);
  flex-shrink: 0;
}

/* ── Text areas ──────────────────────────────────────────────────────────── */

.text-area {
  flex: 1;
  padding: 16px 18px;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.75;
  color: var(--slate-800);
  border: none;
  outline: none;
  resize: none;
  background: transparent;
}

textarea.text-area::placeholder { color: var(--slate-400); font-style: italic; }

.text-area--output {
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.output-placeholder {
  color: var(--slate-400);
  font-style: italic;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  text-align: center;
}

/* Diff highlighting */
.diff-del {
  color: var(--red-600);
  text-decoration: line-through;
  background: var(--red-100);
  border-radius: 2px;
  padding: 0 2px;
}

.diff-ins {
  background: var(--amber-100);
  color: var(--amber-800);
  border-radius: 2px;
  padding: 0 2px;
}

/* Token heatmap */
.tok-flagged {
  background: linear-gradient(to bottom, transparent 60%, rgba(245,158,11,.35) 60%);
}

.tok-critical {
  background: linear-gradient(to bottom, transparent 55%, rgba(245,158,11,.55) 55%);
  font-weight: 600;
}

.text-area--heatmap {
  flex: 1;
  padding: 16px 18px;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.75;
  color: var(--slate-800);
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  cursor: default;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  transition: all .2s ease;
  letter-spacing: .01em;
}

.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn--primary {
  background: linear-gradient(135deg, var(--blue-600), var(--indigo-500));
  color: var(--white);
  box-shadow: 0 2px 8px rgba(37, 99, 235, .25);
}
.btn--primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--blue-700), var(--indigo-600));
  box-shadow: 0 4px 16px rgba(37, 99, 235, .35);
  transform: translateY(-1px);
}
.btn--primary:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(37, 99, 235, .2);
}

.btn--secondary {
  background: linear-gradient(135deg, var(--slate-800), var(--slate-700));
  color: var(--white);
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
}
.btn--secondary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--slate-700), var(--slate-600));
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
  transform: translateY(-1px);
}

.btn--ghost { background: transparent; color: var(--slate-600); padding: 6px 10px; border-radius: 6px; }
.btn--ghost:hover { background: var(--slate-100); color: var(--slate-800); }

.btn--reject { background: var(--red-100); color: var(--red-700); border: 1px solid var(--red-600); font-weight: 600; }
.btn--reject:hover:not(:disabled) { background: var(--red-600); color: var(--white); transform: translateY(-1px); }

.btn--sm { font-size: 12px; padding: 5px 10px; }
.btn--full { width: 100%; justify-content: center; margin-top: 12px; }

/* ── Spinner ─────────────────────────────────────────────────────────────── */

.spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

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

/* ── Word & token count ──────────────────────────────────────────────────── */

.word-count { font-size: 12px; color: var(--slate-500); }

.token-count {
  font-size: 12px;
  color: var(--slate-500);
  margin-left: 12px;
  font-variant-numeric: tabular-nums;
  transition: color 0.2s ease;
}
.token-ok   { color: var(--slate-500); }
.token-warn { color: #d97706; }
.token-over { color: #dc2626; font-weight: 600; }

/* ── Badges ──────────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
}

.badge--neutral  { background: var(--slate-100); color: var(--slate-700); }
.badge--success  { background: var(--green-100); color: var(--green-700); }
.badge--warning  { background: var(--amber-100); color: var(--amber-800); }
.badge--danger   { background: var(--red-100);   color: var(--red-700); }
.badge--info     { background: var(--blue-50);   color: var(--blue-600); }

/* ── Verdict ─────────────────────────────────────────────────────────────── */

.verdict-badge {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .04em;
  padding: 5px 14px;
  border-radius: var(--radius);
}

.verdict-badge--accepted { background: var(--green-100); color: var(--green-700); }
.verdict-badge--rejected { background: var(--red-100);   color: var(--red-700); }

/* ── Score grid ──────────────────────────────────────────────────────────── */

.score-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 1px;
  background: var(--slate-200);
  border-top: 1px solid var(--slate-200);
}

.score-card {
  background: var(--white);
  padding: 16px 18px;
  transition: background .2s ease;
}

.score-card:hover {
  background: rgba(248, 250, 252, .8);
}

.score-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--slate-500);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 8px;
}

.score-bar-wrap {
  height: 6px;
  background: var(--slate-200);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}

.score-bar {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #ef4444, #f97316);
  width: 0%;
  transition: width .5s cubic-bezier(.4,0,.2,1);
}

.score-bar--good { background: linear-gradient(90deg, #22c55e, #10b981); }

.score-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--slate-800);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}

.score-value--lg { font-size: 18px; }

.score-sub {
  font-size: 11px;
  color: var(--slate-500);
  margin-top: 4px;
  line-height: 1.3;
}

/* ── Binoculars panel ────────────────────────────────────────────────────── */

.bino-section {
  padding: 16px 18px;
  border-top: 1px solid var(--slate-200);
}

.bino-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.bino-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--slate-600);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.bino-row {
  display: flex;
  align-items: center;
  gap: 20px;
}

.bino-bar-wrap { flex: 1; }

.bino-bar-track {
  position: relative;
  height: 10px;
  background: var(--slate-200);
  border-radius: 5px;
  overflow: visible;
  margin-bottom: 6px;
}

.bino-bar-fill {
  height: 100%;
  border-radius: 5px;
  width: 0%;
  transition: width .5s ease, background .3s;
}

.bino-threshold-marker {
  position: absolute;
  top: -4px;
  width: 2px;
  height: 18px;
  background: var(--slate-700);
  border-radius: 1px;
  transform: translateX(-50%);
}

.bino-threshold-marker::after {
  content: attr(data-label);
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--slate-600);
  white-space: nowrap;
  font-weight: 500;
}

.bino-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--slate-500);
}

.bino-score-block { text-align: center; min-width: 80px; }
.bino-score-value { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.bino-score-sub   { font-size: 11px; color: var(--slate-500); margin-top: 2px; }

/* ── Academic section ────────────────────────────────────────────────────── */

.acad-section {
  padding: 12px 18px;
  background: var(--slate-50);
  border-top: 1px solid var(--slate-200);
}

.acad-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.acad-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--slate-600);
}

.acad-detail {
  font-size: 12px;
  color: var(--slate-500);
}

/* ── Statistical Detection section ───────────────────────────────────────── */

.stat-section {
  padding: 14px 18px;
  border-top: 1px solid var(--slate-200);
}

.stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.stat-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--slate-700);
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-bar-wrap {
  flex: 1;
  min-width: 0;
}

.stat-bar-track {
  position: relative;
  height: 10px;
  border-radius: 5px;
  background: linear-gradient(90deg,
    rgba(220, 38, 38, 0.12) 0%,
    rgba(245, 158, 11, 0.12) 50%,
    rgba(22, 163, 74, 0.12) 100%);
  overflow: visible;
}

.stat-bar-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.6s cubic-bezier(.4, 0, .2, 1), background 0.4s ease;
  min-width: 4px;
}

.stat-threshold-marker {
  position: absolute;
  top: -4px;
  width: 2px;
  height: 18px;
  background: var(--slate-600);
  border-radius: 1px;
  transform: translateX(-1px);
  z-index: 1;
}

.stat-threshold-marker::after {
  content: attr(data-label);
  position: absolute;
  bottom: -16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  color: var(--slate-500);
  white-space: nowrap;
}

.stat-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--slate-400);
  margin-top: 4px;
}

.stat-score-block {
  text-align: right;
  min-width: 70px;
  flex-shrink: 0;
}

.stat-score-value {
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.stat-score-sub {
  font-size: 10px;
  color: var(--slate-500);
  margin-top: 2px;
}

/* Confidence badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge--success { background: var(--green-100); color: var(--green-700); }
.badge--info    { background: var(--blue-50);    color: var(--blue-600); }
.badge--neutral { background: var(--slate-100);  color: var(--slate-500); }

/* Feature breakdown */
.stat-features {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--slate-200);
}

.stat-features-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--slate-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.stat-features-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 16px;
}

.stat-feature-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-feature-label {
  font-size: 11px;
  color: var(--slate-600);
  width: 100px;
  flex-shrink: 0;
}

.stat-feature-bar-wrap {
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: var(--slate-100);
  overflow: hidden;
}

.stat-feature-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

.stat-feature-val {
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--slate-600);
  width: 36px;
  text-align: right;
  flex-shrink: 0;
}

/* Threshold highlight */
.threshold-val--highlight {
  color: var(--indigo-600);
  font-weight: 700;
}

/* ── Notice ──────────────────────────────────────────────────────────────── */

.notice {
  margin: 14px 18px;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.5;
}

.notice--info    { background: var(--blue-50);   color: var(--slate-700); border-left: 3px solid var(--blue-600); }
.notice--success { background: var(--green-100); color: var(--green-700); border-left: 3px solid var(--green-600); }

.notice code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: rgba(0,0,0,.06);
  padding: 1px 5px;
  border-radius: 3px;
}

/* ── Calibration status ──────────────────────────────────────────────────── */

.calib-status {
  padding: 16px 18px 10px;
}

/* ── Status header (badge + message) ──── */
.calib-status-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  transition: background 0.3s, border-color 0.3s;
}

.calib-status-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  flex-shrink: 0;
}

.calib-status-msg {
  font-size: 13px;
  line-height: 1.4;
  font-weight: 500;
}

/* Status tiers — coordinated background + badge + text colors */
.calib-status-badge[data-tier="empty"]  {
  background: var(--slate-200); color: var(--slate-600);
}
.calib-status-header:has(.calib-status-badge[data-tier="empty"]) {
  background: var(--slate-50); border: 1px solid var(--slate-200);
}
.calib-status-header:has(.calib-status-badge[data-tier="empty"]) .calib-status-msg {
  color: var(--slate-500);
}

.calib-status-badge[data-tier="seeding"] {
  background: #f59e0b; color: #fff;
}
.calib-status-header:has(.calib-status-badge[data-tier="seeding"]) {
  background: #fffbeb; border: 1px solid #fde68a;
}
.calib-status-header:has(.calib-status-badge[data-tier="seeding"]) .calib-status-msg {
  color: #92400e;
}

.calib-status-badge[data-tier="calibrating"] {
  background: #3b82f6; color: #fff;
}
.calib-status-header:has(.calib-status-badge[data-tier="calibrating"]) {
  background: #eff6ff; border: 1px solid #bfdbfe;
}
.calib-status-header:has(.calib-status-badge[data-tier="calibrating"]) .calib-status-msg {
  color: #1e40af;
}

.calib-status-badge[data-tier="confident"] {
  background: #10b981; color: #fff;
}
.calib-status-header:has(.calib-status-badge[data-tier="confident"]) {
  background: #ecfdf5; border: 1px solid #a7f3d0;
}
.calib-status-header:has(.calib-status-badge[data-tier="confident"]) .calib-status-msg {
  color: #065f46;
}

.calib-status-badge[data-tier="reliable"] {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  box-shadow: 0 1px 4px rgba(99, 102, 241, 0.3);
}
.calib-status-header:has(.calib-status-badge[data-tier="reliable"]) {
  background: linear-gradient(135deg, #eef2ff, #f5f3ff);
  border: 1px solid #c7d2fe;
}
.calib-status-header:has(.calib-status-badge[data-tier="reliable"]) .calib-status-msg {
  color: #4338ca;
}

/* ── Sample breakdown cards ──── */
.calib-sample-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.sample-card {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--slate-200);
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.sample-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.sample-card--human { border-left: 4px solid #3b82f6; }
.sample-card--ai    { border-left: 4px solid #8b5cf6; }

.sample-card-icon {
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 1px;
}

.sample-card-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sample-card-count {
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.sample-card--human .sample-card-count { color: #2563eb; }
.sample-card--ai    .sample-card-count { color: #7c3aed; }

.sample-card-label {
  font-size: 10px;
  color: var(--slate-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.sample-card-hint {
  font-size: 11px;
  color: var(--slate-500);
  line-height: 1.35;
  width: 100%;
  padding-top: 6px;
  border-top: 1px solid var(--slate-100);
}

.sample-card-hint:empty { display: none; }

/* ── Guidance callout ──── */
.calib-guidance {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--slate-700);
  padding: 10px 14px;
  border-radius: 8px;
  background: linear-gradient(135deg, #f0f9ff, #faf5ff);
  border: 1px solid #e0e7ff;
}

.calib-guidance:empty { display: none; }

.calib-guidance strong {
  color: var(--indigo, #4f46e5);
  font-weight: 700;
}

.threshold-display {
  padding: 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.threshold-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.threshold-label { color: var(--slate-600); }
.threshold-val   { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--slate-800); }
.threshold-val--highlight { color: var(--blue-600); }
.threshold-val--muted     { color: var(--slate-500); font-size: 12px; }

.section-subtitle {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--slate-500);
  padding: 12px 18px 6px;
  border-top: 1px solid var(--slate-200);
  margin-top: 4px;
}

/* ── Contributor list ────────────────────────────────────────────────────── */

.contributor-section {}

.contributor-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 18px 12px;
}

.contributor-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--slate-100);
  border-radius: 100px;
  padding: 4px 12px;
  font-size: 12px;
  color: var(--slate-700);
}

.contributor-chip-count {
  background: var(--slate-800);
  color: var(--white);
  border-radius: 100px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 600;
}

/* ── Calibration form ────────────────────────────────────────────────────── */

.calib-form { padding: 0 18px 18px; }

.calib-hint {
  font-size: 13px;
  color: var(--slate-500);
  padding: 10px 0;
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.radio-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1.5px solid var(--slate-200);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.radio-label:has(input:checked) {
  border-color: var(--blue-600);
  background: var(--blue-50);
}

.radio-label input { margin-top: 3px; accent-color: var(--blue-600); }

.radio-text { display: flex; flex-direction: column; }
.radio-text small { color: var(--slate-500); font-size: 12px; margin-top: 1px; }

.form-field { display: flex; flex-direction: column; gap: 4px; }

.field-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--slate-600);
}

.field-input {
  padding: 8px 12px;
  border: 1.5px solid var(--slate-200);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}

.field-input:focus { border-color: var(--blue-600); }

/* ── Toggle ──────────────────────────────────────────────────────────────── */

.toggle-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--slate-600);
  cursor: pointer;
  user-select: none;
}

/* ── Footer ──────────────────────────────────────────────────────────────── */

.site-footer {
  text-align: center;
  padding: 20px 24px;
  font-size: 12px;
  color: var(--slate-400);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  border-top: 1px solid var(--slate-200);
  margin-top: 8px;
  background: linear-gradient(180deg, transparent 0%, rgba(241,245,249,.5) 100%);
  letter-spacing: .02em;
}

.site-footer a {
  color: var(--slate-500);
  text-decoration: none;
  transition: color .15s ease;
  font-weight: 500;
}
.site-footer a:hover { color: var(--blue-600); }

/* ── Edit log ────────────────────────────────────────────────────────────── */

.editlog-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}

.editlog-toggle-icon {
  transition: transform .2s ease;
  font-size: 10px;
  color: var(--slate-500);
}

.editlog-toggle-icon.open { transform: rotate(90deg); }

.editlog-body {
  padding: 0 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.editlog-body[hidden] { display: none; }

.edit-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  background: var(--slate-50);
  border-radius: var(--radius);
  border-left: 3px solid var(--slate-300);
}

.edit-card--transition      { border-left-color: var(--blue-600); }
.edit-card--phrase          { border-left-color: #7c3aed; }
.edit-card--structure       { border-left-color: var(--green-600); }
.edit-card--burstiness      { border-left-color: #e67e22; }
.edit-card--vocabulary      { border-left-color: #2ecc71; }
.edit-card--start_diversity { border-left-color: #3498db; }
.edit-card--repetition      { border-left-color: #e74c3c; }

.edit-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.edit-category {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.edit-category--transition      { background: var(--blue-50); color: var(--blue-600); }
.edit-category--phrase          { background: #f3e8ff; color: #7c3aed; }
.edit-category--structure       { background: var(--green-100); color: var(--green-700); }
.edit-category--burstiness      { background: #fef3e2; color: #e67e22; }
.edit-category--vocabulary      { background: #e8f8f0; color: #27ae60; }
.edit-category--start_diversity { background: #eaf4fd; color: #2980b9; }
.edit-category--repetition      { background: #fde8e8; color: #c0392b; }

.edit-change {
  font-size: 14px;
  line-height: 1.5;
}

.edit-original {
  color: var(--red-600);
  text-decoration: line-through;
}

.edit-arrow {
  color: var(--slate-400);
  margin: 0 4px;
}

.edit-revised {
  color: var(--green-700);
  font-weight: 500;
}

.edit-reason {
  font-size: 12px;
  color: var(--slate-500);
  line-height: 1.4;
}

/* ── Loading skeleton ───────────────────────────────────────────────────── */

.skeleton-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 0;
}

.skeleton-line {
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(
    90deg,
    var(--slate-200) 25%,
    var(--slate-100) 50%,
    var(--slate-200) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-line:nth-child(1) { width: 100%; }
.skeleton-line:nth-child(2) { width: 88%; }
.skeleton-line:nth-child(3) { width: 65%; }

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Settings panel ─────────────────────────────────────────────────────── */

.settings-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.35);
  z-index: 200;
  opacity: 0;
  transition: opacity .2s ease;
  pointer-events: none;
}

.settings-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

.settings-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 340px;
  max-width: 90vw;
  height: 100vh;
  background: var(--white);
  box-shadow: var(--shadow-lg);
  z-index: 201;
  transform: translateX(100%);
  transition: transform .25s ease;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.settings-panel.open { transform: translateX(0); }

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--slate-200);
}

.settings-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--slate-800);
}

.settings-close {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--slate-500);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.settings-close:hover { background: var(--slate-100); }

.settings-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setting-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--slate-700);
}

.setting-desc {
  font-size: 12px;
  color: var(--slate-500);
  line-height: 1.4;
}

.setting-slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.setting-slider-row input[type="range"] {
  flex: 1;
  accent-color: var(--blue-600);
  height: 6px;
}

.setting-slider-val {
  min-width: 40px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 14px;
  color: var(--slate-800);
}

.setting-toggle-row {
  display: flex;
  gap: 0;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius);
  overflow: hidden;
}

.toggle-btn {
  flex: 1;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  border: none;
  background: var(--white);
  color: var(--slate-500);
  cursor: pointer;
  transition: all .15s ease;
}

.toggle-btn:first-child { border-right: 1px solid var(--slate-200); }

.toggle-btn:hover:not(.active) {
  background: var(--slate-50);
  color: var(--slate-700);
}

.toggle-btn.active {
  background: var(--blue-600);
  color: var(--white);
  font-weight: 600;
}

.btn--icon {
  background: transparent;
  border: none;
  color: var(--slate-400);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn--icon:hover { color: var(--white); background: rgba(255,255,255,.12); }

/* ── Session history ────────────────────────────────────────────────────── */

.history-wrapper {
  position: relative;
  display: inline-flex;
}

.history-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 280px;
  max-width: 400px;
  background: var(--white);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.history-dropdown.open { display: flex; }

.history-empty {
  padding: 12px 14px;
  font-size: 12px;
  color: var(--slate-400);
  font-style: italic;
}

.history-item {
  padding: 10px 14px;
  font-size: 13px;
  color: var(--slate-700);
  cursor: pointer;
  border-bottom: 1px solid var(--slate-100);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background .1s;
}

.history-item:last-child { border-bottom: none; }
.history-item:hover { background: var(--blue-50); }

/* ── Tooltips ────────────────────────────────────────────────────────────── */

.tooltip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  font-size: 10px;
  font-weight: 700;
  color: var(--slate-400);
  border: 1.5px solid var(--slate-300);
  border-radius: 50%;
  cursor: help;
  vertical-align: middle;
  margin-left: 4px;
  flex-shrink: 0;
}

.tooltip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--slate-900);
  color: var(--white);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
  padding: 8px 12px;
  border-radius: var(--radius);
  white-space: normal;
  width: 240px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s ease;
  z-index: 60;
  box-shadow: var(--shadow);
}

.tooltip:hover::after { opacity: 1; }

/* ── Keyboard shortcuts modal ────────────────────────────────────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.45);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal-backdrop.visible { display: flex; }

.modal-box {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 380px;
  max-width: 90vw;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--slate-200);
}

.modal-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--slate-800);
}

.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--slate-500);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.modal-close:hover { background: var(--slate-100); }

.modal-body { padding: 16px 20px 20px; }

.shortcut-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--slate-700);
}

.kbd {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--slate-100);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--slate-700);
  white-space: nowrap;
}

/* ── Calibration chart ──────────────────────────────────────────────────── */

.calib-chart {
  padding: 14px 18px;
  border-top: 1px solid var(--slate-200);
}

.calib-chart svg {
  width: 100%;
  display: block;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .main-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "input"
      "output"
      "editlog"
      "scores"
      "calibration"
      "scan";
    padding: 12px;
  }

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

  .settings-panel { width: 100vw; }

  .tooltip::after { width: 180px; left: auto; right: 0; transform: none; }

  .scan-stats-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ── Full Document Scan ──────────────────────────────────────────────────── */

.text-area--scan {
  min-height: 200px;
  max-height: 400px;
}

/* Progress */
.scan-progress {
  padding: 12px 16px;
  border-top: 1px solid var(--slate-200);
}

.scan-progress-bar-wrap {
  height: 6px;
  background: var(--slate-200);
  border-radius: 3px;
  overflow: hidden;
}

.scan-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(135deg, var(--blue-600), #818cf8);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.scan-progress-label {
  font-size: 12px;
  color: var(--slate-500);
  margin-top: 6px;
  text-align: center;
}

/* Summary dashboard */
.scan-summary {
  padding: 16px;
  border-top: 1px solid var(--slate-200);
}

.scan-summary-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.scan-summary-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--slate-900);
}

.scan-stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.scan-stat {
  text-align: center;
  background: var(--slate-50);
  padding: 12px 8px;
  border-radius: var(--radius);
  border: 1px solid var(--slate-200);
}

.scan-stat--flagged {
  background: var(--red-100);
  border-color: #fca5a5;
}

.scan-stat--clean {
  background: var(--green-100);
  border-color: #86efac;
}

.scan-stat-value {
  font-size: 24px;
  font-weight: 800;
  line-height: 1.2;
  color: var(--slate-900);
}

.scan-stat--flagged .scan-stat-value { color: var(--red-700); }
.scan-stat--clean   .scan-stat-value { color: var(--green-700); }

.scan-stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--slate-500);
  margin-top: 2px;
}

/* Category pills */
.scan-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.scan-cat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  background: var(--slate-100);
  color: var(--slate-700);
  border: 1px solid var(--slate-200);
}

.scan-cat-pill .cat-count {
  background: var(--slate-700);
  color: var(--white);
  font-size: 11px;
  min-width: 20px;
  height: 20px;
  line-height: 20px;
  text-align: center;
  border-radius: 10px;
  padding: 0 6px;
}

/* Paragraph results */
.scan-results {
  padding: 0 16px 16px;
}

.scan-results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--slate-200);
}

.scan-results-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--slate-800);
}

.scan-results-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Individual paragraph card */
.scan-para-card {
  border: 1px solid var(--slate-200);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s;
}

.scan-para-card--flagged {
  border-color: #fca5a5;
  border-left: 3px solid var(--red-600);
}

.scan-para-card--clean {
  border-color: #86efac;
  border-left: 3px solid var(--green-600);
}

.scan-para-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  cursor: pointer;
  background: var(--slate-50);
  user-select: none;
  transition: background 0.1s;
}

.scan-para-header:hover {
  background: var(--slate-100);
}

.scan-para-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.scan-para-index {
  font-weight: 700;
  font-size: 13px;
  color: var(--slate-500);
  min-width: 28px;
  text-align: center;
}

.scan-para-preview {
  font-size: 13px;
  color: var(--slate-600);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.scan-para-badges {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  margin-left: 12px;
}

.scan-edit-count {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
}

.scan-edit-count--flagged {
  background: var(--red-100);
  color: var(--red-700);
}

.scan-edit-count--clean {
  background: var(--green-100);
  color: var(--green-700);
}

.scan-para-chevron {
  font-size: 12px;
  color: var(--slate-400);
  transition: transform 0.2s;
}

.scan-para-card.open .scan-para-chevron {
  transform: rotate(90deg);
}

.scan-para-body {
  display: none;
  padding: 14px;
  border-top: 1px solid var(--slate-200);
  background: var(--white);
}

.scan-para-card.open .scan-para-body {
  display: block;
}

.scan-edit-item {
  padding: 8px 12px;
  margin-bottom: 8px;
  border-radius: var(--radius-sm);
  background: var(--slate-50);
  border-left: 3px solid var(--amber-500);
}

.scan-edit-cat {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--amber-800);
  margin-bottom: 4px;
}

.scan-edit-original {
  font-size: 13px;
  color: var(--red-600);
  text-decoration: line-through;
  margin-bottom: 2px;
}

.scan-edit-replacement {
  font-size: 13px;
  color: var(--green-700);
  font-weight: 600;
}

.scan-para-text {
  font-size: 13px;
  line-height: 1.6;
  color: var(--slate-700);
  margin-bottom: 10px;
  padding: 10px;
  background: var(--slate-50);
  border-radius: var(--radius-sm);
  border: 1px solid var(--slate-200);
}

.scan-no-edits {
  font-size: 13px;
  color: var(--green-700);
  font-style: italic;
  padding: 8px 0;
}

/* ── Dropzone ────────────────────────────────────────────────────────────── */

.scan-dropzone {
  margin: 16px;
  padding: 32px 20px;
  border: 2px dashed var(--slate-300);
  border-radius: 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s ease;
  background: linear-gradient(135deg, var(--slate-50) 0%, rgba(239,246,255,.3) 100%);
  position: relative;
}

.scan-dropzone:hover,
.scan-dropzone--active {
  border-color: var(--blue-500);
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.04), rgba(99, 102, 241, 0.04));
  box-shadow: 0 0 0 4px rgba(59, 130, 246, .06);
  transform: translateY(-1px);
}

.scan-dropzone-icon {
  font-size: 36px;
  margin-bottom: 10px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.08));
}

.scan-dropzone-label {
  font-size: 14px;
  color: var(--slate-700);
}

.scan-dropzone-hint {
  font-size: 12px;
  color: var(--slate-400);
  margin-top: 6px;
}

.btn-link {
  background: none;
  border: none;
  color: var(--blue-600);
  cursor: pointer;
  font-size: inherit;
  font-weight: 600;
  text-decoration: underline;
  padding: 0;
}

.btn-link:hover { color: var(--blue-800); }

/* File badge */
.scan-file-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 6px 14px;
  background: var(--blue-100);
  border: 1px solid var(--blue-300);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--blue-800);
}

.scan-file-remove {
  font-size: 14px;
  color: var(--slate-500);
  text-decoration: none !important;
}
.scan-file-remove:hover { color: var(--red-600); }

/* Divider */
.scan-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 16px 4px;
  color: var(--slate-400);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.scan-divider::before,
.scan-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--slate-200);
}

/* Footer with two buttons */
.scan-footer-actions {
  display: flex;
  gap: 8px;
}

/* ── Document Report ──────────────────────────────────────────────────── */

.scan-report {
  padding: 20px 16px;
  border-top: 1px solid var(--slate-200);
}

/* File info banner */
.scan-file-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--blue-50);
  border: 1px solid var(--blue-200);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 13px;
}
.scan-file-info-name { font-weight: 700; color: var(--blue-800); }
.scan-file-info-size { color: var(--slate-500); }

/* Health + Risk row */
.scan-health-row {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
  padding: 16px 0;
}

.scan-health-gauge {
  text-align: center;
  min-width: 100px;
}

.scan-health-score {
  font-size: 48px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -2px;
  color: var(--slate-800);
  font-variant-numeric: tabular-nums;
}

.scan-health-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--slate-500);
  margin-top: 4px;
}

/* Risk colours */
.scan-health-score.risk--low      { color: var(--green-600); }
.scan-health-score.risk--moderate { color: var(--amber-600); }
.scan-health-score.risk--high     { color: #ea580c; }
.scan-health-score.risk--critical { color: var(--red-600); }

.scan-risk-badge {
  flex: 1;
  padding: 14px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--slate-200);
  background: var(--slate-50);
}

.scan-risk-badge.risk--low      { background: var(--green-50);  border-color: #86efac; }
.scan-risk-badge.risk--moderate { background: #fffbeb;         border-color: #fcd34d; }
.scan-risk-badge.risk--high     { background: #fff7ed;         border-color: #fb923c; }
.scan-risk-badge.risk--critical { background: var(--red-50);    border-color: #fca5a5; }

.scan-risk-level {
  display: block;
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 4px;
}

.risk--low      .scan-risk-level { color: var(--green-700); }
.risk--moderate .scan-risk-level { color: var(--amber-700); }
.risk--high     .scan-risk-level { color: #c2410c; }
.risk--critical .scan-risk-level { color: var(--red-700); }

.scan-risk-desc {
  font-size: 13px;
  color: var(--slate-600);
  line-height: 1.4;
}

/* ── Density heatmap ──────────────────────────────────────────────────── */

.scan-heatmap-section {
  margin: 16px 0;
}

.scan-heatmap-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--slate-500);
  margin-bottom: 8px;
}

.scan-heatmap-bar {
  display: flex;
  height: 20px;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--slate-200);
  background: var(--slate-100);
}

.heatmap-seg {
  height: 100%;
  transition: opacity 0.15s;
  cursor: default;
  min-width: 2px;
}
.heatmap-seg:hover { opacity: 0.7; }

.heatmap-seg--clean { background: #86efac; }
.heatmap-seg--low   { background: #fde68a; }
.heatmap-seg--med   { background: #fb923c; }
.heatmap-seg--high  { background: #ef4444; }

.scan-heatmap-legend {
  display: flex;
  gap: 14px;
  margin-top: 6px;
  font-size: 11px;
  color: var(--slate-500);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.legend-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.legend-swatch--clean { background: #86efac; }
.legend-swatch--low   { background: #fde68a; }
.legend-swatch--med   { background: #fb923c; }
.legend-swatch--high  { background: #ef4444; }

/* ── Top hotspots ─────────────────────────────────────────────────────── */

.scan-hotspots {
  margin: 16px 0;
}

.scan-hotspots-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--slate-800);
  margin-bottom: 10px;
}

.scan-hotspots-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hotspot-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--red-50);
  border: 1px solid #fca5a5;
  border-left: 3px solid var(--red-500);
  border-radius: var(--radius-sm);
}

.hotspot-idx {
  font-weight: 800;
  font-size: 13px;
  color: var(--red-700);
  min-width: 28px;
}

.hotspot-count {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--red-100);
  color: var(--red-700);
  white-space: nowrap;
}

.hotspot-preview {
  font-size: 12px;
  color: var(--slate-600);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Report actions */
.scan-report-actions {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--slate-200);
  display: flex;
  justify-content: flex-end;
}

/* ── Responsive tweaks for report ─────────────────────────────────────── */

@media (max-width: 640px) {
  .scan-health-row {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .scan-health-gauge { margin-bottom: 4px; }
  .scan-heatmap-legend { flex-wrap: wrap; gap: 8px; }
  .scan-dropzone { padding: 20px 14px; }
  .scan-footer-actions { flex-direction: column; }
  .scan-footer-actions .btn { width: 100%; }
}

/* ── Convergence info strip ─────────────────────────────────────────────────── */

.convergence-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 18px;
  margin: 8px 0;
  background: linear-gradient(135deg, rgba(59,130,246,0.06) 0%, rgba(16,185,129,0.06) 100%);
  border: 1px solid rgba(59,130,246,0.15);
  border-radius: var(--radius);
  font-size: 13px;
}

.convergence-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.convergence-label {
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
}

.convergence-value {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.convergence-arrow {
  color: var(--text-secondary);
  font-weight: 400;
  margin: 0 2px;
}

@media (max-width: 640px) {
  .convergence-strip {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
}
