:root {
  color-scheme: light;
  font-family: system-ui, sans-serif;
  color: #182b27;
  background: #f2f4ef;
  --line: #d8e1d8;
  --muted: #52635d;
  --green: #154739;
  --blue: #1b5490;
  --red: #9c3744;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; line-height: 1.5; }
button, input, select { font: inherit; border-radius: 0; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .48; }
a { color: var(--green); text-underline-offset: .18em; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid #688723;
  outline-offset: 2px;
}

.wrap { width: min(1120px, 100% - 2rem); margin-inline: auto; }
.masthead { padding-block: 2.2rem 2.5rem; background: #153d33; color: #fff; }
.masthead h1 {
  margin: 0;
  font-size: clamp(1.9rem, 5vw, 3rem);
  letter-spacing: -.04em;
  line-height: 1.14;
}
.workspace {
  display: grid;
  grid-template-columns: minmax(250px, 320px) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
  margin-block: 1.5rem;
}
.panel { background: #fff; border: 1px solid var(--line); }
.settings, .crystal, .breakdown { padding: 1.15rem; }
h2 { margin: 0 0 .85rem; font-size: 1.15rem; letter-spacing: -.02em; }
label, legend { display: block; font-size: .875rem; font-weight: 650; }
input, select {
  display: block;
  width: 100%;
  min-width: 0;
  height: 2.6rem;
  margin-top: .3rem;
  padding: .35rem .55rem;
  border: 1px solid #adbbb2;
  background: #fff;
  color: #182b27;
  font-variant-numeric: tabular-nums;
}
fieldset { border: 0; padding: 0; margin: .95rem 0 0; min-width: 0; }
legend { padding: 0; margin-bottom: .25rem; }
.pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
.settings > .pair { margin-top: .95rem; }
.primary {
  width: 100%;
  margin-top: 1.1rem;
  padding: .6rem 1rem;
  border: 1px solid transparent;
  background: var(--green);
  color: #fff;
  font-weight: 700;
}
.primary:hover:not(:disabled) { background: #205d4d; }
#message { color: var(--red); font-size: .9rem; margin: .6rem 0 0; }
#message:empty { display: none; }

.blue { color: var(--blue); }
.red { color: var(--red); }
.crystal-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem; }
.crystal { border-top: 3px solid currentColor; }
.stepper {
  display: grid;
  grid-template-columns: 2.3rem minmax(0, 1fr) 2.3rem;
  gap: .25rem;
  margin-top: .3rem;
}
.stepper button {
  border: 1px solid #adbbb2;
  background: #f4f7f4;
  color: inherit;
  font-size: 1.2rem;
  font-weight: 650;
}
.stepper button:hover:not(:disabled) { background: #e5eee7; }
.stepper input { margin: 0; text-align: center; appearance: textfield; }
.stepper input::-webkit-inner-spin-button,
.stepper input::-webkit-outer-spin-button { appearance: none; margin: 0; }
dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .5rem;
  margin: .9rem 0 0;
  padding-top: .8rem;
  border-top: 1px solid var(--line);
}
dt { color: var(--muted); font-size: .8rem; }
dd {
  margin: .1rem 0 0;
  color: #182b27;
  font-weight: 750;
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.rank-note {
  margin: 0 0 .9rem;
  padding: .7rem .9rem;
  background: #fff5d6;
  border: 1px solid #e5cd86;
  color: #624700;
}
.breakdown { margin-top: .9rem; }
.breakdown p { margin: 0; color: var(--muted); }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: .55rem .35rem; border-bottom: 1px solid var(--line); }
th { font-weight: 650; }
thead { color: var(--muted); font-size: .8rem; }
th, td { text-align: right; }
th:first-child { text-align: left; }
.cost-group th { background: #f2f4ef; font-size: .8rem; }
td { overflow-wrap: anywhere; }
tbody:last-child tr:last-child > * { border-bottom: 0; }
footer { padding-bottom: 1.6rem; color: var(--muted); font-size: .85rem; }

@media (max-width: 740px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 440px) {
  .wrap { width: calc(100% - 1.25rem); }
  .crystal-grid { gap: .5rem; }
  .settings, .crystal, .breakdown { padding: .75rem; }
  .stepper { grid-template-columns: 1.65rem minmax(0, 1fr) 1.65rem; }
  .breakdown table { font-size: .8rem; }
  th, td { padding-inline: .25rem; }
}
