:root {
  --desk:        #f2f2ef;
  --desk-deep:   #e5e5e0;
  --paper:       #ffffff;

  --ink:         #1a1d21;
  --ink-soft:    #78838d;
  --accent:      #0077cc;
  --accent-deep: #005ba6;
  --accent-line: #bcd8ec;
  --danger:      #de2636;
  --line:        #e3e6e9;

  --r-pill: 100vmax;

  --font-display: 'Zen Kaku Gothic New', sans-serif;
  --font-ui:      'Zen Kaku Gothic New', sans-serif;
  --font-num:     'Outfit', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--desk);
}

:root { --head-h: 60px; }

.site-head {
  position: sticky;
  top: 0;
  z-index: 60;
  height: var(--head-h);
  background: rgba(248,248,246,.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.head-inner {
  height: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 16px;
  color: var(--ink);
  flex-shrink: 0;
  letter-spacing: .02em;
}
.brand svg { display: block; flex-shrink: 0; }

.head-nav {
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 13.5px;
}
.head-nav a {
  text-decoration: none;
  color: var(--ink-soft);
  font-weight: 500;
  padding: 4px 1px;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.head-nav a:hover { color: var(--accent); }
.head-nav a.is-current { color: var(--accent); border-color: var(--accent); font-weight: 700; }

.head-nav a.head-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  background: var(--accent);
  text-decoration: none;
  padding: 8px 16px;
  border-radius: var(--r-pill);
  transition: background .15s, transform .15s;
}
.head-btn:hover { background: var(--accent-deep); transform: translateY(-1px); }

@media (max-width: 680px) {
  .head-nav a:not(.head-btn) { display: none; }
}

.app {
  display: grid;
  grid-template-columns: 310px 1fr;
  min-height: calc(100vh - var(--head-h));
}

.panel {
  background: var(--paper);
  border-right: 2px solid var(--ink);
  padding: 22px 20px 40px;
  overflow-y: auto;
  max-height: calc(100vh - var(--head-h));
}

.panel h1 {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .04em;
  margin: 0 0 4px;
}

.panel .lead {
  font-size: 11.5px;
  color: var(--ink-soft);
  line-height: 1.7;
  margin: 0 0 20px;
  padding-bottom: 16px;
  border-bottom: 1px dashed var(--rule-light);
}

fieldset { border: none; padding: 0; margin: 0 0 22px; }

legend {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  color: var(--accent);
  padding: 0;
  margin-bottom: 12px;
}

.field { margin-bottom: 14px; }

.field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 5px;
}

.field .hint {
  font-size: 10.5px;
  color: var(--ink-soft);
  margin-top: 4px;
  line-height: 1.55;
}

.field .hint code {
  font-family: ui-monospace, monospace;
  background: #f0ece1;
  padding: 1px 4px;
  border-radius: 3px;
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--ink);
  padding: 7px 9px;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 10px;
}

input:focus-visible, select:focus-visible, button:focus-visible {
  outline: 2.5px solid var(--accent);
  outline-offset: 2px;
}

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.line-row {
  display: grid;
  grid-template-columns: 1fr 88px;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.line-row span { font-size: 12px; }
.line-row select { padding: 5px 7px; font-size: 12px; }

.slider-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 5px;
}
.slider-head label { margin: 0; }
.slider-head output {
  font-family: var(--font-num);
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
}
input[type="range"] { width: 100%; accent-color: var(--accent); }

.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.presets button {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 500;
  color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--accent-line);
  border-radius: var(--r-pill);
  padding: 5px 12px;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.presets button:hover { background: var(--accent); border-color: var(--accent); color: #fff; }

.fit-btn {
  width: 100%;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  background: #fff;
  border: 1.5px dashed var(--accent-line);
  border-radius: 12px;
  padding: 9px;
  cursor: pointer;
}
.fit-btn:hover { background: #f2efe6; }

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  margin-bottom: 14px;
  cursor: pointer;
}
.check input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }

.print-btn {
  width: 100%;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .08em;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--r-pill);
  padding: 14px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0,119,204,.32);
  transition: transform .18s, box-shadow .18s, background .18s;
}
.print-btn:hover  { background: var(--accent-deep); transform: translateY(-2px); box-shadow: 0 9px 20px rgba(0,119,204,.36); }
.print-btn:active { transform: translateY(0); box-shadow: 0 4px 10px rgba(0,119,204,.3); }

.note {
  font-size: 10.5px;
  line-height: 1.6;
  color: var(--ink-soft);
  margin: 10px 0 0;
}

.sticky-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--paper);
  margin: 0 0 18px;
  box-shadow: 0 6px 12px -4px rgba(26,29,33,.10);
  padding: 1em;
}

.status {
  font-size: 11.5px;
  line-height: 1.6;
  padding: 9px 11px;
  border-radius: 12px;
  margin-bottom: 8px;
}
.status.ok   { color: #2c5c3f; background: #eef6f0; border-left: 3px solid #4a8f68; }
.status.over { color: var(--danger); background: #fdf0ed; border-left: 3px solid var(--danger); }

.stage {
  padding: 34px;
  overflow-y: auto;
  background: var(--desk);
  max-height: calc(100vh - var(--head-h));
}

.stage-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
  font-size: 12px;
  color: #4a4436;
}
.stage-bar input[type="range"] { width: 130px; }

#sheets { display: flex; flex-direction: column; align-items: center; }

.sheet {
  position: relative;
  width: var(--pw);
  height: var(--ph);
  padding: var(--pm);
  background: var(--paper);
  box-shadow: 0 10px 30px rgba(0,0,0,.28);
  margin: 0 0 28px;
  display: flex;
  flex-direction: column;
  transform-origin: top center;

  overflow: hidden;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}

.sheet-credit {
  position: absolute;
  left: var(--credit-left, var(--pm));
  top: var(--credit-top);
  font-size: 6pt;
  line-height: 1;
  color: #78838d;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP",
               "MS PGothic", sans-serif;
}

.sheet-head .blank {
  display: inline-block;
  border-bottom: .25mm solid var(--rule);
  width: 9mm;
  margin: 0 .6mm;
}
.sheet-head .no .blank { width: 15mm; }

.sheet svg { display: block; }

.mini-foot {
  background: var(--ink);
  color: #b3bcc4;
  padding: 20px 0;
}
.mini-foot-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12.5px;
}
.mini-foot-links { display: flex; gap: 20px; }
.mini-foot-links a { color: #b3bcc4; text-decoration: none; }
.mini-foot-links a:hover { color: #fff; }

@media print {
  html, body { background: #fff; }
  .site-head, .panel, .stage-bar, .mini-foot { display: none !important; }
  .app { display: block; }
  .stage { padding: 0; background: none; overflow: visible; max-height: none; }
  #sheets { display: block; }
  .sheet {
    box-shadow: none;
    margin: 0;
    transform: none !important;
    break-after: page;
    page-break-after: always;
  }
  .sheet:last-child { break-after: auto; page-break-after: auto; }
}

@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; }

  .panel { max-height: none; overflow-y: visible; border-right: none; border-bottom: 2px solid var(--ink); }
  .stage { max-height: none; overflow-y: visible; }
  .sticky-bar { top: var(--head-h); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
