/* 共通スタイル(全品番ページで読み込む) */
  * { box-sizing: border-box; }
  html, body {
    height: 100%;
    margin: 0;
  }
  body {
    font-family: "Yu Gothic", "Meiryo", sans-serif;
    background: #f4f4f6;
    color: #222;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .layout {
    display: flex;
    gap: 24px;
    align-items: flex-start;
    flex: 1 1 auto;
    min-height: 0;
  }
  .preview {
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.12);
    flex: 1 1 560px;
    min-width: 320px;
    align-self: flex-start;
    position: sticky;
    top: 0;
    max-height: 100%;
    overflow: auto;
  }
  .preview svg { width: 100%; height: auto; display: block; }
  /* 右下の四角 = マーク添付エリア。元データではピンクのベタ塗りだが、
     マークを載せる枠として点線表示に切り替える。 */
  #print_guide {
    fill: none !important;
    stroke: #b6b6c2 !important;
    stroke-width: 26 !important;
    stroke-dasharray: 130 90 !important;
  }
  #mark_frame_hint { fill: #a8a8b4; user-select: none; }
  #mark_coat_layer .mark-img { cursor: move; }
  #mark_coat_layer .mark-img.dragging { opacity: 0.7; }
  #mark_frame_layer .mark-img { cursor: pointer; }
  #mark_frame_sel { fill: none; stroke: #2563eb; pointer-events: none; }

  /* マーク添付スロット。左からマーク1枚ずつのタイルが並び、右端が追加用の＋ */
  .mark-slots {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    border: 2px dashed #c3c3cc;
    border-radius: 10px;
    padding: 10px;
    background: #fafafb;
    transition: border-color .15s, background .15s;
  }
  .mark-slots.over { border-color: #2563eb; background: #eff5ff; }
  .mark-slot {
    position: relative;
    width: 74px;
    height: 74px;
    flex: none;
    border: 1px solid #d5d5dd;
    border-radius: 8px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: pointer;
  }
  .mark-slot img { max-width: 86%; max-height: 86%; object-fit: contain; pointer-events: none; }
  .mark-slot.selected { border-color: #2563eb; box-shadow: 0 0 0 2px #fff, 0 0 0 3px #2563eb; }
  .mark-slot.busy { color: #bbb; font-size: 11px; }
  .mark-slot .slot-no { position: absolute; left: 4px; top: 2px; font-size: 10px; color: #aaa; }
  .mark-slot .slot-del {
    position: absolute; right: 2px; top: 2px;
    width: 18px; height: 18px; padding: 0; line-height: 1;
    border: none; border-radius: 50%;
    background: rgba(0,0,0,.45); color: #fff;
    font-size: 12px; cursor: pointer; display: none;
  }
  .mark-slot:hover .slot-del { display: block; }
  .mark-slot.add { border-style: dashed; color: #2563eb; font-size: 26px; }
  .mark-slot.add:hover { background: #eff5ff; border-color: #2563eb; }
  .mark-hint { font-size: 11px; color: #888; line-height: 1.6; margin: 8px 0 12px; }
  .mark-hint .filename { color: #2563eb; }
  .mark-note {
    font-size: 12px; color: #888;
    background: #f7f7f9;
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 12px;
  }
  .btn {
    font: inherit;
    font-size: 12px;
    padding: 7px 16px;
    border: 1px solid #bbb;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
  }
  .btn:hover { background: #f0f4ff; border-color: #2563eb; color: #2563eb; }
  .btn.danger:hover { background: #fff0f0; border-color: #c33; color: #c33; }
  .chk { display: flex; align-items: center; gap: 6px; font-size: 12px; margin-bottom: 8px; cursor: pointer; }
  .slider-row {
    display: grid;
    grid-template-columns: 4.5em 1fr 4.5em;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    margin-bottom: 8px;
  }
  .slider-row input[type=range] { width: 100%; }
  .slider-row .val { text-align: right; color: #555; font-variant-numeric: tabular-nums; }
  .slider-row.disabled { opacity: .4; pointer-events: none; }
  .preset-row { display: flex; gap: 6px; margin: 4px 0 12px; }
  .preset-row .btn { flex: 1; padding: 7px 4px; }
  .preset-row .btn.active { background: #2563eb; border-color: #2563eb; color: #fff; }
  /* マーク直接操作ハンドル(枠線・四隅=サイズ・上の丸=回転) */
  #mark_gizmo .giz-line { fill: none; stroke: #2563eb; pointer-events: none; }
  #mark_gizmo .giz-handle { fill: #fff; stroke: #2563eb; }
  #mark_gizmo .giz-corner { cursor: nwse-resize; }
  #mark_gizmo .giz-corner.ne, #mark_gizmo .giz-corner.sw { cursor: nesw-resize; }
  #mark_gizmo .giz-rot { fill: #2563eb; cursor: grab; }
  #mark_gizmo.acting .giz-rot { cursor: grabbing; }

  .panel {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.12);
    flex: 1 1 380px;
    min-width: 320px;
    height: 100%;
    overflow-y: auto;
  }
  .step-title {
    font-weight: bold;
    font-size: 15px;
    margin: 20px 0 10px;
    padding-bottom: 6px;
    border-bottom: 2px solid #333;
  }
  .step-title:first-child { margin-top: 0; }
  .control-row { margin-bottom: 16px; }
  .control-label { font-size: 13px; margin-bottom: 6px; display: flex; justify-content: space-between; }
  .control-label .code { color: #888; font-weight: normal; }
  .swatches { display: flex; flex-wrap: wrap; gap: 6px; }
  .swatch {
    width: 28px; height: 28px;
    border-radius: 6px;
    border: 2px solid transparent;
    cursor: pointer;
    position: relative;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.15);
  }
  .swatch.selected { border-color: #2563eb; box-shadow: 0 0 0 2px #fff, 0 0 0 4px #2563eb; }
  .swatch:hover { transform: scale(1.08); }
  .swatch::after {
    content: attr(data-code);
    position: absolute;
    bottom: -16px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 8px;
    color: #999;
    white-space: nowrap;
  }
  .summary {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px dashed #ccc;
    font-size: 13px;
    line-height: 1.8;
  }
  /* サマリーはセクション見出し + 明細の2段構成 */
  .summary b {
    display: block;
    margin: 12px 0 2px;
    padding-bottom: 3px;
    border-bottom: 1px solid #e5e5ea;
    color: #333;
  }
  .summary b:first-child { margin-top: 0; }
  .note {
    background: #fff8e1;
    border: 1px solid #f0d878;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 12px;
    color: #6b5900;
    margin: 16px 0 0;
    line-height: 1.6;
  }
  /* STEP.0 品番 */
  .product-row { display: flex; gap: 8px; margin-bottom: 4px; }
  .product-row .opt {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 13px;
    cursor: pointer;
  }
  .product-row .opt:hover { border-color: #2563eb; }
  .product-row .opt.checked { border-color: #2563eb; background: #eff5ff; color: #2563eb; font-weight: bold; }
  .btn.primary {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
    padding: 10px 20px;
    font-size: 13px;
  }
  .btn.primary:hover { background: #1d4ed8; border-color: #1d4ed8; color: #fff; }
  .btn.primary:disabled { background: #9db7e8; border-color: #9db7e8; cursor: default; }
  .export-row { margin-top: 18px; display: flex; align-items: center; gap: 12px; }
  /* ===== 品番ナビゲーション ===== */
  .nav {
    display: flex;
    flex-wrap: nowrap;   /* 品番ボタンは常に横一列 */
    gap: 8px;
    align-items: stretch;
    margin-bottom: 18px;
    flex: none;
    overflow-x: auto;    /* 画面が狭いときは横スクロールで逃がす */
    padding-bottom: 2px;
  }
  .nav-btn {
    flex: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1px;
    padding: 7px 12px;
    border: 1px solid #ccc;
    border-radius: 8px;
    background: #fff;
    color: #333;
    text-decoration: none;
    font-size: 13px;
    font-weight: bold;
    line-height: 1.2;
    white-space: nowrap;
  }
  .nav-btn small { font-weight: normal; font-size: 10px; color: #999; }
  .nav-btn:hover { border-color: #2563eb; color: #2563eb; }
  .nav-btn:hover small { color: #2563eb; }
  .nav-btn.active { background: #2563eb; border-color: #2563eb; color: #fff; }
  .nav-btn.active small { color: #cfe0ff; }
  .nav-btn.soon { opacity: .45; cursor: not-allowed; }
  .nav-btn.soon:hover { border-color: #ccc; color: #333; }
  .nav-btn.soon:hover small { color: #999; }

  /* PDF書き出しでは getComputedStyle で色を読むが、transition が効いていると
     変更前の色が返ってしまう。書き出しの一瞬だけ transition を止める。 */
  #preview.no-transition, #preview.no-transition * { transition: none !important; }
  /* ===== ヘッダー(黒帯 + REWARDロゴ) ===== */
  .appbar {
    flex: none;
    display: flex;
    align-items: center;
    gap: 18px;
    height: 72px;
    padding: 0 24px;
    background: #111114;
    color: #fff;
  }
  .appbar .logo { height: 26px; width: auto; display: block; flex: none; }
  .appbar .logo path { fill: #fff; }
  .appbar-title { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; min-width: 0; }
  .appbar-title .t-main { font-size: 19px; font-weight: bold; letter-spacing: .02em; }
  .appbar-title .t-sub { font-size: 12px; color: #9a9a9f; letter-spacing: .06em; }
  .wrap {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 18px 24px 24px;
  }
  .nav-spacer { flex: 1 1 auto; min-width: 12px; }
  .nav .export-note { font-size: 11px; color: #999; text-align: right; max-width: 20em; flex: none; }
  .nav .btn { flex: none; white-space: nowrap; }
