:root {
  color-scheme: light;
  --bg: #f5efe6;
  --bg-accent: #f6d7ae;
  --ink: #1b1b1b;
  --muted: #575757;
  --card: #ffffff;
  --accent: #d6453d;
  --accent-2: #2c6e63;
  --shadow: 0 20px 50px rgba(27, 27, 27, 0.12);
  --radius: 20px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Space Grotesk", "IBM Plex Sans", "Avenir Next", "Trebuchet MS",
    sans-serif;
  background: radial-gradient(circle at top, #fff4e0 0%, var(--bg) 45%, #f2e2d1 100%);
  color: var(--ink);
  min-height: 100vh;
}

.grain {
  position: fixed;
  inset: 0;
  background-image: linear-gradient(90deg, rgba(0, 0, 0, 0.03), rgba(0, 0, 0, 0.03));
  mix-blend-mode: multiply;
  opacity: 0.2;
  pointer-events: none;
}

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 48px 32px 64px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 24px;
  align-items: center;
  animation: float-in 0.7s ease-out both;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 12px;
}

h1 {
  font-size: clamp(2.4rem, 3vw, 3.4rem);
  margin-bottom: 12px;
}

.subtitle {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
  max-width: 560px;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat .label {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.65rem;
  color: var(--muted);
}

.stat .value {
  font-size: 1.1rem;
  font-weight: 600;
}

.panel {
  display: grid;
  grid-template-columns: minmax(0, 280px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.controls {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: float-in 0.7s ease-out 0.1s both;
}

.control label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
}

.input-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

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

input[type="number"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #d2c8bb;
  font-size: 1rem;
}

.primary {
  margin-top: 8px;
  padding: 12px 16px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(120deg, var(--accent) 0%, #f08a5b 100%);
  color: white;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 16px 30px rgba(214, 69, 61, 0.25);
}

.primary:disabled {
  opacity: 0.7;
  cursor: wait;
}

.primary:hover:not(:disabled) {
  transform: translateY(-2px);
}

.chart-wrap {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  min-height: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: float-in 0.7s ease-out 0.2s both;
  position: relative;
}

.tooltip {
  position: absolute;
  top: 0;
  left: 0;
  background: rgba(27, 27, 27, 0.92);
  color: #fff;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 0.8rem;
  pointer-events: none;
  opacity: 0;
  transform: translate(12px, 12px);
  transition: opacity 0.15s ease;
  white-space: nowrap;
}

.table-wrap {
  grid-column: 1 / -1;
  width: 100%;
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  max-height: 420px;
  overflow: auto;
}

.hist-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.hist-table thead th {
  text-align: left;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 8px 6px;
  border-bottom: 1px solid #e5d6c4;
}

.hist-table tbody td {
  padding: 8px 6px;
  border-bottom: 1px solid #f0e6da;
}

.hist-table tbody tr.is-highlight {
  background: rgba(214, 69, 61, 0.12);
}

canvas {
  width: 100%;
  height: 100%;
  max-height: 520px;
}

@keyframes float-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

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