:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --ink: #18202f;
  --muted: #687386;
  --line: #dce2eb;
  --teal: #0f766e;
  --blue: #2563eb;
  --orange: #c2410c;
  --soft: #eef6f5;
  --shadow: 0 18px 50px rgba(31, 41, 55, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #fbfcfe 0%, var(--bg) 55%, #eef3f8 100%);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px clamp(16px, 4vw, 34px);
  background: rgba(255, 255, 255, 0.88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand,
.nav-links {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 850;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: white;
  background: var(--teal);
  border-radius: 8px;
}

.nav-links {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
}

.nav-links a {
  padding: 8px 10px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 750;
}

.nav-links a:hover {
  color: var(--teal);
}

.workspace {
  width: min(1380px, 100%);
  margin: 0 auto;
  padding: 28px clamp(14px, 3vw, 30px) 64px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(340px, 0.85fr);
  gap: 22px;
  align-items: stretch;
  min-height: 420px;
}

.hero-copy,
.quick-panel,
.section,
.panel,
.chart-card,
.export-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(28px, 5vw, 58px);
  background:
    linear-gradient(120deg, rgba(15, 118, 110, 0.12), rgba(37, 99, 235, 0.07)),
    var(--panel);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--orange);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  max-width: 900px;
  margin: 0;
  font-size: clamp(2.15rem, 5vw, 4.6rem);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: clamp(1.35rem, 2.4vw, 2.1rem);
  line-height: 1.12;
  letter-spacing: 0;
}

h3 {
  margin: 0;
  font-size: 1rem;
}

.hero-copy p:not(.eyebrow),
.export-section p {
  max-width: 780px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.65;
}

.quick-panel {
  display: grid;
  align-content: center;
  gap: 22px;
  padding: 28px;
}

.section {
  margin-top: 22px;
  padding: clamp(18px, 3vw, 28px);
}

.section-title,
.chart-head,
.signal-card-head,
.export-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.button-row,
.view-toggles {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.button {
  min-height: 40px;
  padding: 9px 14px;
  color: var(--ink);
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-weight: 800;
}

.button.primary {
  color: white;
  background: var(--teal);
  border-color: var(--teal);
}

.button.ghost {
  background: transparent;
}

label {
  display: grid;
  gap: 8px;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 800;
}

label span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--teal);
}

select {
  min-height: 40px;
  padding: 8px 10px;
  color: var(--ink);
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
}

.toggle.compact {
  color: var(--ink);
}

.view-toggles label {
  min-height: 36px;
  padding: 8px 10px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 0.84rem;
}

.signal-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 14px;
  margin-top: 22px;
}

.signal-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  background: #fbfdff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  color: var(--muted);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-weight: 900;
}

.component-preview {
  display: grid;
  gap: 10px;
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.preview-toolbar {
  display: grid;
  grid-template-columns: minmax(70px, 0.35fr) minmax(180px, 1fr);
  gap: 12px;
  align-items: end;
}

.preview-toolbar label {
  grid-template-columns: minmax(48px, 0.25fr) minmax(48px, auto) minmax(120px, 1fr);
  align-items: center;
  gap: 8px;
}

.preview-toolbar input[type="range"] {
  min-width: 0;
}

.panel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.panel {
  display: grid;
  gap: 18px;
  padding: clamp(18px, 3vw, 28px);
}

.chart-grid {
  display: grid;
  gap: 16px;
  margin-top: 20px;
}

.chart-card {
  overflow: hidden;
}

.chart-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.chart-head span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
  white-space: nowrap;
}

.plot,
canvas {
  display: block;
  width: 100%;
  height: 320px;
}

.component-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.chart-card.mini canvas,
.chart-card.mini .plot {
  height: 220px;
}

.component-preview canvas,
.component-preview .plot {
  height: 210px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.plot-empty {
  display: grid;
  place-items: center;
  min-height: 100%;
  padding: 18px;
  color: var(--muted);
  background: #f8fafc;
  border-radius: 8px;
  text-align: center;
  font-size: 0.92rem;
  line-height: 1.4;
}

.export-section {
  align-items: flex-start;
  flex-wrap: wrap;
}

.export-section > div:first-child {
  max-width: 720px;
}

.code-preview {
  flex-basis: 100%;
  max-height: 430px;
  margin: 4px 0 0;
  overflow: auto;
  color: #e6edf7;
  background: #121826;
  border: 1px solid #263244;
  border-radius: 8px;
}

.code-preview code {
  display: block;
  min-width: min-content;
  padding: 18px;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.86rem;
  line-height: 1.55;
  white-space: pre;
}

[hidden] {
  display: none !important;
}

@media (max-width: 900px) {
  .hero,
  .panel-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
  }

  .section-title,
  .export-section {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav-links {
    justify-content: flex-start;
  }

  .workspace {
    padding-top: 16px;
  }

  h1 {
    font-size: 2.25rem;
  }

  .button-row,
  .button {
    width: 100%;
  }

  .component-grid {
    grid-template-columns: 1fr;
  }

  .signal-list {
    grid-template-columns: 1fr;
  }

  .preview-toolbar,
  .preview-toolbar label {
    grid-template-columns: 1fr;
  }

  .plot,
  canvas {
    height: 260px;
  }
}
