:root {
  color-scheme: light;
  font: 16px/1.5 "Inter", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #202c26;
  background: #f5f6f2;
  --ink: #202c26;
  --green: #214639;
  --accent: #e9c36f;
  --error: #a43329;
}

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

body {
  margin: 0;
  min-width: 0;
}

.calculator {
  width: min(58rem, calc(100% - 5rem));
  margin: 0 auto;
  padding: 5.5rem 0 4rem;
}

.masthead {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid #d6ddd5;
}

.masthead h1 {
  margin: 0;
  font-size: 2.375rem;
  font-weight: 700;
  line-height: 1.2;
}

.book-mark {
  display: grid;
  grid-template-columns: 1fr 1fr;
  place-content: center;
  flex: 0 0 3rem;
  height: 3rem;
  padding: 0.75rem;
  color: #f5f6f2;
  background: var(--green);
  border-radius: 7px;
}

.book-mark i {
  height: 1.125rem;
  align-self: center;
  border: 1.5px solid currentColor;
}

.book-mark i:first-child {
  border-radius: 2px 4px 1px 2px;
  transform: skewY(9deg);
}

.book-mark i:last-child {
  border-left: 0;
  border-radius: 4px 2px 2px 1px;
  transform: skewY(-9deg);
}

.version {
  align-self: center;
  padding: 0.125rem 0.45rem;
  border: 1px solid #c5d0c6;
  border-radius: 4px;
  color: #435b4d;
  font-size: 0.75rem;
  font-weight: 650;
  line-height: 1.4;
}

.calculator-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: start;
  gap: 3.75rem;
  padding-top: 2rem;
}

form {
  min-width: 0;
  padding-top: 0.125rem;
}

.field + .field {
  margin-top: 1.25rem;
}

label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 650;
}

.input-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  min-height: 3.5rem;
  border: 1px solid #aab7ad;
  border-radius: 6px;
  background: #fff;
}

.input-wrap:focus-within {
  border-color: var(--green);
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.input-wrap:has([aria-invalid="true"]) {
  border-color: var(--error);
}

input {
  width: 100%;
  min-width: 0;
  padding: 0.875rem 1rem;
  border: 0;
  border-radius: 6px;
  outline: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-variant-numeric: tabular-nums;
}

input::placeholder {
  color: #626e65;
  opacity: 1;
}

.input-wrap span {
  padding-right: 1rem;
  color: #4f6256;
  font-size: 0.875rem;
}

.actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(5rem, 30%);
  gap: 0.75rem;
  margin-top: 1.5rem;
}

button {
  min-height: 3rem;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--green);
  border-radius: 6px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

button:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 3px;
}

button[type="submit"] {
  color: #fff;
  background: var(--green);
}

button[type="submit"]:hover {
  background: #305847;
}

button[type="reset"] {
  border-color: #aab7ad;
  color: var(--green);
  background: transparent;
}

button[type="reset"]:hover {
  background: #e7ece5;
}

.form-error {
  margin: 0.625rem 0 0;
  color: var(--error);
  font-size: 0.875rem;
  min-height: 1.3125rem;
}

.result {
  position: relative;
  min-width: 0;
  padding: 2rem;
  border-radius: 8px;
  color: #f9faf4;
  background: #17382e;
}

.result::after {
  position: absolute;
  top: 0;
  right: 2rem;
  width: 1.25rem;
  height: 2.625rem;
  background: var(--accent);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 82%, 0 100%);
  content: "";
}

.result h2 {
  margin: 0 2rem 0 0;
  color: #d4e4d9;
  font-size: 1rem;
  font-weight: 650;
}

.completion {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 0.3125rem;
  margin: 0.75rem 0 1.125rem;
  font-size: 3.5rem;
  font-weight: 550;
  font-variant-numeric: tabular-nums;
  line-height: 1.125;
}

.completion span:first-child {
  overflow-wrap: anywhere;
}

.percent-unit {
  color: var(--accent);
  font-size: 1.625rem;
}

.progress-track {
  height: 0.5rem;
  overflow: hidden;
  border-radius: 999px;
  background: #466357;
}

#progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.remaining {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.375rem 0.75rem;
  margin: 1.625rem 0 0;
  padding-top: 1.125rem;
  border-top: 1px solid #466357;
}

.remaining dt {
  color: #d4e4d9;
  font-size: 0.875rem;
}

.remaining dd {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.page-unit {
  margin-left: 0.375rem;
  color: #d4e4d9;
  font-size: 0.875rem;
  font-weight: 400;
}

@media (max-width: 44rem) {
  .calculator {
    width: calc(100% - 2.5rem);
    padding-top: 2.25rem;
  }

  .masthead {
    gap: 0.625rem;
    padding-bottom: 1.25rem;
  }

  .masthead h1 {
    font-size: 1.625rem;
  }

  .book-mark {
    flex-basis: 2.375rem;
    height: 2.375rem;
    padding: 0.5rem;
  }

  .calculator-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.625rem;
    padding-top: 1.5rem;
  }

  .result {
    padding: 1.5rem;
  }

  .result::after {
    right: 1.5rem;
  }

  .completion {
    font-size: 2.75rem;
  }
}
