:root {
  color-scheme: light;
  --ink: #151923;
  --muted: #5c6474;
  --paper: #fffaf0;
  --panel: rgba(255, 255, 255, 0.78);
  --line: rgba(21, 25, 35, 0.12);
  --teal: #00a6a6;
  --coral: #ff6b5f;
  --gold: #f4b942;
  --blue: #4361ee;
  --shadow: 0 24px 70px rgba(31, 42, 68, 0.18);
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  overflow: hidden;
}

body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 12%, rgba(0, 166, 166, 0.22), transparent 28rem),
    radial-gradient(circle at 88% 8%, rgba(244, 185, 66, 0.28), transparent 24rem),
    linear-gradient(135deg, #fffaf0 0%, #edf7f6 48%, #fff2ef 100%);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0;
  transform: scale(var(--page-scale, 1));
  transform-origin: top center;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(320px, 0.92fr);
  gap: 24px;
  align-items: end;
}

.hero-copy {
  padding: 24px 0 14px;
}

.eyebrow {
  width: fit-content;
  margin: 0 0 14px;
  padding: 9px 14px;
  border: 1px solid rgba(0, 166, 166, 0.32);
  border-radius: 999px;
  color: #087d7d;
  background: rgba(255, 255, 255, 0.62);
  font-size: 1.02rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(2.7rem, 6.8vw, 6.3rem);
  line-height: 0.88;
  letter-spacing: 0;
}

.intro {
  max-width: 570px;
  margin: 18px 0 0;
  padding-left: 1.2rem;
  color: var(--muted);
  font-size: clamp(0.98rem, 1.6vw, 1.12rem);
  line-height: 1.45;
}

.intro li {
  padding-left: 0.15rem;
}

.intro li + li {
  margin-top: 0.45rem;
}

.control-panel,
.equation-panel {
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.control-panel {
  padding: 18px;
}

.date-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

label span,
.code-heading span,
.graph-badge span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

select,
input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.88);
}

select {
  padding: 0 12px;
}

.code-card {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.code-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 12px;
}

.code-heading span {
  margin: 0;
}

.code-heading strong {
  color: #087d7d;
  font-size: 1.55rem;
  letter-spacing: 0.16em;
}

.digit-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(48px, 1fr));
  gap: 10px;
}

.digit-grid label {
  min-width: 0;
}

.digit-grid input {
  aspect-ratio: 1;
  min-height: 0;
  padding: 0;
  text-align: center;
  font-size: 1.55rem;
  font-weight: 800;
}

.digit-grid input:disabled {
  border-color: rgba(0, 166, 166, 0.32);
  color: #087d7d;
  background: rgba(0, 166, 166, 0.09);
  opacity: 1;
}

.stepper-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 7px;
}

.stepper-row[hidden] {
  display: none;
}

.stepper-row button {
  min-width: 0;
  min-height: 32px;
  border: 1px solid rgba(21, 25, 35, 0.14);
  border-radius: 8px;
  color: #1f2a44;
  background: rgba(255, 255, 255, 0.86);
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 900;
  line-height: 1;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.stepper-row button:hover:not(:disabled) {
  border-color: rgba(0, 166, 166, 0.5);
  background: rgba(0, 166, 166, 0.1);
}

.stepper-row button:active:not(:disabled) {
  transform: translateY(1px);
}

.stepper-row button:disabled {
  color: rgba(92, 100, 116, 0.42);
  background: rgba(255, 255, 255, 0.42);
  cursor: not-allowed;
}

.graph-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 24px;
  align-items: stretch;
  margin-top: 20px;
}

.graph-column {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.graph-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  justify-content: space-between;
}

.shop-link {
  width: fit-content;
  color: #087d7d;
  font-size: 1rem;
  font-weight: 900;
  text-decoration-color: rgba(0, 166, 166, 0.38);
  text-underline-offset: 4px;
}

.shop-link:hover {
  color: #ff6b5f;
  text-decoration-color: rgba(255, 107, 95, 0.55);
}

.graph-wrap {
  position: relative;
  min-height: clamp(330px, 42vw, 520px);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 8px;
  background:
    linear-gradient(rgba(21, 25, 35, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(21, 25, 35, 0.05) 1px, transparent 1px),
    rgba(255, 255, 255, 0.56);
  background-size: 44px 44px;
  box-shadow: var(--shadow);
}

canvas {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.graph-badge {
  position: absolute;
  right: 18px;
  bottom: 18px;
  min-width: 120px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.84);
}

.play-button {
  position: absolute;
  top: 18px;
  right: 18px;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid rgba(0, 166, 166, 0.28);
  border-radius: 8px;
  color: #072f35;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 14px 38px rgba(31, 42, 68, 0.14);
  cursor: pointer;
  font-weight: 900;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.play-button:hover {
  border-color: rgba(0, 166, 166, 0.56);
  background: rgba(237, 247, 246, 0.96);
}

.play-button[aria-pressed="true"] {
  border-color: rgba(255, 107, 95, 0.55);
  background: rgba(255, 242, 239, 0.96);
}

.play-button[aria-pressed="true"] span {
  background: #ff6b5f;
}

.play-button:active {
  transform: translateY(1px);
}

.play-button span {
  display: inline-grid;
  width: 22px;
  height: 22px;
  place-items: center;
  margin: 0;
  border-radius: 999px;
  color: #fff;
  background: #00a6a6;
  font-size: 0.72rem;
}

.play-button strong {
  font-size: 0.82rem;
  letter-spacing: 0;
}

.graph-badge span {
  margin-bottom: 2px;
}

.graph-badge strong {
  font-size: 1.22rem;
}

.equation-panel {
  padding: 20px;
  align-self: stretch;
}

.equation-panel h2 {
  margin: 0 0 14px;
  font-size: 1.25rem;
}

.formula {
  margin: 0 0 12px;
  padding: 13px 12px 15px;
  border-radius: 8px;
  color: #243047;
  background: rgba(255, 255, 255, 0.72);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.9;
  overflow-wrap: normal;
}

.formula var {
  font-style: italic;
  font-weight: 700;
}

.formula .func {
  font-style: normal;
  letter-spacing: 0;
}

.formula .paren {
  color: #5c6474;
}

.formula .frac {
  display: inline-grid;
  grid-template-rows: auto auto;
  align-items: center;
  vertical-align: middle;
  text-align: center;
  line-height: 1.05;
  transform: translateY(-0.04em);
}

.formula .frac span {
  display: block;
  padding: 0 0.2em;
}

.formula .frac span:first-child {
  border-bottom: 1.5px solid currentColor;
  padding-bottom: 0.12em;
}

.formula .frac span:last-child {
  padding-top: 0.12em;
  font-size: 0.88em;
}

.image-class-panel {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px solid rgba(0, 166, 166, 0.22);
  border-radius: 8px;
  background: rgba(0, 166, 166, 0.08);
}

.image-class-panel span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.image-class-panel strong {
  color: #087d7d;
  font-size: 1.35rem;
}

.shared-panel {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.shared-panel[hidden] {
  display: none;
}

.shared-panel h3 {
  margin: 0 0 12px;
  color: #243047;
  font-size: 1rem;
}

.shared-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.shared-panel ul {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.shared-panel li {
  padding: 7px 10px;
  border: 1px solid rgba(0, 166, 166, 0.22);
  border-radius: 999px;
  color: #087d7d;
  background: rgba(0, 166, 166, 0.08);
  font-size: 0.9rem;
  font-weight: 800;
}

#stateLine {
  margin: 22px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.video-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(0, 166, 166, 0.16), rgba(255, 201, 71, 0.18)),
    var(--paper);
}

.video-shell {
  width: min(100%, 960px);
}

.video-shell h1 {
  margin: 8px 0 18px;
  color: var(--ink);
  font-size: clamp(2rem, 6vw, 4.4rem);
  line-height: 0.95;
}

.feature-video {
  display: block;
  width: 100%;
  max-height: 76vh;
  border: 1px solid rgba(16, 24, 40, 0.14);
  border-radius: 8px;
  background: #111827;
  box-shadow: 0 18px 55px rgba(16, 24, 40, 0.18);
}

@media (max-width: 880px) {
  html,
  body {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .app-shell {
    transform: none;
  }

  .hero,
  .graph-section {
    grid-template-columns: 1fr;
  }

  .hero-copy {
    padding-top: 22px;
  }

  .graph-section {
    margin-top: 20px;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 22px, 1180px);
    padding: 12px 0;
  }

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

  .control-panel,
  .equation-panel {
    padding: 16px;
  }

  .digit-grid {
    gap: 7px;
  }

  .digit-grid input {
    font-size: 1.18rem;
  }

  .code-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .graph-wrap {
    min-height: 300px;
  }
}
