:root {
  color-scheme: dark;
  --bg: #0d1113;
  --surface: #13191b;
  --surface-raised: #182022;
  --line: #283235;
  --line-soft: #20292b;
  --text: #edf2ee;
  --muted: #899694;
  --muted-strong: #b5c0bb;
  --accent: #c5f36b;
  --accent-dim: #9aba51;
  --danger: #ff806c;
  --mono: "DM Mono", "SFMono-Regular", Consolas, monospace;
  --sans: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(ellipse 760px 440px at 86% -190px, rgba(197, 243, 107, 0.075), transparent 70%),
    var(--bg);
}

button, input, select { font: inherit; }
a { color: inherit; }

.app-shell { width: min(100% - 80px, 1400px); margin: 0 auto; }

.topbar {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.075);
  animation: rise-in 520ms ease-out both;
}

.brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(197, 243, 107, 0.44);
  border-radius: 9px;
  color: var(--accent);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.08em;
  line-height: 1;
}
.brand-mark span { color: var(--text); }
.brand-name { font-size: 12px; font-weight: 800; letter-spacing: 0.17em; }

.market-status, .section-kicker, .eyebrow, .metric-label, .contract-kind, .result-state, .formula-tag, .intro-index span {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.105em;
}
.market-status { display: inline-flex; align-items: center; gap: 10px; color: var(--muted); }
.status-dot, .result-state > span {
  width: 6px;
  height: 6px;
  display: inline-block;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px rgba(197, 243, 107, 0.45);
}

.main-content { width: min(100%, 1160px); margin: 0 auto; padding: 55px 0 30px; }
.page-intro { margin-bottom: 35px; animation: rise-in 600ms 70ms ease-out both; }
.eyebrow { display: flex; align-items: center; gap: 10px; color: var(--accent); }
.eyebrow-divider { width: 22px; height: 1px; background: #506044; }
.intro-row { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 16px; }
.intro-row h1 { margin: 0; font-size: clamp(38px, 5vw, 61px); font-weight: 600; letter-spacing: -0.075em; line-height: 1.04; }
.intro-row h1 span { color: var(--accent); }
.intro-row p { max-width: 570px; margin: 14px 0 0; color: var(--muted); font-size: 14px; line-height: 1.65; }
.intro-index { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; padding-bottom: 5px; color: var(--muted); }
.intro-index strong { color: #364140; font-family: var(--mono); font-size: 28px; font-weight: 400; letter-spacing: -0.08em; }

.calculator-layout { display: grid; grid-template-columns: minmax(290px, 0.78fr) minmax(510px, 1.4fr); gap: 16px; align-items: stretch; }
.setup-panel, .results-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  animation: rise-in 620ms 130ms ease-out both;
}
.setup-panel { padding: 25px 25px 23px; }
.results-panel { padding: 25px 27px 22px; animation-delay: 190ms; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; }
.section-kicker { display: block; margin-bottom: 7px; color: var(--accent-dim); }
.panel-heading h2 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -0.045em; }
.panel-number { color: #43504d; font-family: var(--mono); font-size: 12px; }

.field-label { display: block; margin-bottom: 8px; color: var(--muted-strong); font-size: 11px; font-weight: 600; letter-spacing: 0.01em; }
.select-wrap, .input-wrap { position: relative; }
.select-wrap select, .input-wrap input {
  display: block;
  width: 100%;
  height: 47px;
  padding: 0 14px;
  border: 1px solid #303b3d;
  border-radius: 8px;
  outline: none;
  background: #101617;
  color: var(--text);
  font-size: 13px;
  transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}
.select-wrap select { appearance: none; padding-right: 42px; cursor: pointer; }
.select-wrap select:hover, .input-wrap input:hover { border-color: #475552; }
.select-wrap select:focus, .input-wrap input:focus { border-color: var(--accent-dim); background: #12191a; box-shadow: 0 0 0 3px rgba(197, 243, 107, 0.08); }
.select-chevron { position: absolute; top: 11px; right: 15px; color: var(--muted); font-size: 18px; pointer-events: none; }
.instrument-meta { display: flex; align-items: center; gap: 9px; min-height: 29px; margin-top: 6px; }
.instrument-symbol { color: var(--accent); font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em; }
.instrument-name { color: var(--muted); font-size: 10px; }
.field-divider { height: 1px; margin: 17px 0 19px; background: var(--line-soft); }
.input-wrap input { padding-right: 55px; font-family: var(--mono); font-size: 13px; font-variant-numeric: tabular-nums; }
.input-wrap input::placeholder { color: #52605d; opacity: 1; }
.input-suffix { position: absolute; top: 16px; right: 13px; color: #87938f; font-family: var(--mono); font-size: 9px; letter-spacing: 0.08em; pointer-events: none; }
.price-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin-top: 16px; }
.price-field { min-width: 0; }
.price-field input { padding-right: 12px; }
.stop-input-wrap input:focus { border-color: rgba(255, 128, 108, 0.7); box-shadow: 0 0 0 3px rgba(255, 128, 108, 0.07); }
.stop-mark { position: absolute; top: 21px; right: 13px; width: 5px; height: 5px; border-radius: 50%; background: var(--danger); opacity: 0.8; }
.field-error { min-height: 0; margin: 0; color: var(--danger); font-size: 10px; line-height: 1.45; }
.field-error:not(:empty) { margin-top: 6px; }
.input-wrap.has-error input { border-color: rgba(255, 128, 108, 0.7); }
.tick-hint { display: flex; align-items: flex-start; gap: 8px; margin-top: 20px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.tick-icon { color: var(--accent-dim); font-family: var(--mono); font-size: 12px; line-height: 1.1; }

.results-heading { margin-bottom: 19px; }
.result-state { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 8px; white-space: nowrap; }
.result-state > span { width: 5px; height: 5px; background: #788581; box-shadow: none; }
.result-state.is-ready { color: var(--accent); }
.result-state.is-ready > span { background: var(--accent); box-shadow: 0 0 10px rgba(197, 243, 107, 0.55); }
.result-state.is-invalid { color: var(--danger); }
.result-state.is-invalid > span { background: var(--danger); }

.distance-strip { display: flex; align-items: center; gap: 20px; padding: 15px 17px; border: 1px solid var(--line-soft); border-radius: 9px; background: #101617; }
.distance-block { display: flex; flex-direction: column; gap: 5px; min-width: 86px; }
.metric-label { color: var(--muted); font-size: 8px; }
.distance-block strong { font-family: var(--mono); font-size: 18px; font-weight: 400; letter-spacing: -0.07em; font-variant-numeric: tabular-nums; }
.metric-unit { color: #65716e; font-family: var(--mono); font-size: 9px; }
.distance-rule { position: relative; flex: 1; height: 1px; background: #293334; }
.distance-rule::before, .distance-rule::after { position: absolute; top: -2px; width: 5px; height: 5px; border-radius: 50%; content: ""; background: var(--accent-dim); }
.distance-rule::before { left: 0; }
.distance-rule::after { right: 0; background: var(--danger); }
.distance-rule span { position: absolute; top: -3px; left: 50%; width: 7px; height: 7px; border: 1px solid #73816e; border-radius: 50%; background: #101617; transform: translateX(-50%); }

.contract-results { display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin-top: 17px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.contract-result { min-width: 0; padding: 17px 18px 16px; background: rgba(255, 255, 255, 0.012); transition: background-color 180ms ease; }
.contract-result:hover { background: rgba(255, 255, 255, 0.032); }
.micro-result { border-right: 1px solid var(--line); }
.contract-result-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.contract-kind { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 8px; white-space: nowrap; }
.contract-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.mini-result .contract-dot { background: #8da39b; }
.result-ticker { color: #dce4df; font-family: var(--mono); font-size: 10px; }
.quantity-line { display: flex; align-items: baseline; gap: 9px; margin: 10px 0 13px; }
.quantity { color: var(--accent); font-family: var(--mono); font-size: clamp(41px, 5vw, 54px); font-weight: 400; letter-spacing: -0.11em; line-height: 1; font-variant-numeric: tabular-nums; transition: color 180ms ease, transform 180ms ease; }
.mini-result .quantity { color: #dbe5df; }
.quantity-line > span { color: var(--muted); font-size: 10px; }
.quantity.updated { transform: translateY(-2px); }
.result-breakdown { display: grid; gap: 7px; padding-top: 11px; border-top: 1px solid var(--line-soft); }
.result-breakdown > div, .risk-usage-label { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.result-breakdown span { color: var(--muted); font-size: 9px; }
.result-breakdown strong { color: #d7e0db; font-family: var(--mono); font-size: 10px; font-weight: 400; font-variant-numeric: tabular-nums; }
.risk-usage { margin-top: 13px; }
.risk-usage-label { color: #71807b; font-size: 8px; }
.risk-usage-label strong { color: #a9b5af; font-family: var(--mono); font-size: 8px; font-weight: 400; }
.usage-track { height: 3px; margin-top: 7px; overflow: hidden; border-radius: 3px; background: #2b3434; }
.usage-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--accent); transition: width 360ms cubic-bezier(0.2, 0.7, 0.2, 1); }
.mini-result .usage-track span { background: #a7b9ae; }
.result-note { min-height: 15px; margin-top: 12px; color: #75817d; font-size: 9px; line-height: 1.45; }
.result-note.is-warning { color: #d3a17c; }

.specs-row { display: grid; grid-template-columns: minmax(150px, 1.3fr) repeat(4, minmax(105px, 1fr)) auto; align-items: center; gap: 18px; min-height: 91px; padding: 18px 3px; border-bottom: 1px solid var(--line); animation: rise-in 620ms 240ms ease-out both; }
.specs-title .section-kicker { margin-bottom: 6px; }
.specs-title strong { font-family: var(--mono); font-size: 12px; font-weight: 400; }
.specs-title strong span { color: var(--muted); font-family: var(--sans); font-size: 10px; }
.spec-item { display: flex; flex-direction: column; gap: 7px; }
.spec-item > span { color: var(--muted); font-size: 9px; }
.spec-item strong { color: #dce3de; font-family: var(--mono); font-size: 10px; font-weight: 400; white-space: nowrap; }
.spec-item strong span { color: var(--muted); }
.spec-link { color: var(--accent); font-family: var(--mono); font-size: 9px; text-decoration: none; white-space: nowrap; transition: color 150ms ease; }
.spec-link:hover { color: #e0ff9e; }
.spec-link span { margin-left: 3px; }

.formula-section { display: grid; grid-template-columns: 0.78fr 1.4fr; gap: 36px; padding: 24px 3px 22px; border-bottom: 1px solid var(--line); animation: rise-in 620ms 290ms ease-out both; }
.formula-heading .section-kicker { margin-bottom: 8px; }
.formula-heading h2 { max-width: 290px; margin: 0; color: #c1cbc5; font-size: 13px; font-weight: 500; line-height: 1.5; }
.formula-content { display: grid; gap: 10px; }
.formula-line { display: flex; align-items: center; gap: 11px; }
.formula-tag { width: 107px; flex: 0 0 107px; color: var(--accent-dim); font-size: 8px; }
.formula-line code { color: #dce4de; font-family: var(--mono); font-size: 10px; line-height: 1.5; white-space: normal; }
.actual-formula .formula-tag { color: #95a49c; }
.formula-content p { margin: 1px 0 0 118px; color: #77837e; font-size: 9px; line-height: 1.55; }
.page-footer { display: flex; justify-content: space-between; gap: 20px; padding: 18px 3px 0; color: #65716e; font-family: var(--mono); font-size: 8px; letter-spacing: 0.035em; animation: rise-in 620ms 340ms ease-out both; }
.footer-separator { padding: 0 5px; color: #3f4b47; }

@keyframes rise-in { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 900px) {
  .app-shell { width: min(100% - 48px, 720px); }
  .main-content { padding-top: 42px; }
  .calculator-layout { grid-template-columns: 1fr; }
  .setup-panel { padding-bottom: 20px; }
  .price-fields { max-width: 520px; }
  .specs-row { grid-template-columns: 1fr 1fr; gap: 17px 24px; padding: 20px 0; }
  .specs-title { grid-column: 1 / -1; }
  .spec-link { justify-self: end; align-self: end; }
  .formula-section { grid-template-columns: 1fr; gap: 17px; }
  .formula-heading h2 { max-width: none; }
}

@media (max-width: 560px) {
  .app-shell { width: min(100% - 32px, 500px); }
  .topbar { height: 64px; }
  .market-status { gap: 7px; font-size: 8px; letter-spacing: 0.04em; }
  .brand { gap: 8px; }
  .brand-mark { width: 29px; height: 29px; }
  .brand-name { font-size: 10px; }
  .main-content { padding-top: 34px; }
  .page-intro { margin-bottom: 25px; }
  .intro-row { align-items: flex-start; }
  .intro-row h1 { font-size: clamp(39px, 12vw, 52px); }
  .intro-row p { max-width: 330px; margin-top: 11px; font-size: 12px; }
  .intro-index { display: none; }
  .setup-panel, .results-panel { padding: 20px 17px; }
  .panel-heading { margin-bottom: 20px; }
  .results-heading { margin-bottom: 17px; }
  .panel-heading h2 { font-size: 16px; }
  .result-state { font-size: 7px; }
  .distance-strip { gap: 12px; padding: 13px 12px; }
  .distance-block { min-width: 75px; }
  .distance-block strong { font-size: 16px; }
  .metric-label { font-size: 7px; }
  .contract-result { padding: 14px 12px 13px; }
  .contract-kind { gap: 5px; font-size: 7px; letter-spacing: 0.06em; }
  .quantity { font-size: clamp(38px, 12vw, 48px); }
  .result-breakdown span { font-size: 8px; }
  .result-breakdown strong { font-size: 9px; }
  .risk-usage-label { font-size: 7px; }
  .risk-usage-label strong { font-size: 7px; }
  .specs-row { column-gap: 12px; }
  .formula-section { padding-top: 20px; }
  .formula-line { align-items: flex-start; gap: 8px; }
  .formula-tag { width: 93px; flex-basis: 93px; font-size: 7px; }
  .formula-line code { font-size: 9px; }
  .formula-content p { margin-left: 101px; font-size: 8px; }
  .page-footer { flex-direction: column; gap: 7px; font-size: 7px; }
}

@media (max-width: 370px) {
  .app-shell { width: calc(100% - 24px); }
  .market-status { font-size: 7px; }
  .setup-panel, .results-panel { padding-right: 13px; padding-left: 13px; }
  .contract-result { padding-right: 9px; padding-left: 9px; }
  .contract-kind { letter-spacing: 0.025em; }
  .distance-strip { gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
