:root {
  --navy-dark: #0f172a;
  --navy: #16213e;
  --card: #1e293b;
  --teal: #14b8a6;
  --teal-light: #5eead4;
  --white: #ffffff;
  --offwhite: #f1f5f9;
  --muted: #94a3b8;
  --red: #f87171;
  --amber: #fbbf24;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--navy-dark);
  color: var(--offwhite);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Accessibility utilities */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  background: var(--teal);
  color: var(--navy-dark);
  padding: 0.6rem 1rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.85rem;
  z-index: 100;
  transition: top 0.15s ease;
}

.skip-link:focus {
  top: 1rem;
}

/* Visible, on-brand focus states everywhere */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
.dropzone:focus-visible {
  outline: 2px solid var(--teal-light);
  outline-offset: 2px;
}

.shell {
  max-width: 720px;
  margin: 0 auto;
  padding: 3rem 1.5rem 2rem;
  flex: 1;
  width: 100%;
}

.shell-header h1 {
  font-size: 2rem;
  margin: 0 0 0.4rem 0;
  color: var(--white);
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--teal-light);
  margin: 0 0 2.5rem 0;
  font-size: 0.95rem;
}

.card {
  background: var(--card);
  border-radius: 12px;
  padding: 2rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Screen enter animation */
.screen-enter {
  animation: screenFadeIn 0.25s ease both;
}

@keyframes screenFadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .screen-enter {
    animation: none;
  }
  .spinner {
    animation-duration: 1.5s;
  }
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.tab-btn {
  flex: 1;
  background: var(--navy);
  color: var(--muted);
  border: 1px solid transparent;
  padding: 0.65rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.tab-btn.active {
  background: rgba(20, 184, 166, 0.12);
  color: var(--teal-light);
  border-color: var(--teal);
}

.tab-panel {
  display: none;
}

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

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  border: 2px dashed var(--muted);
  border-radius: 10px;
  padding: 2.5rem 1rem;
  text-align: center;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.9rem;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--teal);
  background: rgba(20, 184, 166, 0.06);
}

.dropzone:active {
  transform: scale(0.995);
}

.dropzone-icon {
  font-size: 1.5rem;
}

textarea {
  width: 100%;
  background: var(--navy);
  color: var(--offwhite);
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 0.75rem;
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
  transition: border-color 0.15s ease;
}

textarea:focus-visible {
  border-color: var(--teal);
}

.field-group {
  margin-top: 1.5rem;
}

.field-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}

button#analyze-btn,
button#error-retry-btn {
  margin-top: 1.5rem;
  width: 100%;
  background: var(--teal);
  color: var(--navy-dark);
  border: none;
  padding: 0.85rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.1s ease;
}

button#analyze-btn:hover,
button#error-retry-btn:hover {
  opacity: 0.9;
}

button#analyze-btn:active,
button#error-retry-btn:active {
  transform: scale(0.985);
}

button#analyze-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.status-line {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--teal-light);
}

.status-line.error {
  color: var(--red);
}

/* Loading screen */
.loading-card {
  text-align: center;
  padding: 3rem 2rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--navy);
  border-top-color: var(--teal);
  border-radius: 50%;
  margin: 0 auto 1.25rem;
  animation: spin 0.8s linear infinite;
}

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

#loading-message {
  color: var(--muted);
  font-size: 0.9rem;
}

/* Report toolbar */
.report-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.toolbar-actions {
  display: flex;
  gap: 1rem;
}

.link-btn {
  background: none;
  border: none;
  color: var(--teal-light);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.4rem 0;
  transition: opacity 0.15s ease;
}

.link-btn:hover {
  text-decoration: underline;
}

.link-btn:active {
  opacity: 0.7;
}

/* Score header */
.score-header {
  background: var(--card);
  border-radius: 12px;
  padding: 2rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.score-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}

.score-ring {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}

.score-ring-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--white);
}

.score-label {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.4rem;
}

.score-feedback {
  margin: 0;
  font-size: 0.9rem;
  color: var(--offwhite);
  line-height: 1.5;
}

/* Report cards */
.report-cards {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.report-card {
  background: var(--card);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: box-shadow 0.15s ease;
}

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

.report-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.85rem;
  gap: 0.75rem;
}

.report-card-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--white);
}

.status-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  white-space: nowrap;
}

.status-good {
  background: rgba(20, 184, 166, 0.15);
  color: var(--teal-light);
}

.status-needs_work {
  background: rgba(251, 191, 36, 0.15);
  color: var(--amber);
}

.status-missing {
  background: rgba(248, 113, 113, 0.15);
  color: var(--red);
}

.issue-list {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.6;
}

.no-issues {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-style: italic;
}

.skill-tags {
  margin-top: 0.5rem;
  font-size: 0.85rem;
}

.skill-tags-label {
  color: var(--muted);
  margin-right: 0.4rem;
}

.skill-tag {
  display: inline-block;
  background: rgba(251, 191, 36, 0.12);
  color: var(--amber);
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  margin: 0.15rem 0.25rem 0.15rem 0;
}

.bullet-rewrite {
  background: var(--navy);
  border-radius: 8px;
  padding: 0.85rem;
  margin-top: 0.75rem;
  font-size: 0.85rem;
  line-height: 1.5;
}

.bullet-original {
  color: var(--muted);
  margin: 0 0 0.5rem 0;
  text-decoration: line-through;
  text-decoration-color: rgba(248, 113, 113, 0.5);
}

.bullet-rewritten {
  color: var(--teal-light);
  margin: 0;
}

.jd-match-card {
  border: 1px solid var(--teal);
}

.jd-match-percent {
  font-weight: 700;
  color: var(--teal-light);
  font-size: 1.1rem;
}

/* Secondary button (Generate Cover Letter) */
.secondary-btn {
  margin-top: 1.5rem;
  width: 100%;
  background: transparent;
  color: var(--teal-light);
  border: 1px solid var(--teal);
  padding: 0.85rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.secondary-btn:hover {
  background: rgba(20, 184, 166, 0.08);
}

.secondary-btn:active {
  transform: scale(0.985);
}

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

/* Cover letter screen */
.jd-used-badge {
  display: inline-block;
  background: rgba(20, 184, 166, 0.15);
  color: var(--teal-light);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  margin-bottom: 1rem;
}

.cover-letter-text {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--offwhite);
  margin: 0;
}

/* Error screen */
#error-screen {
  text-align: center;
}

.error-icon {
  font-size: 2rem;
  margin: 0 0 0.5rem 0;
}

.error-message {
  color: var(--offwhite);
  margin: 0 0 1rem 0;
  font-size: 0.95rem;
}

/* Footer */
.site-footer {
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--card);
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
  .shell {
    padding: 2rem 1rem 1.5rem;
  }

  .shell-header h1 {
    font-size: 1.6rem;
  }

  .card,
  .report-card,
  .score-header {
    padding: 1.25rem;
  }

  .score-header {
    flex-direction: column;
    text-align: center;
    gap: 1rem;
  }

  .report-toolbar {
    justify-content: flex-start;
  }

  .toolbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .tabs {
    flex-direction: column;
  }

  .dropzone {
    padding: 1.75rem 1rem;
  }
}
