:root {
  color-scheme: light;
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --ink: #162033;
  --muted: #657184;
  --line: #d8dee8;
  --line-strong: #b9c3d1;
  --accent: #1f6f8b;
  --accent-strong: #164f66;
  --accent-soft: #e8f4f8;
  --danger: #b42318;
  --good: #0f766e;
  --warning: #a15c07;
  --shadow: 0 18px 48px rgba(22, 32, 51, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background:
    linear-gradient(180deg, #ffffff 0, #f6f8fb 220px, var(--bg) 100%);
  color: var(--ink);
  font-family:
    "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo,
    system-ui, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.app-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.72fr);
  gap: 20px;
  align-items: stretch;
  margin-bottom: 20px;
  text-align: left;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-strong);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 10px;
  font-size: clamp(1.75rem, 3vw, 2.7rem);
  line-height: 1.12;
  letter-spacing: 0;
}

.app-header p:not(.eyebrow) {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.75;
}

.saved-panel {
  display: grid;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.saved-panel h2 {
  margin: 0 0 10px;
  font-size: 0.98rem;
  line-height: 1.25;
}

.saved-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.saved-grid div {
  min-width: 0;
  padding: 10px;
  border: 1px solid #e7ebf1;
  border-radius: 6px;
  background: var(--surface-soft);
}

.saved-grid span,
.meta-label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.35;
}

.saved-grid strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 0.96rem;
  line-height: 1.2;
}

.progress {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.progress-step {
  display: block;
  min-height: 54px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: inherit;
  text-decoration: none;
}

.progress-step span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.2;
}

.progress-step strong {
  display: block;
  margin-top: 4px;
  font-size: 0.92rem;
  line-height: 1.2;
}

.progress-step.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.progress-step.is-complete {
  border-color: #a9d6c9;
}

.progress-step.is-disabled {
  opacity: 0.52;
}

.step-panel {
  min-height: 460px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.step-inner {
  padding: 22px;
}

.step-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  text-align: left;
}

.step-heading h2 {
  margin-bottom: 6px;
  font-size: clamp(1.32rem, 2.2vw, 1.9rem);
  line-height: 1.18;
}

.step-heading p {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.7;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.card-grid.two-columns {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.provider-list {
  grid-template-columns: 1fr;
  width: 100%;
  max-width: none;
  gap: 12px;
}

.provider-list .select-card {
  min-height: 0;
  grid-template-areas:
    "mark title prices"
    "mark desc prices";
  grid-template-columns: 72px minmax(220px, 1.15fr) minmax(300px, 0.85fr);
  align-items: center;
  gap: 12px 18px;
  padding: 16px;
}

.provider-list .card-top {
  grid-area: mark;
  display: grid;
  min-width: 0;
  gap: 8px;
  align-content: center;
  justify-items: start;
}

.provider-list .card-title {
  grid-area: title;
  min-width: 0;
  align-self: end;
  text-align: left;
}

.provider-list .card-title .meta-label {
  margin: 0 0 5px;
  font-size: 0.78rem;
}

.provider-list .price-pair {
  grid-area: prices;
  align-self: stretch;
}

.provider-list .price-pair > span {
  display: grid;
  align-content: center;
}

.provider-list .select-card > p {
  grid-area: desc;
  min-width: 0;
  margin: 0;
  text-align: left;
}

.select-card {
  display: grid;
  width: 100%;
  min-height: 220px;
  gap: 14px;
  align-content: start;
  padding: 18px;
  border: 1px solid var(--line);
  border-top: 5px solid var(--card-accent, var(--accent));
  border-radius: 8px;
  background: #fff;
  color: inherit;
  text-align: left;
  transition:
    border-color 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease;
}

.select-card:hover,
.select-card:focus-visible {
  border-color: var(--card-accent, var(--accent));
  box-shadow: 0 16px 34px rgba(22, 32, 51, 0.12);
  outline: none;
  transform: translateY(-2px);
}

.select-card.is-selected {
  border-color: var(--card-accent, var(--accent));
  background: color-mix(in srgb, var(--card-accent, var(--accent)) 9%, #fff);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.brand-mark {
  display: inline-grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: color-mix(in srgb, var(--card-accent, var(--accent)) 16%, #fff);
  color: var(--card-accent, var(--accent));
  font-size: 1rem;
  font-weight: 900;
}

.card-title h3 {
  margin-bottom: 6px;
  font-size: 1.2rem;
  line-height: 1.2;
  text-align: left;
}

.card-title p,
.select-card p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.6;
}

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

.price-pair > span,
.mini-stat {
  padding: 10px;
  border: 1px solid #e7ebf1;
  border-radius: 6px;
  background: var(--surface-soft);
}

.price-pair > span > span,
.mini-stat span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.price-pair strong,
.mini-stat strong {
  display: block;
  margin-top: 4px;
  font-size: 1.08rem;
  line-height: 1.15;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}

.option-stack {
  display: grid;
  gap: 16px;
}

.form-section,
.side-panel,
.result-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.form-section {
  padding: 16px;
}

.form-section h3,
.side-panel h3,
.result-card h3 {
  margin-bottom: 10px;
  font-size: 1.04rem;
  line-height: 1.25;
}

.section-note {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.6;
}

.required-options {
  border-color: #d6c7a8;
  background: #fffdf7;
}

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

.required-option-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid #eadfca;
  border-radius: 6px;
  background: #fff;
}

.required-option-list span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
  line-height: 1.35;
}

.required-option-list strong {
  flex: 0 0 auto;
  font-size: 0.96rem;
  line-height: 1.2;
}

.required-option-list .required-option-total {
  border-color: #d8bd89;
  background: #fff8e8;
}

.required-option-list .required-option-total span,
.required-option-list .required-option-total strong {
  color: var(--warning);
}

.choice-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.radio-card,
.check-card {
  display: grid;
  gap: 7px;
  min-height: 86px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.radio-card:has(input:checked),
.check-card:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.radio-card input,
.check-card input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.choice-label {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 850;
  line-height: 1.35;
}

.choice-note {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.55;
}

.option-price {
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 850;
}

.nested-options {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.input-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.form-field {
  display: grid;
  gap: 7px;
}

.form-field span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.form-field input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 9px 11px;
}

.form-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 111, 139, 0.14);
  outline: none;
}

.side-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
  position: sticky;
  top: 16px;
}

.side-list,
.source-list,
.note-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.side-list li,
.source-list li,
.note-list li {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.55;
}

.source-list a {
  color: var(--accent-strong);
  font-weight: 800;
  text-decoration: none;
}

.source-list a:hover {
  text-decoration: underline;
}

.result-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.82fr);
  gap: 12px;
  align-items: stretch;
  margin-bottom: 16px;
}

.quote-overview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
  border: 1px solid #dbe7ec;
  border-radius: 8px;
  background: #fbfdff;
}

.quote-overview div {
  min-width: 0;
  padding: 10px;
  border: 1px solid #e7ebf1;
  border-radius: 6px;
  background: #fff;
}

.quote-overview span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1.25;
}

.quote-overview strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 0.98rem;
  line-height: 1.3;
}

.result-stack {
  display: grid;
  gap: 14px;
}

.result-extras {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.result-card {
  overflow: hidden;
  break-inside: avoid;
  page-break-inside: avoid;
}

.result-card h3 {
  margin: 0;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #eef7fa;
  color: var(--accent-strong);
}

.cost-table {
  width: 100%;
  border-collapse: collapse;
}

.cost-table th,
.cost-table td {
  padding: 10px 16px;
  border-bottom: 1px solid #e9edf3;
  text-align: left;
  vertical-align: top;
}

.cost-table th {
  width: 58%;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 750;
}

.cost-table td {
  text-align: right;
  font-weight: 850;
  white-space: nowrap;
}

.cost-table tr:last-child th,
.cost-table tr:last-child td {
  border-bottom: 0;
}

.cost-table .total th,
.cost-table .total td {
  background: #f0f8fb;
  color: var(--accent-strong);
  font-size: 1.12rem;
}

.info-band {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid #dbe7ec;
  border-radius: 8px;
  background: #f7fbfd;
  color: var(--muted);
  line-height: 1.65;
}

.info-band strong {
  color: var(--ink);
}

.source-disclosure {
  align-self: start;
}

.source-disclosure summary {
  cursor: pointer;
  font-weight: 850;
  line-height: 1.25;
}

.source-disclosure .source-list {
  margin-top: 12px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 15px;
  font-weight: 850;
  line-height: 1.2;
  text-decoration: none;
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.button.danger {
  border-color: #f2c1bd;
  color: var(--danger);
}

.button:hover,
.button:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 111, 139, 0.12);
  outline: none;
}

.final-totals {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 0;
}

.final-totals div {
  display: grid;
  align-content: center;
  min-height: 94px;
  padding: 16px 18px;
  border: 1px solid #cfe5eb;
  border-radius: 8px;
  background: linear-gradient(180deg, #f5fbfd 0%, #eef8fb 100%);
}

.final-totals span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.final-totals strong {
  display: block;
  margin-top: 6px;
  color: var(--accent-strong);
  font-size: clamp(1.55rem, 3vw, 2.3rem);
  line-height: 1.1;
}

.important-notice {
  display: grid;
  gap: 8px;
  margin: -4px 0 16px;
  padding: 14px 16px;
  border: 2px solid #dc2626;
  border-radius: 8px;
  background: #fff5f5;
}

.important-notice p {
  margin: 0;
  color: #b91c1c;
  font-size: 0.98rem;
  font-weight: 900;
  line-height: 1.65;
}

.result-notes {
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
  margin-top: 14px;
}

.note-section {
  break-inside: avoid;
  page-break-inside: avoid;
}

.is-hidden {
  display: none !important;
}

@media (max-width: 920px) {
  .app-header,
  .detail-layout,
  .result-grid,
  .result-hero,
  .result-notes {
    grid-template-columns: 1fr;
  }

  .saved-grid,
  .card-grid,
  .card-grid.two-columns {
    grid-template-columns: 1fr;
  }

  .provider-list .select-card {
    grid-template-areas:
      "mark title"
      "mark prices"
      "desc desc";
    grid-template-columns: 64px minmax(0, 1fr);
    align-items: start;
  }

  .side-panel {
    position: static;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 16px;
  }

  .step-inner {
    padding: 16px;
  }

  .progress {
    grid-template-columns: 1fr 1fr;
  }

  .choice-row,
  .input-grid,
  .quote-overview,
  .final-totals {
    grid-template-columns: 1fr;
  }

  .price-pair {
    grid-template-columns: 1fr;
  }

  .provider-list .price-pair {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .step-heading {
    display: grid;
  }

  .cost-table th,
  .cost-table td {
    padding: 10px 12px;
  }
}

@media print {
  @page {
    size: A4;
    margin: 10mm;
  }

  :root {
    --ink: #111827;
    --muted: #4b5563;
    --line: #cfd7e3;
    --shadow: none;
  }

  * {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  body {
    background: #fff;
    color: #111827;
    font-size: 10.5pt;
  }

  .app-shell {
    width: 100%;
    padding: 0;
  }

  .app-header {
    display: none;
  }

  .progress,
  .actions,
  .step-heading .button,
  .source-disclosure {
    display: none !important;
  }

  .step-inner {
    padding: 0;
  }

  .step-heading {
    display: block;
    margin-bottom: 8mm;
    break-after: avoid;
    page-break-after: avoid;
  }

  .step-heading h2 {
    margin-bottom: 2mm;
    font-size: 18pt;
  }

  .step-heading p {
    color: #374151;
    font-size: 9.5pt;
    line-height: 1.45;
  }

  .result-hero,
  .result-extras,
  .result-notes {
    display: grid;
    grid-template-columns: 1fr;
    gap: 4mm;
  }

  .result-stack {
    display: block !important;
  }

  .result-hero {
    margin-bottom: 4mm;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .quote-overview {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 2mm;
    padding: 3mm;
    border-color: #cfd7e3;
  }

  .quote-overview div {
    padding: 2.5mm;
    border-color: #d8dee8;
  }

  .quote-overview span,
  .final-totals span {
    font-size: 8pt;
  }

  .quote-overview strong {
    font-size: 9.5pt;
  }

  .final-totals {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 3mm;
  }

  .final-totals div {
    min-height: 22mm;
    padding: 4mm;
    background: #f2f8fb;
  }

  .final-totals strong {
    font-size: 18pt;
  }

  .important-notice {
    margin: 0 0 4mm;
    padding: 3mm;
    border-width: 1.5px;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .important-notice p {
    font-size: 9.5pt;
    line-height: 1.45;
  }

  .step-panel,
  .saved-panel,
  .result-card,
  .form-section,
  .side-panel {
    box-shadow: none;
  }

  .step-panel,
  .result-card,
  .form-section,
  .info-band,
  .quote-overview,
  .final-totals div {
    border-radius: 3mm;
  }

  .step-panel {
    min-height: 0;
    border: 0;
  }

  .result-card {
    border-color: #cfd7e3;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .initial-cost-card {
    margin-bottom: 0;
    break-after: page !important;
    page-break-after: always !important;
  }

  .monthly-cost-card {
    margin-top: 0;
    break-before: page !important;
    page-break-before: always !important;
    break-inside: auto;
    page-break-inside: auto;
    overflow: visible;
  }

  .result-card h3 {
    padding: 3mm 4mm;
    background: #edf7fa;
    font-size: 11pt;
  }

  .cost-table {
    font-size: 9.5pt;
  }

  .cost-table tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .cost-table th,
  .cost-table td {
    padding: 2.5mm 4mm;
  }

  .monthly-cost-card .cost-table {
    break-inside: auto;
    page-break-inside: auto;
  }

  .monthly-cost-card .cost-table th,
  .monthly-cost-card .cost-table td {
    padding-top: 2mm;
    padding-bottom: 2mm;
  }

  .cost-table th {
    width: 68%;
  }

  .cost-table .choice-note {
    display: block;
    margin-top: 1mm;
    color: #4b5563;
    font-size: 8pt;
    line-height: 1.35;
  }

  .cost-table .total th,
  .cost-table .total td {
    font-size: 10.5pt;
  }

  .info-band {
    gap: 1.5mm;
    padding: 3mm;
    line-height: 1.45;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .result-notes {
    margin-top: 4mm;
  }

  .note-section {
    padding: 3.5mm;
    border-color: #cfd7e3;
  }

  .note-section h3 {
    margin-bottom: 2mm;
    font-size: 10.5pt;
  }

  .note-list {
    gap: 1.5mm;
  }

  .note-list li {
    color: #374151;
    font-size: 8.5pt;
    line-height: 1.4;
  }
}
