:root {
  --bg: #08080c;
  --surface: #0e0e14;
  --surface-border: #1a1a24;
  --surface-hover: #14141e;
  --amber: #c8a46e;
  --amber-dim: #a08050;
  --amber-glow: rgba(200, 164, 110, 0.08);
  --amber-glow-strong: rgba(200, 164, 110, 0.15);
  --text: #c8c8d0;
  --text-dim: #5a5a6a;
  --text-faint: #3a3a48;
  --mono: "JetBrains Mono", "SF Mono", "Fira Code", monospace;
  --serif: "Cormorant Garamond", "Georgia", serif;
}

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

body {
  font-family: var(--mono);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Noise texture overlay */
.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

.app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2.5rem 2rem 1.5rem;
  animation: fadeIn 0.6s ease-out;
}

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

/* Header */
header {
  margin-bottom: 2.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.header-rule {
  flex: 1;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--surface-border),
    transparent
  );
}

.header-content {
  text-align: center;
  flex-shrink: 0;
}

h1 {
  font-family: var(--serif);
  font-size: 2.2rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #fff;
  line-height: 1;
}

.subtitle {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 0.4rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.subtitle em {
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.8rem;
  text-transform: none;
}

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 2rem;
  align-items: start;
}

/* Panels */
.panel,
.equation {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 10px;
  padding: 1rem 1.15rem;
  margin-bottom: 1rem;
  position: relative;
}

.panel-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  margin-bottom: 0.85rem;
}

/* Parameter controls */
.control-group {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.param {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.param-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.param-header label {
  font-family: var(--serif);
  font-size: 1.1rem;
  color: var(--amber);
  font-weight: 400;
}

.param-header label em {
  font-style: italic;
}

.num-input {
  width: 64px;
  background: var(--bg);
  border: 1px solid var(--surface-border);
  border-radius: 5px;
  color: #fff;
  font-size: 0.72rem;
  font-family: var(--mono);
  padding: 0.25rem 0.4rem;
  text-align: right;
  transition: border-color 0.2s;
}

.num-input:focus {
  outline: none;
  border-color: var(--amber-dim);
  box-shadow: 0 0 0 2px var(--amber-glow);
}

/* Range slider */
.slider-track {
  padding: 2px 0;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 2px;
  background: var(--surface-border);
  border-radius: 1px;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--amber);
  border: 2px solid var(--bg);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 0 6px var(--amber-glow);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.25);
  box-shadow: 0 0 12px var(--amber-glow-strong);
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--amber);
  border: 2px solid var(--bg);
  cursor: pointer;
}

input[type="range"]::-moz-range-track {
  height: 2px;
  background: var(--surface-border);
  border: none;
}

/* Presets */
.presets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}

.preset {
  background: var(--bg);
  border: 1px solid var(--surface-border);
  border-radius: 7px;
  color: var(--text);
  padding: 0.5rem 0.6rem;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.preset-name {
  font-family: var(--serif);
  font-size: 0.85rem;
  color: var(--text);
  font-weight: 400;
}

.preset-vals {
  font-size: 0.58rem;
  color: var(--text-faint);
  letter-spacing: 0.02em;
}

.preset:hover {
  border-color: var(--amber-dim);
  background: var(--surface-hover);
}

.preset:hover .preset-name {
  color: var(--amber);
}

.preset:hover .preset-vals {
  color: var(--text-dim);
}

/* Status */
.panel-status {
  padding: 0.85rem 1.15rem;
}

.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.status-label {
  font-size: 0.6rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.status-value {
  font-size: 0.82rem;
  color: var(--amber);
  font-weight: 500;
}

.warning {
  margin-top: 0.65rem;
  padding: 0.55rem 0.7rem;
  background: rgba(200, 130, 50, 0.06);
  border: 1px solid rgba(200, 130, 50, 0.15);
  border-radius: 6px;
  font-size: 0.68rem;
  color: var(--amber-dim);
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

/* Equation display */
.equation {
  padding-bottom: 1.15rem;
}

.eq-lines {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-family: var(--serif);
  font-size: 0.95rem;
  color: var(--text-dim);
}

.eq-lines em {
  font-style: italic;
  color: var(--text);
}

/* Chart area */
.chart-area {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.chart-frame {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 10px;
  padding: 1.25rem;
  min-height: 520px;
  box-shadow: 0 0 40px rgba(200, 164, 110, 0.02),
    inset 0 0 60px rgba(0, 0, 0, 0.2);
}

#chart {
  width: 100% !important;
  height: 100% !important;
  min-height: 470px;
}

.chart-caption {
  font-size: 0.62rem;
  color: var(--text-faint);
  text-align: center;
  letter-spacing: 0.03em;
  line-height: 1.5;
}

.chart-caption em {
  font-family: var(--serif);
  font-style: italic;
  color: var(--text-dim);
}

/* Loading overlay */
.loading {
  position: absolute;
  inset: 0;
  background: rgba(8, 8, 12, 0.85);
  backdrop-filter: blur(4px);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  z-index: 10;
  font-size: 0.72rem;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--surface-border);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Footer */
footer {
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--surface-border);
  text-align: center;
}

footer a {
  font-size: 0.62rem;
  color: var(--text-faint);
  text-decoration: none;
  letter-spacing: 0.06em;
  transition: color 0.2s;
}

footer a:hover {
  color: var(--amber-dim);
}

/* Responsive */
@media (max-width: 800px) {
  .app {
    padding: 1.5rem 1rem 1rem;
  }

  header {
    margin-bottom: 1.5rem;
  }

  h1 {
    font-size: 1.6rem;
  }

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

  .chart-frame {
    min-height: 360px;
  }

  #chart {
    min-height: 320px;
  }

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