:root {
  --ink: #24323a;
  --muted: #68757a;
  --paper: #fffdfa;
  --paper-deep: #f5eee7;
  --line: #e5d9ce;
  --coral: #ed7569;
  --coral-deep: #c9504d;
  --coral-pale: #fff0ea;
  --teal: #277d7c;
  --teal-pale: #e7f3ef;
  --yellow: #f1ba5b;
  --shadow: 0 16px 40px rgba(83, 62, 48, .09);
  --radius-lg: 24px;
  --radius-md: 16px;
  --font-sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Yu Gothic", "YuGothic", "Noto Sans JP", sans-serif;
  --font-display: Georgia, "Times New Roman", "Hiragino Mincho ProN", "Yu Mincho", serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 4% 10%, rgba(237, 117, 105, .08), transparent 26rem),
    linear-gradient(180deg, #fffaf5 0%, #f9f4ee 42%, #fffdfa 100%);
  font-family: var(--font-sans);
  line-height: 1.65;
}

button, input, select { font: inherit; }
button, label.button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
a { color: inherit; }
:focus-visible { outline: 3px solid rgba(39, 125, 124, .5); outline-offset: 3px; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }

.site-header, main, .site-footer { width: min(1180px, calc(100% - 40px)); margin-inline: auto; }
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 82px;
  border-bottom: 1px solid rgba(229, 217, 206, .75);
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px 12px 12px 4px;
  color: white;
  background: var(--coral);
  font-family: var(--font-display);
  font-size: 21px;
  box-shadow: 4px 4px 0 rgba(201, 80, 77, .15);
}
.brand strong, .brand small { display: block; line-height: 1.2; }
.brand strong { font-size: 14px; letter-spacing: .04em; }
.brand small { margin-top: 4px; color: var(--muted); font-size: 9px; letter-spacing: .2em; }
.site-header nav { display: flex; gap: 24px; color: var(--muted); font-size: 13px; }
.site-header nav a { text-decoration: none; }
.site-header nav a:hover { color: var(--coral-deep); }

.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, .72fr); align-items: center; gap: clamp(24px, 6vw, 64px); padding: 56px 0 40px; }
.eyebrow, .step-label, .aside-kicker { margin: 0; color: var(--coral-deep); font-size: 11px; font-weight: 800; letter-spacing: .18em; }
.hero h1, h2, h3 { letter-spacing: -.025em; }
.hero-tagline { margin: 0 0 8px; color: var(--coral-deep); font-size: 12px; font-weight: 800; letter-spacing: .04em; }
.hero h1 { max-width: 540px; margin: 0 0 14px; font-family: var(--font-display); font-size: clamp(28px, 3.4vw, 42px); font-weight: 500; line-height: 1.25; word-break: auto-phrase; }
.hero h1 em { color: var(--coral-deep); font-style: normal; }
.hero-lede { max-width: 480px; margin: 0 0 18px; color: #5f6c70; font-size: 15px; }
.hero-cta { min-width: 168px; }
.hero-sample { margin: 0; padding: 16px 18px 14px; border: 1px solid var(--line); border-radius: var(--radius-md); background: rgba(255,255,255,.75); box-shadow: var(--shadow); }
.hero-sample-kicker { margin: 0 0 6px; color: var(--coral-deep); font-size: 11px; font-weight: 800; letter-spacing: .06em; }
.hero-sample-input { margin: 0 0 10px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.hero-sample-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.hero-sample-table th, .hero-sample-table td { padding: 6px 5px; border-top: 1px solid #eee5de; text-align: left; }
.hero-sample-table th { color: var(--muted); font-size: 10px; font-weight: 800; }
.hero-sample-table th:last-child, .hero-sample-table td.amount { text-align: right; }
.hero-sample-table td.amount { color: var(--coral-deep); font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }

.intro-strip { padding: 14px 20px; border: 1px solid var(--line); border-radius: var(--radius-md); background: rgba(255, 253, 250, .7); }
.intro-steps { display: flex; align-items: center; gap: 18px; margin: 0; padding: 0; list-style: none; }
.intro-steps li { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 0; }
.intro-steps li > span { display: grid; place-items: center; flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%; color: white; background: var(--teal); font-size: 12px; font-weight: 800; }
.intro-steps p { margin: 0; }
.intro-steps strong, .intro-steps small { display: block; line-height: 1.35; }
.intro-steps strong { font-size: 12px; }
.intro-steps small { color: var(--muted); font-size: 10px; }
.hero-privacy-note { margin: 10px 0 0; color: var(--muted); font-size: 10px; letter-spacing: .01em; }

.workspace { margin-top: 76px; }
.section-heading, .form-section-heading, .result-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; }
h2 { margin: 5px 0 0; font-family: var(--font-display); font-size: clamp(28px, 3.4vw, 43px); font-weight: 500; line-height: 1.18; }
h3 { margin: 3px 0 0; font-size: 20px; line-height: 1.35; }
.section-note, .helper-text, .form-footnote { color: var(--muted); font-size: 12px; }
.section-note { margin: 0 0 4px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 26px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-md); background: rgba(255,255,255,.66); }
.toolbar-group { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.toolbar-group-end { margin-left: auto; }
.toolbar-label { margin-right: 4px; color: var(--muted); font-size: 11px; font-weight: 700; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 9px 15px; border: 1px solid transparent; border-radius: 10px; font-size: 13px; font-weight: 700; line-height: 1.2; text-decoration: none; transition: transform .18s ease, background-color .18s ease, border-color .18s ease; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button-primary { color: white; background: var(--teal); box-shadow: 0 6px 15px rgba(39, 125, 124, .2); }
.button-coral { color: white; background: var(--coral); }
.button-coral:hover:not(:disabled) { background: var(--coral-deep); }
.button-quiet { border-color: var(--line); color: var(--ink); background: rgba(255,255,255,.72); }
.button-quiet:hover:not(:disabled), .button-outline:hover:not(:disabled) { border-color: var(--teal); color: var(--teal); }
.button-outline { border-color: #bfd5cf; color: var(--teal); background: var(--teal-pale); }
.file-button input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; clip-path: inset(50%); }
.draft-status { min-height: 20px; margin: 8px 3px 0; color: var(--teal); font-size: 12px; }

.error-summary { margin-top: 18px; padding: 14px 16px; border: 1px solid #e4aaa2; border-radius: 13px; color: #7b3435; background: #fff1ef; }
.error-summary p { margin: 0 0 4px; font-weight: 800; }
.error-summary ul { margin: 5px 0 0; padding-left: 20px; }
.error-summary li { margin: 2px 0; }
.error-link { padding: 0; border: 0; color: inherit; background: transparent; text-decoration: underline; cursor: pointer; font-size: inherit; text-align: left; }

.calculator-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(260px, .55fr); align-items: start; gap: 24px; margin-top: 24px; }
.form-panel, .result-section { padding: clamp(20px, 3vw, 34px); border: 1px solid var(--line); border-radius: var(--radius-lg); background: rgba(255, 253, 250, .93); box-shadow: var(--shadow); }
.form-section + .form-section { margin-top: 34px; padding-top: 30px; border-top: 1px dashed var(--line); }
.form-section-heading { align-items: center; }
.step-label { font-size: 10px; letter-spacing: .16em; }
.count-badge { padding: 4px 9px; border-radius: 99px; color: var(--teal); background: var(--teal-pale); font-size: 11px; font-weight: 800; }
.helper-text { margin: 7px 0 16px; }
.people-list, .payments-list { display: grid; gap: 10px; }
.person-row, .payment-card { position: relative; padding: 15px; border: 1px solid var(--line); border-radius: var(--radius-md); background: #fff; }
.person-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: end; }
.row-number { margin: 0 0 6px; color: var(--coral-deep); font-size: 10px; font-weight: 800; letter-spacing: .12em; }
.field-label, .payment-card label { display: grid; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 700; }
input[type="text"], input[type="number"], select { width: 100%; min-height: 44px; padding: 9px 11px; border: 1px solid #d8cdc3; border-radius: 9px; color: var(--ink); background: #fffdfa; font-size: 16px; }
input[type="number"] { font-variant-numeric: tabular-nums; }
input::placeholder { color: #a1aaa9; }
input:focus, select:focus { border-color: var(--teal); outline: 3px solid rgba(39, 125, 124, .12); }
.remove-button { align-self: end; min-height: 44px; padding: 9px 10px; border: 0; border-radius: 9px; color: #8c5b5b; background: #fff0ed; font-size: 12px; }
.remove-button:hover:not(:disabled) { background: #ffe3dd; }
.add-button { width: 100%; margin-top: 12px; }
.participant-fieldset { min-width: 0; margin: 25px 0 0; padding: 17px; border: 1px solid #cde2dc; border-radius: var(--radius-md); background: #f7fcfa; }
.participant-fieldset legend { padding: 0 6px; color: var(--teal); font-size: 13px; font-weight: 800; }
.participant-fieldset .helper-text { margin: 0 0 12px; }
.participant-list { display: flex; flex-wrap: wrap; gap: 8px; }
.participant-option { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; padding: 8px 11px; border: 1px solid #cde2dc; border-radius: 10px; color: var(--ink); background: #fff; font-size: 13px; cursor: pointer; }
.participant-option:has(input:checked) { border-color: var(--teal); color: var(--teal); background: #e9f6f1; }
.participant-option input { width: 18px; height: 18px; accent-color: var(--teal); }
.payment-card { padding-top: 18px; }
.payment-card + .payment-card { margin-top: 2px; }
.payment-topline { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 13px; }
.payment-index { color: var(--coral-deep); font-size: 10px; font-weight: 800; letter-spacing: .14em; }
.payment-meta { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(135px, .65fr) minmax(140px, .8fr); gap: 10px; }
.weight-fieldset { min-width: 0; margin: 16px 0 0; padding: 13px; border: 1px dashed #decfc3; border-radius: 12px; background: #fffcf9; }
.weight-fieldset legend { padding: 0 5px; color: var(--muted); font-size: 11px; font-weight: 800; }
.weight-help { margin: -2px 0 10px; color: var(--muted); font-size: 11px; }
.weight-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.weight-input { display: grid; gap: 4px; }
.weight-input span { overflow: hidden; color: var(--ink); font-size: 11px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.weight-input input { min-height: 42px; }
.form-actions { margin-top: 30px; padding-top: 24px; border-top: 1px solid var(--line); }
.calculate-button { width: 100%; min-height: 54px; font-size: 15px; }
.form-footnote { margin: 10px 0 0; text-align: center; }

.calculation-aside { display: grid; gap: 14px; }
.aside-card { padding: 22px; border-radius: var(--radius-lg); }
.coral-card { color: #fffaf4; background: var(--coral); box-shadow: 0 12px 28px rgba(201, 80, 77, .18); }
.coral-card .aside-kicker { color: #ffe0d7; }
.paper-card { border: 1px solid var(--line); background: var(--paper); }
.aside-card h3 { margin: 10px 0 10px; font-family: var(--font-display); font-size: 24px; font-weight: 500; }
.aside-card p:not(.aside-kicker) { margin: 0; font-size: 13px; }
.equation { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 20px; padding: 13px 9px; border: 1px solid rgba(255,255,255,.3); border-radius: 11px; font-size: 12px; font-weight: 800; text-align: center; }
.equation b { opacity: .7; font-size: 17px; }
.check-list { display: grid; gap: 9px; margin: 16px 0 0; padding: 0; list-style: none; color: var(--muted); font-size: 12px; }
.check-list li { position: relative; padding-left: 21px; }
.check-list li::before { position: absolute; left: 0; top: 3px; content: "✓"; color: var(--teal); font-weight: 900; }

.result-section { margin-top: 28px; border-color: #c9dfd8; background: #f9fdfb; }
.result-heading { align-items: flex-start; }
.result-summary { margin: 10px 0 0; color: var(--muted); font-size: 13px; }
.result-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.result-content { display: grid; gap: 17px; margin-top: 25px; }
.result-card { padding: 19px; border: 1px solid var(--line); border-radius: var(--radius-md); background: #fff; }
.result-card h3 { margin: 0; font-size: 16px; }
.result-card-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.result-card-heading small { color: var(--muted); font-size: 11px; }
.total-chip { color: var(--coral-deep); font-size: 16px; font-weight: 900; font-variant-numeric: tabular-nums; }
.allocation-table, .summary-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.allocation-table th, .allocation-table td, .summary-table th, .summary-table td { padding: 9px 7px; border-top: 1px solid #eee5de; text-align: left; vertical-align: top; }
.allocation-table th, .summary-table th { color: var(--muted); font-size: 10px; font-weight: 800; }
.allocation-table td:last-child, .allocation-table th:last-child, .summary-table td:not(:first-child), .summary-table th:not(:first-child) { text-align: right; }
.share-list { display: flex; flex-wrap: wrap; gap: 5px; }
.share-chip { padding: 3px 7px; border-radius: 99px; color: var(--teal); background: var(--teal-pale); font-size: 11px; white-space: nowrap; }
.amount { font-variant-numeric: tabular-nums; white-space: nowrap; }
.balance-positive { color: var(--teal); font-weight: 800; }
.balance-negative { color: var(--coral-deep); font-weight: 800; }
.transfer-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.transfer-item { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 11px 12px; border-radius: 10px; background: var(--coral-pale); font-size: 13px; }
.transfer-person { overflow: hidden; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.transfer-arrow { color: var(--coral-deep); }
.transfer-amount { color: var(--coral-deep); font-weight: 900; font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty-transfer { margin: 0; padding: 13px; border-radius: 10px; color: var(--teal); background: var(--teal-pale); font-size: 13px; }
.verification-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
.verification-list li { padding: 9px 11px; border-radius: 9px; color: var(--teal); background: #eff9f5; font-size: 11px; }
.verification-list li::before { content: "✓ "; font-weight: 900; }

.guide-section { margin-top: 88px; padding: 52px 0; border-top: 1px solid var(--line); }
.compact-heading { align-items: end; }
.info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 28px; }
.info-card { min-height: 190px; padding: 21px; border: 1px solid var(--line); border-radius: var(--radius-md); background: rgba(255,255,255,.65); }
.info-number { color: var(--coral); font-size: 11px; font-weight: 900; letter-spacing: .14em; }
.info-card h3 { margin: 11px 0 8px; font-family: var(--font-display); font-size: 20px; font-weight: 500; }
.info-card p { margin: 0; color: var(--muted); font-size: 12px; }
.details-section { display: grid; grid-template-columns: .85fr 1.15fr; gap: 70px; padding: 55px 0 78px; border-top: 1px solid var(--line); }
.details-copy h2 { margin-bottom: 15px; }
.details-copy > p:last-child { max-width: 470px; margin: 0; color: var(--muted); font-size: 13px; }
.details-list { display: grid; gap: 0; }
.details-list div { display: grid; grid-template-columns: 75px 1fr; gap: 15px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.details-list strong { color: var(--teal); }
.details-list span { color: var(--muted); }
.site-footer { display: flex; justify-content: space-between; gap: 20px; padding: 19px 0 28px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.site-footer p { margin: 0; }

@media (max-width: 850px) {
  .hero { grid-template-columns: 1fr; padding-top: 40px; }
  .hero-sample { max-width: 650px; }
  .calculator-grid { grid-template-columns: 1fr; }
  .calculation-aside { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .details-section { gap: 35px; }
}

@media (max-width: 680px) {
  .site-header, main, .site-footer { width: min(100% - 24px, 560px); }
  .site-header { min-height: 70px; }
  .site-header nav { gap: 10px; font-size: 11px; }
  .site-header nav a:last-child { display: none; }
  .hero { gap: 10px; padding: 20px 0 16px; }
  .hero-tagline { display: none; }
  .hero h1 { margin: 0 0 8px; font-size: clamp(24px, 7.5vw, 32px); line-height: 1.3; }
  .hero-lede { margin: 0 0 12px; font-size: 13px; }
  .hero-cta { width: 100%; min-height: 40px; }
  .hero-sample { display: none; }
  .intro-strip { padding: 10px 14px; }
  .intro-steps { flex-direction: column; align-items: flex-start; gap: 7px; }
  .intro-steps li > span { width: 22px; height: 22px; font-size: 10px; }
  .hero-privacy-note { margin-top: 8px; font-size: 9px; }
  .workspace { margin-top: 32px; }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 5px; }
  .section-note { margin: 0; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-group, .toolbar-group-end { width: 100%; margin-left: 0; }
  .toolbar-group .button, .toolbar-group-end .button, .file-button { flex: 1 1 auto; }
  .calculator-grid { gap: 14px; }
  .form-panel, .result-section { padding: 18px 14px; border-radius: 18px; }
  .payment-meta { grid-template-columns: 1fr 1fr; }
  .payment-meta label:first-child { grid-column: 1 / -1; }
  .calculation-aside { grid-template-columns: 1fr; }
  .result-heading { flex-direction: column; }
  .result-actions { justify-content: flex-start; }
  .result-actions .button { flex: 1 1 auto; }
  .allocation-table th:nth-child(2), .allocation-table td:nth-child(2) { display: none; }
  .verification-list { grid-template-columns: 1fr; }
  .info-grid, .details-section { grid-template-columns: 1fr; }
  .info-grid { gap: 10px; }
  .info-card { min-height: 0; }
  .details-section { gap: 25px; }
  .site-footer { flex-direction: column; gap: 6px; }
}

@media (max-width: 360px) {
  .site-header, main, .site-footer { width: calc(100% - 20px); }
  .brand strong { font-size: 12px; }
  .site-header nav { gap: 7px; font-size: 10px; }
  .toolbar-group { display: grid; grid-template-columns: 1fr 1fr; }
  .toolbar-label { grid-column: 1 / -1; }
  .toolbar-group-end { display: grid; grid-template-columns: 1fr 1fr; }
  .toolbar-group-end .file-button { grid-column: 1 / -1; }
  .payment-meta { grid-template-columns: 1fr; }
  .payment-meta label:first-child { grid-column: auto; }
  .details-list div { grid-template-columns: 58px 1fr; gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

@media print {
  body { background: #fff; }
  .no-print, .form-panel, .calculation-aside, .site-header, .site-footer, .hero, .intro-strip, .guide-section, .details-section { display: none !important; }
  main, .workspace { width: 100%; margin: 0; }
  .result-section { display: block !important; margin: 0; padding: 0; border: 0; box-shadow: none; background: #fff; }
  .result-heading { padding-bottom: 15px; border-bottom: 2px solid #333; }
  .result-content { margin-top: 15px; }
  .result-card { break-inside: avoid; box-shadow: none; }
  .share-chip { border: 1px solid #bbb; color: #222; background: #fff; }
}


/* A7: mobile tool heading compression */
@media (max-width: 640px) {
  .workspace { margin-top: 28px; }
  .workspace > .section-heading { gap: 6px; }
  .workspace > .section-heading > div > .eyebrow { display: none; }
  .workspace > .section-heading h2 { margin-top: 0; font-size: clamp(22px, 6vw, 28px); line-height: 1.25; }
  .workspace > .section-heading > .section-note { margin: 5px 0 0; font-size: 11px; line-height: 1.45; }
}


/* Hero CTA contrast adjustment */
.button-coral.hero-cta { background: var(--teal); }
.button-coral.hero-cta:hover:not(:disabled) { background: var(--teal); }
