:root {
  --ink: #18202c;
  --muted: #667085;
  --line: #dbe3ee;
  --surface: #ffffff;
  --soft: #f4f7fb;
  --navy: #101827;
  --teal: #14b8a6;
  --blue: #2f80ed;
  --gold: #f7c948;
  --green: #18a058;
  --danger: #c2410c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(244, 247, 251, 0.92), rgba(236, 242, 248, 0.98)),
    repeating-linear-gradient(90deg, rgba(47, 128, 237, 0.06) 0 1px, transparent 1px 96px);
}

button,
select,
textarea,
input {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 460px);
  gap: 28px;
  align-items: stretch;
  margin-bottom: 24px;
}

.brand-block,
.science-panel,
.workspace,
.card {
  border: 1px solid rgba(219, 227, 238, 0.9);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 18px 48px rgba(24, 32, 44, 0.08);
}

.brand-block {
  min-height: 260px;
  padding: 32px;
  border-radius: 8px;
}

.brand-row {
  display: flex;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
}

.brand-mark {
  position: relative;
  width: 76px;
  height: 76px;
  flex: 0 0 76px;
  border-radius: 22px;
  background: linear-gradient(145deg, var(--navy), #22314a);
  border: 1px solid rgba(255, 255, 255, 0.4);
  overflow: hidden;
}

.brand-mark::before,
.brand-mark::after,
.brand-mark span {
  content: "";
  position: absolute;
  border-radius: 999px;
}

.brand-mark::before {
  inset: 18px;
  border: 3px solid var(--teal);
  border-right-color: transparent;
  transform: rotate(-18deg);
}

.brand-mark::after {
  width: 42px;
  height: 3px;
  left: 17px;
  bottom: 21px;
  background: linear-gradient(90deg, var(--blue), var(--gold));
}

.brand-mark span {
  width: 13px;
  height: 13px;
  right: 15px;
  top: 18px;
  background: var(--gold);
  box-shadow: -30px 24px 0 var(--blue), -10px 10px 0 var(--teal);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(42px, 6vw, 68px);
  line-height: 1;
  letter-spacing: 0;
}

.tagline {
  margin-top: 10px;
  font-size: 20px;
  font-weight: 700;
  color: #263244;
}

.hero-copy {
  max-width: 680px;
  font-size: 17px;
  line-height: 1.75;
  color: var(--muted);
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.hero-badges span {
  padding: 8px 12px;
  border-radius: 999px;
  color: #173047;
  background: #e8f4ff;
  border: 1px solid #cfe5ff;
  font-size: 13px;
  font-weight: 700;
}

.science-panel {
  min-height: 260px;
  border-radius: 8px;
  overflow: hidden;
  background: linear-gradient(145deg, #101827, #1b2a3f);
}

.science-panel svg {
  width: 100%;
  height: 100%;
  display: block;
}

.grid-line {
  fill: none;
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 1;
}

.axis {
  fill: none;
  stroke: rgba(255, 255, 255, 0.45);
  stroke-width: 3;
}

.curve {
  fill: none;
  stroke: url(#lineGradient);
  stroke-width: 6;
  stroke-linecap: round;
}

.nodes circle {
  fill: #ffffff;
  stroke: var(--teal);
  stroke-width: 4;
}

.nodes path {
  fill: none;
  stroke: rgba(247, 201, 72, 0.75);
  stroke-width: 3;
}

.workspace {
  border-radius: 8px;
  overflow: hidden;
}

.tabs {
  display: flex;
  gap: 0;
  padding: 8px;
  background: #eef3f8;
  border-bottom: 1px solid var(--line);
}

.tab {
  min-height: 48px;
  padding: 0 20px;
  border: 0;
  border-radius: 6px;
  color: #3b495c;
  background: transparent;
  cursor: pointer;
  font-weight: 700;
}

.tab.is-active {
  color: #ffffff;
  background: var(--navy);
}

.tab-panel {
  display: none;
  padding: 22px;
}

.tab-panel.is-active {
  display: block;
}

.tool-grid {
  display: grid;
  grid-template-columns: minmax(320px, 440px) minmax(0, 1fr);
  gap: 20px;
}

.card {
  border-radius: 8px;
  padding: 24px;
}

.section-title {
  margin-bottom: 20px;
}

.section-title h2,
.result-header h2,
.about-card h2 {
  font-size: 24px;
  line-height: 1.25;
}

.section-title p,
.result-header p,
.hint,
.about-card p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.65;
}

label {
  display: block;
  margin-top: 16px;
}

label span {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
  color: #29384c;
}

select,
textarea,
input[type="file"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfdff;
  color: var(--ink);
}

select {
  height: 44px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  min-height: 156px;
  padding: 12px;
  line-height: 1.6;
}

input[type="file"] {
  padding: 10px;
}

.primary-btn,
.secondary-btn,
.ghost-btn {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
}

.primary-btn {
  width: 100%;
  margin-top: 18px;
  color: #ffffff;
  background: var(--blue);
}

.secondary-btn {
  color: #0f4b43;
  background: #dff7f2;
}

.ghost-btn {
  padding: 0 16px;
  color: var(--blue);
  background: #eef5ff;
}

.ghost-btn.is-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
}

.button-row .primary-btn {
  margin-top: 0;
}

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

.text-result {
  min-height: 430px;
  max-height: 620px;
  overflow: auto;
  margin: 0;
  padding: 18px;
  border-radius: 6px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.7;
  color: #243247;
  background: #f7fafc;
  border: 1px solid #e5edf6;
}

.metrics {
  display: grid;
  grid-template-columns: 1.4fr 0.6fr 0.6fr;
  gap: 10px;
  margin-bottom: 16px;
}

.metrics div {
  min-width: 0;
  padding: 14px;
  border: 1px solid #e5edf6;
  border-radius: 6px;
  background: #f7fafc;
}

.metrics span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.metrics strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 17px;
}

.chart-frame {
  position: relative;
  min-height: 330px;
  border: 1px solid #e5edf6;
  border-radius: 6px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #f7fafc;
}

.chart-frame img {
  display: none;
  width: 100%;
  height: auto;
}

.chart-frame.has-image img {
  display: block;
}

.chart-frame.has-image #chart-empty {
  display: none;
}

#chart-empty {
  color: var(--muted);
}

.about-card {
  max-width: 980px;
}

.about-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 22px;
}

.about-grid div {
  padding: 18px;
  border-radius: 6px;
  background: #f7fafc;
  border: 1px solid #e5edf6;
}

.about-grid h3 {
  font-size: 18px;
  margin-bottom: 8px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(16px);
  opacity: 0;
  pointer-events: none;
  min-width: 220px;
  max-width: calc(100% - 32px);
  padding: 12px 16px;
  border-radius: 6px;
  color: #ffffff;
  background: var(--navy);
  text-align: center;
  box-shadow: 0 16px 32px rgba(16, 24, 39, 0.22);
  transition: 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

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

  .science-panel {
    min-height: 210px;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 14px;
  }

  .brand-block,
  .card,
  .tab-panel {
    padding: 18px;
  }

  .brand-row {
    align-items: flex-start;
  }

  .brand-mark {
    width: 58px;
    height: 58px;
    flex-basis: 58px;
    border-radius: 16px;
  }

  .tagline {
    font-size: 17px;
  }

  .tabs {
    overflow-x: auto;
  }

  .tab {
    white-space: nowrap;
  }

  .button-row,
  .metrics {
    grid-template-columns: 1fr;
  }

  .result-header {
    display: block;
  }

  .ghost-btn {
    margin-top: 12px;
  }
}
