﻿:root {
  --bg: #ffffff;
  --bg-soft: #f3f5f9;
  --ink: #1c2230;
  --muted: #657084;
  --line: #d4d8e1;

  --dm-purple-deep: #4b2973;
  --dm-purple: #7822d0;
  --dm-turquoise: #71e4d1;

  --accent: #7822d0;
  --accent-dynamic: #003c30;
  --axis-output-color: #003c30;
  --danger: #b00020;
  --image-bg: #ffffff;
  --axis-label-size: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 12% 5%, #f7f8fc 0%, #ffffff 42%), var(--bg);
}

body.preview-mode {
  overflow-x: hidden;
  overflow-y: auto;
}

h1,
h2,
h3 {
  margin: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(5px);
}

.topbar h1 {
  color: var(--accent-dynamic);
  font-size: 1.8rem;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mse-logo {
  width: 62px;
  height: 34px;
  display: block;
  --main-color: var(--accent-dynamic);
  --secondary-color: #bfbfbf;
}

.mse-logo .main-line {
  fill: none;
  stroke: var(--main-color);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 260;
  stroke-dashoffset: 260;
  animation: draw-main 1.1s ease forwards 0.4s;
}

.mse-logo .back-line {
  fill: none;
  stroke: var(--secondary-color);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 260;
  stroke-dashoffset: 260;
  animation: draw-back 1.1s ease forwards;
}

.mse-logo .node {
  fill: var(--main-color);
  opacity: 0;
  transform: scale(0.6);
  transform-origin: center;
  animation: node-pop 0.35s ease forwards;
}

.mse-logo .n1 { animation-delay: 1.1s; }
.mse-logo .n2 { animation-delay: 1.2s; }
.mse-logo .n3 { animation-delay: 1.3s; }
.mse-logo .n4 { animation-delay: 1.4s; }
.mse-logo .n5 { animation-delay: 1.5s; }

@keyframes draw-back {
  to { stroke-dashoffset: 0; }
}

@keyframes draw-main {
  to { stroke-dashoffset: 0; }
}

@keyframes node-pop {
  0% { opacity: 0; transform: scale(0.6); }
  70% { opacity: 1; transform: scale(1.15); }
  100% { opacity: 1; transform: scale(1); }
}

.mse-logo:hover .back-line {
  stroke-width: 4.5;
}

.explorer-date {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.copyright-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
}

.copyright-link:hover {
  text-decoration: underline;
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem 2rem 2.5rem 2.5rem;
  min-height: calc(100vh - 74px);
}

.panel {
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  min-height: 0;
}

.chart-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 0.4rem;
}

.study-header {
  margin-bottom: 0.35rem;
}

.study-header h2 {
  margin: 0;
  font-size: 1.05rem;
  color: var(--ink);
}

.study-header p {
  margin: 0.05rem 0 0;
  font-size: 0.86rem;
  color: var(--muted);
}

.chart-controls label {
  font-size: 0.85rem;
}

.chart-controls select {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0.3rem 0.5rem;
  color: var(--ink);
}

.chart-controls input[type="color"] {
  width: 34px;
  height: 28px;
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 0;
}

.chart-controls input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.chart-controls input[type="color"]::-webkit-color-swatch {
  border: 1px solid #d4d8e1;
}

.chart-controls input[type="color"]::-moz-color-swatch {
  border: 1px solid #d4d8e1;
}

.chart-controls input[type="range"] {
  width: 110px;
  accent-color: var(--accent-dynamic);
}

#gradMidPosValue {
  min-width: 38px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.color-menu {
  position: relative;
}

.color-menu > summary {
  list-style: none;
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0.32rem 0.5rem;
  color: var(--ink);
}

.color-menu > summary::-webkit-details-marker {
  display: none;
}

.color-menu[open] > .color-menu-grid {
  display: grid;
}

.color-menu-grid {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 20;
  min-width: 250px;
  grid-template-columns: auto auto;
  gap: 0.4rem 0.6rem;
  align-items: center;
  padding: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 8px 20px rgba(26, 34, 49, 0.12);
}

.mid-pos-wrap {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.chart-controls p {
  margin: 0;
  font-weight: 600;
  color: var(--ink);
}

.sort-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: -0.2rem;
}

.sort-row label {
  font-size: 0.85rem;
}

.sort-row select {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  height: 34px;
  padding: 0 0.5rem;
  color: var(--ink);
}

.icon-btn {
  min-width: 34px;
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
}

.chart-panel {
  width: 100%;
  max-width: 100%;
  height: 30vh;
  min-height: 220px;
  display: flex;
  flex-direction: column;
}

.top-charts {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 75vw) minmax(0, 1fr);
  gap: 1rem;
}

#chartWrap {
  min-width: 0;
  min-height: 0;
  height: 100%;
}

#chart {
  width: 100%;
  height: 100%;
  min-height: 0;
}

#radarPanel {
  min-width: 0;
  min-height: 0;
  height: 100%;
}

#radarChart {
  width: 100%;
  height: 100%;
  min-height: 0;
}

.radar-empty {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.radar-grid {
  fill: none;
  stroke: #cbd2de;
  stroke-width: 1;
}

.radar-axis-line {
  stroke: #b5becd;
  stroke-width: 1;
}

.radar-axis-label {
  font-size: 10px;
  fill: var(--axis-output-color);
  font-weight: 600;
  paint-order: stroke;
  stroke: #ffffff;
  stroke-width: 3px;
  stroke-linejoin: round;
}

.radar-shape-mean {
  fill: #8f99ad;
  fill-opacity: 0.14;
  stroke: #8f99ad;
  stroke-width: 1.4;
}

.radar-shape-selected {
  fill: var(--accent-dynamic);
  fill-opacity: 0.2;
  stroke: var(--accent-dynamic);
  stroke-width: 2.2;
}

.radar-legend {
  font-size: 10px;
  fill: #657084;
  font-weight: 600;
}

.line {
  fill: none;
  transition: stroke 140ms ease, stroke-opacity 140ms ease, stroke-width 140ms ease;
}

.axis-group path,
.axis-group line {
  stroke: #98a1af;
}

.axis-label {
  font-size: var(--axis-label-size);
  fill: #2a3241;
  font-weight: 600;
}

.axis-group.axis-input path,
.axis-group.axis-input line {
  stroke: #111111;
}

.axis-group.axis-input text {
  fill: #111111;
}

.axis-group.axis-output path,
.axis-group.axis-output line {
  stroke: var(--axis-output-color);
}

.axis-group.axis-output text {
  fill: var(--axis-output-color);
}

.axis-group .tick text {
  paint-order: stroke;
  stroke: #ffffff;
  stroke-width: 4px;
  stroke-linejoin: round;
}

.content-row {
  width: 100%;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  gap: 0.7rem;
}

.content-row.has-preview {
  display: grid;
  grid-template-columns: minmax(0, 65vw) minmax(0, 10vw) minmax(0, 25vw);
  gap: 1.8rem;
  align-items: start;
  height: calc(100vh - 74px - 30vh - 3.5rem);
  min-height: 280px;
}

.preview-panel {
  display: none;
}

.content-row.has-preview .preview-panel {
  display: block;
  min-width: 0;
}

.data-panel {
  display: none;
}

.content-row.has-preview .data-panel {
  display: block;
  min-width: 0;
  overflow-y: auto;
}

.content-row.has-preview .gallery-panel {
  height: 100%;
  overflow: hidden;
  min-width: 0;
  justify-self: end;
  width: 100%;
  padding: 0;
}

.content-row.has-preview .gallery {
  height: 100%;
  overflow-y: auto;
  padding: 0.7rem 1.15rem 0.7rem 0.7rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
  justify-items: stretch;
  align-items: stretch;
  align-content: start;
  scrollbar-gutter: stable;
}

.content-row.has-preview .card {
  width: 100%;
  min-height: 0;
}

.card {
  border: 4px solid var(--line);
  background: #fff;
  border-radius: 11px;
  overflow: hidden;
  text-align: left;
  cursor: pointer;
  padding: 0;
  display: block;
  position: relative;
}

.card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(120, 34, 208, 0.4), 0 10px 22px rgba(23, 16, 34, 0.22);
  transform: translateY(-1px);
}

.card-thumb {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background-color: var(--image-bg);
}

.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-label {
  display: block;
  padding: 0.45rem 0.55rem;
  font-size: 0.88rem;
}

.preview-empty {
  color: var(--muted);
  padding-top: 0.4rem;
}

.preview img {
  width: 100%;
  height: auto;
  max-width: 100%;
  max-height: none;
  border-radius: 8px;
  border: none;
  margin: 0 0 0.9rem 0;
  object-fit: contain;
  background: var(--image-bg);
  display: block;
}

.preview {
  position: relative;
}

.preview-meta {
  position: absolute;
  left: 0.7rem;
  bottom: 0.7rem;
  max-width: min(48%, 360px);
  border: 1px solid rgba(212, 216, 225, 0.9);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(2px);
  padding: 0.5rem 0.58rem;
  font-size: 0.78rem;
  line-height: 1.25;
}

.preview-meta h4 {
  margin: 0 0 0.32rem;
  font-size: 0.82rem;
}

.preview-meta .preview-section {
  margin-top: 0.36rem;
  font-weight: 700;
}

.preview-meta ul {
  margin: 0.14rem 0 0;
  padding-left: 0.8rem;
}

.preview-meta li {
  margin-bottom: 0.1rem;
}

.data-empty {
  color: var(--muted);
}

.legend-card {
  width: 100%;
  min-height: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  flex-direction: column;
  gap: 0.55rem;
}

#legendView {
  width: 100%;
}

.image-selector-host {
  width: 100%;
}

.image-selector-wrap {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.image-selector-wrap label {
  font-size: 0.8rem;
  color: var(--muted);
}

.image-selector-wrap select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0.28rem 0.44rem;
  font-size: 0.8rem;
}

.legend-image {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
}

.legend-empty {
  color: var(--muted);
  font-size: 0.9rem;
}

.data-title {
  margin: 0 0 0.65rem;
  font-size: 0.98rem;
}

.data-panel h3 {
  margin: 0 0 0.6rem;
  font-size: 1rem;
}

.data-panel h4 {
  margin: 0.75rem 0 0.35rem;
  font-size: 0.9rem;
}

#dataView > h4:first-child {
  margin-top: 0;
  margin-bottom: 0.5rem;
  font-size: 1rem;
}

.data-list {
  margin: 0;
  padding-left: 0;
  display: grid;
  gap: 0.25rem;
  list-style-position: inside;
}

.data-list li {
  font-size: 0.9rem;
}

.metrics {
  margin: 0;
  padding-left: 1rem;
  max-height: 220px;
  overflow-y: auto;
}

.metrics li {
  margin-bottom: 0.24rem;
}

.btn {
  border: 1px solid var(--accent-dynamic);
  background: var(--accent-dynamic);
  color: #fff;
  border-radius: 9px;
  padding: 0.48rem 0.7rem;
  cursor: pointer;
}

.btn.secondary {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.btn.active-toggle {
  background: var(--accent-dynamic);
  border-color: var(--accent-dynamic);
  color: #fff;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

body.capture-mode .workspace .btn {
  visibility: hidden !important;
}

.rating-editor {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.rating-editor input[type="range"] {
  width: 120px;
  accent-color: var(--accent-dynamic);
}

.rating-editor span {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(12, 15, 22, 0.42);
  display: grid;
  place-items: center;
  padding: 1rem;
}

.hidden {
  display: none;
}

.modal-card {
  width: min(520px, 96vw);
  background: #fff;
  border-radius: 14px;
  border: 1px solid var(--line);
  padding: 1rem;
  display: grid;
  gap: 0.7rem;
}

.settings-modal-card {
  width: min(760px, 96vw);
  max-height: 86vh;
  overflow-y: auto;
}

.settings-color-grid {
  display: grid;
  grid-template-columns: auto auto;
  gap: 0.4rem 0.6rem;
  align-items: center;
}

.settings-color-grid input[type="color"] {
  width: 34px;
  height: 28px;
  padding: 0;
  border: 1px solid #d4d8e1;
  border-radius: 6px;
  background: #fff;
}

.settings-color-grid input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.settings-color-grid input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 5px;
}

.settings-color-grid input[type="color"]::-moz-color-swatch {
  border: none;
  border-radius: 5px;
}

.settings-color-grid input[type="range"] {
  accent-color: var(--accent-dynamic);
}

.axis-settings-list {
  display: grid;
  gap: 0.45rem;
}

.axis-settings-actions {
  margin: 0.1rem 0 0.35rem;
}

.axis-setting-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.45rem;
  background: #fff;
}

.axis-setting-item summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--ink);
}

.axis-setting-grid {
  margin-top: 0.45rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
}

.axis-setting-grid label {
  font-size: 0.86rem;
}

.modal-card label {
  display: grid;
  gap: 0.25rem;
  font-weight: 600;
  font-size: 0.92rem;
}

.modal-card input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.52rem 0.62rem;
  font: inherit;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.error {
  color: var(--danger);
  min-height: 1rem;
  margin: 0;
}

.muted,
.modal-note {
  color: var(--muted);
  margin: 0;
}

@media (max-width: 1100px) {
  .top-charts {
    grid-template-columns: 1fr;
    height: auto;
    gap: 0.6rem;
  }

  #chartWrap {
    height: 26vh;
    min-height: 190px;
  }

  #radarPanel {
    height: 22vh;
    min-height: 170px;
  }

  .content-row.has-preview {
    grid-template-columns: 1fr;
    height: auto;
  }

  body.preview-mode {
    overflow: auto;
  }
}
