/* ============================================================
   ジェネレーター共通CSS（ますめ屋準拠デザイン）
   studio TOFU / 展開図ジェネレーター系ツールで共通利用する
   ============================================================ */
/* ============ ますめ屋準拠デザイン（単一ファイル版） ============ */
* { box-sizing: border-box; }

:root {
  --ink:        #2b3a4e;
  --rule:       #6f7f96;
  --rule-light: #a9b6c8;
  --bg:         #edf1f6;
  --line:       #d8e0ea;
  --accent:     #0077cc;
  --accent-dk:  #005fa3;
  --glue:       #e0679a;
  --glue-fill:  #fce9f1;
  --cut:        #46586e;
  --head-h:     56px;      /* ヘッダー高さ（JSで実測値に上書き） */
}

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Zen Kaku Gothic New", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  font-size: 14px;
  line-height: 1.65;
}

/* ---------- header ----------
   画面上部に固定。高さは JS が --head-h に実測値を書き込む */
.site-head {
  position: sticky; top: 0; z-index: 30;
  background: #fff; border-bottom: 1px solid var(--line);
}
.head-inner {
  margin: 0; padding: 10px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.head-inner-flex {
  display: flex;
  gap: 2em;
  align-items: center;
}
.brand {
  display: flex; align-items: center; gap: 9px;
  font-family: Outfit, "Zen Kaku Gothic New", sans-serif;
  font-weight: 900; font-size: 17px; color: var(--ink); text-decoration: none;
}
.head-nav { display: flex; gap: 14px; align-items: center; font-size: 12.5px; }
.head-nav a { color: var(--rule); text-decoration: none; }
.head-nav a:hover { color: var(--accent); }
.head-btn { border: 1px solid var(--line); padding: 5px 12px; border-radius: 999px; }
.lead { font-size: 12px; color: #66738a; margin: 0; }
.head-tag a { text-decoration: none; }

/* ---------- layout：左ベタ付けサイドバー ---------- */
.app { display: flex; align-items: stretch; }

/* サイドバー：ヘッダー直下に固定し、高さは「画面高 − ヘッダー高」。
   これで初回表示から下端の印刷ボタンまで必ず画面内に収まる */
.side {
  flex: none; width: 264px;
  background: #fff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: var(--head-h);
  height: calc(100vh - var(--head-h));
  height: calc(100dvh - var(--head-h));
}
.side-scroll {
  flex: 1; min-height: 0;
  overflow-y: auto;
  padding: 14px 16px 10px;
}
.ctrl { margin: 0 0 14px; }
.ctrl-label {
  display: block; font-size: 11.5px; font-weight: 700; color: var(--rule);
  margin-bottom: 5px;
}
.ctrl-label output { font-family: Outfit, sans-serif; color: var(--accent); }
.ctrl-label .note-inline { font-weight: normal; font-size: 10.5px; color: #7f8ba0; }
.ctrl input[type="number"], .ctrl select {
  width: 100%;
  padding: 6px 8px; border: 1px solid #c6d1df; border-radius: 8px;
  font: inherit; font-size: 13px; background: #fff; color: var(--ink);
}
.ctrl input[type="range"] { width: 100%; margin: 2px 0 0; }
input[type="range"] { accent-color: var(--accent); }

/* 寸法：3つの入力を横並び、それぞれにラベル */
.dims { display: flex; gap: 8px; }
.dims > div { flex: 1; min-width: 0; }
.dims .ctrl-label { white-space: nowrap; }

.check {
  display: flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  margin: 0 0 14px;
}
.check input { accent-color: var(--accent); width: 15px; height: 15px; }
.pattern-row { display: flex; gap: 14px; }
.pattern-row .check { margin: 0; }

.side-sep { border: none; border-top: 1px solid var(--line); margin: 4px 0 14px; }

/* ---------- 色スウォッチ・カラーピッカー ---------- */
.swatch-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.swatch-btn {
  width: 22px; height: 22px; border-radius: 50%; padding: 0;
  border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line);
  cursor: pointer;
}
.swatch-btn.is-none { background: #fff; position: relative; }
.swatch-btn.is-none::before,
.swatch-btn.is-none::after {
  content: ''; position: absolute; left: 4px; right: 4px; top: 50%;
  border-top: 1.4px solid #c04a5f;
}
.swatch-btn.is-none::before { transform: rotate(45deg); }
.swatch-btn.is-none::after  { transform: rotate(-45deg); }
.swatch-btn.is-active { box-shadow: 0 0 0 2px var(--accent); }
input[type="color"] {
  width: 28px; height: 28px; padding: 0; border: 1px solid var(--line);
  border-radius: 6px; cursor: pointer; background: none;
}

/* ---------- 画像アップロード ---------- */
.file-row { display: flex; flex-direction: column; gap: 6px; }
input[type="file"] { font-size: 11.5px; color: var(--rule); }
.img-status { font-size: 11.5px; color: var(--accent); min-height: 1.4em; }

/* ---------- アイテム追加・一覧 ---------- */
.item-actions { display: flex; flex-direction: column; gap: 8px; }
.add-btn {
  display: block; width: 100%;
  background: var(--accent); color: #fff;
  border: none; border-radius: 8px; padding: 9px 10px;
  font: inherit; font-weight: 700; font-size: 12.5px; cursor: pointer;
}
.add-btn:hover { background: var(--accent-dk); }
.reset-btn {
  display: block; width: 100%;
  background: #fff; color: #8a4a5c;
  border: 1px solid #e7c3cf; border-radius: 8px; padding: 7px 10px;
  font: inherit; font-weight: 700; font-size: 12px; cursor: pointer;
}
.reset-btn:hover { background: #fdf0f4; }

.item-list { list-style: none; margin: 8px 0 6px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.item-row {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px;
  font-size: 12px; background: #fbfcfe;
}
.item-swatch {
  flex: none; width: 16px; height: 16px; border-radius: 50%;
  border: 1px solid #c6d1df;
}
.item-label { flex: 1; min-width: 0; color: var(--ink); line-height: 1.4; }
.item-del {
  flex: none; border: none; background: none; color: #b45a70;
  font-size: 15px; line-height: 1; cursor: pointer; padding: 2px 4px;
}
.item-del:hover { color: #7a2f42; }

/* 印刷ボタン：サイドバー最下部に固定（常に見える） */
.side-print {
  flex: none;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: #fff;
}

/* 保存・読み込みのように、対になるボタンを横2列に並べるための箱 */
.btn-row { display: flex; gap: 10px; margin-top: 8px; }
.btn-row > * { flex: 1 1 0; min-width: 0; }
.sub-btn {
  display: block; width: 100%;
  background: #fff; color: var(--accent);
  border: 1.5px solid var(--accent); border-radius: 6px;
  padding: 3px 6px;
  font: inherit; font-weight: 700; font-size: 14px; letter-spacing: .08em;
  cursor: pointer; text-align: center;
}
.sub-btn:hover:not(:disabled) { background: #eaf4fd; }
.sub-btn:disabled { color: #b9c4d2; border-color: var(--line); cursor: default; }
.print-btn {
  display: block; width: 100%;
  background: var(--accent); color: #fff;
  border: none; border-radius: 10px; padding: 11px;
  font: inherit; font-weight: 800; font-size: 14px; cursor: pointer;
}
.print-btn:hover { background: var(--accent-dk); }

/* ---------- stage ---------- */
.stage { flex: 1; min-width: 0; padding: 12px 20px 22px; position: relative; }

/* 表示倍率：プレビューウインドウ（.stage）の中の右上に固定表示 */
.stage-bar {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 20;
  display: flex; align-items: center; gap: 10px;
  background: rgba(255, 255, 255, .92);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 16px;
  font-size: 12.5px; font-weight: 700;
  box-shadow: 0 4px 16px rgba(20, 40, 70, .18);
}
.stage-bar input[type="range"] { width: 160px; }
.stage-bar output { font-family: Outfit, sans-serif; color: var(--accent); }

/* 収まらないときだけ表示する警告カード（通常は非表示） */
.err-card {
  display: none;
  margin: 0 0 12px; padding: 10px 14px;
  background: #fdf0ee; border: 1px solid #e7b7ae; border-radius: 10px;
  color: #c0392b; font-size: 12.5px; font-weight: 700; line-height: 1.7;
}
.err-card.show { display: block; }

.note { font-size: 11px; color: #7f8ba0; margin: 4px 0 0;
  font-weight: normal;
}

.sheet-area { overflow: auto; padding-bottom: 10px; }

/* 保存対象外の用紙にかぶせる警告。プレビュー上で一目でわかるようにする */
.sheet-wrap { position: relative; }
.sheet.is-over { opacity: .45; }
.sheet-warn {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  z-index: 5; margin: 0; width: 86%;
  text-align: center; line-height: 1.6;
  color: #c0392b; font-weight: 900; font-size: 15px;
  background: rgba(255, 255, 255, .92);
  border: 2px solid #c0392b; border-radius: 10px;
  padding: 12px 14px;
  box-shadow: 0 4px 16px rgba(20, 40, 70, .12);
}
.sheet-warn span {
  display: block; margin-top: 6px;
  font-size: 11.5px; font-weight: 400; color: #7a4038;
}
#sheets { width: max-content; margin: 0 auto; min-width: 100%; }

.sheet {
  background: #fff; border-radius: 8px;
  box-shadow: 0 2px 12px rgba(20, 40, 70, .14);
  width: max-content;
  margin: 0 auto 26px;
}
.sheet svg { display: block; }

/* ---------- footer ---------- */
.mini-foot { border-top: 1px solid var(--line); background: #fff; }
.mini-foot-inner {
  margin: 0; padding: 14px 20px;
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px;
  font-size: 12px; color: #7f8ba0;
}
.mini-foot-links { display: flex; gap: 14px; }
.mini-foot-links a { color: var(--rule); text-decoration: none; }
.mini-foot-links a:hover { color: var(--accent); }

@media (max-width: 760px) {
  .head-inner-flex .lead { display: none; }
  .app { flex-direction: column; }
  .side {
    width: 100%; height: auto; position: static;
    border-right: none; border-bottom: 1px solid var(--line);
  }
  .side-scroll { overflow: visible; }
  .side-print {
    position: sticky; bottom: 0; z-index: 10;
    box-shadow: 0 -4px 10px rgba(20, 40, 70, .06);
  }
  .stage-bar { right: 10px; top: 10px; }
  .stage-bar input[type="range"] { width: 110px; }
}

@media print {
  body { background: #fff; }
  .site-head, .side, .stage-bar, .err-card, .note, .mini-foot { display: none !important; }
  .app, .stage, .sheet-area { display: block; padding: 0; margin: 0; overflow: visible; }
  #sheets { width: auto; min-width: 0; margin: 0; }
  .sheet {
    box-shadow: none; border-radius: 0; margin: 0; width: auto;
    page-break-after: always; break-after: page;
  }
  .sheet:last-child { page-break-after: auto; break-after: auto; }
  .sheet svg { width: auto !important; height: auto !important; }
}
