/* 紙メダルメーカー（金・銀・銅＋カラフルな円形メダルをA4面付け印刷）
   ticket-maker / iron-beads と同じ「単一SVGシート→印刷／PNG」方式。プレフィックス md- */

/* ============ レイアウト ============ */
.md-layout {
  display: flex;
  gap: 28px;
  max-width: 1120px;
  margin: 18px auto 40px;
  padding: 0 4px;
  align-items: flex-start;
}

.md-privacy {
  font-size: 12px;
  color: #94a3b8;
  margin: 4px 0 0;
}

/* --- フォーム --- */
.md-form {
  width: 390px;
  flex-shrink: 0;
  text-align: left;
}
.md-form .fs-title {
  font-size: 15px;
  font-weight: 700;
  color: #333;
  margin: 20px 0 8px;
  padding-bottom: 5px;
  border-bottom: 2px solid var(--accent, #2a9d8f);
}
.md-form .fs-title:first-child {
  margin-top: 0;
}
.md-form input[type='text'],
.md-form input[type='number'] {
  box-sizing: border-box;
  font-size: 14px;
  color: #333;
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #fff;
  font-family: inherit;
}
.md-form input[type='text'] {
  width: 100%;
}
.md-hint {
  font-size: 11.5px;
  color: #888;
  margin: 6px 0 0;
  line-height: 1.6;
}

/* メダルの種類（チップ） */
.md-kinds {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.md-kind {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #fff;
  color: #475569;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  max-width: 100%;
}
.md-kind.is-active {
  border-color: var(--accent, #2a9d8f);
  background: var(--accent, #2a9d8f);
  color: #fff;
}
.md-kind-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}
.md-kind-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 15em;
}
.md-kind-qty {
  font-size: 11.5px;
  opacity: 0.8;
}
.md-kind-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.md-mini {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #475569;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
.md-mini:hover:not(:disabled) {
  background: #f1f5f9;
}
.md-mini:disabled {
  opacity: 0.45;
  cursor: default;
}

/* プリセット */
.md-preset-group {
  margin-top: 10px;
}
.md-preset-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #64748b;
  margin-bottom: 5px;
}
.md-preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.md-preset {
  border: 1px solid #dbe3ea;
  background: #f8fafc;
  color: #475569;
  border-radius: 999px;
  padding: 6px 11px;
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
}
.md-preset:hover {
  background: #eef2f7;
  border-color: var(--accent, #2a9d8f);
}

/* 色えらび */
.md-colors {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.md-color {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #fff;
  color: #475569;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.md-colors input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.md-color:has(input:checked) {
  border-color: var(--accent, #2a9d8f);
  background: var(--accent, #2a9d8f);
  color: #fff;
}
.md-swatch {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.18);
  display: inline-block;
}

.md-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
  margin-top: 6px;
}
.md-row label {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0;
  font-size: 13.5px;
  color: #333;
  cursor: pointer;
}
.md-qty-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
  font-weight: 600;
  color: #555;
}
.md-qty-field input {
  width: 110px;
}

.md-warn,
.md-small-note {
  display: block;
  margin: 8px 0 0;
  padding: 8px 10px;
  border: 1px solid #f0b429;
  background: #fff8e6;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: #8a5a00;
  line-height: 1.5;
}
.md-warn[hidden],
.md-small-note[hidden] {
  display: none;
}

/* --- プレビュー側 --- */
.md-preview {
  flex: 1;
  min-width: 0;
  position: sticky;
  top: 16px;
  align-self: flex-start;
  text-align: center;
}
.md-btn-row {
  display: flex;
  gap: 10px;
}
.md-print-btn,
.md-png-btn {
  flex: 1;
  border: none;
  border-radius: 8px;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.2s ease;
}
.md-print-btn {
  background: var(--accent, #2a9d8f);
  color: #fff;
}
.md-png-btn {
  background: #fff;
  color: var(--accent, #2a9d8f);
  border: 2px solid var(--accent, #2a9d8f);
  padding: 12px;
}
.md-print-btn:hover,
.md-png-btn:hover {
  opacity: 0.82;
}
.md-scale-warn {
  display: block;
  margin: 8px 0 4px;
  padding: 8px 10px;
  border: 1px solid #f0b429;
  background: #fff8e6;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: #8a5a00;
  line-height: 1.5;
  text-align: left;
}
.md-print-note {
  font-size: 12px;
  color: #888;
  margin: 4px 0 10px;
  line-height: 1.5;
}
.md-sheet-info {
  font-size: 13px;
  font-weight: 700;
  color: #333;
  margin: 0 0 8px;
  min-height: 1.2em;
}
.md-caption {
  font-size: 12px;
  color: #888;
  margin-top: 8px;
}

/* A4シート */
.md-sheet-box {
  overflow: hidden;
  border-radius: 4px;
}
.md-sheet-box + .md-sheet-box {
  margin-top: 16px;
}
.md-sheet {
  width: 210mm;
  height: 297mm;
  background: #fff;
  box-sizing: border-box;
  position: relative;
  transform-origin: top left;
  overflow: hidden;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.18);
}
.md-sheet svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* 組み立ての図解 */
.md-howto {
  max-width: 760px;
  margin: 8px auto 0;
  padding: 0 8px;
}
.md-howto svg {
  width: 100%;
  height: auto;
}

/* ============ レスポンシブ ============ */
@media (max-width: 940px) {
  .md-layout {
    flex-direction: column;
  }
  .md-form {
    width: 100%;
  }
  .md-preview {
    position: static;
    width: 100%;
  }
}

/* ============ 印刷：シートだけをA4いっぱいに ============ */
@media print {
  @page {
    size: A4 portrait;
    margin: 0;
  }
  html,
  body {
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    height: auto !important;
  }
  body > *:not(.container) {
    display: none !important;
  }
  .container {
    margin: 0 !important;
    padding: 0 !important;
    max-width: none !important;
    width: auto !important;
  }
  .container > *:not(.md-layout) {
    display: none !important;
  }
  .md-layout {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    max-width: none !important;
  }
  .md-layout > *:not(.md-preview) {
    display: none !important;
  }
  .md-preview {
    position: static !important;
    margin: 0 !important;
    padding: 0 !important;
    width: auto !important;
  }
  .md-preview > *:not(.md-sheet-wrap) {
    display: none !important;
  }
  .md-sheet-box {
    height: auto !important;
    margin: 0 !important;
    overflow: visible !important;
    border-radius: 0 !important;
    break-after: page;
    page-break-after: always;
  }
  .md-sheet-box:last-child {
    break-after: auto;
    page-break-after: auto;
  }
  .md-sheet {
    transform: none !important;
    box-shadow: none !important;
    margin: 0 !important;
    width: 210mm !important;
    height: 296mm !important;
    overflow: hidden !important;
  }
}
