:root {
  --color-background: #fafafa;
  --color-surface: #ffffff;
  --color-surface-2: #f5f5f5;
  --color-surface-3: #ebebeb;
  --color-border: rgba(0, 0, 0, 0.08);
  --color-border-strong: rgba(0, 0, 0, 0.16);
  --color-accent: #fbbf24;
  --color-accent-hover: #f59e0b;
  --color-accent-subtle: #fef3c7;
  --color-foreground: #171717;
  --color-muted: #737373;
  --color-success: #16a34a;
  --color-danger: #dc2626;
  --color-link: #92400e;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.05), 0 10px 15px rgba(0, 0, 0, 0.08);
  --card-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08), var(--shadow-sm);
  --medal-gold: #b45309;
  --medal-gold-bg: #fef3c7;
  --medal-silver: #525252;
  --medal-silver-bg: #f5f5f5;
  --medal-bronze: #92400e;
  --medal-bronze-bg: #ffedd5;
  --medal-slop: #a3a3a3;
  --medal-slop-bg: #f5f5f5;
}

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

html {
  scroll-behavior: smooth;
}

body {
  background-color: var(--color-background);
  background-image: radial-gradient(circle, rgba(0, 0, 0, 0.055) 1px, transparent 1px);
  background-size: 22px 22px;
  color: var(--color-foreground);
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: -0.01em;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--color-link);
  text-decoration: none;
  transition: color 0.15s;
}

a:hover {
  color: var(--color-foreground);
}

code {
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 0.92em;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

@media (min-width: 1024px) {
  .container {
    padding: 0 40px;
  }
}

/* Nav */
nav {
  border-bottom: 1px solid var(--color-border);
  background: rgba(250, 250, 250, 0.92);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.logo {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
}

.logo-img {
  display: block;
  height: 32px;
  width: auto;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-muted);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
  transition: 0.15s;
}

.nav-link:hover {
  color: var(--color-foreground);
  border-color: var(--color-border-strong);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-link.active {
  color: var(--color-foreground);
  border-color: var(--color-accent);
  background: var(--color-accent-subtle);
}

/* Hero */
.hero {
  padding: 56px 0 44px;
  border-bottom: 1px solid var(--color-border);
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--color-accent-subtle);
  border: 1px solid rgba(251, 191, 36, 0.35);
  border-radius: 999px;
  padding: 5px 13px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-link);
  margin-bottom: 22px;
  letter-spacing: 0.01em;
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-accent);
  animation: blink 2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.25;
  }
}

h1 {
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: clamp(30px, 5vw, 48px);
  font-weight: 800;
  line-height: 1.06;
  letter-spacing: -0.05em;
  color: var(--color-foreground);
  margin-bottom: 14px;
}

.hero-sub {
  font-size: 15px;
  color: var(--color-muted);
  max-width: 520px;
  line-height: 1.7;
  margin-bottom: 12px;
}

.hero-meta {
  font-size: 13px;
  color: var(--color-muted);
  margin-bottom: 32px;
}

.hero-meta strong {
  color: var(--color-foreground);
  font-weight: 500;
}

.stats {
  display: flex;
  gap: 0;
  flex-wrap: wrap;
}

.stat {
  padding-right: 32px;
  margin-right: 32px;
  border-right: 1px solid var(--color-border);
}

.stat:last-child {
  border-right: none;
  padding-right: 0;
  margin-right: 0;
}

.stat-value {
  font-family: "DM Mono", monospace;
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.03em;
  color: var(--color-foreground);
  line-height: 1;
  margin-bottom: 5px;
}

.stat-value.loading {
  background: var(--color-surface-3);
  border-radius: 6px;
  color: transparent;
  width: 48px;
  animation: pulse 1.4s ease-in-out infinite;
}

.stat-label {
  font-size: 13px;
  color: var(--color-muted);
}

/* Toolbar */
.toolbar {
  padding: 18px 0;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--color-border);
}

.search-wrap {
  position: relative;
  flex: 1 1 0%;
  min-width: 180px;
  max-width: 340px;
}

.search-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-muted);
  pointer-events: none;
}

#search {
  width: 100%;
  height: 40px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  padding: 0 14px 0 38px;
  font-family: "DM Sans", sans-serif;
  font-size: 14px;
  color: var(--color-foreground);
  outline: none;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}

#search::placeholder {
  color: var(--color-muted);
}

#search:focus {
  border-color: var(--color-border-strong);
  box-shadow: var(--shadow-sm), 0 0 0 4px rgba(251, 191, 36, 0.15);
}

.toolbar label.sort-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--color-muted);
  font-weight: 500;
}

#sort-select {
  height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-family: "DM Sans", sans-serif;
  font-size: 13px;
  color: var(--color-foreground);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.pill {
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-family: "DM Sans", sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-muted);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: 0.15s;
}

.pill:hover {
  border-color: var(--color-border-strong);
  color: var(--color-foreground);
}

.pill.active {
  background: var(--color-foreground);
  border-color: var(--color-foreground);
  color: #fff;
}

/* Section */
.section {
  padding: 28px 0 80px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--color-muted);
}

#package-count {
  font-size: 13px;
  color: var(--color-muted);
}

/* Leaderboard table */
.leaderboard-panel {
  margin-bottom: 0;
}

.leaderboard-panel table tbody tr {
  cursor: default;
}

.leaderboard-panel table tbody tr.clickable-row {
  cursor: pointer;
}

.leaderboard-panel table tbody tr.clickable-row:hover {
  background: var(--color-surface-2);
}

.leaderboard-panel td code {
  font-size: 13px;
}

.leaderboard-panel .details-link {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.table-empty {
  padding: 2rem 1.25rem;
  text-align: center;
  font-size: 13px;
  color: var(--color-muted);
  border-top: 1px solid var(--color-border);
}

.subtle {
  color: var(--color-muted);
  font-size: 0.85em;
}

/* Package cards (unused on index; kept for reference) */
.pkg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}

.card {
  background: var(--color-surface);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  padding: 20px;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: box-shadow 0.18s, transform 0.18s;
  animation: fadeUp 0.35s ease both;
  color: inherit;
}

.card:hover {
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12), var(--shadow-md);
  transform: translateY(-1px);
}

.card:active {
  transform: scale(0.99);
}

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

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.card-rank {
  font-family: "DM Mono", monospace;
  font-size: 11px;
  font-weight: 500;
  color: var(--color-muted);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 2px 8px;
}

.card-arrow {
  color: var(--color-surface-3);
  flex-shrink: 0;
  transition: color 0.15s, transform 0.15s;
}

.card:hover .card-arrow {
  color: var(--color-foreground);
  transform: translate(2px, -2px);
}

.card-name {
  font-family: "DM Mono", monospace;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--color-foreground);
}

.card-desc {
  font-size: 13px;
  line-height: 1.65;
  color: var(--color-muted);
  flex: 1;
}

.card-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 10px;
  border-top: 1px solid var(--color-border);
}

.score-pill {
  font-family: "DM Mono", monospace;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-foreground);
}

.parse-pill {
  font-size: 11px;
  color: var(--color-muted);
}

/* Medals */
.medal-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 11px;
  border: 1px solid transparent;
}

.medal-badge.gold {
  background: var(--medal-gold-bg);
  color: var(--medal-gold);
  border-color: rgba(251, 191, 36, 0.4);
}

.medal-badge.silver {
  background: var(--medal-silver-bg);
  color: var(--medal-silver);
  border-color: var(--color-border);
}

.medal-badge.bronze {
  background: var(--medal-bronze-bg);
  color: var(--medal-bronze);
  border-color: rgba(146, 64, 14, 0.2);
}

.medal-badge.slop {
  background: var(--medal-slop-bg);
  color: var(--medal-slop);
  border-color: var(--color-border);
}

/* Empty */
.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 0;
}

.empty-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--color-surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.empty h3 {
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.03em;
  margin-bottom: 6px;
}

.empty p {
  font-size: 13px;
  color: var(--color-muted);
}

.hidden {
  display: none !important;
}

/* Footer */
footer {
  border-top: 1px solid var(--color-border);
  padding: 22px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

footer span {
  font-size: 13px;
  color: var(--color-muted);
}

footer a {
  font-size: 13px;
  color: var(--color-muted);
}

footer a:hover {
  color: var(--color-foreground);
}

/* Terminal loader */
.page-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(250, 250, 250, 0.88);
  backdrop-filter: blur(14px);
}

.term-loader {
  width: min(620px, 100%);
  background: var(--color-surface);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: rgba(0, 0, 0, 0.07) 0 0 0 1px, rgba(0, 0, 0, 0.06) 0 8px 24px,
    rgba(0, 0, 0, 0.1) 0 32px 80px;
}

.term-hdr {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  background: var(--color-surface-2);
  border-bottom: 1px solid var(--color-border);
}

.term-dots {
  display: flex;
  gap: 6px;
}

.term-dots span {
  width: 11px;
  height: 11px;
  border-radius: 50%;
}

.term-dots span:nth-child(1) {
  background: #ff5f57;
}
.term-dots span:nth-child(2) {
  background: #ffbd2e;
}
.term-dots span:nth-child(3) {
  background: #28ca41;
}

.term-ttl {
  font-family: "DM Mono", monospace;
  font-size: 11px;
  color: var(--color-muted);
}

.term-body {
  padding: 18px 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-height: clamp(200px, 50vh, 380px);
  overflow-y: auto;
  scrollbar-width: none;
}

.term-body::-webkit-scrollbar {
  display: none;
}

.term-line {
  font-family: "DM Mono", monospace;
  font-size: 12.5px;
  line-height: 1.85;
  color: var(--color-foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.term-dim {
  color: var(--color-muted);
}

.term-accent {
  color: var(--color-link);
  font-weight: 500;
}

.term-ok {
  color: var(--color-muted);
}

.term-blink {
  font-family: "DM Mono", monospace;
  font-size: 12.5px;
  animation: cur-blink 1s step-end infinite;
}

@keyframes cur-blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Package detail page */
.detail-page {
  padding: 32px 0 80px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-muted);
  margin-bottom: 24px;
  text-decoration: none;
}

.back-link:hover {
  color: var(--color-foreground);
}

.package-header {
  margin-bottom: 28px;
}

.package-header h1 {
  margin-bottom: 8px;
}

.package-header p {
  font-size: 14px;
  color: var(--color-muted);
}

.score-summary {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 36px;
}

.score-card {
  background: var(--color-surface);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  padding: 18px;
  text-align: center;
}

.score-card h3 {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-muted);
}

.score-value {
  font-family: "DM Mono", monospace;
  font-size: 1.75rem;
  font-weight: 500;
  letter-spacing: -0.03em;
}

.distribution-section {
  margin-top: 40px;
}

.distribution-section h2 {
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 16px;
}

.metrics-grid-full {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.metric-card {
  background: var(--color-surface);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  padding: 16px;
}

.metric-header {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 8px;
  color: var(--color-muted);
}

.metric-header strong {
  color: var(--color-foreground);
  font-family: "DM Mono", monospace;
  font-size: 11px;
}

.sparkline-container-full {
  height: 72px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  margin-top: 8px;
  background: var(--color-surface-2);
  padding: 6px;
  border-radius: 8px;
}

.sparkline-bar {
  flex: 1;
  background: var(--color-accent);
  min-height: 1px;
  border-radius: 2px 2px 0 0;
  opacity: 0.85;
}

.metric-foot {
  margin-top: 0.5rem;
  font-size: 12px;
  color: var(--color-muted);
}

.metric-card-const {
  display: flex;
  flex-direction: column;
}

.metric-const-value {
  font-family: "DM Mono", monospace;
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--color-foreground);
  margin: 14px 0 6px;
}

.table-panel {
  background: var(--color-surface);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

th {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-muted);
  background: var(--color-surface-2);
}

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

tbody tr:hover {
  background: var(--color-surface-2);
}

.medal-list {
  list-style: none;
  background: var(--color-surface);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

.medal-item {
  display: flex;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  font-size: 13px;
}

.medal-item:last-child {
  border-bottom: none;
}

.not-found-panel {
  background: var(--color-surface);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  padding: 48px 32px;
  text-align: center;
}

.not-found-panel h1 {
  font-size: 24px;
  margin-bottom: 12px;
}

.not-found-panel p {
  color: var(--color-muted);
  font-size: 14px;
}

.error {
  color: var(--color-danger);
  font-size: 14px;
}

@media (max-width: 768px) {
  .leaderboard-panel th:nth-child(7),
  .leaderboard-panel td:nth-child(7),
  .leaderboard-panel th:nth-child(8),
  .leaderboard-panel td:nth-child(8) {
    display: none;
  }
}

@media (max-width: 640px) {
  .stat {
    padding-right: 20px;
    margin-right: 20px;
  }
}

/* Calibration page */
.hero-compact {
  padding-bottom: 32px;
}

/* Calibration Nav */
.cal-nav-sticky {
  position: sticky;
  top: 56px;
  background: rgba(250, 250, 250, 0.95);
  backdrop-filter: blur(8px);
  z-index: 9;
  border-bottom: 1px solid var(--color-border);
  margin-top: -1px;
}

.cal-nav-inner {
  display: flex;
  gap: 24px;
  padding: 12px 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.cal-nav-inner::-webkit-scrollbar {
  display: none;
}

.cal-nav-item {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-muted);
  white-space: nowrap;
  padding-bottom: 4px;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.cal-nav-item:hover {
  color: var(--color-foreground);
}

.cal-nav-item.active {
  color: var(--color-foreground);
  border-bottom-color: var(--color-accent);
}

/* --- Calibration Premium Style System --- */

.cal-section {
  padding: 48px 0;
  border-bottom: 1px solid var(--color-border);
  scroll-margin-top: 100px;
}

.cal-section:last-child {
  border-bottom: none;
}

.cal-prose,
.cal-lead {
  color: var(--color-muted);
  font-size: 15px;
  max-width: 800px;
  margin-bottom: 20px;
  line-height: 1.6;
}

.cal-prose strong {
  color: var(--color-foreground);
}

.cal-prose p + p {
  margin-top: 12px;
}

.cal-source {
  font-size: 13px;
  margin-top: 16px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--color-surface-2);
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--color-border);
}

/* Premium Dashboard & Concept Cards */
.cal-concept-card {
  background: linear-gradient(135deg, var(--color-surface) 0%, rgba(254, 243, 199, 0.15) 100%);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 32px;
  position: relative;
  overflow: hidden;
}

.cal-concept-card::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 150px;
  height: 150px;
  background: radial-gradient(circle, rgba(251, 191, 36, 0.08) 0%, transparent 70%);
  pointer-events: none;
}

.cal-flow-diagram {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-top: 24px;
  align-items: stretch;
}

.cal-flow-step {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.2s, box-shadow 0.2s;
}

.cal-flow-step:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.cal-step-num {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-link);
  margin-bottom: 8px;
}

.cal-step-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--color-foreground);
}

.cal-step-desc {
  font-size: 12px;
  color: var(--color-muted);
  line-height: 1.4;
}

/* Math blocks */
.cal-math-block {
  font-family: "DM Mono", ui-monospace, monospace;
  background: var(--color-surface-2);
  border-left: 4px solid var(--color-link);
  padding: 12px 16px;
  border-radius: 0 8px 8px 0;
  margin: 16px 0;
  font-size: 13px;
  overflow-x: auto;
  line-height: 1.5;
  color: var(--color-foreground);
}

.cal-math-term {
  color: #b45309;
}
.cal-math-op {
  color: var(--color-foreground);
  font-weight: bold;
}
.cal-math-cond {
  color: #16a34a;
}

/* Pillar Cards (The Three Generators) */
.cal-pillars-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}

.cal-pillar-card {
  background: var(--color-surface);
  border-radius: 16px;
  border: 1px solid var(--color-border);
  box-shadow: var(--card-shadow);
  padding: 24px;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
}

.cal-pillar-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.cal-pillar-card.simple {
  border-top: 4px solid var(--medal-bronze);
}
.cal-pillar-card.composable {
  border-top: 4px solid var(--medal-silver);
}
.cal-pillar-card.secure {
  border-top: 4px solid var(--medal-gold);
}

.cal-pillar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.cal-pillar-header h3 {
  font-size: 18px;
  font-weight: 700;
}

.cal-pillar-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.cal-pillar-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  text-transform: uppercase;
}

.cal-pillar-card.simple .cal-pillar-badge {
  background: var(--medal-bronze-bg);
  color: var(--medal-bronze);
}
.cal-pillar-card.composable .cal-pillar-badge {
  background: var(--medal-silver-bg);
  color: var(--medal-silver);
}
.cal-pillar-card.secure .cal-pillar-badge {
  background: var(--medal-gold-bg);
  color: var(--medal-gold);
}

.cal-pillar-desc {
  font-size: 13px;
  color: var(--color-muted);
  margin-bottom: 16px;
  min-height: 40px;
}

.cal-metric-rule-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cal-metric-rule-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(0,0,0,0.04);
}

.cal-metric-rule-row:last-child {
  border-bottom: none;
}

.cal-metric-name {
  font-weight: 600;
  color: var(--color-foreground);
}

.cal-metric-bound {
  font-family: "DM Mono", monospace;
  background: var(--color-surface-2);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--color-link);
}

/* Table styling */
.cal-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  overflow: hidden;
  font-size: 14px;
}

.cal-table-compact {
  font-size: 12px;
}

.cal-table td,
.cal-table th {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.cal-table th {
  background: var(--color-surface-2);
  font-weight: 600;
  color: var(--color-foreground);
}

.cal-table tr:last-child td {
  border-bottom: none;
}

/* Stat grids & Cards */
.cal-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.cal-stat-card {
  background: var(--color-surface);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  padding: 20px;
}

.cal-stat-card h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 6px;
}

.cal-stat-meta {
  font-size: 12px;
  color: var(--color-muted);
  margin-bottom: 16px;
}

.cal-dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
  font-size: 13px;
}

.cal-dl dt {
  color: var(--color-muted);
}

.cal-dl dd {
  font-weight: 600;
  text-align: right;
  color: var(--color-foreground);
}

/* Chart sections */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
}

.chart-card {
  background: var(--color-surface);
  border-radius: 16px;
  border: 1px solid var(--color-border);
  box-shadow: var(--card-shadow);
  padding: 20px;
  margin: 0;
}

.chart-card.chart-wide {
  max-width: 100%;
}

.chart-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--color-foreground);
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 8px;
}

.chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

.chart-note {
  font-size: 12px;
  color: var(--color-muted);
  margin-top: 12px;
}

.floor-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.floor-pill {
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.floor-pill code {
  color: var(--color-link);
  font-weight: bold;
}

.cal-legacy h3 {
  font-size: 15px;
  margin-bottom: 8px;
}

.card-panel {
  background: var(--color-surface);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  padding: 24px;
}

.cal-two-col {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 32px;
}

@media (max-width: 900px) {
  .cal-two-col {
    grid-template-columns: 1fr;
  }
}

.dist-chart {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dist-row {
  display: grid;
  grid-template-columns: 110px 1fr 100px;
  align-items: center;
  gap: 16px;
  font-size: 13px;
}

.dist-bar-wrap {
  height: 12px;
  background: var(--color-surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.dist-bar {
  height: 100%;
  border-radius: 999px;
  background: var(--color-accent);
}

.dist-bar.medal-gold {
  background: var(--medal-gold);
}

.dist-bar.medal-silver {
  background: var(--medal-silver);
}

.dist-bar.medal-bronze {
  background: var(--medal-bronze);
}

.dist-bar.medal-slop {
  background: var(--medal-slop);
}

.dist-count {
  text-align: right;
  color: var(--color-muted);
  font-size: 12px;
}

.bar-highlight {
  stroke: var(--medal-gold);
  stroke-width: 2.5;
  fill: rgba(254, 243, 199, 0.4);
}

.cal-error-detail {
  margin-top: 8px;
  font-size: 13px;
  color: var(--color-danger);
}

.cal-corpus-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 24px 0 32px;
}

.cal-corpus-stat {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.cal-corpus-value {
  display: block;
  font-size: 28px;
  font-weight: 800;
  color: var(--color-foreground);
  font-family: "Plus Jakarta Sans", sans-serif;
}

.cal-corpus-label {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.cal-method-steps {
  margin: 20px 0 8px;
  padding-left: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cal-method-steps li {
  font-size: 14px;
  color: var(--color-muted);
  line-height: 1.5;
  padding: 12px 14px 12px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
}

.cal-method-steps .cal-step-num {
  display: inline-block;
  margin-right: 8px;
}

.cal-floor-decision-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.cal-floor-decision-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--card-shadow);
}

.cal-floor-decision-card.composable {
  border-color: rgba(82, 82, 82, 0.25);
}

.cal-floor-decision-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.cal-floor-decision-header h3 {
  font-size: 16px;
  margin: 0;
}

.cal-floor-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.floor-pill.chosen {
  background: var(--color-surface-2);
  border-color: var(--color-border-strong);
  font-weight: 700;
}

.floor-pill.previous {
  opacity: 0.7;
  text-decoration: line-through;
}

.floor-change-pill {
  font-size: 11px;
  color: var(--color-muted);
  margin-left: 4px;
}

.cal-floor-gates {
  font-size: 12px;
  color: var(--color-foreground);
  margin-bottom: 8px;
}

.cal-floor-rationale {
  font-size: 13px;
  color: var(--color-muted);
  line-height: 1.55;
  margin-bottom: 12px;
}

.cal-dl-compact {
  font-size: 12px;
}

.chart-grid-wide {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.cal-card-panel {
  background: var(--color-surface);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  padding: 20px;
  border: 1px solid var(--color-border);
}

@media (max-width: 700px) {
  .cal-corpus-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Playground (Live Interactive Calibration Experience)
   ========================================================================== */
.play-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
  border-radius: 20px;
  overflow: hidden;
}

.play-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
}

@media (max-width: 850px) {
  .play-grid {
    grid-template-columns: 1fr;
  }
}

.play-controls {
  padding: 24px;
  border-right: 1px solid var(--color-border);
}

@media (max-width: 850px) {
  .play-controls {
    border-right: none;
    border-bottom: 1px solid var(--color-border);
  }
}

.play-section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-muted);
  margin-bottom: 16px;
  padding-bottom: 4px;
  border-bottom: 1px dashed var(--color-border);
}

.play-sliders {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.play-slider-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.play-slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.play-slider-label {
  font-weight: 600;
  color: var(--color-foreground);
}

.play-slider-value {
  font-family: "DM Mono", monospace;
  font-weight: 700;
  color: var(--color-link);
}

.play-slider-input {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: var(--color-surface-3);
  border-radius: 999px;
  outline: none;
  transition: background 0.15s;
}

.play-slider-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-link);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.1s;
}

.play-slider-input::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.play-slider-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--color-muted);
}

.play-results {
  padding: 24px;
  background: var(--color-surface-2);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 20px;
}

/* Medal Result panel */
.play-medal-card {
  padding: 24px;
  border-radius: 16px;
  text-align: center;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(0,0,0,0.06);
}

.play-medal-card.medal-gold {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  color: #78350f;
  box-shadow: 0 10px 20px rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.play-medal-card.medal-silver {
  background: linear-gradient(135deg, #f5f5f5 0%, #e5e5e5 100%);
  color: #1f2937;
  box-shadow: 0 10px 20px rgba(107, 114, 128, 0.1);
  border: 1px solid rgba(107, 114, 128, 0.15);
}

.play-medal-card.medal-bronze {
  background: linear-gradient(135deg, #ffedd5 0%, #fed7aa 100%);
  color: #7c2d12;
  box-shadow: 0 10px 20px rgba(234, 88, 12, 0.12);
  border: 1px solid rgba(234, 88, 12, 0.18);
}

.play-medal-card.medal-slop {
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
  color: #991b1b;
  box-shadow: 0 10px 20px rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.15);
}

.play-medal-emoji {
  font-size: 48px;
  line-height: 1;
  margin-bottom: 8px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.play-medal-title {
  font-size: 20px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.play-medal-lattice {
  font-family: "DM Mono", monospace;
  font-size: 12px;
  opacity: 0.8;
}

.play-morphism-visual {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.play-morphism-header {
  font-size: 12px;
  font-weight: bold;
  text-transform: uppercase;
  color: var(--color-muted);
  margin-bottom: 10px;
  letter-spacing: 0.05em;
}

.play-badge-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
  border-bottom: 1px solid rgba(0,0,0,0.03);
}

.play-badge-row:last-child {
  border-bottom: none;
}

.play-badge-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.play-badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-border-strong);
}

.play-badge-dot.active {
  background: var(--color-success);
  box-shadow: 0 0 6px var(--color-success);
}

.play-badge-dot.inactive {
  background: var(--color-danger);
}

.play-badge-name {
  font-weight: 600;
}

.play-badge-score-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.play-badge-score {
  font-family: "DM Mono", monospace;
  font-weight: bold;
}

.play-badge-status {
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 4px;
}

.play-badge-status.achieved {
  background: rgba(22, 163, 74, 0.1);
  color: var(--color-success);
}

.play-badge-status.failed {
  background: rgba(220, 38, 38, 0.1);
  color: var(--color-danger);
}

.play-floor-visual {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow-sm);
  margin-top: 12px;
}

.play-floor-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.play-floor-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.play-floor-val {
  font-family: "DM Mono", monospace;
  font-weight: bold;
  color: var(--color-link);
}

/* Metric Distribution Grids */
.metric-dist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 24px;
}

.metric-mini-chart {
  background: var(--color-surface-2);
  border-radius: 8px;
  padding: 10px;
  border: 1px solid var(--color-border);
}

.metric-mini-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-muted);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-hist-svg {
  width: 100%;
  height: auto;
  display: block;
}

/* Override math blocks for MathJax */
.cal-math-block {
  text-align: center;
  font-size: 1.1em;
  border-left: none;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 16px;
}

/* ==========================================================================
   Condensed calibration page
   ========================================================================== */
.cal-nav-report {
  color: var(--color-link);
  margin-left: auto;
}

.cal-h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--color-foreground);
}

.cal-sub {
  font-size: 11.5px;
  color: var(--color-muted);
  margin-top: 3px;
}

/* Pillar gate chip (plain-language pillars) */
.cal-gate-chip {
  margin-top: auto;
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 11.5px;
  color: var(--color-muted);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 8px 10px;
  line-height: 1.5;
}

.cal-pillars-grid .cal-pillar-card {
  padding: 20px;
}

.cal-pillar-card .cal-pillar-desc {
  min-height: 0;
  margin-bottom: 14px;
}

/* Threshold summary cards */
.cal-threshold-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.cal-threshold-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-top: 4px solid var(--dim);
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: var(--card-shadow);
}

.cal-threshold-card h4 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--dim);
}

.cal-threshold-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.cal-threshold-stats > div {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--color-surface-2);
  border-radius: 10px;
  padding: 8px 4px;
}

.cal-tv {
  font-family: "DM Mono", monospace;
  font-size: 17px;
  font-weight: 700;
  color: var(--color-foreground);
}

.cal-tl {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-muted);
  margin-top: 2px;
}

/* Callout linking to the full report */
.cal-callout {
  margin-top: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  background: linear-gradient(135deg, var(--color-surface) 0%, var(--color-accent-subtle) 100%);
  border: 1px solid rgba(251, 191, 36, 0.35);
  border-radius: 14px;
  padding: 16px 20px;
  font-size: 14px;
  color: var(--color-foreground);
}

.cal-callout-link {
  font-weight: 700;
  white-space: nowrap;
  color: var(--color-link);
}

