@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
  color-scheme: dark;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Cascadia Mono', Consolas, monospace;

  /* Deep High-Tech Palette */
  --bg-base: #080c10;
  --bg-gradient: radial-gradient(circle at 15% 15%, rgba(16, 185, 129, 0.08) 0%, transparent 45%),
                      radial-gradient(circle at 85% 20%, rgba(56, 189, 248, 0.09) 0%, transparent 45%),
                      radial-gradient(circle at 50% 85%, rgba(168, 85, 247, 0.05) 0%, transparent 50%),
                      #080c10;
  --panel-bg: rgba(15, 23, 33, 0.72);
  --panel-border: rgba(255, 255, 255, 0.09);
  --panel-hover-border: rgba(56, 189, 248, 0.35);
  --panel-glass: rgba(13, 20, 29, 0.82);

  --text-main: #f1f5f9;
  --text-dim: #94a3b8;
  --text-muted: #64748b;

  --accent-cyan: #38bdf8;
  --accent-cyan-glow: rgba(56, 189, 248, 0.3);
  --accent-emerald: #10b981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.25);
  --accent-lime: #a3e635;
  --accent-rose: #f43f5e;
  --accent-amber: #fbbf24;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  --shadow-subtle: 0 4px 20px -2px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 25px -4px var(--accent-cyan-glow);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent-cyan);
  text-decoration: none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
a:hover {
  color: #7dd3fc;
  text-shadow: 0 0 10px rgba(56, 189, 248, 0.4);
}

button, input, select {
  font: inherit;
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--accent-cyan);
  outline-offset: 2px;
}

/* Accessibility skip link */
.skip {
  position: fixed;
  top: -100px;
  left: 20px;
  z-index: 100;
  padding: 12px 20px;
  background: #0f172a;
  color: var(--accent-cyan);
  border: 1px solid var(--accent-cyan);
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  transition: top 0.2s ease;
}
.skip:focus {
  top: 20px;
}

/* Header & Glass Navigation */
header {
  position: sticky;
  top: 0;
  z-index: 50;
  max-width: 100%;
  padding: 16px 6%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(8, 12, 16, 0.78);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--panel-border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #fff;
}
.brand::before {
  content: '⚗';
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(56, 189, 248, 0.2));
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: var(--radius-sm);
  font-size: 18px;
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.2);
}
.brand span {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-dim);
  background: linear-gradient(90deg, #94a3b8, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

nav {
  display: flex;
  gap: 16px;
  align-items: center;
}
nav a {
  color: var(--text-dim);
  font-size: 13.5px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: all 0.2s ease;
}
nav a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}

#language {
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: var(--accent-cyan);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  gap: 6px;
}
#language:hover {
  background: rgba(56, 189, 248, 0.18);
  border-color: var(--accent-cyan);
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.25);
  transform: translateY(-1px);
}

/* Main Container */
main {
  max-width: 1680px;
  margin: 0 auto;
  padding: 0 5%;
}

/* Intro Section */
.intro {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 6%;
  padding: 56px 0 40px;
  align-items: center;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--accent-emerald);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin: 0 0 14px;
  padding: 4px 12px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 20px;
}

h1 {
  font-size: clamp(40px, 5.2vw, 78px);
  line-height: 1.04;
  letter-spacing: -0.05em;
  font-weight: 800;
  margin: 0 0 20px;
  color: #fff;
}
h1 span {
  background: linear-gradient(135deg, var(--accent-emerald), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 300;
}

.lead {
  font-size: clamp(17px, 1.8vw, 22px);
  color: #cbd5e1;
  line-height: 1.5;
  margin: 0 0 16px;
  font-weight: 400;
}
p {
  color: var(--text-dim);
  font-size: 15px;
  margin: 0 0 14px;
}

/* Principle Showcase Holographic Card */
.principle {
  position: relative;
  padding: 32px;
  border-radius: var(--radius-xl);
  background: linear-gradient(135deg, rgba(20, 32, 45, 0.85) 0%, rgba(13, 22, 30, 0.95) 100%);
  border: 1px solid rgba(56, 189, 248, 0.25);
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.7), 0 0 30px -5px rgba(56, 189, 248, 0.12);
  display: grid;
  gap: 14px;
  overflow: hidden;
}
.principle::after {
  content: '';
  position: absolute;
  top: 0; right: 0; width: 140px; height: 140px;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.15) 0%, transparent 70%);
  pointer-events: none;
}
.principle > span {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--accent-cyan);
  text-transform: uppercase;
}
.formula {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.04em;
}
.ratio {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.1);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  width: fit-content;
  border: 1px solid rgba(16, 185, 129, 0.2);
}
.principle strong {
  font-family: var(--font-mono);
  font-size: 42px;
  line-height: 1.1;
  font-weight: 700;
  background: linear-gradient(135deg, #ffffff 30%, var(--accent-cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.principle small {
  font-size: 13px;
  color: var(--text-dim);
  border-top: 1px solid var(--panel-border);
  padding-top: 12px;
}

/* Workflow Steps */
.flow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 22px 28px;
  margin: 10px 0 40px;
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  font-size: 13.5px;
  box-shadow: var(--shadow-subtle);
}
.flow span {
  font-weight: 600;
  color: #e2e8f0;
}
.flow b {
  color: var(--accent-cyan);
  font-size: 16px;
  opacity: 0.8;
}

/* Section Heading */
.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  margin: 36px 0 20px;
}
.section-heading h2 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0;
  color: #fff;
}
.section-heading > span {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.08);
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid rgba(56, 189, 248, 0.2);
}

/* Interactive Controls Bar */
.controls {
  display: grid;
  grid-template-columns: 2.2fr 1fr 1fr auto;
  gap: 14px;
  margin: 0 0 24px;
  align-items: end;
  background: var(--panel-bg);
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-subtle);
}
.controls label {
  display: grid;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}
.controls input, .controls select {
  width: 100%;
  min-width: 0;
  height: 46px;
  padding: 0 14px;
  background: rgba(11, 18, 27, 0.9);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 14px;
  transition: all 0.2s ease;
}
.controls input:focus, .controls select:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 12px var(--accent-cyan-glow);
  background: rgba(15, 23, 34, 0.95);
}
.controls select {
  cursor: pointer;
}
#reset {
  height: 46px;
  padding: 0 22px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}
#reset:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

/* Workspace Grid: Aside Inspector + Matrix Table */
.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 350px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

/* Analytical Telemetry Sidebar (Aside) */
aside {
  background: var(--panel-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 26px;
  overflow-wrap: anywhere;
  max-height: 700px;
  overflow-y: auto;
  box-shadow: var(--shadow-subtle);
  position: relative;
}
aside::-webkit-scrollbar {
  width: 6px;
}
aside::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

aside h3 {
  font-family: var(--font-mono);
  font-size: 34px;
  font-weight: 700;
  margin: 10px 0 14px;
  background: linear-gradient(135deg, #ffffff 40%, var(--accent-cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.02em;
}

aside p {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-dim);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 20px;
  padding: 4px 12px;
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: var(--accent-cyan);
}

aside dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  font-size: 13px;
  gap: 10px 14px;
  margin: 20px 0;
  padding: 16px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
}
aside dt {
  color: var(--text-muted);
  font-weight: 500;
}
aside dd {
  margin: 0;
  font-family: var(--font-mono);
  font-weight: 600;
  color: #e2e8f0;
  text-align: right;
}

aside h4 {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-emerald);
  margin: 24px 0 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
aside ul {
  padding-left: 20px;
  font-size: 12.5px;
  color: var(--text-dim);
  margin: 0 0 14px;
}
aside li {
  margin-bottom: 8px;
}
aside li a {
  font-weight: 600;
  color: var(--accent-cyan);
}

/* Matrix Table Wrapper */
.matrix-wrap {
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  overflow: auto;
  max-height: 700px;
  background: var(--panel-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow-subtle);
  scroll-padding: 72px 100px;
}
.matrix-wrap::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
.matrix-wrap::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}
.matrix-wrap::-webkit-scrollbar-corner {
  background: transparent;
}

table {
  border-collapse: separate;
  border-spacing: 0;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 13px;
  width: 100%;
}

caption {
  padding: 14px 20px;
  text-align: left;
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  caption-side: top;
  border-bottom: 1px solid var(--panel-border);
  background: rgba(0, 0, 0, 0.2);
}

th {
  background: #141e2a;
  padding: 12px 14px;
  font-weight: 600;
  height: 56px;
  border-bottom: 1px solid var(--panel-border);
  border-right: 1px solid var(--panel-border);
  color: #f1f5f9;
  letter-spacing: 0.02em;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #131c26;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

tbody th {
  position: sticky;
  left: 0;
  z-index: 9;
  min-width: 120px;
  text-align: left;
  background: #131c26;
  box-shadow: 2px 0 8px rgba(0,0,0,0.4);
}

thead th:first-child {
  left: 0;
  z-index: 20;
  background: #182330;
  color: var(--accent-cyan);
}

td {
  border-right: 1px solid rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  padding: 3px;
}

td button {
  min-width: 110px;
  width: 100%;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 13.5px;
  font-weight: 600;
  text-align: left;
  padding: 8px 10px;
  color: #e2e8f0;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

td button:hover {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.35);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

td button[aria-pressed="true"] {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-emerald)) !important;
  color: #041018 !important;
  font-weight: 700;
  border-color: #fff;
  box-shadow: 0 0 20px var(--accent-cyan-glow);
  transform: scale(1.02);
  z-index: 2;
  position: relative;
}

td button .mark {
  display: block;
  font-size: 10.5px;
  font-weight: 500;
  opacity: 0.75;
  margin-top: 2px;
}

td button[aria-pressed="true"] .mark {
  opacity: 0.95;
  color: #041018;
}

/* Status Highlights */
.supported {
  color: var(--accent-emerald) !important;
  background: rgba(16, 185, 129, 0.05);
}
.excluded {
  color: var(--accent-rose) !important;
  background: rgba(244, 63, 94, 0.04);
}
.unmatched {
  opacity: 0.18;
}

/* Legend */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  font-size: 12.5px;
  color: var(--text-dim);
  padding: 20px 8px;
}
.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
}

/* Pedagogical Notes */
.notes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  padding: 50px 0;
  border-top: 1px solid var(--panel-border);
  margin-top: 40px;
}
.notes article {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 30px;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-subtle);
}
.notes h2 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 8px 0 14px;
  color: #fff;
}
.notes p {
  font-size: 14.5px;
  line-height: 1.6;
}

/* Footer */
footer {
  border-top: 1px solid var(--panel-border);
  padding: 36px 0 48px;
  font-size: 13px;
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: center;
  color: var(--text-muted);
}
footer p {
  margin: 0;
}
footer a {
  color: var(--text-dim);
}
footer a:hover {
  color: var(--accent-cyan);
}
#provenance {
  flex-basis: 100%;
  overflow-wrap: anywhere;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
}

/* Error callout */
#error {
  background: rgba(244, 63, 94, 0.12);
  border: 1px solid var(--accent-rose);
  border-radius: var(--radius-md);
  padding: 18px 24px;
  color: #fecdd3;
  margin: 16px 0;
}

sup, sub {
  line-height: 0;
}

/* Responsive Media Queries */
@media (max-width: 1024px) {
  .intro {
    grid-template-columns: 1fr;
    gap: 32px;
  }
  .workspace {
    grid-template-columns: 1fr;
  }
  aside {
    max-height: 380px;
  }
  .matrix-wrap {
    max-height: 560px;
  }
}

@media (max-width: 768px) {
  header {
    padding: 14px 5%;
  }
  .brand span {
    display: none;
  }
  .controls {
    grid-template-columns: 1fr 1fr;
  }
  .controls label:first-child {
    grid-column: 1 / -1;
  }
  #reset {
    grid-column: 1 / -1;
  }
  .flow {
    flex-wrap: wrap;
    justify-content: flex-start;
  }
  .flow span {
    flex-basis: 45%;
  }
  .flow b:nth-of-type(2) {
    display: none;
  }
  .notes {
    grid-template-columns: 1fr;
    gap: 24px;
  }
}

@media (max-width: 480px) {
  h1 {
    font-size: 36px;
  }
  .principle strong {
    font-size: 32px;
  }
  .matrix-wrap {
    max-height: 460px;
  }
}

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