:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #607080;
  --line: #d9e1e7;
  --paper: #f7f9fb;
  --surface: #ffffff;
  --teal: #168a94;
  --yellow: #f2b63d;
  --coral: #d85c4a;
  --violet: #6557a8;
  --green: #2f9f72;
  --shadow: 0 18px 46px rgba(28, 42, 58, 0.11);
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: linear-gradient(180deg, #f7f9fb 0%, #eef4f7 48%, #f8fafb 100%);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

canvas {
  max-width: 100%;
}

code {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.site {
  width: min(1320px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: end;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 13px;
  font-weight: 850;
}

h1 {
  margin: 0;
  font-size: clamp(30px, 4vw, 54px);
  line-height: 1.05;
  font-weight: 880;
}

.subtitle {
  max-width: 780px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  font-weight: 780;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.portal-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
}

.search-panel {
  padding: 16px;
  margin-bottom: 18px;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 12px;
}

.search-input,
.select {
  width: 100%;
  min-height: 44px;
  border: 1px solid #bac8d2;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
}

.demo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.demo-card {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
  min-height: 220px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.demo-card:hover {
  border-color: #9ab2c0;
  box-shadow: 0 14px 36px rgba(28, 42, 58, 0.12);
  transform: translateY(-1px);
}

.card-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.demo-card h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #f8fbfc;
  font-size: 12px;
  font-weight: 760;
  white-space: nowrap;
}

.formula {
  color: var(--teal);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 15px;
  font-weight: 800;
}

.card-copy {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.mini-viz {
  display: block;
  width: 100%;
  height: 58px;
  border-radius: 8px;
  background: #f7fafb;
}

.side-panel {
  padding: 18px;
}

.side-panel h2,
.demo-panel h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.side-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.side-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.side-list li:last-child {
  border-bottom: 0;
}

.demo-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
}

.demo-panel {
  padding: 18px;
}

.canvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfe;
}

.controls {
  display: grid;
  gap: 14px;
}

.control {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfe;
}

.control-label {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: baseline;
  font-size: 14px;
  font-weight: 820;
}

.value {
  color: var(--teal);
  font-variant-numeric: tabular-nums;
  font-weight: 850;
  text-align: right;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--teal);
}

.readouts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.readout {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.readout span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.readout strong {
  display: block;
  margin-top: 5px;
  font-size: clamp(20px, 2.6vw, 30px);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.notice {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.hidden {
  display: none !important;
}

@media (max-width: 980px) {
  .topbar,
  .portal-grid,
  .demo-layout,
  .search-row {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 640px) {
  .site {
    width: min(1320px, calc(100% - 20px));
    padding-top: 18px;
  }

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

  .control-label {
    grid-template-columns: 1fr;
  }
}
