::-moz-selection {
  background-color: #D8A068;
  color: #0F202E;
}

::selection {
  background-color: #D8A068;
  color: #0F202E;
}

body {
  margin: 0;
  box-sizing: border-box;
  background-color: #F5EEE1;
  color: #0F202E;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.toastHolder {
  font-family: "Playfair Display", serif;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  border: 1px solid #0F202E;
  background-color: #F5EEE1;
  top: -15rem;
  z-index: 10;
  padding: 1rem;
  border-radius: 5px;
  box-shadow: 2px 2px 2px #D8A068;
  transition-duration: 250ms;
  user-select: none;
}

.down {
  top: 1rem;
}

.heading {
  position: fixed;
  left: 0;
  top: 0;
  border: 0.2rem solid #D8A068;
  background-color: #0F202E;
  color: #F5EEE1;
  margin-block-start: 0;
  margin-block-end: 0;
  padding: 1rem;
  border-radius: 0 0 15px 0;
  z-index: 9;
}

/* ----- Save-state panel (case reference, saved-case dropdown, save/export/import) ----- */
#saveStateHolder {
  position: fixed;
  right: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
  border: 0.2rem solid #0F202E;
  background-color: #0F202E;
  padding: 1rem;
  border-radius: 0 0 0 15px;
  z-index: 9;
  font-family: "Playfair Display", serif;
  min-width: 14rem;
}

.caseRefInput {
  font-family: "Playfair Display", serif;
  font-size: 1rem;
  padding: 0.4rem;
  border-radius: 4px;
  border: none;
  outline: none;
  text-align: center;
  background-color: #F5EEE1;
  color: #0F202E;
}

#savedCasesDropdown {
  font-family: "Playfair Display", serif;
  font-size: 0.9rem;
  padding: 0.4rem;
  border-radius: 4px;
  border: none;
  outline: none;
  background-color: #D8A068;
  color: #0F202E;
  cursor: pointer;
}

.saveStateBtns {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.saveStateBtns button {
  flex: 1 1 auto;
  background-color: #F5EEE1;
  color: #0F202E;
  font-family: "Playfair Display", serif;
  border: 0.15rem solid #F5EEE1;
  border-radius: 5px;
  cursor: pointer;
  padding: 0.35rem 0.6rem;
  font-size: 0.85rem;
  transition-duration: 150ms;
}

.saveStateBtns button:hover {
  background-color: #0F202E;
  color: #F5EEE1;
  border-color: #0F202E;
}

.saveStateBtns button:focus {
  background-color: #D8A068;
  color: #0F202E;
}

.saveStateStatus {
  margin: 0;
  min-height: 1rem;
  font-size: 0.75rem;
  color: #D8A068;
  text-align: center;
  opacity: 0;
  transition: opacity 200ms;
}

.saveStateStatus.visible {
  opacity: 1;
}

.saveMenuToggle {
  display: none;
}

@media (max-width: 1129px) {
  .saveMenuToggle {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 0;
    right: 0;
    z-index: 20;
    height: 3.2rem;
    box-sizing: border-box;
    background-color: #0F202E;
    color: #F5EEE1;
    font-family: "Playfair Display", serif;
    font-size: 1.05rem;
    font-weight: bold;
    border: 0.2rem solid #D8A068;
    border-radius: 0 0 0 15px;
    padding: 0 0.9rem;
    cursor: pointer;
    white-space: nowrap;
  }

  .saveMenuToggle:hover,
  .saveMenuToggle:focus-visible,
  .saveMenuToggle.active {
    background-color: #D8A068;
    color: #0F202E;
  }

  #saveStateHolder {
    position: fixed;
    top: 0;
    left: 50%;
    margin-top: 0;
    border-radius: 15px;
    width: 90%;
    max-width: 20rem;
    box-sizing: border-box;
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    overflow: hidden;
    pointer-events: none;
    transform: translate(-50%, -0.5rem);
    transition: max-height 0.35s ease, opacity 0.25s ease,
      transform 0.3s ease, top 0.3s ease, padding 0.35s ease;
  }

  #saveStateHolder.saveMenuOpen {
    top: 4rem;
    max-height: 28rem;
    opacity: 1;
    padding-top: 1rem;
    padding-bottom: 1rem;
    pointer-events: auto;
    transform: translate(-50%, 0);
  }
}

.tips {
  display: block;
  border: 1px solid #0F202E;
  border-radius: 5px;
  left: 0;
  top: 5rem;
  position: absolute;
  padding: 1rem;
  max-width: 14rem;
  user-select: none;
}

@media (max-width: 1129px) {
  .tips {
    display: none;
  }
}

#figureHolder {
  display: flex;
  flex-direction: column;
  gap: 2vh;
  margin-top: 5rem;
}

#quantums {
  display: flex;
  flex-direction: row;
  gap: 1vh;
  position: relative;
}

#quantums input {
  font-family: Arial, sans-serif;
  border: 0.25vh solid transparent;
  border-bottom: 0.25vh solid #0F202E;
  margin-top: 1vh;
  outline: none;
  cursor: text;
}

.quantumChildren {
  width: 100%;
}

.quantumInputs {
  width: 100%;
  height: 5rem;
  font-size: 1.5rem;
  text-align: center;
  background-color: #D8A068;
  color: #0F202E;
  box-sizing: border-box;
  transition-duration: 150ms;
}

.quantumInputs:focus {
  border: 0.25vh solid #0F202E !important;
}

.quantumInputs::selection {
  background-color: #D8A068;
  color: #0F202E;
}

.quantumInputs::placeholder {
  color: #4A4A4A;
}

.mulNums {
  width: 100%;
  height: 4rem;
  font-size: 1.5rem;
  border: none;
  text-align: center;
  background-color: #F5EEE1;
}

.offerRow {
  width: 100%;
}

.offerInputs {
  width: 100%;
  height: 5rem;
  font-size: 1.5rem;
  text-align: center;
  border-radius: 5px;
  border: 1px solid transparent;
  background-color: #F5EEE1;
  cursor: text;
}

/* Shown when a real offer figure has been typed in directly and is being
   used as the reference point for recalculating other splits */
.manualOverride {
  border: 1px dashed #0F202E !important;
}

#offerFigs {
  display: flex;
  flex-direction: row;
  gap: 1vh;
  position: relative;
}

.offerRow {
  position: relative;
  display: flex;
  flex-direction: row;
}

.toPayment {
  border-color: #0F202E;
  color: #0F202E;
}

.copied {
  position: absolute;
  margin-top: 0.8vh;
  right: 0;
}

#multiples {
  width: 100%;
  display: flex;
  flex-direction: row;
  gap: 1vh;
  position: relative;
}

#multiples input {
  font-family: Arial, sans-serif;
  margin-top: 1vh;
  outline: none;
  cursor: text;
}

#offerFigs input {
  font-family: Arial, sans-serif;
  margin-top: 1vh;
  outline: none;
  cursor: text;
}

.slidecontainer {
  margin-top: 5vh;
}

.slider {
  -webkit-appearance: none; /* Override default CSS styles */
  -moz-appearance: none;
  appearance: none;
  width: 100%; /* Full-width */
  height: 52px; /* Specified height */
  background: #F5EEE1; /* Grey background */
  outline: none; /* Remove outline */
  box-sizing: border-box;
  border: 1px solid #0F202E;
  border-radius: 5px;
  opacity: 0.7; /* Set transparency (for mouse-over effects on hover) */ /* 0.2 seconds transition on hover */
  transition: opacity 0.2s;
}

.slider:hover {
  opacity: 1; /* Fully shown on mouse-over */
}

/* The slider handle (use -webkit- (Chrome, Opera, Safari, Edge) and -moz- (Firefox) to override default look) */
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; /* Override default look */
  appearance: none;
  width: 50px; /* Set a specific slider handle width */
  height: 50px; /* Slider handle height */
  background: #0F202E; /* Green background */
  border-radius: 5px;
  cursor: pointer; /* Cursor on hover */
}

.slider::-moz-range-thumb {
  width: 50px; /* Set a specific slider handle width */
  height: 50px; /* Slider handle height */
  background: #0F202E; /* Green background */
  border-radius: 5px;
  cursor: pointer; /* Cursor on hover */
}

#intHolder {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1vh;
  font-family: "Playfair Display", serif;
}

.intInputs {
  display: flex;
  flex-direction: column;
  gap: 1vh;
  justify-content: center;
}

.selects {
  display: flex;
  flex-direction: row;
  justify-content: center;
  gap: 1rem;
}

.intInputs input {
  font-family: "Playfair Display", serif;
  border: none;
  border-bottom: 0.25vh solid #0F202E;
  margin-top: 1vh;
  outline: none;
  cursor: text;
  background-color: #F5EEE1;
  font-size: 1.2rem;
}

#intHolder select {
  font-family: "Playfair Display", serif;
  font-size: 1.5rem;
  background-color: #F5EEE1;
  color: #0F202E;
  outline: none;
  border: none;
  border-bottom: 0.15rem solid #0F202E;
  -webkit-appearance: none;
  -moz-appearance: none;
  text-indent: 1px;
  text-overflow: "";
  cursor: pointer;
  font-weight: bold;
  text-align: center;
}

#ciPortion {
  display: flex;
  flex-direction: column;
  gap: 1vh;
  position: relative;
}

#ciPortion input {
  width: 100%;
  font-family: Arial, sans-serif;
  border: 0.25vh solid transparent;
  margin-top: 1vh;
  outline: none;
  cursor: text;
  text-align: center;
}

.costs {
  display: flex;
  flex-direction: row;
  gap: 1vh;
}

.costs input {
  background-color: #D8A068;
  border-bottom: 0.25vh solid #0F202E;
}

.interest {
  display: flex;
  flex-direction: row;
  gap: 1vh;
}

.interest input {
  background-color: #F5EEE1;
}

.totals {
  display: flex;
  flex-direction: row;
  gap: 1vh;
}

.totals input {
  background-color: #F5EEE1;
}

#totOffset {
  font-size: 1.5rem;
  font-family: "Playfair Display", serif;
  border: 0.25vh solid transparent;
  margin-top: 1vh;
  outline: none;
  cursor: text;
  text-align: center;
  background-color: #F5EEE1;
}

.hide {
  display: none;
}

#calcCostsBtn {
  background-color: #0F202E;
  color: #F5EEE1;
  font-family: "Playfair Display", serif;
  border-radius: 5px;
  cursor: pointer;
  border: 0.25vh solid #0F202E;
  transition-duration: 150ms;
}

#calcCostsBtn:focus {
  background-color: #F5EEE1;
  color: #0F202E;
}

/* ===================================================================
   MOBILE / SMALL-SCREEN FIXES ONLY
   Everything below only applies at <=1129px (the same breakpoint the
   layout already switches to a stacked, non-fixed save panel at) and
   never touches the desktop rules above.
   =================================================================== */
@media (max-width: 1129px) {
  html {
    overflow-x: hidden;
  }

  body {
    width: 100%;
    box-sizing: border-box;
    padding: 0 1rem;
  }

  /* Keep the title fixed top-left as on desktop, just shrink and
     stabilise its height so we can reliably reserve clear space below
     it (see #saveStateHolder margin-top above), and match the height
     of the "Save menu" toggle on the opposite corner */
  .heading {
    height: 3.2rem;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    font-size: 1.05rem;
    padding: 0 0.9rem;
    white-space: nowrap;
  }

  #figureHolder {
    margin-top: 4.5rem;
    width: 100%;
    max-width: 26rem;
    box-sizing: border-box;
    padding: 0 0.25rem;
  }

  /* Let the two-column rows wrap and shrink instead of overflowing
     the viewport width */
  #quantums,
  #multiples,
  #offerFigs,
  .costs,
  .interest,
  .totals {
    flex-wrap: wrap;
  }

  .quantumChildren,
  .offerRow {
    flex: 1 1 45%;
    min-width: 0;
  }

  #multiples input,
  .costs input,
  .interest input,
  .totals input {
    min-width: 0;
    flex: 1 1 45%;
    box-sizing: border-box;
  }

  .quantumInputs {
    font-size: 1.15rem;
    height: 4rem;
  }

  .mulNums {
    font-size: 1.1rem;
    height: 3.25rem;
  }

  .offerInputs {
    font-size: 1.15rem;
    height: 4rem;
  }

  #totOffset {
    width: 100%;
    box-sizing: border-box;
    font-size: 1.25rem;
  }

  #calcCostsBtn {
    width: 100%;
    box-sizing: border-box;
    padding: 0.6rem 0;
    font-size: 1rem;
  }

  #intHolder,
  #ciPortion {
    width: 100%;
    box-sizing: border-box;
  }

  .selects {
    flex-wrap: wrap;
  }

  #intHolder select {
    font-size: 1.1rem;
  }

  .intInputs input {
    width: 100%;
    box-sizing: border-box;
  }
}
