:root {
  --bg: #f7f4ed;
  --panel: rgba(255, 255, 255, 0.86);
  --stroke: #1f2937;
  --text: #102a43;
  --muted: #486581;
  --accent: #0ea5a3;
  --accent-2: #f97316;
  --good: #06b6d4;
  --warn: #f59e0b;
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 12% 18%, #d7f8f7 0%, transparent 44%),
    radial-gradient(circle at 90% 0%, #ffe7cc 0%, transparent 42%), var(--bg);
}

.bg-shape {
  position: fixed;
  z-index: -1;
  filter: blur(20px);
}

.bg-shape-a {
  width: 220px;
  height: 220px;
  background: rgba(20, 184, 166, 0.23);
  left: 3vw;
  top: 60vh;
  border-radius: 38% 62% 62% 38%;
  animation: drift 18s ease-in-out infinite alternate;
}

.bg-shape-b {
  width: 260px;
  height: 260px;
  background: rgba(249, 115, 22, 0.2);
  right: 2vw;
  top: 10vh;
  border-radius: 63% 37% 30% 70%;
  animation: drift 24s ease-in-out infinite alternate-reverse;
}

@keyframes drift {
  from {
    transform: translate(0, 0) rotate(0deg);
  }
  to {
    transform: translate(10px, -30px) rotate(8deg);
  }
}

.hero {
  max-width: 1100px;
  margin: 28px auto 10px;
  padding: 0 18px;
}

.hero h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 3rem);
  font-weight: 700;
  letter-spacing: 0.01em;
}

.hero p {
  margin: 8px 0 0;
  color: var(--muted);
}

.hero-status {
  margin: 6px 0 0;
  font-size: 0.84rem;
  color: #0f172a;
}

.hero-status.error {
  color: #b45309;
}

.tabs {
  max-width: 1100px;
  margin: 14px auto;
  padding: 0 18px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.tab-button {
  border: 2px solid var(--stroke);
  background: rgba(255, 255, 255, 0.75);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 12px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 140ms ease, background-color 140ms ease;
}

.tab-button:hover {
  transform: translateY(-2px);
}

.tab-button.active {
  background: linear-gradient(92deg, var(--accent), #34d399);
  color: #042f2e;
}

main {
  max-width: 1100px;
  margin: 0 auto 36px;
  padding: 0 18px 30px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
  animation: reveal 260ms ease-out;
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.panel-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 16px;
}

.card {
  background: var(--panel);
  border: 2px solid var(--stroke);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: 0 8px 24px rgba(16, 42, 67, 0.08);
}

.card h2 {
  margin: 0;
  font-size: 1.15rem;
}

.card p {
  margin: 8px 0 12px;
  color: var(--muted);
}

.controls-card label {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  font-size: 0.95rem;
}

input,
select,
button {
  font: inherit;
}

input[type="number"],
select,
button {
  border: 2px solid var(--stroke);
  border-radius: 12px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.9);
}

input[type="range"] {
  width: 100%;
}

.button-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.button-row button {
  cursor: pointer;
  transition: transform 120ms ease;
}

.button-row button:hover {
  transform: translateY(-1px);
}

.curve-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 8px;
  max-height: 420px;
  overflow: auto;
  padding-right: 4px;
}

.curve-item {
  border: 2px solid var(--stroke);
  border-radius: 12px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  transition: transform 120ms ease, background-color 120ms ease;
}

.curve-item:hover {
  transform: translateY(-1px);
}

.curve-item.active {
  background: linear-gradient(140deg, rgba(14, 165, 163, 0.23), rgba(52, 211, 153, 0.19));
}

.curve-item span {
  display: block;
  margin-top: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #0f172a;
}

canvas {
  max-width: 100%;
  border: 2px solid var(--stroke);
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff, #edf6f5);
}

.progress-wrap {
  margin-top: 10px;
  border: 2px solid var(--stroke);
  border-radius: 999px;
  height: 14px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.8);
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.stage {
  position: relative;
  height: 170px;
  margin-top: 10px;
}

.track {
  position: absolute;
  left: 14px;
  right: 14px;
  top: 84px;
  height: 4px;
  border-radius: 99px;
  background: var(--stroke);
}

.box {
  position: absolute;
  top: 58px;
  left: 14px;
  width: 46px;
  height: 46px;
  border: 2px solid var(--stroke);
  background: linear-gradient(145deg, #22d3ee, #34d399);
  border-radius: 10px;
}

.spark-grid {
  margin-top: 10px;
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr;
}

.mono {
  font-family: "Space Mono", monospace;
  font-size: 0.95rem;
}

.small {
  font-size: 0.85rem;
}

.timeline-editor {
  display: grid;
  gap: 10px;
}

.timeline-track {
  position: relative;
  height: 66px;
  border: 2px solid var(--stroke);
  border-radius: 12px;
  background: linear-gradient(90deg, #f4f9f9, #fff8ee);
  overflow: hidden;
}

.timeline-label {
  position: absolute;
  left: 8px;
  top: 6px;
  font-size: 0.78rem;
  font-weight: 700;
}

.timeline-block {
  position: absolute;
  top: 22px;
  height: 34px;
  border: 2px solid var(--stroke);
  border-radius: 8px;
  cursor: grab;
  user-select: none;
  color: #041017;
  font-size: 0.74rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.timeline-block.square {
  background: #5eead4;
}

.timeline-block.circle {
  background: #fbbf24;
}

.timeline-block.triangle {
  background: #f97316;
}

.playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #111827;
  pointer-events: none;
}

@media (max-width: 920px) {
  .tabs {
    grid-template-columns: repeat(2, 1fr);
  }

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