:root {
  --blue: #1877f2;
  --blue-dark: #0d5fcc;
  --blue-soft: #eaf3ff;
  --ink: #162033;
  --muted: #667085;
  --border: #dfe4ec;
  --surface: #ffffff;
  --canvas: #f5f7fb;
  --success: #14804a;
  --success-soft: #e9f7ef;
  --danger: #c43d4b;
  --danger-soft: #fff0f1;
  --warning: #a15c00;
  --warning-soft: #fff6df;
  --shadow: 0 18px 48px rgba(16, 42, 86, 0.08);
  --radius-lg: 20px;
  --radius-md: 12px;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--canvas);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, rgba(24, 119, 242, 0.08), transparent 25rem),
    var(--canvas);
}

button,
textarea {
  font: inherit;
}

button {
  border: 0;
}

.page-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 34px 0 56px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: end center;
  overflow: hidden;
  border-radius: 14px;
  color: #fff;
  background: var(--blue);
  font: 800 45px/0.94 Arial, sans-serif;
  box-shadow: 0 9px 24px rgba(24, 119, 242, 0.24);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--blue-dark);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.35rem, 2vw, 1.7rem);
  line-height: 1.15;
  letter-spacing: -0.03em;
}

h2 {
  margin-bottom: 7px;
  font-size: 1.25rem;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.api-badge {
  margin-left: auto;
  padding: 7px 11px;
  border: 1px solid #c7dbf7;
  border-radius: 999px;
  color: #235d9f;
  background: rgba(255, 255, 255, 0.72);
  font-size: 0.78rem;
  font-weight: 700;
}

.workspace,
.results-section {
  border: 1px solid rgba(212, 219, 230, 0.92);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.workspace {
  padding: 26px;
}

.workspace-heading,
.results-header,
.form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.workspace-heading p,
.empty-state p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.55;
}

.shortcut {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 8px;
  color: #596579;
  background: #f8fafc;
  font-size: 0.75rem;
  font-weight: 700;
}

textarea {
  display: block;
  width: 100%;
  min-height: 190px;
  margin: 20px 0 14px;
  padding: 16px 18px;
  resize: vertical;
  border: 1px solid #cbd4e1;
  border-radius: var(--radius-md);
  outline: none;
  color: var(--ink);
  background: #fbfcfe;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.91rem;
  line-height: 1.75;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

textarea::placeholder {
  color: #98a2b3;
}

textarea:focus {
  border-color: var(--blue);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(24, 119, 242, 0.12);
}

.url-count {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 650;
}

.primary-actions,
.result-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 15px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.89rem;
  font-weight: 750;
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease, opacity 150ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:focus-visible,
.open-link:focus-visible {
  outline: 3px solid rgba(24, 119, 242, 0.28);
  outline-offset: 2px;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.button-primary {
  min-width: 155px;
  color: #fff;
  background: var(--blue);
  box-shadow: 0 8px 20px rgba(24, 119, 242, 0.2);
}

.button-primary:hover:not(:disabled) {
  background: var(--blue-dark);
}

.button-secondary {
  border: 1px solid var(--border);
  color: #475467;
  background: #fff;
}

.button-secondary:hover:not(:disabled),
.button-quiet:hover:not(:disabled) {
  border-color: #b8c3d1;
  background: #f8fafc;
}

.button-quiet {
  min-height: 38px;
  border: 1px solid var(--border);
  color: #344054;
  background: #fff;
}

.button-quiet svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
}

.spinner {
  display: none;
  width: 17px;
  height: 17px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.is-loading .spinner {
  display: inline-block;
}

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

.notice {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  margin-top: 20px;
  padding: 14px 16px;
  border: 1px solid #cfe1fa;
  border-radius: 11px;
  color: #315779;
  background: #f3f8ff;
}

.notice svg {
  flex: 0 0 auto;
  width: 19px;
  height: 19px;
  margin-top: 2px;
  fill: var(--blue);
}

.notice p {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.55;
}

.results-section {
  margin-top: 22px;
  overflow: hidden;
}

.results-header {
  padding: 22px 24px;
  border-bottom: 1px solid var(--border);
}

.results-header h2 {
  margin-bottom: 0;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  padding: 20px 24px;
  background: #fbfcfe;
  border-bottom: 1px solid var(--border);
}

.summary-card {
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 78px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: #fff;
}

.summary-icon {
  display: grid;
  width: 39px;
  height: 39px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 11px;
}

.summary-icon svg {
  width: 21px;
  height: 21px;
  fill: currentColor;
}

.summary-total .summary-icon {
  color: var(--blue);
  background: var(--blue-soft);
}

.summary-success .summary-icon {
  color: var(--success);
  background: var(--success-soft);
}

.summary-failed .summary-icon {
  color: var(--danger);
  background: var(--danger-soft);
}

.summary-card span:not(.summary-icon) {
  display: block;
  margin-bottom: 2px;
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1;
}

.summary-card small {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 650;
}

.table-shell {
  min-height: 252px;
}

.empty-state {
  display: grid;
  min-height: 252px;
  place-items: center;
  align-content: center;
  padding: 32px;
  text-align: center;
}

.empty-icon {
  display: grid;
  width: 56px;
  height: 56px;
  margin-bottom: 14px;
  place-items: center;
  border-radius: 17px;
  color: #7791af;
  background: #eff4fa;
}

.empty-icon svg {
  width: 28px;
  height: 28px;
  fill: currentColor;
}

.empty-state h3 {
  margin-bottom: 6px;
  font-size: 1rem;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 1240px;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  padding: 15px 14px;
  border-bottom: 1px solid #e8ecf2;
  text-align: left;
  vertical-align: middle;
}

th {
  color: #536176;
  background: #f8fafc;
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

td {
  color: #344054;
  font-size: 0.87rem;
  line-height: 1.4;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: #fbfdff;
}

th:nth-child(1), td:nth-child(1) { width: 58px; }
th:nth-child(2), td:nth-child(2) { width: 17%; }
th:nth-child(3), td:nth-child(3) { width: 21%; }
th:nth-child(4), td:nth-child(4) { width: 8%; }
th:nth-child(5), td:nth-child(5) { width: 8%; }
th:nth-child(6), td:nth-child(6) { width: 9%; }
th:nth-child(7), td:nth-child(7) { width: 31%; }

.row-number {
  color: #98a2b3;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.title-cell {
  color: var(--ink);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.unavailable {
  color: #98a2b3;
  font-style: italic;
  font-weight: 500;
}

.url-cell-inner {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 9px;
}

.url-text {
  min-width: 0;
  overflow: hidden;
  color: #526075;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.79rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.open-link {
  display: inline-flex;
  min-width: 57px;
  min-height: 30px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border: 1px solid #cbdcf3;
  border-radius: 8px;
  color: var(--blue-dark);
  background: #f3f8ff;
  font-size: 0.76rem;
  font-weight: 800;
  text-decoration: none;
}

.metric {
  color: #27364c;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 800;
  text-transform: capitalize;
}

.status-badge::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.status-success {
  color: var(--success);
  background: var(--success-soft);
}

.status-partial {
  color: var(--warning);
  background: var(--warning-soft);
}

.status-failed,
.status-invalid {
  color: var(--danger);
  background: var(--danger-soft);
}

.api-message {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.debug-details {
  margin-top: 9px;
  color: #475467;
  font-size: 0.76rem;
}

.debug-details summary {
  width: max-content;
  cursor: pointer;
  color: var(--blue-dark);
  font-weight: 750;
}

.debug-details pre {
  max-height: 300px;
  margin: 8px 0 0;
  padding: 10px;
  overflow: auto;
  border: 1px solid #dbe4f0;
  border-radius: 8px;
  color: #344054;
  background: #f8fafc;
  font: 0.7rem/1.45 "SFMono-Regular", Consolas, monospace;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 10;
  max-width: min(380px, calc(100vw - 44px));
  padding: 12px 15px;
  border-radius: 10px;
  color: #fff;
  background: #263449;
  box-shadow: 0 12px 34px rgba(16, 24, 40, 0.22);
  font-size: 0.87rem;
  font-weight: 650;
  line-height: 1.45;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  background: #9f2937;
}

.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;
}

[hidden] {
  display: none !important;
}

@media (max-width: 860px) {
  .page-shell {
    width: min(100% - 28px, 760px);
    padding-top: 24px;
  }

  .summary-grid {
    gap: 10px;
  }

  .table-wrap {
    overflow: visible;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100% !important;
  }

  table {
    min-width: 0;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 12px;
    padding: 14px;
    background: #f8fafc;
  }

  tbody tr {
    display: grid;
    grid-template-columns: 74px minmax(0, 1fr);
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: #fff;
  }

  tbody tr:hover {
    background: #fff;
  }

  td {
    display: grid;
    grid-template-columns: 118px minmax(0, 1fr);
    grid-column: 1 / -1;
    gap: 12px;
    padding: 12px 14px;
  }

  td::before {
    color: #667085;
    content: attr(data-label);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .url-cell-inner {
    align-items: flex-start;
    flex-direction: column;
  }

  .url-text {
    width: 100%;
  }

  .message-cell .debug-details {
    min-width: 0;
    grid-column: 2;
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 20px, 560px);
    padding: 16px 0 34px;
  }

  .brand-mark {
    width: 43px;
    height: 43px;
    border-radius: 12px;
    font-size: 40px;
  }

  .api-badge,
  .shortcut {
    display: none;
  }

  .workspace {
    padding: 19px;
  }

  .workspace-heading,
  .form-footer,
  .results-header {
    align-items: stretch;
    flex-direction: column;
  }

  textarea {
    min-height: 220px;
    padding: 14px;
  }

  .form-footer {
    gap: 13px;
  }

  .primary-actions,
  .result-actions {
    width: 100%;
  }

  .primary-actions .button,
  .result-actions .button {
    flex: 1 1 0;
  }

  .results-header {
    gap: 15px;
    padding: 19px;
  }

  .summary-grid {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .summary-card {
    min-height: 66px;
  }

  td {
    grid-template-columns: 94px minmax(0, 1fr);
  }
}

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