/* Page-specific adjustments. The shared tool surface is loaded first. */
.r8-phase4b:has(#r8-furu-form) { --tool-hero-icon: url("../img/home/gift.svg"); }
.r8-phase4b:has(#r8-res-form) { --tool-hero-icon: url("../img/home/house.svg"); }
.r8-phase4b:has(#r8-sole-form) { --tool-hero-icon: url("../img/home/clipboard.svg"); }
.r8-phase4b:has(#r8-ye-form) { --tool-hero-icon: url("../img/home/calendar.svg"); }

.r8-phase4b .r8-calculator :is(.r8-field, select, textarea),
.r8-phase4b .r8-calculator .r8-fields > * { min-width: 0; }
.r8-phase4b .r8-calculator .r8-field-heading { align-items: start; }
.r8-phase4b .r8-calculator textarea {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  border-radius: 8px;
  font-size: 16px;
}
.r8-phase4b .r8-calculator :is(select, textarea):focus-visible {
  outline: 2px solid var(--tool-green);
  outline-offset: 2px;
}
.r8-phase4b .r8-calculator .r8-field:has(:is(#r8-ye-employment, #r8-ye-exception, #r8-ye-mode, #r8-sole-businessCondition, #r8-res-youngSpecial)) {
  grid-column: 1 / -1;
}
.r8-phase4b #r8-furu-form .r8-year-end { background: var(--tool-surface); }
.r8-phase4b #r8-furu-form .r8-year-end .choice { padding: 4px 0; }
.r8-phase4b #r8-furu-transfer:not([hidden]) { margin-block-end: 12px; background: var(--tool-surface); }
.r8-phase4b :is(#r8-ye-prior, #r8-ye-later):not([hidden]) {
  padding: 4px 11px;
  border: 1px solid var(--tool-line);
  border-radius: 8px;
  background: var(--tool-soft);
}
.r8-phase4b #r8-ye-withheld-note { background: var(--tool-surface); }
.r8-phase4b #r8-ye-error:not([hidden]) {
  margin: 10px 0;
  padding: 10px 12px;
  border: 1px solid #dfadb7;
  border-radius: 9px;
  background: #fff1f3;
  color: #912638;
}
.r8-phase4b #r8-furu-donation {
  min-height: 44px;
  width: 100%;
  font-size: 16px;
}
.r8-phase4b #r8-ye-main:not(:empty) {
  margin: 0 0 12px;
  padding: 16px 15px 16px clamp(48px, 5vw, 73px);
  border-radius: 11px;
  background:
    url("../img/home/coins.svg") 14px center / clamp(24px, 3vw, 36px) no-repeat,
    linear-gradient(120deg, #e9f7e9, #dcf2e3);
  color: var(--tool-green);
  font-size: clamp(20px, 2.45vw, 34px);
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}
.r8-phase4b :is(#r8-res-results, .r8-sole-list, #r8-ye-rows):not(:empty) {
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  margin: 12px 0;
  padding: 4px 11px;
  border: 1px solid var(--tool-line);
  border-radius: 9px;
  background: var(--tool-surface);
}
.r8-phase4b :is(#r8-res-results, .r8-sole-list, #r8-ye-rows) > div {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 8px;
  border-color: var(--tool-line);
  font-size: 14px;
}
.r8-phase4b :is(#r8-res-results, .r8-sole-list, #r8-ye-rows) > div:last-child { border-bottom: 0; }
.r8-phase4b :is(#r8-res-results, .r8-sole-list, #r8-ye-rows) dd {
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: end;
}
.r8-phase4b #r8-furu-result > h3 {
  margin-block: 17px 9px;
  padding-block-start: 12px;
  border-block-start: 1px solid var(--tool-line);
  color: var(--tool-green);
}
.r8-phase4b #r8-furu-donation-output:not(:empty) { margin-top: 10px; }
.r8-phase4b #r8-sole-comparison { --tool-section-icon: url("../img/home/calculator.svg"); }
.r8-phase4b .r8-sole-table { border: 1px solid var(--tool-line); border-radius: 8px; }
.r8-phase4b .r8-sole-table table { margin: 0; font-variant-numeric: tabular-nums; }
.r8-phase4b .r8-sole-table thead th { background: var(--tool-green); color: #fff; }
.r8-phase4b .r8-sole-table :is(td, th) { padding: 9px 10px; }
.r8-phase4b .r8-sole-table td { text-align: end; white-space: nowrap; }

@media (max-width: 410px) {
  .r8-phase4b .r8-hero:has(> .r8-phase4a-hero-art) > div { min-width: 0; }
  .r8-phase4b :is(#r8-res-results, .r8-sole-list, #r8-ye-rows) > div { font-size: 13px; }
}
