:root {
  color-scheme: dark;
  --bg: #090d12;
  --surface: #101720;
  --surface-strong: #151e29;
  --line: rgba(202, 171, 103, 0.18);
  --gold: #c9a85f;
  --gold-bright: #e4c77c;
  --blue: #2fc7d5;
  --green: #51d69b;
  --orange: #efa85c;
  --red: #f07373;
  --text: #f3f0e7;
  --muted: #84909e;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 15% -10%, rgba(47, 199, 213, 0.12), transparent 32rem),
    radial-gradient(circle at 90% 10%, rgba(201, 168, 95, 0.1), transparent 28rem),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
}

button,
textarea {
  font: inherit;
}

button {
  touch-action: manipulation;
}

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

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

.topbar {
  margin-bottom: 34px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.2em;
}

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

h1 {
  margin-bottom: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 500;
  letter-spacing: -0.04em;
}

h2 {
  margin-bottom: 0;
  font-size: 1.2rem;
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  transition: 150ms ease;
}

.button:focus-visible,
textarea:focus-visible,
summary:focus-visible,
pre:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}

.button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.button-primary {
  border-color: rgba(228, 199, 124, 0.52);
  background: linear-gradient(135deg, #dac070, #a88036);
  color: #151109;
  box-shadow: 0 10px 28px rgba(151, 112, 38, 0.18);
}

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

.button-quiet {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
}

.button-quiet:hover {
  border-color: var(--line);
  color: var(--text);
}

.button-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.is-spinning .button-dot {
  animation: pulse 800ms ease-in-out infinite alternate;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.75fr);
  gap: 18px;
}

.score-card,
.meta-card,
.panel {
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(21, 30, 41, 0.96), rgba(12, 18, 26, 0.96));
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.22);
}

.score-card {
  min-height: 300px;
  padding: 28px;
  border-radius: 14px;
}

.score-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.9rem;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

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

.is-live { color: var(--green); }
.is-stale { color: var(--orange); }
.is-loading { color: var(--blue); }
.is-error { color: var(--red); }

.score-value {
  margin: 26px 0 18px;
  color: var(--gold-bright);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(5rem, 16vw, 9rem);
  line-height: 0.88;
  letter-spacing: -0.08em;
  text-shadow: 0 12px 44px rgba(201, 168, 95, 0.2);
}

.score-scale {
  overflow: hidden;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
}

.score-scale span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--gold-bright));
  transition: width 500ms ease;
}

.score-note {
  margin: 20px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.latest-change {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  color: #b8c2cc;
  font-size: 0.86rem;
  line-height: 1.5;
}

.latest-change[hidden] {
  display: none;
}

.delta-pill {
  display: inline-flex;
  min-width: 46px;
  min-height: 30px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-family: var(--mono);
  font-weight: 800;
}

.is-positive { color: var(--green); }
.is-negative { color: var(--red); }
.is-neutral { color: var(--muted); }

.meta-card {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  padding: 1px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
}

.meta-item {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 24px 20px;
  background: linear-gradient(145deg, rgba(21, 30, 41, 0.98), rgba(12, 18, 26, 0.98));
}

.meta-label {
  color: var(--muted);
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.meta-item strong {
  overflow-wrap: anywhere;
  font-size: 1.05rem;
  line-height: 1.45;
}

.notice {
  margin-top: 18px;
  padding: 13px 16px;
  border: 1px solid rgba(240, 115, 115, 0.35);
  border-radius: 9px;
  background: rgba(240, 115, 115, 0.08);
  color: #ffb4b4;
  line-height: 1.5;
}

.notice[data-kind="warning"] {
  border-color: rgba(239, 168, 92, 0.35);
  background: rgba(239, 168, 92, 0.08);
  color: #f4c38c;
}

.notice[data-kind="success"] {
  border-color: rgba(81, 214, 155, 0.3);
  background: rgba(81, 214, 155, 0.07);
  color: #96ebc5;
}

.panel {
  margin-top: 18px;
  border-radius: 12px;
}

.history-panel {
  padding: 24px;
}

.panel-heading {
  margin-bottom: 18px;
}

.history-caption {
  color: var(--muted);
  font-size: 0.78rem;
}

.history-table-wrap {
  overflow-x: auto;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 9px;
  background: rgba(8, 12, 17, 0.55);
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.history-table th,
.history-table td {
  padding: 15px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.055);
  text-align: left;
  vertical-align: middle;
}

.history-table th {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

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

.history-table tbody tr.is-latest {
  background: rgba(201, 168, 95, 0.06);
  box-shadow: inset 3px 0 0 var(--gold);
}

.cell-primary,
.cell-secondary {
  display: block;
}

.cell-primary {
  color: var(--text);
  line-height: 1.45;
  white-space: nowrap;
}

.cell-secondary {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.35;
}

.latest-marker {
  display: inline-block;
  margin-right: 7px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(201, 168, 95, 0.16);
  color: var(--gold-bright);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  vertical-align: 1px;
}

.delta-cell .cell-primary {
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 800;
}

.delta-cell.is-positive .cell-primary { color: var(--green); }
.delta-cell.is-negative .cell-primary { color: var(--red); }
.delta-cell.is-neutral .cell-primary { color: var(--muted); }

.history-empty {
  margin: 0;
  padding: 46px 20px;
  color: var(--muted);
  text-align: center;
}

.history-toggle {
  width: 100%;
  margin-top: 14px;
}

.raw-details,
.cookie-panel {
  overflow: hidden;
}

.raw-details summary,
.cookie-panel summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 24px;
  cursor: pointer;
  list-style: none;
}

.raw-details summary::-webkit-details-marker,
.cookie-panel summary::-webkit-details-marker {
  display: none;
}

.raw-details summary strong,
.cookie-panel summary strong {
  font-size: 1.05rem;
}

.raw-details[open] .summary-action,
.cookie-panel[open] .summary-action {
  visibility: hidden;
}

.raw-panel {
  padding: 0 24px 24px;
}

.raw-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

pre {
  overflow: auto;
  max-height: 540px;
  min-height: 220px;
  margin: 0;
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  background: #080c11;
  color: #b7c9d3;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.65;
  tab-size: 2;
}

.summary-action {
  color: var(--gold);
  font-size: 0.82rem;
}

.cookie-panel form {
  padding: 0 24px 24px;
}

label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.86rem;
}

textarea {
  width: 100%;
  resize: vertical;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: #080c11;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.55;
}

textarea::placeholder {
  color: #47525e;
}

.form-footer {
  margin-top: 14px;
}

.form-footer p {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

footer {
  padding: 24px 4px 0;
  color: #5f6b77;
  font-size: 0.75rem;
}

@keyframes pulse {
  from { opacity: 0.35; }
  to { opacity: 1; }
}

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

  .topbar {
    align-items: flex-end;
  }

  .topbar .button {
    min-width: 46px;
    padding-inline: 14px;
    font-size: 0;
  }

  .topbar .button-dot {
    width: 9px;
    height: 9px;
  }

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

  .meta-card {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1px;
    padding: 1px;
  }

  .meta-item {
    padding: 17px 14px;
  }

  .meta-item strong {
    overflow-wrap: anywhere;
    font-size: 0.88rem;
  }

  .history-panel {
    padding: 18px;
  }

  .raw-panel,
  .raw-details summary,
  .cookie-panel summary,
  .cookie-panel form {
    padding-inline: 18px;
  }

  .history-caption {
    text-align: right;
  }

  .history-table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
  }

  .history-table,
  .history-table tbody,
  .history-table tr,
  .history-table td {
    display: block;
    width: 100%;
  }

  .history-table thead {
    display: none;
  }

  .history-table tbody {
    display: grid;
    gap: 12px;
  }

  .history-table tbody tr {
    padding: 8px 14px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 9px;
    background: rgba(8, 12, 17, 0.58);
  }

  .history-table tbody tr.is-latest {
    border-color: rgba(201, 168, 95, 0.22);
    background: rgba(201, 168, 95, 0.055);
    box-shadow: inset 3px 0 0 var(--gold);
  }

  .history-table td {
    display: grid;
    grid-template-columns: minmax(76px, 0.38fr) minmax(0, 1fr);
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  }

  .history-table td::before {
    color: var(--muted);
    content: attr(data-label);
    font-size: 0.72rem;
    line-height: 1.5;
  }

  .history-table tbody tr:last-child td,
  .history-table tbody tr td:last-child {
    border-bottom: 0;
  }

  .cell-primary {
    white-space: normal;
  }

  .panel-heading,
  .form-footer,
  footer {
    align-items: flex-start;
  }

  .form-footer,
  footer {
    flex-direction: column;
  }

  .form-footer .button {
    width: 100%;
  }

  pre {
    padding: 16px;
    font-size: 0.75rem;
  }
}
