:root {
  color-scheme: light;
  --brand: #a9472a;
  --brand-dark: #85371f;
  --brand-soft: #fff4ef;
  --ink: #20201e;
  --ink-soft: #66625d;
  --line: #e7e2dc;
  --surface: #ffffff;
  --surface-muted: #f6f4f1;
  --warning: #9b5b13;
  --warning-bg: #fff7e8;
  --shadow: 0 12px 36px rgba(45, 35, 27, 0.07);
  --radius: 18px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background: var(--surface-muted);
}

body {
  min-width: 320px;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 88% 0%, rgba(169, 71, 42, 0.08), transparent 260px),
    var(--surface-muted);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button,
input,
select {
  font: inherit;
}

button,
select,
a {
  -webkit-tap-highlight-color: transparent;
}

.page-shell {
  width: min(100% - 32px, 640px);
  margin-inline: auto;
}

.site-header {
  height: 48px;
  border-bottom: 1px solid rgba(231, 226, 220, 0.8);
  background: rgba(255, 255, 255, 0.92);
}

.header-inner {
  display: flex;
  height: 100%;
  align-items: center;
  justify-content: space-between;
}

.brand {
  color: var(--brand);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-decoration: none;
}

.brand-slogan {
  color: #776f68;
  font-size: 11px;
  font-weight: 550;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.intro {
  padding: 16px 4px 13px;
}

.subtitle,
.intro h1 {
  margin: 0;
}

.intro h1 {
  font-size: clamp(25px, 7vw, 31px);
  line-height: 1.25;
  letter-spacing: -0.025em;
}

.subtitle {
  margin-top: 3px;
  color: var(--ink-soft);
  font-size: 15px;
}

.calculator-card,
.result-card,
.result-hero {
  border: 1px solid rgba(231, 226, 220, 0.95);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.calculator-card {
  padding: 16px;
}

.area-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-field {
  position: relative;
  margin-bottom: 9px;
}

.form-field > label,
.label-with-help > label {
  display: inline-block;
  margin-bottom: 7px;
  color: #34322f;
  font-size: 14px;
  font-weight: 700;
}

.input-with-unit,
.select-wrap {
  position: relative;
}

input,
select {
  width: 100%;
  height: 48px;
  border: 1px solid #dcd6cf;
  border-radius: 11px;
  outline: none;
  color: var(--ink);
  background: #fbfaf8;
  font-size: 16px;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input {
  padding: 0 42px 0 13px;
}

select {
  appearance: none;
  padding: 0 44px 0 13px;
  cursor: pointer;
}

input:focus,
select:focus {
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(169, 71, 42, 0.12);
}

input[aria-invalid="true"],
select[aria-invalid="true"] {
  border-color: #bd3f32;
}

.input-with-unit > span {
  position: absolute;
  top: 50%;
  right: 13px;
  color: #79736c;
  font-size: 14px;
  transform: translateY(-50%);
  pointer-events: none;
}

.select-wrap::after {
  position: absolute;
  top: 50%;
  right: 15px;
  width: 7px;
  height: 7px;
  border-right: 1.5px solid #77716a;
  border-bottom: 1.5px solid #77716a;
  content: "";
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.field-help-text,
.form-note {
  margin: 4px 2px 0;
  font-size: 12px;
  line-height: 1.4;
}

.field-help-text,
.form-note {
  color: #837d76;
}

.field-error {
  margin: 0 2px;
  min-height: 0;
  color: #b13b30;
  font-size: 12px;
  line-height: 1.4;
}

.field-error:not(:empty) {
  margin-top: 4px;
  min-height: 17px;
}

.label-with-help {
  display: flex;
  align-items: center;
  gap: 7px;
}

.help-popover {
  position: relative;
  margin-top: -7px;
}

.help-popover summary {
  display: grid;
  width: 19px;
  height: 19px;
  border: 1px solid #cfc7be;
  border-radius: 50%;
  color: #777068;
  background: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  list-style: none;
  place-items: center;
}

.help-popover summary::-webkit-details-marker {
  display: none;
}

.help-popover > div {
  position: absolute;
  z-index: 10;
  top: 27px;
  left: -60px;
  width: min(286px, calc(100vw - 48px));
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: #5e5953;
  background: #fff;
  box-shadow: 0 9px 30px rgba(39, 30, 24, 0.15);
  font-size: 12px;
  line-height: 1.7;
}

.inline-warning {
  margin: 4px 0 12px;
  padding: 10px 12px;
  border: 1px solid #f1d39e;
  border-radius: 10px;
  color: var(--warning);
  background: var(--warning-bg);
  font-size: 13px;
}

.form-note {
  margin: 0 0 10px;
  text-align: center;
}

.primary-button,
.secondary-button,
.text-button {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  cursor: pointer;
}

.primary-button {
  width: 100%;
  min-height: 50px;
  padding: 13px 18px;
  border-radius: 12px;
  color: #fff;
  background: var(--brand);
  box-shadow: 0 8px 20px rgba(169, 71, 42, 0.2);
  font-size: 16px;
  font-weight: 750;
  text-decoration: none;
  transition: background 160ms ease, transform 160ms ease;
}

.primary-button:active {
  background: var(--brand-dark);
  transform: translateY(1px);
}

.result-section {
  scroll-margin-top: 0;
  padding-top: 18px;
}

.result-hero {
  position: relative;
  overflow: hidden;
  padding: 24px 22px 20px;
  border-color: #ead7d0;
  background: linear-gradient(145deg, #fff 35%, #fff8f5 100%);
}

.result-hero::after {
  position: absolute;
  top: -55px;
  right: -55px;
  width: 150px;
  height: 150px;
  border: 24px solid rgba(169, 71, 42, 0.04);
  border-radius: 50%;
  content: "";
}

.result-kicker,
.result-total,
.condition-summary {
  margin: 0;
}

.result-kicker {
  color: #6c655f;
  font-size: 14px;
  font-weight: 650;
}

.result-total {
  position: relative;
  z-index: 1;
  margin-top: 3px;
  color: var(--brand);
  font-size: clamp(34px, 10vw, 46px);
  font-weight: 850;
  letter-spacing: -0.05em;
  line-height: 1.18;
}

.unit-price-row {
  display: flex;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #eddfda;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  color: #6c655f;
  font-size: 13px;
}

.unit-price-row strong {
  color: #383431;
  font-size: 17px;
}

.condition-summary {
  margin-top: 12px;
  color: #79726c;
  font-size: 12px;
  line-height: 1.65;
}

.result-card {
  margin-top: 14px;
}

.result-card {
  padding: 20px;
}

.section-heading {
  display: flex;
  margin-bottom: 9px;
  align-items: flex-end;
  justify-content: space-between;
}

.section-index,
.section-heading h2 {
  margin: 0;
}

.section-index {
  color: var(--brand);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.section-heading h2,
.notes-card h2 {
  font-size: 17px;
  line-height: 1.4;
}

.section-heading > span {
  color: #98918a;
  font-size: 11px;
}

.cost-list {
  margin: 0;
}

.cost-list > div {
  display: flex;
  min-height: 43px;
  border-bottom: 1px solid #eeeae5;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
}

.cost-list > div:last-child {
  border-bottom: 0;
}

.cost-list dt {
  color: #625d57;
  font-size: 13px;
}

.cost-list dd {
  margin: 0;
  color: #2d2a27;
  font-size: 14px;
  font-weight: 700;
  text-align: right;
}

.cost-list .cost-total-row {
  margin: 6px -8px -4px;
  padding: 5px 8px 0;
  border-radius: 9px;
  background: var(--brand-soft);
}

.cost-total-row dt,
.cost-total-row dd {
  color: var(--brand);
  font-weight: 800;
}

.notes-card section + section {
  margin-top: 19px;
  padding-top: 18px;
  border-top: 1px solid #eeeae5;
}

.notes-card h2,
.notes-card p {
  margin: 0;
}

.notes-card h2 {
  margin-bottom: 7px;
  font-size: 15px;
}

.notes-card p,
.tag-list {
  color: #716b65;
  font-size: 12px;
}

.tag-list {
  display: flex;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
  gap: 7px;
  list-style: none;
}

.tag-list li {
  padding: 4px 8px;
  border-radius: 6px;
  background: #f3f1ee;
}

.excluded-list {
  line-height: 1.75;
}

.result-actions {
  display: grid;
  margin-top: 12px;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.secondary-button,
.text-button {
  min-height: 52px;
  border-radius: 11px;
  font-size: 14px;
  font-weight: 650;
}

.secondary-button {
  border: 1px solid #dfd8d1;
  color: #4b4641;
  background: #fff;
  gap: 6px;
}

.text-button {
  color: var(--brand);
  background: #f6eae5;
}

.result-cta {
  margin-top: 10px;
  min-height: 58px;
}

.disclaimer {
  margin: 16px 4px 0;
  color: #8b8580;
  font-size: 11px;
  line-height: 1.7;
}

.site-footer {
  padding: 28px 16px calc(28px + env(safe-area-inset-bottom));
  color: #aaa39c;
  font-size: 11px;
  text-align: center;
}

.site-footer p {
  margin: 0;
}

.toast {
  position: fixed;
  z-index: 30;
  right: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  width: max-content;
  max-width: calc(100vw - 40px);
  padding: 10px 16px;
  border-radius: 999px;
  color: #fff;
  background: rgba(32, 32, 30, 0.92);
  box-shadow: 0 7px 24px rgba(0, 0, 0, 0.18);
  font-size: 13px;
  transform: translateX(50%);
}

[hidden] {
  display: none !important;
}

@media (max-width: 370px) {
  .page-shell {
    width: min(100% - 22px, 640px);
  }

  .calculator-card,
  .result-card {
    padding: 17px;
  }

  .area-grid {
    gap: 8px;
  }

  .result-total {
    font-size: 32px;
  }

  .unit-price-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }
}

@media (min-width: 700px) {
  .intro {
    padding-top: 36px;
  }

  .calculator-card,
  .result-card,
  .result-hero {
    border-radius: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
