:root {
  --bg:
    radial-gradient(circle at 18% 20%, rgba(100, 187, 255, 0.18), transparent 32%),
    radial-gradient(circle at 82% 12%, rgba(255, 187, 77, 0.16), transparent 28%),
    linear-gradient(135deg, #f8fbff 0%, #eef6ff 46%, #fffaf1 100%);
  --panel-bg: rgba(255, 255, 255, 0.88);
  --panel-strong: rgba(255, 255, 255, 0.96);
  --panel-border: rgba(149, 176, 210, 0.22);
  --shadow-lg: 0 26px 55px rgba(77, 116, 158, 0.15);
  --shadow-md: 0 14px 28px rgba(77, 116, 158, 0.12);
  --shadow-sm: 0 8px 18px rgba(77, 116, 158, 0.08);
  --text-strong: #17304f;
  --text-main: #24456e;
  --text-muted: #6f85a4;
  --accent-blue: #4ea8ff;
  --accent-blue-deep: #2c8ff2;
  --accent-orange: #ffb331;
  --accent-red: #f25e58;
  --line-soft: rgba(84, 130, 190, 0.14);
  --card-radius: 28px;
  --slot-gap: 10px;
  --slot-height: 52px;
  --chart-top-gap: 28px;
  --chart-bottom-gap: 112px;
  --plot-side-pad-left: 26px;
  --plot-side-pad-right: 140px;
  --plot-min-height: 660px;
  --font-ui: "HarmonyOS Sans SC", "PingFang SC", "Microsoft YaHei UI", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-ui);
  color: var(--text-main);
  background: var(--bg);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  filter: saturate(0.7);
  transform: none;
}

.page-shell {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 24px;
  min-height: 100vh;
  padding: 24px;
}

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--card-radius);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(20px);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand-card {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 22px 22px 20px;
}

.brand-icon {
  display: grid;
  place-items: center;
  flex: 0 0 58px;
  width: 58px;
  height: 58px;
  border-radius: 20px;
  background: linear-gradient(145deg, rgba(76, 171, 255, 0.18), rgba(255, 181, 82, 0.16));
  color: #67b64e;
  font-size: 30px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.66);
}

.brand-kicker,
.workspace-kicker {
  margin: 0 0 6px;
  color: var(--accent-blue-deep);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand-copy h1,
.workspace-header h2 {
  margin: 0;
  color: var(--text-strong);
  font-weight: 900;
  line-height: 1.16;
}

.brand-copy h1 {
  font-size: 38px;
}

.brand-subtitle,
.workspace-subtitle,
.section-heading p,
.save-note {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1.6;
}

.action-panel,
.axis-panel,
.dataset-panel,
.storage-panel {
  padding: 18px;
}

.action-panel {
  display: grid;
  grid-template-columns: 1.25fr 0.9fr;
  gap: 12px;
}

.btn {
  border: 0;
  border-radius: 18px;
  min-height: 54px;
  padding: 0 18px;
  font-weight: 800;
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
  filter: saturate(1.04);
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-blue-deep));
  box-shadow: 0 12px 24px rgba(47, 144, 241, 0.28);
}

.btn-secondary {
  color: #385679;
  background: linear-gradient(135deg, rgba(214, 223, 236, 0.92), rgba(188, 200, 219, 0.9));
}

.btn-apply,
.btn-ghost {
  min-height: 48px;
  color: var(--accent-blue-deep);
  background: rgba(74, 167, 255, 0.12);
  box-shadow: inset 0 0 0 1px rgba(74, 167, 255, 0.18);
}

.btn-ghost {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.86);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.section-heading h2 {
  margin: 0;
  color: var(--text-strong);
  font-size: 22px;
  white-space: nowrap;
  flex: 0 0 auto;
}

.section-heading p {
  margin: 0;
  flex: 1 1 auto;
  max-width: none;
  text-align: right;
}

.axis-controls {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 54px 92px;
  gap: 12px;
  align-items: end;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border: 0;
  border-radius: 18px;
  color: var(--text-strong);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: inset 0 0 0 1px rgba(108, 149, 197, 0.14), var(--shadow-sm);
}

.axis-input-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--text-muted);
  font-size: 17px;
  font-weight: 700;
}

.axis-input-wrap input {
  width: 100%;
  height: 54px;
  border: 1px solid rgba(99, 145, 201, 0.18);
  border-radius: 18px;
  padding: 0 16px;
  color: var(--text-strong);
  background: var(--panel-strong);
  font-size: 26px;
  font-weight: 900;
}

.axis-input-wrap input:focus,
.dataset-name-input:focus {
  outline: 2px solid rgba(74, 167, 255, 0.26);
  outline-offset: 2px;
}

.dataset-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
}

.dataset-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  max-height: 100%;
  overflow: auto;
  padding-right: 4px;
}

.dataset-list::-webkit-scrollbar,
.plot-shell::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.dataset-list::-webkit-scrollbar-thumb,
.plot-shell::-webkit-scrollbar-thumb {
  background: rgba(90, 135, 190, 0.24);
  border-radius: 999px;
}

.dataset-item {
  padding: 14px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(160, 187, 220, 0.16);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.58);
}

.dataset-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dataset-swatch {
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  box-shadow: inset 0 2px 2px rgba(255, 255, 255, 0.28);
}

.dataset-name-input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  border-radius: 12px;
  padding: 8px 10px;
  background: transparent;
  color: var(--text-strong);
  font-size: 18px;
  font-weight: 800;
}

.remove-item-btn {
  border: 0;
  border-radius: 999px;
  min-height: 38px;
  min-width: 72px;
  padding: 0 14px;
  color: var(--accent-red);
  background: rgba(242, 94, 88, 0.12);
  font-size: 17px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  flex: 0 0 auto;
}

.dataset-controls {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 54px;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
}

.value-badge {
  display: grid;
  place-items: center;
  min-height: 54px;
  border-radius: 18px;
  color: var(--text-strong);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(242, 248, 255, 0.9));
  box-shadow: inset 0 0 0 1px rgba(120, 159, 201, 0.12);
  font-size: 28px;
  font-weight: 900;
}

.storage-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.save-note {
  min-height: 30px;
}

.status-text {
  min-height: 30px;
  margin: 2px 10px 0;
  color: var(--accent-blue-deep);
  font-size: 18px;
  font-weight: 700;
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

.workspace-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  padding: 26px 30px;
}

.workspace-header h2 {
  font-size: clamp(34px, 3vw, 54px);
}

.legend-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--text-main);
  font-size: 18px;
  font-weight: 800;
  white-space: nowrap;
}

.legend-line {
  width: 30px;
  height: 0;
  border-top: 3px dashed rgba(242, 94, 88, 0.85);
}

.formula-panel {
  padding: 18px 28px;
}

.formula-text {
  margin: 0;
  text-align: center;
  color: var(--accent-blue-deep);
  font-size: clamp(24px, 2vw, 34px);
  font-weight: 900;
}

.formula-text strong {
  color: var(--accent-orange);
}

.chart-card {
  padding: 22px 24px 26px;
  min-height: 0;
}

.chart-banner {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  padding: 12px 16px;
  border-radius: 999px;
  color: var(--text-main);
  background: linear-gradient(135deg, rgba(95, 176, 255, 0.12), rgba(255, 191, 86, 0.12));
  font-size: 18px;
  font-weight: 700;
}

.chart-banner-icon {
  color: var(--accent-red);
  font-size: 20px;
}

.chart-stage {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
}

.y-axis {
  position: relative;
  min-height: var(--plot-min-height);
  padding: var(--chart-top-gap) 0 var(--chart-bottom-gap);
}

.axis-tick {
  position: absolute;
  right: 0;
  transform: translateY(-50%);
  color: rgba(28, 51, 81, 0.78);
  font-size: 20px;
  font-weight: 800;
}

.plot-shell {
  overflow: auto hidden;
}

.plot-area {
  position: relative;
  min-width: 900px;
  min-height: var(--plot-min-height);
  padding: var(--chart-top-gap) var(--plot-side-pad-right) var(--chart-bottom-gap) var(--plot-side-pad-left);
  border-radius: 34px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(255, 250, 240, 0.96)),
    linear-gradient(180deg, rgba(255, 244, 207, 0.08), rgba(255, 255, 255, 0));
  box-shadow: inset 0 0 0 1px rgba(163, 186, 214, 0.14);
}

.plot-area::before {
  content: "";
  position: absolute;
  inset: var(--chart-top-gap) var(--plot-side-pad-right) var(--chart-bottom-gap) var(--plot-side-pad-left);
  border-radius: 30px;
  background: linear-gradient(180deg, rgba(255, 244, 207, 0.18), rgba(255, 255, 255, 0));
  pointer-events: none;
}

.grid-lines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.grid-line {
  position: absolute;
  left: var(--plot-side-pad-left);
  right: var(--plot-side-pad-right);
  border-top: 1px solid rgba(92, 137, 194, 0.12);
}

.average-line {
  position: absolute;
  left: var(--plot-side-pad-left);
  right: 30px;
  display: flex;
  justify-content: flex-end;
  pointer-events: none;
  transition: top 0.35s ease;
  z-index: 2;
}

.average-line::before {
  content: "";
  position: absolute;
  inset: 0;
  border-top: 3px dashed rgba(242, 94, 88, 0.78);
}

.average-label {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 44px;
  margin-top: -22px;
  padding: 0 18px;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, #ff8f65, #ee4f4b);
  box-shadow: 0 14px 24px rgba(238, 79, 75, 0.28);
  font-size: 20px;
  font-weight: 900;
}

.columns {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: stretch;
  gap: clamp(18px, 2vw, 26px);
  height: 100%;
  min-height: calc(var(--plot-min-height) - var(--chart-bottom-gap) - var(--chart-top-gap));
}

.chart-column {
  --item-color: #5aa8f6;
  flex: 1 1 0;
  min-width: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  transition: transform 0.22s ease;
}

.chart-column.drop-target {
  transform: translateY(-6px);
}

.column-track {
  position: relative;
  width: 100%;
  flex: 1 1 auto;
  min-height: calc(var(--axis-max) * var(--slot-height) + (var(--axis-max) - 1) * var(--slot-gap));
  padding: 16px;
  border-radius: 30px;
  background: linear-gradient(180deg, rgba(255, 248, 221, 0.82), rgba(255, 241, 196, 0.58));
  border: 1px solid rgba(255, 225, 152, 0.42);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7);
}

.chart-column.drop-target .column-track {
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.78),
    0 0 0 4px rgba(79, 170, 255, 0.24),
    0 18px 30px rgba(78, 168, 255, 0.16);
}

.chart-column.drag-source .column-track {
  filter: saturate(0.88) brightness(0.98);
}

.slot-list {
  display: flex;
  flex-direction: column-reverse;
  height: auto;
  min-height: calc(var(--axis-max) * var(--slot-height) + (var(--axis-max) - 1) * var(--slot-gap));
  gap: var(--slot-gap);
}

.slot {
  flex: 0 0 var(--slot-height);
  min-height: var(--slot-height);
}

.unit-block {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.26);
  opacity: 0.08;
  transform: translateY(10px) scale(0.92);
  transition:
    opacity 0.28s ease,
    transform 0.28s ease,
    box-shadow 0.28s ease,
    background 0.28s ease,
    filter 0.28s ease;
}

.unit-block.filled {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0)),
    var(--item-color);
  opacity: 1;
  transform: translateY(0) scale(1);
  box-shadow:
    inset 0 2px 2px rgba(255, 255, 255, 0.26),
    0 12px 22px rgba(0, 0, 0, 0.12);
  cursor: grab;
  touch-action: none;
}

.unit-block.filled:active {
  cursor: grabbing;
}

.chart-column.drop-forbidden .column-track {
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.78),
    0 0 0 4px rgba(242, 94, 88, 0.18);
}

.column-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.column-value {
  color: var(--text-strong);
  font-size: 42px;
  font-weight: 900;
  line-height: 1;
}

.column-name {
  min-width: 88px;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text-strong);
  text-align: center;
  font-size: 22px;
  font-weight: 900;
  box-shadow: var(--shadow-sm);
}

.drag-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1000;
}

.drag-ghost {
  position: fixed;
  width: 108px;
  height: 54px;
  border-radius: 18px;
  box-shadow:
    inset 0 2px 2px rgba(255, 255, 255, 0.3),
    0 18px 30px rgba(20, 30, 46, 0.2);
  transform: translate(-50%, -50%) rotate(-2deg);
  opacity: 0.94;
}

.is-dragging {
  user-select: none;
}

@media (max-width: 1320px) {
  .page-shell {
    grid-template-columns: 320px minmax(0, 1fr);
    padding: 18px;
  }

  .brand-copy h1 {
    font-size: 32px;
  }

  .workspace-header {
    padding: 24px;
  }

  .workspace-header h2 {
    font-size: clamp(28px, 3vw, 44px);
  }
}

@media (max-width: 1080px) {
  .page-shell {
    grid-template-columns: 1fr;
  }

  .workspace-header {
    flex-direction: column;
    align-items: stretch;
  }

  .chart-stage {
    grid-template-columns: 68px minmax(0, 1fr);
  }
}

@media (max-width: 720px) {
  .page-shell {
    gap: 16px;
    padding: 14px;
  }

  .action-panel,
  .storage-actions {
    grid-template-columns: 1fr;
  }

  .axis-controls {
    grid-template-columns: 1fr 1fr;
  }

  .axis-input-wrap {
    grid-column: 1 / -1;
  }

  .workspace-header h2 {
    font-size: 28px;
  }

  .formula-text {
    font-size: 22px;
  }

  .average-label {
    font-size: 16px;
  }

  .column-name {
    font-size: 18px;
  }
}
