:root {
  color-scheme: light;
  --ink: #15365f;
  --ink-soft: #5b6f84;
  --paper: #fffefa;
  --stage: #eef9fc;
  --grid: #7bd9f3;
  --grid-soft: rgba(123, 217, 243, 0.38);
  --male: #cfefff;
  --male-stroke: #79cdf1;
  --female: #ffd9ee;
  --female-stroke: #f175bd;
  --excellent: #ffd4ec;
  --excellent-stroke: #ff78bd;
  --good: #fff18a;
  --good-stroke: #e9c834;
  --pass: #cdefff;
  --pass-stroke: #7ccff0;
  --yellow: #ffd84d;
  --button-shadow: 4px 4px 0 rgba(21, 54, 95, 0.94);
  --panel-shadow: 5px 5px 0 rgba(21, 54, 95, 0.9), 0 16px 36px rgba(21, 54, 95, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  min-height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background:
    linear-gradient(0deg, rgba(255, 255, 255, 0.76), rgba(255, 255, 255, 0.76)),
    repeating-linear-gradient(0deg, transparent 0 31px, rgba(123, 217, 243, 0.42) 31px 32px),
    repeating-linear-gradient(90deg, transparent 0 31px, rgba(123, 217, 243, 0.42) 31px 32px),
    var(--stage);
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  color: inherit;
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

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

.app-shell {
  position: relative;
  width: 100vw;
  min-height: 100dvh;
  overflow: hidden;
}

#inkCanvas {
  position: fixed;
  inset: 0;
  z-index: 16;
  display: block;
  width: 100vw;
  height: 100dvh;
  pointer-events: none;
  touch-action: none;
  user-select: none;
}

body.ink-active #inkCanvas {
  pointer-events: auto;
  cursor: crosshair;
}

body.eraser-active #inkCanvas {
  pointer-events: auto;
  cursor: cell;
}

#inkCanvas:focus-visible,
button:focus-visible,
.chart-card:focus-visible {
  outline: 3px solid #217fd3;
  outline-offset: 3px;
}

.card-stage {
  position: fixed;
  inset: 0;
  z-index: 5;
}

.chart-card {
  position: absolute;
  container-type: size;
  min-width: 240px;
  min-height: 200px;
  overflow: visible;
  border: 2px solid rgba(21, 54, 95, 0.88);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--panel-shadow);
  cursor: grab;
  touch-action: none;
  user-select: none;
  transition: opacity 180ms ease, filter 180ms ease;
}

.chart-card.table-card {
  min-width: 300px;
  min-height: 100px;
}

.chart-card:active {
  cursor: grabbing;
}

.chart-card.is-source-merging {
  opacity: 0;
}

.is-source-merging .chart-bar,
.is-source-merging .chart-value {
  visibility: hidden;
}

.merge-journey {
  position: fixed;
  inset: 0;
  z-index: 95;
  pointer-events: none;
}

.merge-journey-card {
  position: absolute;
  border: 2px solid rgba(21, 54, 95, 0.88);
  border-radius: 8px;
  background: white;
  box-shadow: var(--panel-shadow);
}

.merge-journey .chart-bar-muted,
.merge-journey .chart-value-muted {
  opacity: 0;
}

.card-content {
  width: 100%;
  height: 100%;
  padding: 6px;
}

.resize-handle {
  position: absolute;
  right: -28px;
  bottom: -28px;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 7px;
  background:
    linear-gradient(135deg, transparent 0 46%, rgba(21, 54, 95, 0.86) 47% 54%, transparent 55% 100%),
    linear-gradient(135deg, transparent 0 64%, rgba(21, 54, 95, 0.58) 65% 70%, transparent 71% 100%),
    #ffffff;
  box-shadow: 2px 2px 0 rgba(21, 54, 95, 0.82);
  cursor: nwse-resize;
}

.split-button {
  position: absolute;
  left: -2px;
  bottom: -30px;
  width: 46px;
  height: 26px;
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: white;
  box-shadow: 2px 2px 0 rgba(21, 54, 95, 0.82);
  font-size: 13px;
  cursor: pointer;
}

.stat-table-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  color: #202933;
  font-family: "Songti SC", "SimSun", "STSong", serif;
}

.stat-table-scale {
  position: absolute;
  top: 0;
  left: 0;
  width: 650px;
  transform-origin: 0 0;
}

.stat-table-title {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  letter-spacing: 0;
  white-space: nowrap;
}

.stat-table-unit {
  margin: -2px 6px 6px 0;
  font-size: 18px;
  line-height: 1;
  text-align: right;
}

.stat-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  background: #dff4fb;
  font-size: 18px;
  line-height: 1.1;
}

.stat-table th,
.stat-table td {
  height: 35px;
  border: 1.5px solid #56cdf5;
  text-align: center;
  font-weight: 500;
}

.stat-table thead th,
.stat-table tbody th {
  background: #bfeaf8;
  font-weight: 500;
  letter-spacing: 0.12em;
}

.stat-table td {
  background: #dcf1f8;
}

.chart-svg {
  display: block;
  width: 100%;
  height: 100%;
  font-family: "Songti SC", "SimSun", "STSong", serif;
}

.chart-title {
  fill: #202933;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0;
}

.chart-label,
.chart-axis,
.chart-value,
.chart-legend-text {
  fill: #202933;
  font-size: 16px;
  letter-spacing: 0;
}

.chart-value {
  font-size: 15px;
}

.chart-grid {
  stroke: var(--grid);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.chart-axis-line {
  stroke: #202933;
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
}

.chart-bar {
  vector-effect: non-scaling-stroke;
}

.chart-bar-muted,
.chart-value-muted {
  opacity: 0.2;
}

.floating-tools {
  position: fixed;
  left: clamp(14px, 2.2vw, 30px);
  bottom: clamp(14px, 2.4vw, 26px);
  z-index: 30;
  display: flex;
  max-width: calc(100vw - 28px);
  align-items: center;
  gap: 10px;
  padding: 0;
  flex-wrap: wrap;
}

.tool-button,
.icon-button,
.pen-swatch {
  border: 2px solid var(--ink);
  background: #fff;
  cursor: pointer;
  font-weight: 1000;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease, opacity 150ms ease;
}

.tool-button,
.icon-button {
  min-height: 48px;
  box-shadow: var(--button-shadow);
}

.tool-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border-radius: 14px;
  font-size: 16px;
  white-space: nowrap;
}

.icon-button {
  display: grid;
  width: 50px;
  height: 48px;
  place-items: center;
  padding: 0;
  border-radius: 14px;
}

.tool-button:hover,
.icon-button:hover,
.pen-swatch:hover {
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0 rgba(21, 54, 95, 0.94);
}

.tool-button[aria-pressed="true"],
.icon-button[aria-pressed="true"] {
  background: var(--yellow);
}

.tool-button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
  box-shadow: 2px 2px 0 rgba(21, 54, 95, 0.58);
}

.chart-toggle:nth-child(1) {
  background: #e0f5ff;
}

.chart-toggle:nth-child(2) {
  background: #ffe5f3;
}

.chart-toggle:nth-child(3) {
  background: #ffe5f3;
}

.chart-toggle:nth-child(4) {
  background: #fff6ac;
}

.chart-toggle:nth-child(5) {
  background: #e0f5ff;
}

.chart-toggle[aria-pressed="true"] {
  background: var(--yellow);
}

.icon-button svg {
  display: block;
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.25;
}

.pen-cluster {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 48px;
  padding: 4px;
  border: 2px solid var(--ink);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--button-shadow);
}

.pen-cluster .icon-button,
.pen-cluster .pen-swatch {
  box-shadow: none;
}

.pen-cluster .icon-button:hover,
.pen-cluster .pen-swatch:hover {
  box-shadow: none;
}

.pen-swatch {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  padding: 0;
  border-radius: 50%;
}

.pen-swatch.red {
  background: #e84855;
}

.pen-swatch.green {
  background: #25a95f;
}

.pen-swatch.blue {
  background: #247ce8;
}

.pen-swatch.black {
  background: #202933;
}

.pen-swatch.is-selected {
  outline: 3px solid var(--yellow);
  outline-offset: 3px;
}


@media (max-width: 760px) {
  .card-content {
    padding: 6px;
  }

  .floating-tools {
    gap: 8px;
  }

  .tool-button {
    min-height: 42px;
    padding: 0 11px;
    border-radius: 12px;
    font-size: 13px;
  }

  .icon-button {
    width: 44px;
    height: 42px;
    border-radius: 12px;
  }

  .pen-cluster {
    min-height: 42px;
    gap: 5px;
  }

  .pen-swatch {
    width: 26px;
    height: 26px;
  }
}
