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

body {
  font-family: 'Lexend', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: linear-gradient(160deg, #f0f4f8 0%, #fafafa 50%, #f5f0e8 100%);
  background-attachment: fixed;
  color: #333;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
header {
  background: #00274C;
  border-bottom: 3px solid #FFCB05;
  padding: 20px 32px;
}

header h1 {
  color: #ffffff;
  font-size: 20px;
  font-weight: 600;
}

.header-subtitle {
  color: #FFCB05;
  font-size: 13px;
  margin-top: 4px;
  font-weight: 400;
}

/* ── Main ── */
main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 20px;
}

/* ── Upload card ── */
.upload-card {
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08), 0 1px 4px rgba(0,0,0,0.04);
  padding: 40px;
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

/* ── Upload zone ── */
.upload-zone {
  width: 100%;
  border: 2px dashed #00274C;
  border-radius: 12px;
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.upload-icon-wrap {
  width: 72px;
  height: 72px;
  background: rgba(0, 39, 76, 0.06);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
  transition: background 0.2s ease;
}

.upload-zone:hover .upload-icon-wrap,
.upload-zone.dragover .upload-icon-wrap {
  background: rgba(255, 203, 5, 0.2);
}

.upload-zone:hover,
.upload-zone.dragover {
  background: rgba(0, 39, 76, 0.04);
  border-color: #FFCB05;
}

.upload-primary {
  font-size: 20px;
  font-weight: 600;
  color: #00274C;
}

.upload-secondary {
  font-size: 13px;
  color: #666;
}

.upload-hint {
  font-size: 15px;
  color: #666;
  margin-top: 4px;
}

/* ── Browse button ── */
.btn-browse {
  background: #FFCB05;
  color: #00274C;
  border: none;
  border-radius: 6px;
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 600;
  font-family: 'Lexend', sans-serif;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-browse:hover {
  background: #e6b800;
}

/* ── File selected state ── */
.file-selected {
  width: 100%;
  background: #f1f3f5;
  border-radius: 6px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.file-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.file-name {
  font-size: 14px;
  font-weight: 600;
  color: #00274C;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-size {
  font-size: 12px;
  color: #666;
  white-space: nowrap;
}

/* ── Error messages ── */
.error-msg {
  width: 100%;
  background: rgba(194, 60, 60, 0.06);
  border-left: 4px solid #C23C3C;
  border-radius: 4px;
  padding: 10px 14px;
  font-size: 13px;
  color: #C23C3C;
  font-weight: 600;
}

.api-error {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: #C23C3C;
  font-size: 14px;
}

/* ── Button row ── */
.btn-row {
  width: 100%;
  display: flex;
  gap: 12px;
}

/* ── Clear button ── */
.btn-clear {
  flex: 1;
  background: none;
  border: 2px solid #C23C3C;
  color: #C23C3C;
  border-radius: 6px;
  padding: 14px;
  font-size: 14px;
  font-weight: 600;
  font-family: 'Lexend', sans-serif;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-clear:hover:not(:disabled) {
  background: #C23C3C;
  color: white;
}

.btn-clear:disabled {
  border-color: #e5e7eb;
  color: #999;
  cursor: not-allowed;
}

/* ── Submit button ── */
.btn-submit {
  flex: 2;
  background: #00274C;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
  font-family: 'Lexend', sans-serif;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-submit:hover:not(:disabled) {
  background: #003a6e;
}

.btn-submit:disabled {
  background: #e5e7eb;
  color: #999;
  cursor: not-allowed;
}


/* ── Loading ── */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  color: #00274C;
  font-size: 15px;
  font-weight: 600;
}

.loading-dots {
  display: flex;
  gap: 10px;
  align-items: center;
}

.loading-dots span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #00274C;
  animation: pulse-dot 1s ease-in-out infinite;
}

.loading-dots span:nth-child(1) { animation-delay: 0s; }
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes pulse-dot {
  0%, 60%, 100% { transform: translateY(0);    background: #00274C; }
  30%            { transform: translateY(-12px); background: #FFCB05; }
}

/* ── Footer ── */
footer {
  background: #00274C;
  border-top: 3px solid #FFCB05;
  padding: 20px 32px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
}

footer a {
  color: #ffffff;
  text-decoration: underline;
  font-size: 14px;
  transition: color 0.2s ease;
}

footer a:hover {
  color: #FFCB05;
}

/* ── Focus styles ── */
:focus-visible {
  outline: 3px solid #FFCB05;
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

/* ── REPORT CARD ── */
#report-card {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 4px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

/* ── Report header ── */
.report-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.report-title-block {
  display: flex;
  flex-direction: column;
  gap: 0;
  flex: 1;
  justify-content: center;
}

.report-doc-title {
  font-size: 20px;
  font-weight: 600;
  color: #00274C;
  margin: 0;
  line-height: 1.4;
}



.report-header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-shrink: 0;
}

.btn-download-report {
  background: none;
  border: 2px solid #00274C;
  color: #00274C;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  font-family: 'Lexend', sans-serif;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.btn-download-report:hover {
  background: #00274C;
  color: white;
}

.btn-download-report {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.dropdown-chevron {
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.download-wrap {
  position: relative;
}

.download-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 100%;
  background: #fff;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
  overflow: hidden;
  z-index: 100;
}

.download-dropdown button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  font-family: 'Lexend', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: #1a1a1a;
  cursor: pointer;
  white-space: nowrap;
  text-align: left;
  transition: background 0.15s ease;
}

.download-dropdown button:hover {
  background: #f5f7fa;
}

.download-dropdown button + button {
  border-top: 1px solid #f0f0f0;
}

.badge-accessible {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  background: #2C9A4B;
  color: #fff;
  padding: 2px 7px;
  border-radius: 10px;
  letter-spacing: 0.3px;
  line-height: 1.4;
}

.btn-analyze-another {
  background: #FFCB05;
  border: none;
  color: #00274C;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  font-family: 'Lexend', sans-serif;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(255, 203, 5, 0.35);
}

.btn-analyze-another:hover {
  background: #e6b800;
  box-shadow: 0 4px 10px rgba(255, 203, 5, 0.45);
  transform: translateY(-1px);
}

/* ── Summary ring ── */
.ring-legend {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
}

.legend-item {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-item::before {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.legend-pass::before { background: #2C9A4B; }
.legend-warn::before { background: #D66A12; }
.legend-fail::before { background: #C23C3C; }

.legend-pass { color: #2C9A4B; }
.legend-warn { color: #D66A12; }
.legend-fail { color: #C23C3C; }

/* ── Report sections ── */
.report-section {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.report-section-title {
  font-size: 17px;
  font-weight: 600;
  color: #00274C;
  margin: 0;
  padding-bottom: 12px;
  border-bottom: 2px solid #FFCB05;
}

/* When title is inside a header row, the header owns the border */
.report-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 2px solid #FFCB05;
}

.report-section-header .report-section-title {
  padding-bottom: 0;
  border-bottom: none;
}

/* ── Summary + ring side by side ── */
.report-summary-row {
  display: flex;
  gap: 24px;
  align-items: stretch;
}

.report-summary-row .report-section {
  flex: 1;
  gap: 0;
  text-align: center;
}

.summary-inner {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.report-ring-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
  padding: 24px;
  min-width: 200px;
  align-self: stretch;
}

/* ── Document summary dl ── */
.report-dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 20px;
  row-gap: 10px;
  margin: 0;
}

.report-dl-row {
  display: contents;
  font-size: 15px;
}

.report-dl-row dt {
  color: #666;
  font-weight: 400;
  text-align: right;
  align-self: start;
  white-space: nowrap;
  padding-top: 1px;
}

.report-dl-row dd {
  color: #00274C;
  font-weight: 600;
  margin: 0;
  text-align: left;
  align-self: start;
  word-break: break-word;
  min-width: 0;
}


/* ── Check cards (fixable + signals) ── */
.check-card {
  border-left: 4px solid #e5e7eb;
  border-radius: 6px;
  padding: 16px;
  background: #fafafa;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.check-card.pass   { border-left-color: #2C9A4B; background: rgba(44,154,75,0.04); }
.check-card.warn   { border-left-color: #D66A12; background: rgba(214,106,18,0.04); }
.check-card.fail   { border-left-color: #C23C3C; background: rgba(194,60,60,0.04); }
.check-card.review { border-left-color: #2a5298; background: rgba(42,82,152,0.04); }

.check-card-header {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 12px;
}

.check-card-header::after {
  content: '';
  display: block;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%2300274C' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  transition: transform 0.2s ease;
  opacity: 0.5;
}

details[open] .check-card-header::after {
  transform: rotate(180deg);
  opacity: 1;
}

.check-card-title {
  font-size: 15px;
  font-weight: 600;
  color: #00274C;
  margin: 0;
}

.check-status-badge {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

.badge-pass { background: #e6f4ea; color: #2C9A4B; }
.badge-warn { background: #fff3e6; color: #D66A12; }
.badge-fail { background: #fde8e8; color: #C23C3C; }
.badge-review { background: #e8eef7; color: #2a5298; }

.check-card-body {
  font-size: 15px;
  color: #4a5568;
  line-height: 1.6;
}

.check-card-fix {
  font-size: 14px;
  color: #4a5568;
  line-height: 1.6;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 12px;
}

.check-card-fix strong {
  display: block;
  color: #00274C;
  margin-bottom: 4px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-banner {
  border-radius: 10px;
  padding: 16px 20px;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.5;
}

.status-banner.banner-fail {
  background: rgba(154, 51, 36, 0.08);
  border-left: 4px solid #9A3324;
  color: #9A3324;
}

.status-banner.banner-warn {
  background: rgba(216, 96, 24, 0.08);
  border-left: 4px solid #D86018;
  color: #D86018;
}

.status-banner.banner-pass {
  background: rgba(44, 154, 75, 0.08);
  border-left: 4px solid #2C9A4B;
  color: #2C9A4B;
}

.status-banner span {
  display: block;
  font-size: 15px;
  font-weight: 400;
  margin-top: 4px;
  opacity: 0.85;
}

.report-page-title {
  font-size: 24px;
  font-weight: 600;
  color: #00274C;
  margin: 0 0 4px 0;
  text-align: center;
}

.btn-expand-all {
  background: none;
  border: 2px solid #00274C;
  color: #00274C;
  border-radius: 5px;
  padding: 4px 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Lexend', sans-serif;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-expand-all:hover {
  background: #00274C;
  color: white;
}

details.check-card summary {
  cursor: pointer;
  list-style: none;
  border-radius: 4px;
  transition: background 0.15s ease;
}

details.check-card summary:hover {
  background: rgba(0, 39, 76, 0.03);
}

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

.check-card-body-content {
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.check-fix-row {
  display: flex;
  gap: 12px;
  margin-top: 4px;
}

/* ── Print styles ── */
@media print {
  @page {
    margin: 24mm 16mm;
  }

  body {
    background: white;
    font-size: 12pt;
  }

  header, footer, .loading, .upload-card, .api-error,
  .btn-analyze-another, .btn-download-report, .report-header-actions,
  .btn-expand-all, .report-page-title {
    display: none !important;
  }

  main {
    padding: 0;
    display: block;
  }

  #report-card {
    padding: 0;
    gap: 16pt;
    max-width: 100%;
  }

  .report-summary-row {
    gap: 12pt;
  }

  .report-section,
  .report-ring-section {
    box-shadow: none;
    border: 1px solid #e5e7eb;
  }

  .report-ring-section,
  .report-summary-row .report-section {
    break-inside: avoid;
  }

  /* Force all check cards open */
  details.check-card {
    display: block;
    break-inside: avoid;
    page-break-inside: avoid;
    margin-bottom: 12pt;
  }

  details.check-card summary::marker,
  details.check-card summary::-webkit-details-marker {
    display: none;
  }

  .check-card-body-content {
    display: flex !important;
  }

  .check-card-header::after {
    display: none;
  }

  .check-fix-row {
    flex-direction: column;
    gap: 8pt;
  }

  .fix-card {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .report-checks {
    break-inside: auto;
  }

  .status-banner {
    break-after: page;
  }

  #fixable-checks {
    break-after: page;
  }

  .status-banner {
    border-radius: 4pt;
  }

  /* Print header in place of site header */
  #report-card::before {
    content: 'PDF Accessibility Report — University of Michigan';
    display: block;
    font-size: 11pt;
    color: #00274C;
    font-weight: 600;
    border-bottom: 2px solid #FFCB05;
    padding-bottom: 8pt;
    margin-bottom: 16pt;
  }
}

.fix-card {
  flex: 1;
  border-radius: 6px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fix-word {
  background: #FAF0EE;
  border: 1px solid #E8C4BC;
}

.fix-acrobat {
  background: #FDF4EC;
  border: 1px solid #F0D4B4;
}

.fix-card-label {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.fix-word .fix-card-label {
  color: #9A3324;
}

.fix-acrobat .fix-card-label {
  color: #D86018;
}

.fix-steps {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.fix-steps li {
  font-size: 14px;
  color: #4a5568;
  line-height: 1.5;
}

/* ── Responsive ── */

/* Tablet and small laptop (≤ 768px) */
@media (max-width: 768px) {
  header {
    padding: 16px 20px;
  }

  footer {
    flex-direction: column;
    gap: 12px;
    padding: 16px 20px;
    text-align: center;
  }

  main {
    padding: 16px;
  }

  /* Upload card */
  .upload-card {
    padding: 28px 20px;
  }

  /* Report card */
  #report-card {
    padding: 4px 0 32px;
    gap: 20px;
  }

  /* Summary + ring stack vertically */
  .report-summary-row {
    flex-direction: column;
  }

  .report-ring-section {
    min-width: unset;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 32px;
    padding: 20px 24px;
  }

  /* Report header: title above, buttons below */
  .report-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .report-header-actions {
    width: 100%;
  }

  .download-wrap,
  .btn-download-report,
  .btn-analyze-another {
    flex: 1;
    text-align: center;
    justify-content: center;
  }

  /* Fix cards stack vertically */
  .check-fix-row {
    flex-direction: column;
  }
}

/* Mobile (≤ 480px) */
@media (max-width: 480px) {
  main {
    padding: 12px;
  }

  header h1 {
    font-size: 17px;
  }

  .header-subtitle {
    font-size: 12px;
  }

  .upload-primary {
    font-size: 17px;
  }

  .upload-zone {
    padding: 28px 16px;
  }

  /* Report title */
  .report-page-title {
    font-size: 20px;
  }

  .report-doc-title {
    font-size: 17px;
  }

  /* Status banner */
  .status-banner {
    font-size: 15px;
  }

  .status-banner span {
    font-size: 13px;
  }

  /* Ring section: back to column on very small screens */
  .report-ring-section {
    flex-direction: column;
    gap: 16px;
  }

  /* Buttons stack vertically on small phones */
  .report-header-actions {
    flex-direction: column;
  }

  .download-wrap,
  .btn-download-report,
  .btn-analyze-another {
    width: 100%;
    justify-content: center;
  }

  .download-dropdown {
    min-width: 100%;
  }

  /* Check card header: tighten spacing */
  .check-card-header {
    gap: 8px;
  }

  .check-card-title {
    font-size: 14px;
  }

  /* Section padding */
  .report-section {
    padding: 18px 16px;
  }
}