:root {
  color-scheme: light;
  --bg: #f6f1ea;
  --bg-alt: #fdfcfb;
  --ink: #1b1a17;
  --muted: #6b5f50;
  --accent: #d47b1e;
  --accent-dark: #b45f0f;
  --border: #e2d8cb;
  --cell-bg: #ffffff;
  --cell-focus: #fff4e5;
  --error: #c53d3d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top left, #fdebd2, transparent 45%),
    radial-gradient(circle at 20% 80%, #fbe7f1, transparent 55%),
    linear-gradient(140deg, var(--bg), var(--bg-alt));
  min-height: 100vh;
}

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 48px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  animation: fadeIn 0.6s ease-out;
}

.hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 24px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--border);
  backdrop-filter: blur(6px);
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 8px;
}

h1 {
  margin: 0 0 8px;
  font-size: clamp(32px, 4vw, 42px);
}

.subhead {
  margin: 0;
  max-width: 480px;
  color: var(--muted);
}

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

button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 12px 20px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
}

button:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.formula-bar {
  display: grid;
  grid-template-columns: 100px 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 12px 20px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--border);
}

.formula-bar label {
  font-weight: 600;
  color: var(--muted);
}

.formula-bar input {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 15px;
  background: #fff;
}

#cell-meta {
  color: var(--muted);
  font-size: 14px;
}

.grid-shell {
  border-radius: 20px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--border);
  box-shadow: 0 20px 40px rgba(27, 26, 23, 0.08);
}

.grid {
  overflow: auto;
  max-height: 60vh;
}

table {
  border-collapse: collapse;
  width: max-content;
  min-width: 100%;
  animation: riseIn 0.4s ease-out;
}

th,
td {
  border: 1px solid var(--border);
  min-width: 120px;
  height: 36px;
  padding: 6px 8px;
  text-align: left;
  background: var(--cell-bg);
}

th {
  position: sticky;
  top: 0;
  background: #f4efe7;
  z-index: 2;
}

th:first-child {
  left: 0;
  z-index: 3;
}

td.row-header {
  position: sticky;
  left: 0;
  background: #f4efe7;
  font-weight: 600;
  z-index: 1;
}

td.cell {
  cursor: pointer;
  transition: background 0.15s ease;
}

td.cell.active {
  background: var(--cell-focus);
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

td.cell.error {
  color: var(--error);
  font-weight: 600;
}

.footer {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
}

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

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

@media (max-width: 900px) {
  .hero {
    flex-direction: column;
  }

  .formula-bar {
    grid-template-columns: 1fr;
  }

  .footer {
    flex-direction: column;
    gap: 6px;
  }
}
