:root {
  color-scheme: light;
  --bg: #ffffff;
  --ink: #102033;
  --muted: #5d7087;
  --line: #c8d8ea;
  --panel: #fbfdff;
  --green: #317DFF;
  --green-dark: #1A59CC;
  --blue: #0b5cad;
  --red: #b33d4a;
  --shadow: 0 10px 28px rgba(49, 125, 255, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Yu Gothic UI", sans-serif;
  font-size: clamp(14px, 3.75vw, 16px);
}

button,
input,
textarea,
select {
  font: inherit;
}

.app-shell {
  width: min(100%, 430px);
  margin: 0 auto;
  padding: clamp(10px, 3.2vw, 14px) clamp(10px, 3.1vw, 12px) 104px;
}

.hero {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: calc(clamp(10px, 3vw, 14px) + env(safe-area-inset-top)) 4px 10px;
  border-bottom: 1px solid rgba(200, 216, 234, 0.78);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
}

.eyebrow,
.step {
  margin: 0 0 7px;
  color: var(--green);
  font-size: clamp(10px, 3.05vw, 12px);
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 5px;
  font-size: clamp(24px, 7.4vw, 32px);
  line-height: 1.06;
  letter-spacing: 0;
}

.brand-block {
  display: grid;
  gap: 6px;
}

.brand-title {
  width: min(100%, 360px);
  height: clamp(56px, 16vw, 72px);
  margin: 0;
  overflow: hidden;
}

.brand-title img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(18px, 5.45vw, 22px);
  line-height: 1.25;
}

h3 {
  margin-bottom: 0;
  font-size: clamp(15px, 4.3vw, 17px);
}

.lead {
  max-width: 26rem;
  margin-bottom: 0;
  color: var(--muted);
  font-size: clamp(12px, 3.55vw, 14px);
  line-height: 1.55;
}

.progress-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.progress-steps li {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: clamp(10px, 3vw, 12px);
  font-weight: 800;
}

.progress-steps li::before,
.progress-steps li::after {
  content: "";
  position: absolute;
  top: 13px;
  height: 3px;
  background: #d8e5f3;
}

.progress-steps li::before {
  right: 50%;
  left: 0;
}

.progress-steps li::after {
  right: 0;
  left: 50%;
}

.progress-steps li:first-child::before,
.progress-steps li:last-child::after {
  display: none;
}

.progress-steps li.done::before,
.progress-steps li.done::after,
.progress-steps li.active::before {
  background: var(--green);
}

.step-dot {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 2px solid #d8e5f3;
  border-radius: 50%;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
}

.progress-steps li.active {
  color: var(--green-dark);
}

.progress-steps li.active .step-dot {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.progress-steps li.done {
  color: var(--green-dark);
}

.progress-steps li.done .step-dot {
  border-color: var(--green);
  background: var(--green);
  color: transparent;
}

.progress-steps li.done .step-dot::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
}

.panel {
  margin: 10px 0;
  padding: clamp(10px, 3.25vw, 13px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(7px, 2.5vw, 10px);
  margin-bottom: 12px;
}

.section-head.compact {
  margin-bottom: 10px;
}

.badge {
  min-width: max-content;
  padding: 5px clamp(7px, 2.3vw, 9px);
  border-radius: 999px;
  background: #e7f1ff;
  color: var(--green-dark);
  font-size: clamp(10px, 2.9vw, 12px);
  font-weight: 800;
}

.badge.accent {
  background: #dcecff;
  color: var(--blue);
}

.badge.error {
  background: #fff0f2;
  color: var(--red);
}

.badge.subtle {
  background: #eef5fc;
  color: var(--muted);
}

.section-note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: clamp(11px, 3.2vw, 13px);
  line-height: 1.5;
}

.upload-box {
  display: grid;
  place-items: center;
  min-height: clamp(116px, 34vw, 132px);
  padding: clamp(11px, 3.5vw, 14px);
  border: 1.5px dashed #8eb2d8;
  border-radius: 8px;
  background: #f5faff;
  text-align: center;
  cursor: pointer;
}

.upload-box input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.upload-icon {
  display: grid;
  place-items: center;
  width: clamp(34px, 9.7vw, 38px);
  height: clamp(34px, 9.7vw, 38px);
  margin-bottom: 8px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: clamp(23px, 7vw, 28px);
  line-height: 1;
}

.upload-box strong {
  font-size: clamp(14px, 4.2vw, 16px);
}

.upload-box small {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.55;
  font-size: clamp(11px, 3.2vw, 13px);
}

.preview {
  width: 100%;
  max-height: 260px;
  margin-top: 12px;
  border-radius: 8px;
  object-fit: cover;
}

.status-message {
  min-height: 1.4em;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: clamp(11px, 3.15vw, 12px);
  line-height: 1.45;
}

.status-message.error {
  color: var(--red);
}

.raw-text {
  width: 100%;
  min-height: 88px;
  margin-top: 10px;
  padding: clamp(8px, 2.8vw, 10px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  resize: vertical;
  line-height: 1.6;
}

.tenancy-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

label span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: clamp(11px, 3.25vw, 13px);
  font-weight: 700;
}

input,
select {
  width: 100%;
  height: clamp(40px, 11.5vw, 44px);
  padding: 0 clamp(7px, 2.4vw, 9px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.items-list {
  display: grid;
  gap: 8px;
}

.item-card {
  position: relative;
  display: grid;
  gap: 8px;
  padding: clamp(8px, 2.8vw, 10px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.item-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(86px, 27vw, 104px);
  gap: clamp(5px, 1.9vw, 7px);
}

.item-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(5px, 1.9vw, 7px);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: clamp(34px, 9.7vw, 38px);
  height: clamp(34px, 9.7vw, 38px);
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-size: 24px;
  cursor: pointer;
}

.remove-btn {
  position: absolute;
  top: -11px;
  right: -11px;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.primary-btn,
.secondary-btn {
  width: 100%;
  min-height: clamp(44px, 12.5vw, 48px);
  border: 0;
  border-radius: 8px;
  font-weight: 800;
  font-size: clamp(14px, 4vw, 16px);
  cursor: pointer;
}

.primary-btn {
  background: var(--green);
  color: #fff;
}

.primary-btn:active,
.secondary-btn:active,
.icon-btn:active {
  transform: translateY(1px);
}

.secondary-btn {
  margin-top: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.add-item-cta {
  margin-top: 10px;
  border-style: dashed;
  color: var(--green-dark);
}

.period-ok-cta {
  margin-top: 10px;
}

.secondary-btn.small {
  width: auto;
  min-height: clamp(32px, 9.4vw, 36px);
  padding: 0 clamp(9px, 3vw, 12px);
  margin-top: 0;
  font-size: clamp(11px, 3.4vw, 13px);
}

.sticky-action {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(32, 33, 36, 0.08);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
}

.sticky-action .primary-btn {
  display: block;
  max-width: 406px;
  margin: 0 auto;
}

.result-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(4px, 1.6vw, 6px);
}

.result-summary div {
  display: grid;
  gap: clamp(3px, 1.3vw, 5px);
  padding: clamp(7px, 2.2vw, 9px) clamp(5px, 1.8vw, 7px);
  border-radius: 8px;
  background: #edf5ff;
}

.result-summary .saving-summary {
  border: 1px solid #f1b8c1;
  background: #fff1f3;
  box-shadow: 0 4px 14px rgba(179, 61, 74, 0.16);
}

.result-summary .saving-summary span {
  color: #8f2834;
}

.result-summary .saving-summary strong {
  color: var(--red);
}

.result-summary span {
  color: var(--muted);
  font-size: clamp(10px, 3vw, 12px);
  font-weight: 700;
}

.result-summary strong {
  font-size: clamp(13px, 4.25vw, 18px);
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.result-rows {
  display: grid;
  gap: 7px;
  margin-top: 12px;
}

.result-row {
  padding: clamp(8px, 2.8vw, 10px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.result-row header,
.result-row .amounts {
  display: grid;
  gap: 6px;
}

.result-row header {
  margin-bottom: 7px;
  font-weight: 800;
  font-size: clamp(14px, 4.1vw, 16px);
}

.result-row .amounts {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(4px, 1.6vw, 6px);
}

.amount-card {
  display: grid;
  gap: 3px;
  padding: clamp(6px, 1.9vw, 7px) clamp(4px, 1.5vw, 5px);
  border-radius: 8px;
  background: #f4f8fd;
}

.amount-card strong {
  color: var(--ink);
  font-size: clamp(12px, 3.55vw, 15px);
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.amount-card.diff strong {
  color: var(--blue);
}

.result-row p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: clamp(11px, 3.15vw, 12px);
  line-height: 1.55;
}

.amounts {
  color: var(--muted);
  font-size: clamp(9px, 2.85vw, 11px);
}

.notice {
  margin-top: 12px;
  padding: clamp(8px, 2.8vw, 10px);
  border-radius: 8px;
  background: #e7f1ff;
}

.notice summary {
  position: relative;
  padding-right: 24px;
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
  list-style: none;
}

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

.notice summary::after {
  content: "+";
  position: absolute;
  top: 50%;
  right: 0;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  color: var(--green-dark);
  font-size: 18px;
  line-height: 1;
  transform: translateY(-50%);
}

.notice[open] summary::after {
  content: "-";
}

.notice p {
  margin: 6px 0 8px;
  color: var(--muted);
  font-size: clamp(11px, 3.15vw, 12px);
  line-height: 1.58;
}

.notice a {
  color: var(--green-dark);
  font-weight: 800;
}

.paid-offer {
  display: grid;
  gap: 9px;
  margin-top: 14px;
  padding: clamp(12px, 3.6vw, 15px);
  border: 1px solid #bfd4eb;
  border-radius: 8px;
  background: #eef7ff;
}

.paid-offer h3 {
  margin: 0;
  line-height: 1.35;
}

.paid-offer p:not(.step) {
  margin: 0;
  color: var(--muted);
  font-size: clamp(11px, 3.2vw, 13px);
  line-height: 1.6;
}

.paid-offer.is-paid {
  border-color: #b7cfe8;
  background: #e8f4ff;
}

.site-footer {
  padding: 16px 0 4px;
  text-align: center;
}

.site-footer a {
  color: var(--muted);
  font-size: clamp(11px, 3.2vw, 13px);
  font-weight: 700;
}

.legal-shell {
  width: min(100%, 430px);
  margin: 0 auto;
  padding: clamp(14px, 4vw, 18px) clamp(12px, 3.4vw, 14px) 40px;
}

.legal-header {
  margin-bottom: 16px;
}

.back-link {
  display: inline-block;
  margin-bottom: 14px;
  color: var(--green-dark);
  font-size: clamp(12px, 3.5vw, 14px);
  font-weight: 800;
}

.legal-panel {
  padding: clamp(12px, 3.6vw, 16px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.legal-list {
  display: grid;
  gap: 0;
  margin: 0;
}

.legal-list div {
  display: grid;
  gap: 5px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

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

.legal-list dt {
  color: var(--muted);
  font-size: clamp(11px, 3.2vw, 13px);
  font-weight: 800;
}

.legal-list dd {
  margin: 0;
  color: var(--ink);
  font-size: clamp(13px, 3.8vw, 15px);
  line-height: 1.65;
}

@media (min-width: 680px) {
  body {
    display: flex;
    justify-content: center;
  }

  .app-shell {
    width: 430px;
    min-height: 100vh;
    padding-top: 18px;
  }

  .sticky-action {
    position: sticky;
    bottom: 0;
    margin: 12px -12px 0;
  }
}

@media (max-width: 374px) {
  .app-shell {
    padding-right: 10px;
    padding-left: 10px;
  }

  .result-summary span,
  .amounts {
    font-size: 10px;
  }

  .amount-card strong {
    font-size: 12px;
  }
}

@media (max-width: 359px) {
  .app-shell {
    padding-right: 8px;
    padding-left: 8px;
  }

  .result-summary {
    gap: 3px;
  }

  .amount-card {
    border-radius: 6px;
  }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 32, 51, 0.52);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-box {
  width: min(280px, 80vw);
  padding: 36px 28px 28px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 24px 64px rgba(16, 32, 51, 0.28);
  text-align: center;
}

.spinner {
  width: 44px;
  height: 44px;
  margin: 0 auto 18px;
  border: 4px solid #dce8f5;
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.modal-label {
  margin: 0 0 20px;
  font-size: clamp(14px, 4.1vw, 16px);
  font-weight: 700;
  color: var(--ink);
}

#modalLoading .modal-label {
  color: var(--muted);
}

.modal-ok-btn {
  margin-top: 0;
}
