:root {
  --ink: #eeeeee;
  --muted: #a5a5a5;
  --soft-muted: #707070;
  --line: #303030;
  --paper: #050505;
  --card: #0c0c0c;
  --green: #eeeeee;
  --green-dark: #ffffff;
  --orange: #eeeeee;
  --shadow: 0 22px 70px rgba(0, 0, 0, .42);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { min-width: 320px; scroll-behavior: smooth; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, .018) 0, rgba(255, 255, 255, .018) 1px, transparent 1px, transparent 4px),
    radial-gradient(circle at 50% 0, #171717 0, var(--paper) 38rem);
  font-family: Consolas, "Liberation Mono", monospace;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button { cursor: pointer; }

.page-shell { width: min(920px, calc(100% - 48px)); margin: 0 auto; }

.topbar {
  display: flex;
  height: 88px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  border: 1px solid #eeeeee;
  border-radius: 2px;
  color: #050505;
  background: #eeeeee;
  box-shadow: none;
  font-size: 17px;
  font-weight: 700;
}

.card {
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
}

.calculator-card {
  margin-top: 78px;
  padding: 45px 48px 42px;
  border-radius: 2px;
}

.eyebrow, .result-label, .count-badge {
  margin: 0;
  color: var(--green);
  font-family: inherit;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .12em;
  text-transform: uppercase;
}

h1 {
  position: relative;
  margin: 14px 0 35px;
  font-size: clamp(32px, 4vw, 45px);
  font-weight: 700;
  letter-spacing: -.04em;
  line-height: .98;
}

.field-label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.equation-input-wrap {
  display: flex;
  min-height: 68px;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #050505;
  transition: border-color .2s, box-shadow .2s, background .2s;
}

.equation-input-wrap:focus-within {
  border-color: var(--green);
  background: #080808;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .08);
}

.equation-input-wrap::before {
  display: grid;
  width: 48px;
  flex: 0 0 48px;
  place-items: center;
  border-right: 1px solid var(--line);
  color: var(--ink);
  content: ">";
  font-size: 17px;
}

.equation-input-wrap input {
  width: 100%;
  min-width: 0;
  padding: 0 20px;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-family: inherit;
  font-size: 15px;
  overflow: hidden;
  scrollbar-width: none;
}

.equation-input-wrap input::-webkit-scrollbar,
.variable-input::-webkit-scrollbar { display: none; }

.equation-input-wrap input::placeholder { color: #5e5e5e; }
.helper-text { margin: 10px 0 0; color: var(--soft-muted); font-size: 11px; }

.variables-container { margin-top: 29px; }
.empty-state { color: var(--soft-muted); font-size: 11px; }
.empty-state p { margin: 0; }
.variables-container:not(.empty-state) { border-top: 1px solid var(--line); }

.variable-row {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  align-items: end;
  padding: 15px 0;
  border-bottom: 1px solid #242424;
  animation: appear .22s ease both;
}

.variable-row:last-child { border-bottom: 0; }
.variable-symbol { min-width: 70px; padding-bottom: 11px; color: var(--green); font-family: inherit; font-size: 23px; font-style: normal; white-space: nowrap; }
.small-label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 10px; }
.variable-input { width: 100%; padding: 10px 11px; border: 1px solid var(--line); border-radius: 2px; outline: 0; color: var(--ink); background: #050505; font-family: inherit; font-size: 12px; overflow: hidden; scrollbar-width: none; }
.variable-input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(255, 255, 255, .08); }

.count-badge { margin-top: 10px; font-size: 9px; }
.form-error { margin-top: 16px; padding: 11px 13px; border: 1px solid #555555; color: #eeeeee; background: #181818; font-size: 11px; line-height: 1.5; }

.primary-button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  margin-top: 26px;
  padding: 15px 17px;
  border: 1px solid #eeeeee;
  border-radius: 2px;
  color: #050505;
  background: #eeeeee;
  font-size: 12px;
  font-weight: 700;
  transition: background .2s, color .2s, transform .2s;
}

.primary-button:hover { color: #eeeeee; background: #050505; transform: translateY(-1px); }
.primary-button:disabled { cursor: wait; opacity: .65; transform: none; }
.primary-button .button-text { font-size: inherit; font-weight: inherit; }
.primary-button > span:last-child { font-size: 18px; font-weight: 400; }

.result-section { padding: 92px 0 70px; }
.result-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.secondary-button { padding: 3px 0; border: 0; color: var(--green); background: transparent; font-size: 11px; font-weight: 700; }
.secondary-button:hover { color: var(--green-dark); }

.result-hero { padding: 28px 31px; border-left: 3px solid var(--orange); border-radius: 2px; }
.result-label { margin-bottom: 14px; }
.final-result { color: var(--green-dark); font-family: inherit; font-size: clamp(26px, 4vw, 38px); letter-spacing: -.06em; }
.result-subline { margin-top: 10px; color: var(--muted); font-size: 11px; }

.result-grid { display: grid; grid-template-columns: 1fr; gap: 16px; margin-top: 16px; }
.result-card { min-width: 0; padding: 25px 27px; border-radius: 2px; }
.result-card h2 { margin: 0 0 16px; font-size: 13px; letter-spacing: -.03em; }
.math-block { min-height: 32px; overflow-x: auto; padding: 8px 0; text-align: center; font-size: 16px; }
.muted-math { margin-top: 10px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }

mjx-container { display: block !important; color: var(--ink) !important; text-align: center !important; }

.site-footer {
  margin-top: 56px;
  padding: 18px 0 30px;
  border-top: 1px solid var(--line);
  color: var(--soft-muted);
  font-size: 11px;
  letter-spacing: .02em;
  text-align: center;
}

.site-footer a { color: var(--ink); text-underline-offset: 3px; }
.site-footer a:hover { color: var(--green-dark); }

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

@media (max-width: 650px) {
  .page-shell { width: min(100% - 30px, 920px); }
  .topbar { height: 74px; }
  .calculator-card { margin-top: 50px; padding: 30px 21px; }
  h1 { margin-bottom: 28px; font-size: 32px; }
  .result-section { padding-top: 62px; }
  .result-grid { grid-template-columns: 1fr; }
}

@media (max-width: 430px) {
  .variable-row { grid-template-columns: max-content minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
  .variable-symbol { min-width: 58px; font-size: 18px; }
  .variable-input { padding-right: 8px; padding-left: 8px; font-size: 11px; }
}
