:root {
  color-scheme: light;
  --ink: #2f352f;
  --muted: #667560;
  --line: #d8cfbf;
  --paper-line: #a99d89;
  --surface: #fffdf8;
  --surface-soft: #f1eadc;
  --accent: #98513e;
  --accent-dark: #743f30;
  --accent-soft: #f3e4dc;
  --sage: #667560;
  --sage-soft: #e5ebe1;
  --ochre: #d7b66b;
  --warning: #815e1c;
  --warning-soft: #f7edcf;
  --error: #9a4136;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  background: #f7f2e8;
  color: var(--ink);
}

* { box-sizing: border-box; }

html { overflow-x: hidden; }

body {
  min-width: 0;
  margin: 0;
  overflow-x: hidden;
  background: #f7f2e8;
}

button, input, select { font: inherit; }

button, input, select { min-height: 2.75rem; }

button { cursor: pointer; }

button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, a:focus-visible {
  outline: 3px solid #b78b2e;
  outline-offset: 2px;
}

.site-header {
  position: relative;
  isolation: isolate;
  min-height: 255px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 3.25rem 1.25rem 2.4rem;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background: #f4ecdd;
}

.hero-art {
  position: absolute;
  z-index: 0;
  inset: 0;
  pointer-events: none;
}

.hero-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 58%;
  opacity: .3;
  filter: saturate(.66) contrast(.82);
}

.hero-art::after {
  position: absolute;
  inset: 0;
  content: "";
  background:
    linear-gradient(90deg, rgba(247, 242, 232, .98) 0%, rgba(247, 242, 232, .9) 48%, rgba(247, 242, 232, .5) 100%),
    linear-gradient(0deg, rgba(247, 242, 232, .86), rgba(247, 242, 232, .2) 70%);
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 42rem;
  padding: 1.25rem 1.4rem;
  border-left: 4px solid var(--ochre);
  background: rgba(255, 253, 248, .58);
}

.eyebrow {
  margin: 0 0 .35rem;
  color: var(--accent-dark);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

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

h1, h2, legend, .paper h2 {
  font-family: "Yu Mincho", "Hiragino Mincho ProN", "HGS明朝E", serif;
}

h1 {
  margin-bottom: .45rem;
  font-size: clamp(1.65rem, 3vw, 2.45rem);
  letter-spacing: -.03em;
}

.lead {
  max-width: 42rem;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.75;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(360px, 420px) minmax(0, 1fr);
  gap: 1.35rem;
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 1.35rem 1.25rem 2.5rem;
  overflow-x: hidden;
  align-items: start;
}

.settings-panel, .preview-panel {
  min-width: 0;
  background: rgba(255, 253, 248, .9);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 7px 20px rgba(81, 62, 37, .07);
}

.settings-panel { padding: 1.2rem; }
.preview-panel { padding: 1rem; overflow-x: hidden; }

.section-heading { padding: .35rem .2rem .9rem; }
.section-heading h2, .preview-heading h2 { margin-bottom: .35rem; font-size: 1.25rem; }
.section-heading p:last-child { margin-bottom: 0; color: var(--muted); font-size: .86rem; line-height: 1.55; }

fieldset {
  min-width: 0;
  margin: 0 0 1rem;
  padding: .9rem;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 253, 248, .72);
}

legend { padding: 0 .35rem; color: var(--accent-dark); font-size: .96rem; font-weight: 800; }

.field-grid { display: grid; gap: .75rem; }
.two-up { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { display: flex; min-width: 0; flex-direction: column; gap: .35rem; }

label { font-size: .82rem; font-weight: 700; line-height: 1.35; }

input[type="month"], input[type="number"], input[type="text"], select {
  width: 100%;
  padding: .45rem .55rem;
  color: var(--ink);
  background: #fffefa;
  border: 1px solid #b8ab98;
  border-radius: 8px;
  font-size: 1rem;
}

input[type="checkbox"] {
  width: 1.25rem;
  height: 1.25rem;
  min-height: 1.25rem;
  accent-color: var(--accent);
  vertical-align: -3px;
}

.input-suffix { display: flex; align-items: center; gap: .35rem; }
.input-suffix input { flex: 1; min-width: 0; }
.input-suffix span { color: var(--muted); font-size: .85rem; }

small { display: block; color: var(--muted); font-size: .72rem; line-height: 1.45; }

.button {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  justify-content: center;
  padding: .55rem .85rem;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 800;
  line-height: 1.2;
}

.button.primary { color: #fffdf8; background: var(--accent); }
.button.primary:hover { background: var(--accent-dark); }
.button:disabled { cursor: not-allowed; opacity: .55; }
.button.secondary { margin-top: .8rem; color: var(--accent-dark); background: var(--accent-soft); border-color: #d8b6a6; font-size: .8rem; }
.button.ghost { color: var(--muted); background: transparent; border-color: var(--line); }
.form-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .3rem; }
.form-actions .primary { flex: 1 1 12rem; }
.form-status { min-height: 1.2rem; margin: .7rem 0 0; color: var(--muted); font-size: .78rem; }
.form-status[data-tone="success"] { color: #3f694c; }
.form-status[data-tone="warning"], .inline-message[data-tone="warning"] { color: var(--warning); }
.form-status[data-tone="error"] { color: var(--error); }

.period-summary {
  display: grid;
  min-height: 2.75rem;
  gap: .18rem;
  margin-top: .8rem;
  padding: .65rem .7rem;
  background: var(--surface-soft);
  border-left: 3px solid var(--ochre);
  border-radius: 3px 8px 8px 3px;
  font-size: .79rem;
  line-height: 1.45;
}

.period-summary strong { color: var(--accent-dark); font-size: .9rem; }
.column-inputs { display: grid; gap: .62rem; margin: .8rem 0 .4rem; }
.column-field { gap: .25rem; }
.inline-message { min-height: 1.1rem; margin: .35rem 0 0; font-size: .75rem; line-height: 1.45; }
.settings-step { margin-bottom: .8rem; }

.settings-step > summary {
  display: flex;
  min-height: 2.75rem;
  align-items: center;
  padding: .65rem .15rem;
  border-bottom: 1px solid var(--line);
}

.settings-step[open] > summary { margin-bottom: .8rem; }
.settings-step fieldset { margin-bottom: .7rem; }
.step-next { width: 100%; color: var(--accent-dark); background: var(--sage-soft); border-color: #bccab7; font-size: .8rem; }
.checkbox-field { justify-content: center; }
.checkbox-field label { display: flex; min-height: 2.75rem; align-items: center; gap: .4rem; padding: .55rem .1rem; }
.guidance { margin-top: 1.1rem; padding: .2rem .2rem 0; border-top: 1px solid var(--line); }

details { color: var(--muted); font-size: .78rem; }

summary {
  display: flex;
  min-height: 2.75rem;
  align-items: center;
  padding: .75rem 0;
  color: var(--accent-dark);
  cursor: pointer;
  font-weight: 800;
}

.details-body { line-height: 1.65; }
.details-body p { margin: 0 0 .55rem; }
.source-note { margin: .8rem 0 0; color: var(--muted); font-size: .7rem; line-height: 1.5; }
a { color: var(--accent-dark); }

.preview-heading { display: flex; align-items: start; justify-content: space-between; gap: 1rem; padding: .25rem .35rem .8rem; }
.preview-heading h2 { margin-bottom: 0; }
.preview-hint { margin: .25rem 0 0; color: var(--muted); font-size: .8rem; }

.paper-shell {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: .9rem;
  background: #e9dfcf;
  border: 1px solid #d6c8b3;
  border-radius: 11px;
}

.paper-shell::before, .paper-shell::after {
  position: absolute;
  z-index: 0;
  inset: .55rem;
  content: "";
  border: 1px solid rgba(169, 157, 137, .55);
  background: #f8f1e4;
  pointer-events: none;
}

.paper-shell::before { transform: rotate(-1deg); }
.paper-shell::after { inset: .65rem .45rem .45rem .7rem; transform: rotate(.7deg); background: #f3eadb; }

.paper {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 297 / 210;
  padding: 2.7%;
  overflow: hidden;
  background: #fffdf7;
  color: var(--ink);
  border: 1px solid #dfd3c1;
  box-shadow: 0 4px 12px rgba(81, 62, 37, .1), 6px 6px 0 rgba(215, 182, 107, .15);
  --row-height: clamp(2px, 1.35vw, 16px);
}

.paper-heading { height: 13%; overflow: hidden; }
.paper-empty { display: grid; height: 100%; min-height: 10rem; place-items: center; padding: 1.5rem; color: var(--error); background: #fff7f3; border: 1px dashed #d5a59a; text-align: center; font-size: clamp(.85rem, 1.5vw, 1.1rem); }
.paper-kicker { color: var(--accent); font-size: clamp(4px, 1vw, 10px); font-weight: 800; letter-spacing: .1em; line-height: 1; }
.paper h2 { margin: .2em 0 .1em; font-size: clamp(6px, 2vw, 21px); letter-spacing: -.025em; line-height: 1.05; white-space: nowrap; }
.paper-heading p { margin: 0; overflow: hidden; font-size: clamp(4px, 1.1vw, 11px); line-height: 1; white-space: nowrap; }

.calendar-table { width: 100%; height: auto; table-layout: fixed; border-collapse: collapse; font-size: clamp(2px, 1.05vw, var(--body-font-size, 8.5px)); line-height: 1; }
.calendar-table th, .calendar-table td { border: 1px solid var(--paper-line); }
.calendar-table thead { height: 7%; }
.calendar-table thead th { padding: .15em .25em; color: #3c473b; background: #eee4d1; font-size: clamp(2px, .72vw, var(--header-font-size, 9px)); line-height: .95; overflow-wrap: anywhere; }
.calendar-table tbody tr { height: var(--row-height, 4.45mm); }
.calendar-table tbody th, .calendar-table tbody td { height: var(--row-height, 4.45mm); }
.calendar-table .date-cell { width: 9%; padding: .08em .2em; text-align: center; font-weight: 700; font-size: clamp(2px, .84vw, var(--body-font-size, 8.5px)); line-height: 1; overflow-wrap: anywhere; }
.calendar-table tbody .date-cell { background: #faf6ed; white-space: normal; }
.calendar-table .date-cell > span { display: block; white-space: nowrap; }
.calendar-table .weekday-0 { color: #a34d3f; }
.calendar-table .weekday-6 { color: var(--sage); }
.calendar-table .holiday-row .date-cell { background: #f7e8d7; }
.holiday-label { display: block; margin-top: .08em; color: #765114; font-size: clamp(1px, .62vw, 6px); font-weight: 700; line-height: 1; white-space: nowrap; }
.entry-header { font-weight: 800; }
.entry-cell { background: #fffefa; }
.paper-footer { display: flex; justify-content: space-between; gap: .5rem; height: 5%; padding-top: .35em; color: var(--muted); font-size: clamp(2px, .8vw, 9px); line-height: 1; }

@supports (width: 1cqw) {
  .paper {
    container-type: inline-size;
    --row-height: clamp(2px, var(--screen-row-height, 1.50cqw), 16px);
  }

  .paper-kicker { font-size: clamp(2px, .8cqw, 10px); }
  .paper h2 { font-size: clamp(4px, 2.1cqw, 21px); }
  .paper-heading p { font-size: clamp(2px, .85cqw, 11px); }
  .calendar-table { font-size: clamp(2px, 1.05cqw, var(--body-font-size, 8.5px)); }
  .calendar-table thead th { font-size: clamp(2px, .72cqw, var(--header-font-size, 9px)); }
  .calendar-table .date-cell { font-size: clamp(2px, .84cqw, var(--body-font-size, 8.5px)); }
  .holiday-label { font-size: clamp(1px, .62cqw, 6px); line-height: 1; }
  .paper-footer { font-size: clamp(2px, .8cqw, 9px); }
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .preview-panel { order: 2; }
  .settings-panel { order: 1; }
}

@media (max-width: 460px) {
  .site-header { min-height: 230px; padding: 1.6rem .8rem 1.25rem; }
  .hero-content { padding: 1rem 1rem 1rem 1.1rem; }
  .app-shell { gap: .9rem; padding: .9rem .8rem 1.8rem; }
  .settings-panel, .preview-panel { border-radius: 13px; padding: .8rem; }
  .two-up { grid-template-columns: 1fr; }
  .paper-shell { padding: .55rem; }
}

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

@page { size: A4 landscape; margin: 0; }

@media print {
  html, body { width: 297mm; height: 210mm; background: #fff; }
  body { min-width: 0; overflow: visible; }
  .site-header, .hero-art, .settings-panel, .preview-heading { display: none !important; }
  .app-shell, .preview-panel, .paper-shell { display: block; margin: 0; padding: 0; border: 0; box-shadow: none; background: #fff; overflow: visible; }
  .app-shell { width: 297mm; height: 210mm; }
  .preview-panel { width: 297mm; height: 210mm; }
  .paper-shell { width: 297mm; height: 210mm; overflow: hidden; }
  .paper-shell::before, .paper-shell::after { display: none; }
  .paper { width: 297mm; height: 210mm; min-width: 0; min-height: 0; aspect-ratio: auto; container-type: normal; padding: 8mm; border: 0; box-shadow: none; page-break-inside: avoid; break-inside: avoid; --row-height: var(--print-row-height, 4.45mm); }
  .paper-heading { height: var(--print-heading-height, 21mm); overflow: visible; }
  .paper-kicker { font-size: 8px; }
  .paper h2 { font-size: 17px; line-height: normal; white-space: normal; }
  .paper-heading p { overflow: visible; font-size: 9px; line-height: normal; white-space: normal; }
  .calendar-table { height: auto; font-size: var(--body-font-size, 8.5px); line-height: normal; }
  .calendar-table thead { height: var(--print-header-height, 9mm); }
  .calendar-table thead th { padding: 1mm 1.2mm; font-size: var(--header-font-size, 9px); line-height: 1.15; }
  .calendar-table .date-cell { font-size: var(--body-font-size, 8.5px); line-height: 1.05; }
  .calendar-table .date-cell > span { font-size: inherit; line-height: inherit; white-space: nowrap; }
  .calendar-table tbody .date-cell { white-space: nowrap; }
  .holiday-label { font-size: .72em; line-height: normal; white-space: normal; }
  .calendar-table tbody tr, .calendar-table tbody th, .calendar-table tbody td { height: var(--row-height, 4.45mm); }
  .paper-footer { height: var(--print-footer-height, 7mm); padding-top: 1.4mm; font-size: 7px; line-height: normal; }
}

/* Stage A: first-view compression and tool entry */
.site-header { min-height: 0; padding: 24px 20px; }
.hero-content { max-width: 48rem; padding: 1rem 1.2rem; }
.hero-content h1 { margin-bottom: .45rem; font-size: clamp(1.75rem, 3vw, 2.25rem); line-height: 1.15; word-break: auto-phrase; }
.hero-content .lead { margin-bottom: .7rem; font-size: .96rem; line-height: 1.5; }
.firstview-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .4rem .75rem; margin: .65rem 0 .55rem; padding-left: 1.2rem; color: var(--ink); font-size: .78rem; font-weight: 700; line-height: 1.4; }
.firstview-steps li { min-width: 0; padding: .2rem 0; }
.firstview-cta { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; padding: .55rem 1rem; border-radius: 8px; color: #fff; background: var(--accent-dark); font-size: .88rem; font-weight: 800; text-decoration: none; }
.firstview-cta:hover { background: #5f3227; }
.firstview-badge { margin: .45rem 0 0; color: var(--muted); font-size: .72rem; font-weight: 700; }
.firstview-cta:focus-visible { outline: 3px solid #6b4b12; outline-offset: 3px; }
@media (max-width: 640px) {
  .site-header { min-height: 0; padding: 14px 12px; }
  .hero-art { display: none; }
  .hero-content { max-width: none; padding: .75rem .85rem; }
  .hero-content h1 { font-size: 1.65rem; }
  .hero-content .lead { font-size: .87rem; }
  .firstview-steps { gap: .25rem .35rem; margin: .5rem 0; font-size: .68rem; }
  .firstview-badge { margin-top: .3rem; font-size: .68rem; }
  .app-shell { padding-top: .5rem; }
  .settings-panel > .section-heading { gap: .3rem; padding: 0 0 .5rem; }
  .settings-panel > .section-heading .eyebrow { display: none; }
  .settings-panel > .section-heading h2 { margin-bottom: .15rem; font-size: 1.08rem; }
  .settings-panel > .section-heading p:last-child { margin-bottom: 0; font-size: .78rem; line-height: 1.4; }
}

