:root {
  --bg0: #d9e2ea;
  --bg1: #eef3f7;
  --surface: #f7fafc;
  --surface-2: #ffffff;
  --ink: #1a2332;
  --ink-soft: #4a5a6d;
  --muted: #7a8b9c;
  --line: #c5d0db;
  --line-soft: #e2e8ef;
  --accent: #0b6e6a;
  --accent-soft: #d7efed;
  --accent-strong: #085652;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(26, 35, 50, 0.12);
  --radius: 14px;
  --font: "Sora", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(900px 480px at 8% 0%, rgba(110, 184, 179, 0.35) 0%, transparent 55%),
    radial-gradient(800px 420px at 92% 8%, rgba(140, 168, 196, 0.4) 0%, transparent 50%),
    radial-gradient(700px 500px at 50% 100%, rgba(197, 221, 224, 0.45) 0%, transparent 55%),
    linear-gradient(165deg, #cfdbe6 0%, #e8eef4 45%, #eef4f6 100%);
}

body {
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

/* —— Drop / landing —— */
.drop-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.landing-top {
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding: 1.1rem clamp(1.25rem, 4vw, 2.5rem);
}

.landing-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 650;
  font-size: 0.92rem;
  letter-spacing: -0.02em;
}

.landing-brand .brand-mark {
  animation: mark-glow 4s ease-in-out infinite;
}

.landing-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
}

.landing-nav a {
  position: relative;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.2rem 0;
}

.landing-nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 100%;
  bottom: 0;
  height: 1.5px;
  background: var(--accent);
  transition: right 0.25s ease;
}

.landing-nav a:hover {
  color: var(--accent-strong);
}

.landing-nav a:hover::after {
  right: 0;
}

.drop-hero {
  position: relative;
  isolation: isolate;
  display: grid;
  place-items: center;
  min-height: min(78vh, 720px);
  margin: 0 clamp(0.75rem, 2.5vw, 1.5rem);
  padding: clamp(2rem, 6vh, 4rem) clamp(1.25rem, 4vw, 3rem);
  border-radius: 28px;
  overflow: hidden;
  cursor: pointer;
  outline: none;
  background:
    linear-gradient(165deg, rgba(255, 255, 255, 0.55) 0%, rgba(232, 242, 244, 0.72) 100%);
  border: 1px solid rgba(255, 255, 255, 0.65);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.8) inset,
    0 24px 60px rgba(26, 35, 50, 0.1);
  transition: border-color 0.25s, box-shadow 0.25s, transform 0.25s;
}

.drop-hero:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(11, 110, 106, 0.2), 0 24px 60px rgba(26, 35, 50, 0.1);
}

.drop-hero.dragover {
  border-color: var(--accent);
  background:
    linear-gradient(165deg, rgba(215, 239, 237, 0.85) 0%, rgba(232, 242, 244, 0.9) 100%);
  transform: translateY(-2px);
  box-shadow: 0 28px 70px rgba(11, 110, 106, 0.18);
}

.hero-wave {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.95;
}

.hero-wave-path {
  stroke-dasharray: 1400;
  stroke-dashoffset: 1400;
  animation: draw-wave 2.8s ease forwards;
}

.hero-wave-path.delay {
  animation-delay: 0.35s;
}

.hero-copy {
  position: relative;
  z-index: 1;
  width: min(560px, 100%);
  text-align: center;
  animation: hero-rise 0.8s ease both;
}

.hero-kicker {
  margin: 0 0 0.85rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent-strong);
}

.hero-copy h1 {
  margin: 0 0 0.85rem;
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 1.05;
  color: var(--ink);
}

.hero-lead {
  margin: 0 auto 1.75rem;
  max-width: 34em;
  color: var(--ink-soft);
  line-height: 1.55;
  font-size: clamp(0.95rem, 2vw, 1.05rem);
}

.hero-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.btn-lg {
  padding: 0.9rem 1.45rem;
  font-size: 0.95rem;
  border-radius: 12px;
}

.hero-or {
  font-size: 0.8rem;
  color: var(--muted);
}

.landing-body {
  width: min(860px, calc(100% - 2.5rem));
  margin: 0 auto;
  padding: 3rem 0 3.5rem;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.landing-section {
  padding: 2rem 0;
  border-top: 1px solid rgba(197, 208, 219, 0.65);
  scroll-margin-top: 1.5rem;
}

.landing-section:first-child {
  border-top: none;
  padding-top: 0.5rem;
}

.landing-section h2 {
  margin: 0 0 0.75rem;
  font-size: 1.2rem;
  font-weight: 650;
  letter-spacing: -0.025em;
}

.landing-section p {
  margin: 0 0 0.75rem;
  color: var(--ink-soft);
  line-height: 1.6;
  font-size: 0.95rem;
  max-width: 42em;
}

.landing-section p:last-child {
  margin-bottom: 0;
}

.landing-section code {
  font-family: var(--mono);
  font-size: 0.84em;
  padding: 0.12em 0.4em;
  border-radius: 5px;
  background: rgba(11, 110, 106, 0.1);
  color: var(--accent-strong);
}

.landing-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 2.5rem;
  border-top: 1px solid rgba(197, 208, 219, 0.65);
}

.landing-split .landing-section {
  border-top: none;
}

.steps {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem 1.75rem;
}

.steps li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.75rem;
  align-items: start;
}

.step-num {
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 650;
  font-family: var(--mono);
}

.steps strong {
  display: block;
  margin-bottom: 0.2rem;
  font-size: 0.92rem;
  color: var(--ink);
}

.steps p {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--ink-soft);
}

.feature-grid {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem 1.25rem;
}

.feature-grid li {
  position: relative;
  padding-left: 1rem;
  color: var(--ink-soft);
  font-size: 0.9rem;
  line-height: 1.4;
}

.feature-grid li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.landing-footer {
  text-align: center;
  padding: 2.5rem 1rem 0.5rem;
  color: var(--ink-soft);
  font-size: 0.88rem;
  border-top: 1px solid rgba(197, 208, 219, 0.65);
  margin-top: 0.5rem;
}

.landing-footer p {
  margin: 0.3rem 0;
}

.footer-meta {
  color: var(--muted);
  font-size: 0.78rem;
}

@keyframes draw-wave {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes hero-rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes mark-glow {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(11, 110, 106, 0);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(11, 110, 106, 0.12);
  }
}

@media (max-width: 800px) {
  .landing-split,
  .steps,
  .feature-grid {
    grid-template-columns: 1fr;
  }

  .drop-hero {
    min-height: min(70vh, 560px);
    border-radius: 20px;
  }

  .landing-split .landing-section + .landing-section {
    border-top: 1px solid rgba(197, 208, 219, 0.65);
  }
}


.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.7rem 1.15rem;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink);
  font: 500 0.9rem/1 var(--font);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn:hover {
  border-color: var(--line);
}

.btn.primary {
  background: var(--accent);
  color: #fff;
}

.btn.primary:hover {
  background: var(--accent-strong);
  border-color: transparent;
}

.btn.compact {
  padding: 0.45rem 0.7rem;
  font-size: 0.8rem;
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-color: transparent;
}

.btn.compact:hover {
  background: #c5e8e5;
}

/* —— Workspace —— */
.workspace {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.5rem;
  padding: 0.7rem 1.15rem;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 200px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(145deg, #0b6e6a, #6eb8b3);
}

.brand-name {
  font-weight: 650;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
}

.brand-meta {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-left: auto;
}

.tool-sep {
  width: 1px;
  height: 22px;
  background: var(--line);
  margin: 0 0.25rem;
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  font: 500 0.78rem/1 var(--font);
  cursor: pointer;
}

.tool-btn:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.tool-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
}

.tool-btn.ghost {
  background: transparent;
}

.tool-btn .icon {
  font-family: var(--mono);
  font-weight: 500;
}

.tool-check {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.65rem;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
}

.tool-check input {
  accent-color: var(--accent);
}

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 240px;
  gap: 0;
  min-height: 0;
}

.sidebar,
.ref-sidebar {
  background: rgba(247, 250, 252, 0.92);
  border-right: 1px solid var(--line-soft);
  padding: 1rem;
  overflow: auto;
  max-height: calc(100vh - 70px);
}

.ref-sidebar {
  border-right: none;
  border-left: 1px solid var(--line-soft);
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 1rem;
  gap: 0.85rem;
}

.panel-block + .panel-block {
  margin-top: 1.1rem;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.field-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.panel-head .field-label {
  margin-bottom: 0;
}

.count {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
}

.hint-inline,
.side-hint {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.4;
}

.side-hint {
  margin: 0.55rem 0 0;
}

.mini-label {
  display: block;
  margin: 0.55rem 0 0.25rem;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--ink-soft);
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

.chip-btn-preset {
  padding: 0.3rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-soft);
  font: 500 0.72rem/1 var(--font);
  cursor: pointer;
}

.chip-btn-preset:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.block-btn {
  width: 100%;
  margin-top: 0.65rem;
}

input[type="datetime-local"] {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--ink);
  font: 400 0.8rem/1.2 var(--mono);
  outline: none;
}

select,
input[type="search"],
input[type="text"],
input[type="number"] {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--ink);
  font: 400 0.85rem/1.2 var(--font);
  outline: none;
}

select:focus,
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(11, 110, 106, 0.15);
}

.var-actions {
  display: flex;
  gap: 0.75rem;
  margin: 0.5rem 0 0.35rem;
}

.link-btn {
  border: none;
  background: none;
  padding: 0;
  font: 500 0.75rem/1 var(--font);
  color: var(--accent);
  cursor: pointer;
}

.link-btn:hover {
  text-decoration: underline;
}

.var-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: calc(100vh - 520px);
  min-height: 120px;
  overflow: auto;
  padding-right: 2px;
}

.var-item {
  display: grid;
  grid-template-columns: 18px 12px minmax(0, 1fr);
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.45rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.8rem;
}

.var-item:hover {
  background: rgba(11, 110, 106, 0.08);
}

.var-item.selected {
  background: var(--accent-soft);
}

.var-item input {
  accent-color: var(--accent);
  margin: 0;
}

.var-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.var-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-shell {
  position: relative;
  flex: 1;
  min-height: 420px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: calc(var(--radius) + 2px);
  box-shadow: 0 10px 32px rgba(26, 35, 50, 0.07);
  padding: 0.75rem 0.85rem 0.5rem;
}

.chart-shell canvas {
  width: 100% !important;
  height: 100% !important;
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.95rem;
  pointer-events: none;
  z-index: 1;
}

.line-mode-banner {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 500;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.legend-bar {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
}

.series-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.series-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--surface);
  font-size: 0.78rem;
}

.series-chip.hidden-series {
  opacity: 0.45;
}

.series-chip .name {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.series-chip input[type="color"] {
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
}

.series-chip select {
  width: auto;
  padding: 0.25rem 0.35rem;
  font-size: 0.72rem;
}

.series-chip .chip-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0 0.15rem;
}

.series-chip .chip-btn:hover {
  color: var(--ink);
}

.ref-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.ref-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.75rem;
  color: var(--ink-soft);
  font-weight: 500;
}

.inline-row {
  display: flex;
  gap: 0.4rem;
}

.scale-group {
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--line-soft);
}

.scale-group:first-of-type {
  border-top: none;
  padding-top: 0;
  margin-top: 0.35rem;
}

.scale-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.2rem;
}

.scale-minmax input {
  min-width: 0;
}

.scale-actions {
  margin-top: 0.65rem;
}

.scale-actions .btn {
  flex: 1;
}

#btn-read-scale {
  margin-top: 0.45rem;
}

.ref-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.ref-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  font-family: var(--mono);
  font-size: 0.72rem;
}

.ref-item button {
  border: none;
  background: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 0.75rem;
  font-family: var(--font);
  font-weight: 500;
}

.toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  padding: 0.7rem 1.1rem;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  font-size: 0.85rem;
  box-shadow: var(--shadow);
}

.loading {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 0.85rem;
  background: rgba(238, 243, 247, 0.72);
  backdrop-filter: blur(4px);
  font-weight: 500;
  color: var(--ink-soft);
}

.spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .ref-sidebar {
    grid-column: 1 / -1;
    border-left: none;
    border-top: 1px solid var(--line-soft);
    max-height: none;
  }
}

@media (max-width: 800px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    max-height: 280px;
    border-right: none;
    border-bottom: 1px solid var(--line-soft);
  }

  .chart-shell {
    min-height: 340px;
  }

  .toolbar {
    margin-left: 0;
  }
}
