:root {
  color-scheme: light;
  --ink: #1f2937;
  --muted: #667085;
  --line: #dbeafe;
  --surface: #ffffff;
  --soft: #f5fbff;
  --teal: #38bdf8;
  --teal-dark: #075985;
  --blue: #0ea5e9;
  --amber: #7dd3fc;
  --red: #e11d48;
  --green: #0ea5e9;
  --purple: #8b5cf6;
  --shadow: 0 18px 48px rgba(14, 165, 233, 0.13);
  font-family: "Segoe UI", "Noto Sans TC", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  background: linear-gradient(180deg, #e0f2fe 0%, #f5fbff 55%, #ffffff 100%);
  color: var(--ink);
  margin: 0;
  min-height: 100vh;
}

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

button {
  background: linear-gradient(135deg, var(--teal), var(--blue));
  border: 0;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  font-weight: 800;
  min-height: 42px;
  padding: 0.72rem 0.95rem;
}

button:hover {
  filter: brightness(0.96);
}

button.ghost {
  background: #e0f2fe;
  color: #075985;
}

button.ghost:hover {
  background: #bae6fd;
}

a {
  color: var(--teal-dark);
  font-weight: 800;
  text-decoration: none;
}

.topbar {
  align-items: center;
  backdrop-filter: blur(14px);
  background: rgba(255, 255, 255, 0.86);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  left: 0;
  padding: 0.9rem clamp(1rem, 4vw, 3rem);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  color: var(--teal);
  font-weight: 900;
}

nav {
  display: flex;
  gap: 1rem;
}

nav a {
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 800;
}

.hero {
  align-items: stretch;
  background: #e0f2fe;
  color: #fff;
  display: grid;
  gap: clamp(1rem, 4vw, 3rem);
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  min-height: 470px;
  overflow: hidden;
  padding: clamp(2rem, 6vw, 5rem) clamp(1rem, 4vw, 3rem);
  position: relative;
}

.hero::after {
  background: linear-gradient(90deg, rgba(7, 89, 133, 0.5), rgba(14, 165, 233, 0.16));
  content: "";
  inset: 0;
  position: absolute;
  z-index: 0;
}

.hero-bg {
  height: 100%;
  inset: 0;
  object-fit: cover;
  object-position: 56% 44%;
  position: absolute;
  width: 100%;
  z-index: 0;
}

.hero-copy {
  align-self: center;
  max-width: 820px;
  position: relative;
  z-index: 1;
}

.hero p,
.hero-card > span,
.panel-head p {
  color: #cffafe;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  margin: 0 0 0.7rem;
  text-transform: uppercase;
}

.hero p {
  font-size: 1rem;
}

.hero h1 {
  font-size: clamp(2.35rem, 6vw, 5rem);
  letter-spacing: 0;
  line-height: 1.02;
  margin: 0;
}

.hero-copy span {
  color: #e0f2fe;
  display: block;
  font-size: 1.08rem;
  line-height: 1.8;
  margin-top: 1.2rem;
  max-width: 760px;
}

.hero-card {
  align-self: center;
  backdrop-filter: blur(14px);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 430px;
  padding: 1.35rem;
  position: relative;
  z-index: 1;
}

.hero-card h2 {
  margin: 0;
}

.hero-card p {
  color: var(--muted);
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1.7;
  margin: 0.8rem 0 1rem;
  text-transform: none;
}

.hero-card > span {
  color: var(--muted);
  display: block;
  font-size: 1.08rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  line-height: 1.8;
  margin: 1.2rem 0 0.7rem;
  text-transform: uppercase;
}

.hero-card div {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 0.25rem;
  padding: 0.8rem 0;
  width: 100%;
}

.hero-card strong {
  color: var(--teal);
  font-size: 1rem;
}

.hero-card div span {
  color: var(--muted);
  font-size: 1.08rem;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.8;
  margin: 1.2rem 0 0;
  text-transform: none;
}

.app-shell {
  padding: 2rem clamp(1rem, 3vw, 2rem) 4rem;
}

.workspace {
  display: grid;
  gap: 1rem;
  margin: 0 auto;
  max-width: 1480px;
}

.panel-head,
.input-toolbar {
  align-items: center;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
}

.panel-head p {
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  margin: 0 0 0.35rem;
  text-transform: uppercase;
}

.panel-head h2 {
  margin: 0;
}

.fit-details,
.textarea-label,
.demo-controls select {
  color: var(--muted);
}

.layout {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(360px, 0.72fr) minmax(0, 1.28fr);
}

.panel {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(30, 41, 59, 0.07);
  padding: 1rem;
}

.input-panel,
.chart-panel {
  display: grid;
  gap: 1rem;
}

.textarea-label {
  display: grid;
  font-weight: 800;
  gap: 0.45rem;
}

textarea {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  color: var(--ink);
  min-height: 128px;
  padding: 0.85rem;
  resize: vertical;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.16);
  outline: 0;
}

.demo-controls {
  display: flex;
  gap: 0.5rem;
}

.demo-controls select {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-weight: 800;
  min-height: 42px;
  padding: 0.6rem 0.7rem;
}

.input-toolbar {
  justify-content: start;
}

.cycle-grid {
  display: grid;
  gap: 0.45rem;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  max-height: 560px;
  overflow: auto;
  padding-right: 0.2rem;
}

.cycle-cell {
  display: grid;
  gap: 0.25rem;
}

.cycle-cell span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
}

.cycle-cell input {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  min-width: 0;
  padding: 0.52rem 0.45rem;
  width: 100%;
}

.cycle-cell input.invalid {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.12);
}

.chart-tabs {
  background: #e0f2fe;
  border-radius: 8px;
  display: grid;
  gap: 0.35rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 0.35rem;
}

.chart-tabs .tab {
  background: transparent;
  color: #475569;
  min-height: 38px;
  padding: 0.55rem 0.65rem;
}

.chart-tabs .tab.active {
  background: #ffffff;
  box-shadow: 0 6px 18px rgba(30, 41, 59, 0.08);
  color: #075985;
}

.chart-wrap {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 360px;
  overflow: hidden;
}

canvas {
  display: block;
  height: auto;
  width: 100%;
}

.result-grid {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.result-grid article {
  background: #e0f2fe;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.9rem;
}

.result-grid span {
  color: var(--muted);
  display: block;
  font-size: 0.82rem;
  font-weight: 800;
}

.result-grid strong {
  display: block;
  font-size: clamp(1.55rem, 3vw, 2.4rem);
  line-height: 1.1;
  margin-top: 0.35rem;
}

.fit-details {
  background: #e0f2fe;
  border-left: 4px solid var(--teal);
  border-radius: 8px;
  line-height: 1.7;
  padding: 0.9rem 1rem;
}

.insight-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1.05fr 0.95fr 1.15fr;
}

.panel-head.compact {
  margin-bottom: 0.8rem;
}

.pipeline {
  display: grid;
  gap: 0.55rem;
}

.pipeline-step,
.qc-item {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 0.25rem;
  grid-template-columns: auto 1fr auto;
  padding: 0.75rem;
}

.step-index,
.status-pill {
  align-items: center;
  border-radius: 999px;
  display: inline-flex;
  font-size: 0.76rem;
  font-weight: 900;
  justify-content: center;
}

.step-index {
  background: #e0f2fe;
  color: var(--teal-dark);
  height: 28px;
  width: 28px;
}

.pipeline-step strong,
.qc-item strong {
  color: var(--ink);
  display: block;
}

.pipeline-step span,
.qc-item span {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.status-pill {
  min-width: 58px;
  padding: 0.28rem 0.55rem;
}

.status-pass {
  background: #dbeafe;
  color: var(--green);
}

.status-warn {
  background: #fef3c7;
  color: var(--amber);
}

.status-fail {
  background: #fee2e2;
  color: var(--red);
}

.qc-list {
  display: grid;
  gap: 0.55rem;
}

.output-panel {
  min-width: 0;
}

pre {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #334155;
  font-size: 0.86rem;
  line-height: 1.55;
  margin: 0;
  max-height: 420px;
  overflow: auto;
  padding: 1rem;
  white-space: pre-wrap;
}

.fit-details p {
  margin: 0;
}

.fit-details strong {
  color: var(--ink);
}

.error {
  border-left-color: var(--red);
  color: var(--red);
}

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

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

  .cycle-grid {
    max-height: none;
  }
}

@media (max-width: 720px) {
  .topbar,
  .panel-head,
  .input-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  nav {
    justify-content: space-between;
    width: 100%;
  }

  .panel-head button,
  .input-toolbar button {
    text-align: center;
    width: 100%;
  }

  .cycle-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .result-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .demo-controls,
  .chart-tabs {
    grid-template-columns: 1fr;
    flex-direction: column;
  }
}
