:root {
  color-scheme: dark;
  --cabinet: #151612;
  --screen: #242820;
  --screen-deep: #181b16;
  --phosphor: #d7ff42;
  --phosphor-soft: #a7cb32;
  --amber: #ffbf42;
  --cyan: #6ec7d1;
  --dim: #70805a;
  --line: rgba(215, 255, 66, 0.38);
  --line-strong: rgba(215, 255, 66, 0.72);
  --shadow: 0 26px 70px rgba(0, 0, 0, 0.5);
  --radius: 4px;
}

@font-face {
  font-family: "Share Tech Mono";
  src:
    url("assets/fonts/ShareTechMono-Regular.ttf") format("truetype"),
    local("Share Tech Mono"),
    local("ShareTechMono-Regular");
  font-display: swap;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--phosphor);
  font-family: "Share Tech Mono", "Courier New", Consolas, monospace;
  line-height: 1.28;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.08), transparent 24%),
    radial-gradient(circle at 78% 20%, rgba(255, 191, 66, 0.06), transparent 26%),
    linear-gradient(145deg, #0d0e0b, #25261f 48%, #10110e);
}

body::before,
body::after {
  position: fixed;
  inset: 0;
  pointer-events: none;
  content: "";
}

body::before {
  z-index: -1;
  background-image:
    linear-gradient(rgba(215, 255, 66, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(215, 255, 66, 0.028) 1px, transparent 1px);
  background-size: 100% 4px, 28px 28px;
  mix-blend-mode: screen;
}

body::after {
  background:
    linear-gradient(rgba(255, 255, 255, 0.03), transparent 28%),
    radial-gradient(circle at 50% 18%, transparent 0 30%, rgba(0, 0, 0, 0.24) 74%);
}

a {
  color: inherit;
}

.screen-shell,
.site-header,
.placeholder-main {
  width: min(1060px, calc(100% - 32px));
  margin-inline: auto;
}

.screen-shell {
  position: relative;
  min-height: calc(100vh - 48px);
  margin-top: 24px;
  margin-bottom: 24px;
  padding: 18px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 14%),
    var(--screen);
  border: 2px solid #4d5146;
  border-radius: var(--radius);
  box-shadow: var(--shadow), inset 0 0 36px rgba(0, 0, 0, 0.56);
}

.screen-shell::before {
  position: absolute;
  inset: 10px;
  z-index: 0;
  content: "";
  border: 1px solid rgba(215, 255, 66, 0.18);
  pointer-events: none;
}

.screen-shell::after {
  position: absolute;
  inset: 0;
  z-index: 0;
  content: "";
  background:
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.035) 0,
      rgba(255, 255, 255, 0.035) 1px,
      transparent 1px,
      transparent 5px
    );
  opacity: 0.52;
  pointer-events: none;
}

.screen-header,
.calculator-section {
  position: relative;
  z-index: 1;
}

.screen-header {
  display: grid;
  min-height: 94px;
  place-items: center;
  padding: 15px 12px 17px;
  border-bottom: 1px solid var(--line);
}

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

h1 {
  margin-bottom: 0;
  color: var(--phosphor);
  font-size: 2.05rem;
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.14em;
  text-align: center;
  text-shadow:
    0 0 7px rgba(215, 255, 66, 0.55),
    0 0 18px rgba(215, 255, 66, 0.22);
}

h2 {
  margin-bottom: 0;
  font-size: 1.5rem;
}

.calculator-section {
  padding: 20px 0 2px;
}

.calculator-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.calculator-card {
  position: relative;
  display: grid;
  grid-template-rows: auto auto 1fr;
  min-height: 226px;
  padding: 16px;
  overflow: hidden;
  text-decoration: none;
  background:
    linear-gradient(180deg, rgba(215, 255, 66, 0.06), transparent 44%),
    rgba(19, 23, 17, 0.84);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: inset 0 0 22px rgba(0, 0, 0, 0.5);
  transition: border-color 140ms ease, color 140ms ease, transform 140ms ease, background-color 140ms ease;
}

.calculator-card::before {
  position: absolute;
  inset: 7px;
  content: "";
  border: 1px solid rgba(215, 255, 66, 0.14);
  pointer-events: none;
}

.calculator-card::after {
  position: absolute;
  right: 12px;
  bottom: 11px;
  width: 78px;
  height: 20px;
  content: "";
  background:
    linear-gradient(90deg, transparent 0 16%, var(--line) 16% 19%, transparent 19% 32%, var(--line) 32% 35%, transparent 35% 48%, var(--line) 48% 51%, transparent 51%),
    linear-gradient(var(--line), var(--line));
  background-repeat: no-repeat;
  background-size: 100% 100%, 100% 2px;
  background-position: 0 0, 0 50%;
  opacity: 0.45;
}

.calculator-card:hover,
.calculator-card:focus-visible {
  color: #f5ff9a;
  background-color: rgba(30, 37, 24, 0.92);
  border-color: var(--line-strong);
  outline: none;
  transform: translateY(-2px);
}

.calculator-card:hover .card-index,
.calculator-card:focus-visible .card-index {
  color: var(--amber);
}

.card-index,
.card-title,
.card-copy {
  position: relative;
  z-index: 1;
}

.card-index {
  width: max-content;
  margin-bottom: 18px;
  padding: 3px 8px 2px;
  color: var(--cyan);
  font-size: 0.95rem;
  font-weight: 400;
  line-height: 1;
  border: 1px solid rgba(110, 199, 209, 0.56);
  text-shadow: 0 0 8px rgba(110, 199, 209, 0.32);
}

.card-title {
  color: var(--phosphor);
  font-size: 1.24rem;
  font-weight: 400;
  line-height: 1.18;
  letter-spacing: 0.075em;
  text-shadow:
    0 0 6px rgba(215, 255, 66, 0.58),
    0 0 14px rgba(215, 255, 66, 0.2);
}

.card-copy {
  max-width: 31ch;
  margin-top: 16px;
  margin-bottom: 0;
  color: #c5dd76;
  font-size: 0.93rem;
  line-height: 1.42;
}

.site-header {
  display: flex;
  min-height: 76px;
  align-items: center;
}

.brand {
  color: var(--phosphor);
  font-size: 1.05rem;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-decoration: none;
  text-shadow: 0 0 8px rgba(215, 255, 66, 0.46);
}

.placeholder-main {
  display: grid;
  min-height: calc(100vh - 108px);
  place-items: center;
  padding: 30px 0;
}

.placeholder-panel {
  width: min(720px, 100%);
  padding: 24px;
  background: rgba(19, 23, 17, 0.88);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow), inset 0 0 22px rgba(0, 0, 0, 0.5);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--cyan);
  font-size: 0.92rem;
  font-weight: 400;
  text-transform: uppercase;
}

.placeholder-panel p {
  color: #c5dd76;
}

.back-link {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  margin-top: 14px;
  padding: 9px 12px;
  color: var(--screen-deep);
  font-size: 0.95rem;
  font-weight: 400;
  text-decoration: none;
  background: var(--phosphor);
  border-radius: var(--radius);
}

.back-link:hover,
.back-link:focus-visible {
  color: #080907;
  background: var(--amber);
  outline: none;
}

.triangle-main {
  width: min(1160px, calc(100% - 32px));
  min-height: calc(100vh - 108px);
  margin-inline: auto;
  padding: 0 0 30px;
  letter-spacing: 0;
}

.triangle-board {
  padding: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 18%),
    rgba(19, 23, 17, 0.9);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow), inset 0 0 24px rgba(0, 0, 0, 0.46);
}

.triangle-topbar,
.precision-row,
.triangle-buttons {
  display: flex;
  gap: 10px;
}

.triangle-topbar {
  align-items: start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.triangle-topbar h1 {
  font-size: 1.6rem;
  letter-spacing: 0;
  text-align: left;
}

.compact-link {
  min-height: 36px;
  margin-top: 0;
  padding: 8px 11px;
}

.triangle-guidance {
  max-width: 78ch;
  margin-bottom: 16px;
  color: #c5dd76;
  font-size: 0.96rem;
  line-height: 1.45;
}

.triangle-workspace {
  display: grid;
  grid-template-columns: minmax(340px, 1.08fr) minmax(340px, 0.92fr);
  gap: 16px;
  align-items: start;
}

.triangle-diagram-wrap {
  min-width: 0;
  background:
    linear-gradient(rgba(215, 255, 66, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(215, 255, 66, 0.035) 1px, transparent 1px),
    rgba(9, 11, 8, 0.45);
  background-size: 28px 28px;
  border: 1px solid rgba(215, 255, 66, 0.26);
  border-radius: var(--radius);
}

.triangle-svg {
  display: block;
  width: 100%;
  aspect-ratio: 64 / 43;
  min-height: 310px;
}

.triangle-shape {
  fill: rgba(215, 255, 66, 0.055);
  stroke: none;
}

.triangle-line {
  stroke: var(--phosphor);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 6px rgba(215, 255, 66, 0.34));
}

.triangle-side-label,
.triangle-vertex-label {
  font-family: "Share Tech Mono", "Courier New", Consolas, monospace;
  font-size: 30px;
  text-transform: none;
  text-anchor: middle;
  dominant-baseline: middle;
  paint-order: stroke;
  stroke: rgba(9, 11, 8, 0.86);
  stroke-width: 6px;
}

.triangle-side-label {
  fill: var(--amber);
}

.triangle-vertex-label {
  fill: var(--cyan);
}

.triangle-controls {
  min-width: 0;
}

.precision-row {
  align-items: center;
  justify-content: flex-end;
  margin-bottom: 12px;
  color: var(--cyan);
  font-size: 0.95rem;
}

.precision-row select {
  min-height: 36px;
  padding: 6px 30px 6px 10px;
  color: var(--phosphor);
  font: inherit;
  letter-spacing: 0;
  text-transform: uppercase;
  background: #10130e;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.value-groups {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.value-group {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.value-group legend {
  margin-bottom: 8px;
  color: var(--cyan);
  font-size: 0.95rem;
}

.value-field {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.value-field label {
  color: var(--phosphor);
  font-size: 1.2rem;
  text-align: center;
  text-transform: none;
}

.value-field input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 8px 10px;
  color: var(--phosphor);
  font: inherit;
  letter-spacing: 0;
  text-transform: none;
  background: rgba(8, 10, 7, 0.82);
  border: 1px solid rgba(215, 255, 66, 0.32);
  border-radius: var(--radius);
  box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.42);
}

.value-field input.is-entered {
  color: #d8fbff;
  background: rgba(110, 199, 209, 0.15);
  border-color: rgba(110, 199, 209, 0.72);
}

.value-field input.is-calculated {
  color: #ffe3a5;
  background: rgba(255, 191, 66, 0.16);
  border-color: rgba(255, 191, 66, 0.76);
}

.value-field input:focus,
.precision-row select:focus {
  border-color: var(--phosphor);
  outline: 2px solid rgba(215, 255, 66, 0.2);
  outline-offset: 2px;
}

.triangle-buttons {
  flex-wrap: wrap;
  margin-top: 8px;
}

.primary-button,
.secondary-button {
  min-height: 42px;
  padding: 9px 14px;
  font: inherit;
  letter-spacing: 0;
  text-transform: uppercase;
  border-radius: var(--radius);
  cursor: pointer;
}

.primary-button {
  color: var(--screen-deep);
  background: var(--phosphor);
  border: 1px solid var(--phosphor);
}

.secondary-button {
  color: var(--amber);
  background: transparent;
  border: 1px solid rgba(255, 191, 66, 0.72);
}

.primary-button:hover,
.primary-button:focus-visible {
  color: #080907;
  background: var(--amber);
  border-color: var(--amber);
  outline: none;
}

.secondary-button:hover,
.secondary-button:focus-visible {
  color: #080907;
  background: var(--amber);
  outline: none;
}

.solver-message {
  min-height: 2.7em;
  margin: 12px 0 0;
  color: #c5dd76;
  line-height: 1.35;
}

.solver-message.is-error {
  color: #ffb08c;
}

.solution-options {
  margin-top: 12px;
  padding: 10px;
  background: rgba(8, 10, 7, 0.48);
  border: 1px solid rgba(110, 199, 209, 0.38);
  border-radius: var(--radius);
}

.solution-note {
  margin-bottom: 10px;
  color: #c5dd76;
  font-size: 0.88rem;
  line-height: 1.4;
}

.solution-option {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 8px 0;
  border-top: 1px solid rgba(215, 255, 66, 0.16);
}

.solution-option button {
  min-height: 34px;
  padding: 6px 9px;
  color: var(--cyan);
  font: inherit;
  letter-spacing: 0;
  text-transform: uppercase;
  background: transparent;
  border: 1px solid rgba(110, 199, 209, 0.56);
  border-radius: var(--radius);
  cursor: pointer;
}

.solution-option.is-active button {
  color: var(--screen-deep);
  background: var(--cyan);
}

.solution-option button:hover,
.solution-option button:focus-visible {
  color: var(--screen-deep);
  background: var(--amber);
  border-color: var(--amber);
  outline: none;
}

.solution-option p {
  margin: 0;
  color: #d5ea91;
  line-height: 1.35;
  text-transform: none;
  overflow-wrap: anywhere;
}

.work-panel {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(215, 255, 66, 0.22);
}

.work-panel summary {
  width: max-content;
  max-width: 100%;
  color: var(--cyan);
  cursor: pointer;
}

.work-panel summary:focus-visible {
  outline: 2px solid rgba(110, 199, 209, 0.42);
  outline-offset: 4px;
}

.work-list {
  margin: 12px 0 0;
  padding-left: 24px;
  color: #d5ea91;
  line-height: 1.55;
  text-transform: none;
  overflow-wrap: anywhere;
}

.work-list li + li {
  margin-top: 8px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 860px) {
  .calculator-grid {
    grid-template-columns: 1fr;
  }

  .triangle-workspace {
    grid-template-columns: 1fr;
  }

  .screen-shell {
    min-height: auto;
  }

  .calculator-card {
    min-height: 168px;
  }

  .card-copy {
    max-width: 40ch;
  }
}

@media (max-width: 560px) {
  .screen-shell,
  .site-header,
  .placeholder-main,
  .triangle-main {
    width: min(100% - 20px, 1060px);
  }

  .screen-shell {
    margin-top: 10px;
    margin-bottom: 10px;
    padding: 14px;
  }

  .screen-header {
    min-height: 78px;
    padding: 12px 8px 16px;
  }

  h1 {
    font-size: 1.5rem;
    letter-spacing: 0.1em;
  }

  .calculator-section {
    padding-top: 18px;
  }

  .calculator-card,
  .placeholder-panel,
  .triangle-board {
    padding: 16px;
  }

  .card-title {
    font-size: 1.08rem;
  }

  .triangle-topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .triangle-topbar h1 {
    font-size: 1.32rem;
  }

  .compact-link {
    width: max-content;
  }

  .value-groups {
    grid-template-columns: 1fr;
  }

  .precision-row {
    justify-content: flex-start;
  }

  .triangle-svg {
    min-height: 0;
  }

  .triangle-side-label,
  .triangle-vertex-label {
    font-size: 24px;
  }

  .solution-option {
    grid-template-columns: 1fr;
  }
}
