:root {
  --bg: #0f1218;
  --surface: #171b24;
  --surface-2: #1e2430;
  --border: #2a3344;
  --text: #e8ecf4;
  --text-muted: #8b95a8;
  --accent: #3b9eff;
  --accent-dim: #2563a8;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Code", "Consolas", monospace;
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(59, 158, 255, 0.12), transparent),
    var(--bg);
}

.app {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 1rem 2rem;
}

.header {
  margin-bottom: 1.75rem;
}

.header__brand {
  display: flex;
  align-items: center;
  gap: 0.875rem;
}

.header__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  font-size: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.header__subtitle {
  margin: 0.15rem 0 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.layout {
  display: grid;
  gap: 1.25rem;
}

@media (min-width: 720px) {
  .layout {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 2px);
  padding: 1.25rem 1.25rem 1.5rem;
  box-shadow: var(--shadow);
}

.panel h2 {
  margin: 0 0 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.field-group {
  margin: 0 0 1.25rem;
  padding: 0;
  border: none;
}

.field-group legend {
  padding: 0;
  margin-bottom: 0.625rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.field__label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.field__badge {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  background: rgba(59, 158, 255, 0.12);
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
}

.field__control {
  width: 100%;
  padding: 0.5rem 0.65rem;
  font: inherit;
  font-size: 0.9375rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field__control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 158, 255, 0.2);
}

.field__control--range {
  padding: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.field__hint {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
}

.link-btn:hover {
  text-decoration: underline;
}

.advanced-panel {
  padding-top: 0.25rem;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.result-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.result-card--primary {
  border-color: var(--accent-dim);
  background: linear-gradient(135deg, rgba(59, 158, 255, 0.08), var(--surface-2));
}

.result-card__label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.result-card__value {
  font-family: var(--mono);
  font-size: 1.625rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text);
}

.result-card--primary .result-card__value {
  color: var(--accent);
}

.result-card__unit {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.warnings {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.warning {
  padding: 0.625rem 0.75rem;
  border-radius: 6px;
  font-size: 0.8125rem;
  line-height: 1.4;
}

.warning--info {
  background: rgba(59, 158, 255, 0.1);
  border: 1px solid rgba(59, 158, 255, 0.3);
  color: #93c5fd;
}

.warning--caution {
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.35);
  color: #fcd34d;
}

.warning--danger {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: #fca5a5;
}

.preset-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.25rem;
}

.btn {
  padding: 0.5rem 1rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn--secondary {
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.btn--secondary:hover {
  background: var(--border);
}

.preset-status {
  margin: 0.35rem 0 0;
  font-size: 0.8125rem;
  color: var(--success);
  min-height: 1.25rem;
}

.preset-status--error {
  color: var(--danger);
}

.engagement-note {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text-muted);
}

.engagement-note strong {
  color: var(--text);
}

.engagement-note__factors {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-top: 0.35rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--accent);
}

.formulas {
  border-top: 1px solid var(--border);
  padding-top: 0.875rem;
}

.formulas summary {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.formulas summary:hover {
  color: var(--text);
}

.formulas__list {
  margin: 0.75rem 0;
}

.formulas__list dt {
  font-family: var(--mono);
  font-size: 0.8125rem;
  color: var(--accent);
  margin-top: 0.5rem;
}

.formulas__list dd {
  margin: 0.15rem 0 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.formulas__note {
  margin: 0.75rem 0 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.footer {
  margin-top: 2rem;
  text-align: center;
}

.footer p {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}
