:root {
  --bg: #f6f7f2;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-strong: rgba(255, 255, 255, 0.96);
  --ink: #102027;
  --muted: #506066;
  --line: rgba(16, 32, 39, 0.12);
  --accent: #197278;
  --accent-soft: rgba(25, 114, 120, 0.14);
  --warm: #edddd4;
  --shadow: 0 18px 50px rgba(16, 32, 39, 0.08);
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(237, 221, 212, 0.88), transparent 26%),
    radial-gradient(circle at left center, rgba(25, 114, 120, 0.1), transparent 28%),
    linear-gradient(180deg, #fbfbf7 0%, var(--bg) 100%);
  font-family: "Avenir Next", "PingFang SC", "Helvetica Neue", sans-serif;
}

a {
  color: inherit;
}

code {
  padding: 0.15rem 0.35rem;
  border-radius: 999px;
  background: rgba(16, 32, 39, 0.07);
  font-family: "SFMono-Regular", "Menlo", monospace;
  font-size: 0.92em;
}

.page-shell {
  width: min(1380px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0 64px;
}

.hero,
.panel {
  backdrop-filter: blur(14px);
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
}

.hero {
  padding: 28px;
  border-radius: 32px;
  margin-bottom: 24px;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 8px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--accent);
  font-weight: 700;
}

.hero h1,
.panel h2 {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.hero h1 {
  font-size: clamp(2rem, 4vw, 3.8rem);
  line-height: 0.94;
}

.hero-copy {
  max-width: 920px;
  color: var(--muted);
  line-height: 1.75;
  margin: 16px 0 0;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.file-picker,
button,
.back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 999px;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.file-picker {
  position: relative;
  overflow: hidden;
  background: var(--accent);
  color: white;
}

.file-picker input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

button,
.back-link {
  background: var(--surface-strong);
  color: var(--ink);
  border-color: var(--line);
}

.file-picker:hover,
button:hover,
.back-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(16, 32, 39, 0.1);
}

.status {
  margin: 16px 0 0;
  min-height: 1.5rem;
  color: var(--muted);
}

.layout-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: 1.35fr 0.9fr;
  grid-template-areas:
    "plot controls"
    "viewer details";
}

.panel {
  border-radius: var(--radius);
  padding: 22px;
}

.panel-plot { grid-area: plot; }
.panel-controls { grid-area: controls; }
.panel-viewer { grid-area: viewer; }
.panel-details { grid-area: details; }

.panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.plot-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.plot-select {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.88rem;
}

.plot-select span {
  color: var(--ink);
  font-weight: 600;
}

.plot-select select {
  min-width: 112px;
  min-height: 38px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  font: inherit;
  color: var(--ink);
  padding: 0 12px;
}

.selection-chip {
  padding: 10px 14px;
  border-radius: 16px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.92rem;
}

.plot-wrap,
.viewer-wrap {
  width: 100%;
  min-height: 420px;
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(245, 247, 242, 0.88)),
    repeating-linear-gradient(
      90deg,
      rgba(16, 32, 39, 0.03) 0,
      rgba(16, 32, 39, 0.03) 1px,
      transparent 1px,
      transparent 72px
    );
  border: 1px solid var(--line);
  overflow: hidden;
}

.viewer-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.control-grid {
  display: grid;
  gap: 16px;
}

.control-grid label {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.control-grid span {
  color: var(--ink);
  font-weight: 600;
}

.control-grid input[type="range"] {
  width: 100%;
}

.toggle {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.meta-box,
.details-wrap {
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
}

.meta-box {
  margin-top: 18px;
  padding: 16px;
  min-height: 132px;
  line-height: 1.7;
}

.meta-box dl {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 6px 12px;
  margin: 0;
}

.meta-box dt {
  color: var(--muted);
}

.meta-box dd {
  margin: 0;
  font-weight: 600;
}

.details-wrap {
  padding: 18px;
  min-height: 420px;
  overflow: auto;
}

.details-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.details-wrap th,
.details-wrap td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.details-wrap th {
  color: var(--muted);
  font-weight: 600;
}

.legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.88rem;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
}

.legend-bar {
  width: 110px;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #2b50aa 0%, #eef3f4 50%, #d62839 100%);
  border: 1px solid rgba(16, 32, 39, 0.08);
}

.empty-state {
  padding: 36px 12px;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 1100px) {
  .layout-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "plot"
      "controls"
      "viewer"
      "details";
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100vw - 20px, 100%);
    padding-top: 18px;
  }

  .hero,
  .panel {
    padding: 18px;
    border-radius: 24px;
  }

  .plot-wrap,
  .viewer-wrap {
    min-height: 320px;
  }

  .plot-tools {
    justify-content: flex-start;
  }
}
