:root {
  --bg: #0a0d12;
  --bg-raised: #12171f;
  --bg-inset: #0d1117;
  --line: #212a36;
  --line-soft: #1a222c;
  --text: #e6edf5;
  --text-dim: #93a1b4;
  --text-faint: #64748b;
  --accent: #4ade9b;
  --accent-dim: #2ba876;
  --accent-glow: rgba(74, 222, 155, 0.14);
  --gold: #d8b26a;
  --danger: #f2789f;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 18px 40px -24px rgba(0, 0, 0, 0.9);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

.aura {
  position: fixed;
  inset: 0 0 auto 0;
  height: 460px;
  background:
    radial-gradient(680px 260px at 22% -8%, rgba(74, 222, 155, 0.12), transparent 70%),
    radial-gradient(560px 240px at 82% -12%, rgba(216, 178, 106, 0.09), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ---------- Top bar ---------- */

.topbar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  padding: 26px clamp(18px, 5vw, 56px) 18px;
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  color: var(--accent);
  background: linear-gradient(160deg, rgba(74, 222, 155, 0.16), rgba(74, 222, 155, 0.03));
  border: 1px solid rgba(74, 222, 155, 0.24);
  flex: none;
}

.brand-mark svg {
  width: 22px;
  height: 22px;
}

.brand h1 {
  margin: 0;
  font-size: 1.16rem;
  font-weight: 620;
  letter-spacing: -0.01em;
}

.brand p {
  margin: 1px 0 0;
  font-size: 0.79rem;
  color: var(--text-faint);
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-inset);
  border: 1px solid var(--line-soft);
  border-radius: 11px;
}

.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 0.855rem;
  font-weight: 540;
  padding: 7px 18px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.16s, color 0.16s;
}

.tab:hover {
  color: var(--text);
}

.tab.is-active {
  background: #1c242f;
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line);
}

/* ---------- Layout ---------- */

main {
  position: relative;
  z-index: 1;
  flex: 1;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 8px clamp(18px, 5vw, 56px) 48px;
}

.panel {
  display: none;
  animation: fade 0.24s ease;
}

.panel.is-active {
  display: block;
}

@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
}

.muted {
  color: var(--text-faint);
  font-size: 0.84rem;
  margin: 2px 0 0;
}

/* ---------- Dropzone ---------- */

.dropzone {
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(18, 23, 31, 0.8), rgba(10, 13, 18, 0.5));
  transition: border-color 0.18s, background 0.18s;
  overflow: hidden;
}

.dropzone.is-dragging {
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(74, 222, 155, 0.07), rgba(10, 13, 18, 0.5));
}

.dropzone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 54px 24px 46px;
}

.dropzone-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  color: var(--accent);
  background: var(--accent-glow);
  border: 1px solid rgba(74, 222, 155, 0.22);
  margin-bottom: 16px;
}

.dropzone-icon svg {
  width: 25px;
  height: 25px;
}

.dropzone-title {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 570;
}

.dropzone-hint {
  margin: 6px 0 20px;
  font-size: 0.815rem;
  color: var(--text-faint);
}

.dropzone-selected {
  padding: 20px;
}

.file-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-inset);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
}

.file-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: var(--accent);
  background: var(--accent-glow);
  flex: none;
}

.file-icon svg {
  width: 18px;
  height: 18px;
}

.file-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.file-meta strong {
  font-weight: 560;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-meta span {
  font-size: 0.775rem;
  color: var(--text-faint);
}

/* ---------- Buttons ---------- */

.btn {
  appearance: none;
  font: inherit;
  font-size: 0.87rem;
  font-weight: 560;
  border-radius: 9px;
  padding: 9px 18px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.16s, border-color 0.16s, transform 0.1s, color 0.16s;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

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

.btn-primary {
  background: var(--accent);
  color: #06130e;
}

.btn-primary:hover:not(:disabled) {
  background: #63ebb0;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border-color: var(--line);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text);
  border-color: #33404f;
}

.btn-icon {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--text-faint);
  font-size: 1.35rem;
  line-height: 1;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  cursor: pointer;
  flex: none;
}

.btn-icon:hover {
  color: var(--danger);
  background: rgba(242, 120, 159, 0.1);
}

/* ---------- Status ---------- */

.status {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 34px 20px;
  margin-top: 18px;
  background: var(--bg-raised);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}

.status p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-dim);
}

.spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2.5px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

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

.progress-track {
  width: min(340px, 80%);
  height: 3px;
  border-radius: 999px;
  background: var(--line-soft);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  transition: width 0.35s ease;
}

/* ---------- Notices ---------- */

.notice {
  margin-top: 16px;
  padding: 12px 15px;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  border: 1px solid var(--line);
  background: var(--bg-raised);
  color: var(--text-dim);
}

.notice-error {
  border-color: rgba(242, 120, 159, 0.32);
  background: rgba(242, 120, 159, 0.09);
  color: #f7a9c0;
}

.notice-ok {
  border-color: rgba(74, 222, 155, 0.3);
  background: rgba(74, 222, 155, 0.08);
  color: #8fe9c1;
}

/* ---------- Result ---------- */

.result {
  margin-top: 20px;
  animation: rise 0.3s ease;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(9px);
  }
}

.verdict {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--bg-raised), #0e131a);
  padding: 26px clamp(18px, 3vw, 30px);
  box-shadow: var(--shadow);
}

.verdict.is-match {
  border-color: rgba(74, 222, 155, 0.32);
  background: linear-gradient(180deg, rgba(74, 222, 155, 0.08), #0e131a 62%);
}

.verdict.is-unsure {
  border-color: rgba(216, 178, 106, 0.3);
  background: linear-gradient(180deg, rgba(216, 178, 106, 0.07), #0e131a 62%);
}

.verdict-label {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 0.735rem;
  font-weight: 620;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 12px;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(74, 222, 155, 0.14);
  flex: none;
}

.verdict.is-unsure .dot {
  background: var(--gold);
  box-shadow: 0 0 0 4px rgba(216, 178, 106, 0.14);
}

.verdict-name {
  margin: 0;
  font-size: clamp(1.5rem, 3.4vw, 2.05rem);
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.verdict-arabic {
  margin: 4px 0 0;
  font-size: 1.16rem;
  color: var(--gold);
}

.verdict-reason {
  margin: 10px 0 0;
  font-size: 0.885rem;
  color: var(--text-dim);
  max-width: 62ch;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 1px;
  margin-top: 22px;
  background: var(--line-soft);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.metric {
  background: #0d1218;
  padding: 12px 14px;
}

.metric-label {
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.metric-value {
  font-size: 1.02rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

/* ---------- Ranked candidates ---------- */

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 28px 0 12px;
}

.section-title h3 {
  margin: 0;
  font-size: 0.775rem;
  font-weight: 620;
  letter-spacing: 0.085em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.section-title span {
  font-size: 0.775rem;
  color: var(--text-faint);
}

.candidates {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.candidate {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px;
  align-items: center;
  gap: 14px;
  padding: 11px 14px;
  background: var(--bg-raised);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  transition: border-color 0.16s, background 0.16s;
}

.candidate.is-top {
  border-color: rgba(74, 222, 155, 0.3);
  background: rgba(74, 222, 155, 0.055);
}

.candidate-name {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.9rem;
  font-weight: 540;
  min-width: 0;
}

.candidate-name .rank {
  font-size: 0.735rem;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  min-width: 15px;
}

.candidate-name .arabic {
  font-size: 0.845rem;
  color: var(--text-faint);
}

.candidate-bar {
  height: 4px;
  margin-top: 8px;
  border-radius: 999px;
  background: var(--line-soft);
  overflow: hidden;
}

.candidate-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2f6f57, var(--accent-dim));
  transition: width 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.candidate.is-top .candidate-fill {
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
}

.candidate-score {
  text-align: right;
  font-size: 0.945rem;
  font-weight: 620;
  font-variant-numeric: tabular-nums;
}

.candidate-score small {
  display: block;
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text-faint);
}

/* ---------- Library ---------- */

.library-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line-soft);
}

.library-head h2 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 600;
}

.library-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 16px 0 26px;
}

.reciter-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 15px;
  background: var(--bg-raised);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
}

.reciter-avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(155deg, rgba(216, 178, 106, 0.2), rgba(216, 178, 106, 0.05));
  border: 1px solid rgba(216, 178, 106, 0.22);
  color: var(--gold);
  font-size: 0.9rem;
  font-weight: 620;
  flex: none;
}

.reciter-info {
  flex: 1;
  min-width: 0;
}

.reciter-info strong {
  display: block;
  font-size: 0.9rem;
  font-weight: 560;
}

.reciter-info span {
  font-size: 0.775rem;
  color: var(--text-faint);
}

.reciter-row .btn-icon {
  opacity: 0.55;
}

.reciter-row:hover .btn-icon {
  opacity: 1;
}

.empty {
  padding: 34px 20px;
  text-align: center;
  color: var(--text-faint);
  font-size: 0.875rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
}

.enroll {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  overflow: hidden;
}

.enroll summary {
  padding: 13px 16px;
  font-size: 0.875rem;
  font-weight: 550;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text-dim);
}

.enroll summary::-webkit-details-marker {
  display: none;
}

.enroll summary::before {
  content: '+';
  font-size: 1.05rem;
  color: var(--accent);
  width: 12px;
}

.enroll[open] summary::before {
  content: '\2212';
}

.enroll summary:hover {
  color: var(--text);
}

.enroll-form {
  padding: 4px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-top: 1px solid var(--line-soft);
  padding-top: 18px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field > span {
  font-size: 0.775rem;
  font-weight: 540;
  color: var(--text-dim);
}

.field em {
  font-style: normal;
  color: var(--text-faint);
  font-weight: 400;
}

.field input[type='text'] {
  font: inherit;
  font-size: 0.875rem;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-inset);
  color: var(--text);
  width: 100%;
}

.field input[type='text']:focus {
  outline: none;
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px rgba(74, 222, 155, 0.1);
}

.field input[type='file'] {
  font: inherit;
  font-size: 0.82rem;
  color: var(--text-dim);
  padding: 8px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--bg-inset);
  width: 100%;
}

.field input[type='file']::file-selector-button {
  font: inherit;
  font-size: 0.8rem;
  font-weight: 550;
  margin-right: 10px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #1b2330;
  color: var(--text);
  cursor: pointer;
}

.help {
  margin: 0;
  font-size: 0.79rem;
  color: var(--text-faint);
}

.enroll-form .btn {
  align-self: flex-start;
}

/* ---------- Footer ---------- */

.footer {
  position: relative;
  z-index: 1;
  padding: 20px clamp(18px, 5vw, 56px) 30px;
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
  border-top: 1px solid var(--line-soft);
}

.footer p {
  margin: 0;
  font-size: 0.775rem;
  color: var(--text-faint);
  max-width: 76ch;
  line-height: 1.6;
}

/* ---------- Responsive ---------- */

@media (max-width: 720px) {
  .topbar {
    padding-top: 20px;
  }

  .brand p {
    display: none;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .dropzone-inner {
    padding: 40px 18px 34px;
  }

  .candidate {
    grid-template-columns: minmax(0, 1fr) 48px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
