.rhd-root {
  display: grid;
  gap: 0;
  width: 100%;
  border: 1px solid #d9ded8;
  border-radius: 8px;
  background: #fbfcfb;
  color: #171a1d;
  overflow: hidden;
}

.rhd-input-panel,
.rhd-output-panel,
.rhd-safety,
.rhd-checklist {
  border: 0;
  border-bottom: 1px solid #e4e8e4;
  border-radius: 0;
  background: transparent;
  padding: 0.8rem;
}

.rhd-checklist {
  border-bottom: 0;
}

.rhd-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.7rem;
}

.rhd-toolbar strong,
.rhd-safety h3,
.rhd-checklist h3 {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.2;
}

.rhd-unit-toggle {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(3.25rem, 1fr));
  border: 1px solid #b8c2ba;
  border-radius: 7px;
  overflow: hidden;
  background: #f1f3f2;
}

.rhd-unit-toggle button {
  border: 0;
  background: transparent;
  color: #344039;
  cursor: pointer;
  font: inherit;
  font-size: 0.8rem;
  padding: 0.32rem 0.6rem;
}

.rhd-unit-toggle button.is-active {
  background: #245b45;
  color: #fff;
}

.rhd-grid {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.rhd-field,
.rhd-select-field {
  display: grid;
  gap: 0.25rem;
}

.rhd-field span,
.rhd-select-field span,
.rhd-primary-results span,
.rhd-saving span,
.rhd-breakdown span {
  color: #5b665f;
  font-size: 0.8rem;
}

.rhd-field b {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  border: 1px solid #c8d0ca;
  border-radius: 8px;
  background: #fff;
}

.rhd-select-wrap {
  position: relative;
  display: block;
  border: 1px solid #c8d0ca;
  border-radius: 8px;
  background: linear-gradient(180deg, #fff, #f6f8f6);
  box-shadow: inset 0 -1px 0 rgba(23, 26, 29, 0.04);
}

.rhd-select-wrap::after {
  position: absolute;
  top: 50%;
  right: 0.7rem;
  width: 0.48rem;
  height: 0.48rem;
  border-right: 2px solid #536057;
  border-bottom: 2px solid #536057;
  content: "";
  pointer-events: none;
  transform: translateY(-65%) rotate(45deg);
}

.rhd-field input,
.rhd-select-field select {
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  min-height: 2.25rem;
  padding: 0.42rem 2rem 0.42rem 0.6rem;
}

.rhd-select-field select {
  appearance: none;
  cursor: pointer;
}

.rhd-select-field select:focus,
.rhd-field input:focus {
  outline: none;
}

.rhd-select-wrap:focus-within,
.rhd-field b:focus-within {
  border-color: #2f6f58;
  box-shadow: 0 0 0 3px rgba(47, 111, 88, 0.16);
}

.rhd-select-field option {
  background: #fff;
  color: #171a1d;
}

.rhd-field input {
  border: 0;
  min-width: 0;
  padding-right: 0.2rem;
}

.rhd-field em {
  color: #5b665f;
  font-style: normal;
  padding-right: 0.6rem;
  white-space: nowrap;
}

.rhd-output-panel {
  display: grid;
  gap: 0.7rem;
}

.rhd-primary-results,
.rhd-breakdown {
  display: grid;
  gap: 0.55rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.rhd-primary-results div,
.rhd-breakdown div {
  display: grid;
  gap: 0.15rem;
  border-left: 2px solid #3f7a60;
  padding-left: 0.55rem;
}

.rhd-primary-results strong,
.rhd-saving strong,
.rhd-breakdown b {
  color: #111713;
  font-size: clamp(1rem, 1.5vw, 1.25rem);
  line-height: 1.2;
}

.rhd-saving {
  display: grid;
  gap: 0.18rem;
  border: 0;
  border-top: 1px solid #e4e8e4;
  border-bottom: 1px solid #e4e8e4;
  border-radius: 0;
  background: #f4f7f5;
  margin: 0 -0.8rem;
  padding: 0.65rem 0.8rem;
}

.rhd-saving small {
  color: #4d6558;
  line-height: 1.45;
}

.rhd-safety {
  background: #fffdf5;
}

.rhd-safety p,
.rhd-checklist li {
  color: #424b45;
  line-height: 1.4;
}

.rhd-safety p {
  margin: 0.4rem 0 0;
  font-size: 0.9rem;
}

.rhd-help-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.rhd-help {
  display: inline-grid;
  width: 1rem;
  height: 1rem;
  place-items: center;
  border: 1px solid #b9c4bd;
  border-radius: 50%;
  background: #fff;
  color: #536057;
  cursor: help;
  font: inherit;
  font-size: 0.68rem;
  line-height: 1;
  padding: 0;
}

.rhd-help:focus {
  outline: 2px solid rgba(47, 111, 88, 0.35);
  outline-offset: 2px;
}

.rhd-drain-note {
  margin-top: 0.45rem;
  border-left: 2px solid #b99735;
  background: rgba(185, 151, 53, 0.1);
  color: #4f4429;
  font-size: 0.86rem;
  line-height: 1.4;
  padding: 0.42rem 0.55rem;
}

.rhd-checklist ul {
  display: grid;
  gap: 0.3rem;
  margin: 0.5rem 0 0;
  padding-left: 1.1rem;
}

.theme-dark .rhd-root {
  border-color: #30363d;
  background: #161b22;
  color: #e8eaed;
}

.theme-dark .rhd-input-panel,
.theme-dark .rhd-output-panel,
.theme-dark .rhd-checklist {
  border-bottom-color: #30363d;
  background: transparent;
}

.theme-dark .rhd-field b,
.theme-dark .rhd-select-wrap {
  border-color: #30363d;
  background: #0d1117;
  color: #e8eaed;
}

.theme-dark .rhd-select-wrap {
  background: linear-gradient(180deg, #151b23, #0d1117);
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.04);
}

.theme-dark .rhd-field input,
.theme-dark .rhd-select-field select {
  color: #e8eaed;
}

.theme-dark .rhd-select-wrap::after {
  border-color: #b8c0cc;
}

.theme-dark .rhd-select-wrap:focus-within,
.theme-dark .rhd-field b:focus-within {
  border-color: #4c9a7c;
  box-shadow: 0 0 0 3px rgba(76, 154, 124, 0.2);
}

.theme-dark .rhd-select-field option {
  background: #161b22;
  color: #e8eaed;
}

.theme-dark .rhd-unit-toggle {
  border-color: #30363d;
  background: #0d1117;
}

.theme-dark .rhd-unit-toggle button {
  color: #b8c0cc;
}

.theme-dark .rhd-unit-toggle button.is-active {
  background: #2f6f58;
  color: #f3f7f5;
}

.theme-dark .rhd-field span,
.theme-dark .rhd-select-field span,
.theme-dark .rhd-primary-results span,
.theme-dark .rhd-saving span,
.theme-dark .rhd-breakdown span,
.theme-dark .rhd-field em {
  color: #aebbb2;
}

.theme-dark .rhd-primary-results strong,
.theme-dark .rhd-saving strong,
.theme-dark .rhd-breakdown b {
  color: #f0f3f6;
}

.theme-dark .rhd-saving {
  border-top-color: #30363d;
  border-bottom-color: #30363d;
  background: #111820;
}

.theme-dark .rhd-saving small,
.theme-dark .rhd-checklist li {
  color: #b8c0cc;
}

.theme-dark .rhd-safety {
  background: #1d1a14;
}

.theme-dark .rhd-safety p {
  color: #d7c9a6;
}

.theme-dark .rhd-help {
  border-color: #48515c;
  background: #0d1117;
  color: #b8c0cc;
}

.theme-dark .rhd-help:focus {
  outline-color: rgba(76, 154, 124, 0.4);
}

.theme-dark .rhd-drain-note {
  border-color: #8f783c;
  background: rgba(143, 120, 60, 0.14);
  color: #d7c9a6;
}

@media (max-width: 720px) {
  .rhd-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .rhd-grid,
  .rhd-primary-results,
  .rhd-breakdown {
    grid-template-columns: 1fr;
  }
}
