:root {
  color-scheme: light;
  --linen: #f2ece2;
  --paper: #fffdf8;
  --ink: #293437;
  --muted: #68706d;
  --red: #b43b31;
  --red-dark: #8e2f2a;
  --blue: #356c86;
  --line: #d9cfc2;
  --shadow: 0 18px 45px rgba(74, 59, 43, 0.12);
}

* { box-sizing: border-box; }

html { background: var(--linen); }

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  color: var(--ink);
  background: var(--linen);
  font-family: ui-rounded, "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  line-height: 1.6;
}

button, input { font: inherit; }

button { cursor: pointer; }

button:focus-visible, input:focus-visible, a:focus-visible {
  outline: 3px solid #e19a52;
  outline-offset: 3px;
}

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

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.9fr);
  gap: clamp(24px, 5vw, 72px);
  align-items: center;
  min-height: 380px;
  padding: 54px 0 44px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--red-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(2.6rem, 7vw, 5.5rem); line-height: 0.98; letter-spacing: -0.04em; }
h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.8rem, 4vw, 2.8rem); line-height: 1.1; }
h3 { margin: 0; font-size: 1.05rem; }

.hero-lead { max-width: 34rem; margin: 24px 0 14px; font-size: clamp(1.05rem, 2vw, 1.25rem); }
.privacy-note { max-width: 38rem; margin: 0; color: var(--muted); font-size: 0.88rem; }
.hero-image { position: relative; margin: 0; }
.hero-image img { display: block; width: 100%; max-height: 330px; object-fit: cover; border-radius: 18px 18px 70px 18px; box-shadow: var(--shadow); }
.hero-image figcaption { position: absolute; right: 16px; bottom: -13px; padding: 5px 12px; color: var(--paper); background: var(--red); border-radius: 999px; font-size: 0.78rem; }

.input-panel, .result-panel { padding: clamp(22px, 5vw, 48px); background: var(--paper); border: 1px solid rgba(180, 59, 49, 0.12); border-radius: 20px; box-shadow: var(--shadow); }
.result-panel { margin-top: 28px; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
fieldset + fieldset { margin-top: 32px; }
legend { width: 100%; margin-bottom: 16px; font-family: Georgia, "Times New Roman", serif; font-size: 1.35rem; font-weight: 700; }
.legend-unit { color: var(--muted); font-family: inherit; font-size: 0.75rem; font-weight: 400; }

.type-choice { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.choice-card { display: flex; align-items: center; gap: 12px; min-height: 66px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; }
.choice-card:has(input:checked) { border-color: var(--red); background: #fff5ef; box-shadow: inset 0 0 0 1px var(--red); }
.choice-card input { width: 20px; height: 20px; accent-color: var(--red); }
.choice-card span { display: grid; line-height: 1.25; }
.choice-card small { color: var(--muted); font-size: 0.78rem; }

.field-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.field label { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 7px; font-weight: 700; }
.input-with-unit { display: flex; align-items: center; overflow: hidden; border: 1px solid #bfb6aa; border-radius: 10px; background: #fff; }
.input-with-unit:focus-within { border-color: var(--red); box-shadow: 0 0 0 3px rgba(180, 59, 49, 0.16); }
.input-with-unit input { width: 100%; min-width: 0; min-height: 46px; padding: 8px 10px; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 16px; }
.input-with-unit span { padding-right: 10px; color: var(--muted); font-size: 0.84rem; }
.field-help { min-height: 1.4em; margin: 4px 0 0; color: var(--muted); font-size: 0.75rem; }
.field-error { min-height: 1.4em; margin: 4px 0 0; color: var(--red-dark); font-size: 0.8rem; font-weight: 700; }
.field-error:empty { display: none; }
.has-error .input-with-unit { border-color: var(--red); }

.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; margin-top: 32px; }
.form-status { flex: 1 1 260px; min-height: 1.6em; margin: 0; color: var(--muted); font-size: 0.9rem; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 9px 17px; border: 1px solid transparent; border-radius: 999px; font-weight: 800; line-height: 1.25; text-align: center; transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { color: #fff; background: var(--red); }
.button-primary:hover { background: var(--red-dark); }
.button-secondary { color: var(--ink); border-color: var(--line); background: #fff; }
.button-secondary:hover { border-color: var(--red); }
.button-accent { color: #fff; background: var(--blue); }
.button-accent:hover { background: #24556c; }
.button-quiet { color: var(--red-dark); border-color: rgba(180, 59, 49, 0.35); background: transparent; }

.result-heading-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.result-heading-row .button { flex: 0 0 auto; }
.result-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 10px; margin: 26px 0; }
.summary-item { padding: 13px 14px; border-left: 3px solid var(--red); background: #f8f1e8; }
.summary-item small { display: block; color: var(--muted); font-size: 0.75rem; }
.summary-item strong { display: block; margin-top: 2px; font-size: 1.1rem; }
.result-tools { display: flex; flex-wrap: wrap; gap: 10px; }
.print-instructions { margin: 14px 0 0; color: var(--muted); font-size: 0.86rem; }
.preview-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(220px, 0.9fr); gap: 24px; align-items: start; margin-top: 32px; }
.screen-preview-figure { min-width: 0; margin: 0; }
.preview-label { margin-bottom: 8px; color: var(--muted); font-size: 0.8rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.svg-preview { overflow: hidden; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #eee7dd; }
.svg-preview svg { display: block; width: 100%; height: auto; max-height: 600px; }
.screen-preview-figure figcaption { margin-top: 8px; color: var(--muted); font-size: 0.78rem; }
.scope-note { padding: 20px; border-left: 3px solid var(--blue); background: #edf3f2; }
.scope-note p { margin: 10px 0 0; color: #4c5c60; font-size: .9rem; }
.print-section { margin-top: 38px; padding-top: 28px; border-top: 1px solid var(--line); }
.section-heading { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.section-heading .eyebrow { margin: 0; }
.section-heading h3 { font-family: Georgia, "Times New Roman", serif; font-size: 1.45rem; }
.print-count { margin: 4px 0 18px; color: var(--muted); font-size: .88rem; }
.print-output { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.print-page { min-width: 0; padding: 7px; border: 1px solid var(--line); background: #eee7dd; }
.print-page svg { display: block; width: 100%; height: auto; background: #fffdf8; }

.site-footer { padding: 28px 0 0; color: var(--muted); font-size: .78rem; }
.site-footer p { margin: 4px 0; }
.site-footer a { color: var(--red-dark); }

[hidden] { display: none !important; }

@media (max-width: 760px) {
  .site-shell { padding-inline: 16px; }
  .hero { grid-template-columns: 1fr; min-height: 0; padding: 34px 0 30px; gap: 28px; }
  .hero-image img { max-height: 250px; border-radius: 15px 15px 54px 15px; }
  .field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .result-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .preview-layout { grid-template-columns: 1fr; }
}

@media (max-width: 430px) {
  .site-shell { padding-inline: 12px; }
  .input-panel, .result-panel { padding: 20px 16px; border-radius: 15px; }
  .type-choice, .field-grid { grid-template-columns: 1fr; }
  .result-heading-row { display: block; }
  .result-heading-row .button { margin-top: 14px; }
  .result-summary { grid-template-columns: 1fr 1fr; gap: 8px; }
  .summary-item { padding: 10px; }
  .result-tools .button { width: 100%; }
  .print-output { grid-template-columns: 1fr; }
}

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

@media print {
  @page { size: A4; margin: 0; }
  html, body { width: 210mm; min-width: 0; background: #fff; }
  body { overflow: visible; }
  .site-shell { width: auto; padding: 0; }
  .site-shell > header, .site-shell > footer, main > form, #result-panel > :not(.print-section), .print-section > .section-heading, .print-section > .print-count { display: none !important; }
  #result-panel, .print-section, .print-output { display: block !important; margin: 0; padding: 0; border: 0; }
  .print-page { width: 210mm; height: 297mm; margin: 0; padding: 0; border: 0; background: #fff; break-after: page; page-break-after: always; }
  .print-page:last-child { break-after: auto; page-break-after: auto; }
  .print-page svg { width: 210mm; height: 297mm; }
}
