:root {
  --bg: #0d1222;
  --bg-soft: #131a2d;
  --panel: #171f35;
  --panel-2: #10182b;
  --text: #eef4ff;
  --muted: #a9b8d6;
  --line: rgba(255, 255, 255, 0.13);
  --accent: #49b6ff;
  --accent-2: #ffca5f;
  --accent-3: #8ff0c3;
  --danger: #ff6b8a;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
  --radius: 18px;
}

html,
body {
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 14% 10%, rgba(73, 182, 255, 0.18), transparent 30%),
    radial-gradient(circle at 86% 12%, rgba(255, 202, 95, 0.14), transparent 34%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

button,
input {
  font: inherit;
}

.page-shell {
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
}

.hero {
  width: min(100%, 1600px);
  margin: 0 auto;
  padding: clamp(12px, 1.7vw, 24px) clamp(12px, 1.8vw, 28px) clamp(8px, 1vw, 14px);
}

.eyebrow {
  margin: 0 0 0.3rem;
  color: var(--accent-3);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0.35rem;
  font-size: clamp(1.6rem, 3vw, 3rem);
  line-height: 1.05;
}

.hero-text {
  max-width: 980px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.65;
}

.simulator {
  width: min(100%, 1600px);
  margin: 0 auto;
  padding: 0 clamp(10px, 1.8vw, 28px) clamp(14px, 1.7vw, 24px);
}

.animation-pane {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(10px, 1.25vw, 18px);
  min-height: 430px;
  height: 65vh;
  max-height: 660px;
  padding: 0 clamp(4px, 0.5vw, 10px);
}

.canvas-panel,
.control-pane,
.explanation-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255,255,255,0.045), rgba(255,255,255,0.02)), var(--panel);
  box-shadow: var(--shadow);
}

.canvas-panel {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 11, 22, 0.38);
}

.panel-header h2 {
  margin-bottom: 0.2rem;
  font-size: clamp(0.98rem, 1.35vw, 1.25rem);
}

.panel-header p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.status-pill {
  flex: 0 0 auto;
  border: 1px solid rgba(143, 240, 195, 0.45);
  border-radius: 999px;
  padding: 0.25rem 0.65rem;
  color: var(--accent-3);
  background: rgba(143, 240, 195, 0.09);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.status-pill.alt {
  border-color: rgba(255, 202, 95, 0.48);
  color: var(--accent-2);
  background: rgba(255, 202, 95, 0.09);
}

canvas {
  display: block;
  width: 100%;
  min-width: 0;
  flex: 1 1 auto;
  background:
    linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px),
    #070b16;
  background-size: 42px 42px;
}

.control-pane {
  display: grid;
  grid-template-columns: 260px minmax(360px, 1.4fr) minmax(300px, 1fr);
  gap: clamp(10px, 1.2vw, 18px);
  min-height: 220px;
  height: 25vh;
  margin: clamp(10px, 1.25vw, 18px) clamp(4px, 0.5vw, 10px) 0;
  padding: clamp(12px, 1.3vw, 18px) clamp(12px, 1.5vw, 22px);
  overflow: auto;
}

.control-actions {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 0.7rem;
}

.primary-button,
.secondary-button {
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 0.85rem 1rem;
  cursor: pointer;
  font-weight: 900;
  letter-spacing: 0.01em;
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}

.primary-button {
  color: #06101f;
  background: linear-gradient(135deg, #56c7ff, #8ff0c3);
  box-shadow: 0 14px 34px rgba(73, 182, 255, 0.28);
}

.primary-button.is-running {
  background: linear-gradient(135deg, #ffca5f, #ff6b8a);
  box-shadow: 0 14px 34px rgba(255, 107, 138, 0.24);
}

.secondary-button {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
}

.primary-button:hover,
.secondary-button:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.clock-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.75rem 0.85rem;
  background: rgba(0, 0, 0, 0.16);
}

.clock-label {
  display: block;
  margin-bottom: 0.22rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.clock-card strong {
  font-variant-numeric: tabular-nums;
  font-size: 1.35rem;
}

.input-grid {
  display: grid;
  min-width: 0;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.58rem;
  align-content: start;
}

.input-grid label {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 0.28rem;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 750;
}

.input-grid input {
  width: 100%;
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  padding: 0.52rem 0.58rem;
  outline: none;
  color: var(--text);
  background: rgba(0, 0, 0, 0.22);
}

.input-grid input:focus {
  border-color: rgba(73, 182, 255, 0.9);
  box-shadow: 0 0 0 3px rgba(73, 182, 255, 0.16);
}

.formula-log {
  min-width: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.75rem 0.9rem;
  background: rgba(0, 0, 0, 0.14);
}

.formula-log p {
  margin-bottom: 0.35rem;
  color: var(--muted);
  line-height: 1.45;
}

.formula-title {
  color: var(--accent-2) !important;
  font-weight: 900;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  font-size: 0.72rem;
}

.log-text {
  color: var(--text) !important;
  font-variant-numeric: tabular-nums;
}

.content-sections {
  width: min(100%, 1180px);
  margin: 0 auto;
  padding: clamp(18px, 3vw, 42px) clamp(12px, 2vw, 28px) clamp(36px, 5vw, 72px);
}

.explanation-card {
  margin-bottom: 1rem;
  padding: clamp(18px, 2.2vw, 30px);
}

.explanation-card h2 {
  color: var(--text);
  font-size: clamp(1.22rem, 2vw, 1.72rem);
}

.explanation-card p {
  color: var(--muted);
  line-height: 1.72;
}

.explanation-card .MathJax {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

@media (max-width: 1180px) {
  .control-pane {
    grid-template-columns: 220px 1fr;
    height: auto;
    min-height: 250px;
  }

  .formula-log {
    grid-column: 1 / -1;
  }

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

@media (max-width: 860px) {
  .animation-pane {
    grid-template-columns: 1fr;
    height: auto;
    max-height: none;
  }

  .canvas-panel {
    height: 440px;
  }

  .control-pane {
    grid-template-columns: 1fr;
    height: auto;
  }

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

@media (max-width: 560px) {
  .hero,
  .simulator,
  .content-sections {
    padding-left: 10px;
    padding-right: 10px;
  }

  .panel-header {
    flex-direction: column;
  }

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

  .canvas-panel {
    height: 380px;
  }
}
