/* ==========================================================================
   掲示物・張り紙作成ツール 専用CSS
   すべてのカスタムクラスは pm- プレフィックスを付け、既存Bizroute CSSと
   衝突しないようにする。
   ========================================================================== */

/* ── Reset & Base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  background: #f3f5f8;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI',
    'Hiragino Kaku Gothic Pro', 'Yu Gothic', 'Meiryo', sans-serif;
  color: #1f2937;
  line-height: 1.6;
}

button { font-family: inherit; }

:focus-visible {
  outline: 2px solid #2f6fb0;
  outline-offset: 2px;
}

@media (max-width: 991px) {
  body { padding-bottom: 64px; }
}

/* ── パンくず ──────────────────────────────────────────────────────── */
.pm-breadcrumb {
  max-width: 1180px;
  margin: 14px auto 0;
  padding: 0 16px;
}

/* ── SEO Header ───────────────────────────────────────────────────── */
.pm-seo-header {
  max-width: 1180px;
  margin: 10px auto 16px;
  padding: 0 16px;
}

.pm-seo-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 8px;
}

.pm-seo-lead {
  color: #444;
  margin-bottom: 4px;
  line-height: 1.75;
}

.pm-seo-lead-sub {
  color: #6b7280;
  font-size: 0.82rem;
  margin: 0 0 10px;
}

/* ── Main Layout ──────────────────────────────────────────────────── */
.pm-main-container {
  max-width: 1180px;
  margin: 0 auto 48px;
  padding: 0 16px;
}

.pm-main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
}

@media (min-width: 992px) {
  .pm-main-grid {
    grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.25fr);
    align-items: start;
  }

  .pm-col-preview {
    align-self: start;
    min-width: 0;
  }

  .pm-col-preview .pm-section-card {
    position: sticky;
    top: 20px;
  }
}

/* ── 3ステップ案内 ───────────────────────────────────────────────── */
.pm-quick-flow {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 8px 10px;
  margin: 0 0 18px;
  padding: 10px 12px;
  border: 1px solid #dbe7f3;
  border-radius: 8px;
  background: #f6f9fd;
  color: #315d8c;
  font-size: 0.8rem;
  font-weight: 600;
}

.pm-quick-flow span:not([aria-hidden="true"]) {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pm-quick-flow b {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #2f6fb0;
  color: #fff;
  font-size: 0.74rem;
  line-height: 1;
}

@media (max-width: 480px) {
  .pm-quick-flow {
    font-size: 0.74rem;
  }
}

/* ── サンプル ─────────────────────────────────────────────────────── */
.pm-sample-trigger-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.pm-btn-tiny {
  padding: 6px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  background: #fff;
  color: #2f6fb0;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 32px;
}

.pm-btn-tiny:hover { background: #eaf2fb; }

.pm-sample-menu {
  margin: -2px 0 14px;
  padding: 12px;
  border: 1px solid #dbe7f3;
  border-radius: 9px;
  background: #f7faff;
}

.pm-sample-menu-hint {
  margin: 0 0 8px;
  font-size: 0.76rem;
  color: #56708c;
}

.pm-sample-menu-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pm-sample-chip {
  padding: 8px 14px;
  border: 1px solid #b9d3ec;
  border-radius: 999px;
  background: #fff;
  color: #1f4f8a;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 38px;
}

.pm-sample-chip:hover { background: #eaf2fb; }

.pm-sample-msg {
  margin: -6px 0 16px;
  padding: 8px 10px;
  border-radius: 7px;
  background: #eef8f0;
  border: 1px solid #cfe9d4;
  color: #2c6b3a;
  font-size: 0.8rem;
}

/* ── Section Cards ────────────────────────────────────────────────── */
.pm-section-card {
  background: #fff;
  border-radius: 12px;
  padding: 18px 20px;
  border: 1px solid #e4e9f0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.pm-setting-section {
  padding: 16px;
  margin-bottom: 14px;
  border: 1px solid #e8edf3;
  border-radius: 10px;
  background: #fff;
}

.pm-setting-section:last-child {
  margin-bottom: 0;
}

.pm-section-title {
  font-size: 1rem;
  font-weight: 700;
  color: #1f4f8a;
  margin: 0 0 10px;
}

.pm-print-section {
  border-color: #cddff1;
  background: #f7faff;
}

.pm-print-section .pm-section-title {
  color: #174f88;
}

/* ── フォーム部品 ─────────────────────────────────────────────────── */
.pm-form-field {
  margin-bottom: 14px;
}

.pm-form-field:last-child { margin-bottom: 0; }

.pm-form-field label,
.pm-form-field-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #444;
  margin-bottom: 6px;
}

.pm-form-field input[type="text"] {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.92rem;
  min-height: 42px;
  background: #fff;
  color: #111827;
}

.pm-form-field input:focus {
  outline: none;
  border-color: #2f6fb0;
  box-shadow: 0 0 0 2px rgba(47, 111, 176, 0.2);
}

.pm-body-textarea,
.pm-note-textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 9px 11px;
  font: inherit;
  font-size: 0.9rem;
  resize: vertical;
}

.pm-body-textarea {
  min-height: 110px;
}

.pm-note-textarea {
  min-height: 70px;
}

.pm-body-textarea:focus,
.pm-note-textarea:focus {
  outline: none;
  border-color: #2f6fb0;
  box-shadow: 0 0 0 2px rgba(47, 111, 176, 0.2);
}

.pm-hint {
  font-size: 0.78rem;
  color: #6b7280;
  margin: 0 0 12px;
  line-height: 1.6;
}

.pm-field-help {
  margin: -6px 0 12px;
  padding: 8px 10px;
  border-radius: 7px;
  background: #fef6e8;
  border: 1px solid #f0e0bb;
  color: #8a6316;
  font-size: 0.78rem;
  line-height: 1.55;
}

.pm-privacy-note {
  font-size: 0.78rem;
  color: #6b7280;
  margin: 8px 0 12px;
  line-height: 1.6;
}

.pm-save-status {
  font-size: 0.78rem;
  color: #2f6fb0;
  min-height: 1.2em;
  margin: 10px 0 0;
}


.pm-field-subhelp {
  margin: 6px 0 0;
  color: #6b7280;
  font-size: 0.75rem;
  line-height: 1.5;
}

/* ── チェックボックス ─────────────────────────────────────────────── */
.pm-checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.pm-checkbox-field input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #2f6fb0;
  cursor: pointer;
}

.pm-checkbox-field label {
  font-size: 0.88rem;
  font-weight: 600;
  color: #1f2937;
  cursor: pointer;
}

/* ── セグメント切替 ───────────────────────────────────────────────── */
.pm-segmented {
  display: inline-flex;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  overflow: hidden;
  width: 100%;
}

.pm-segmented-option {
  position: relative;
  flex: 1 1 0;
}

.pm-segmented-option input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}

.pm-segmented-option span {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 8px;
  font-size: 0.84rem;
  font-weight: 600;
  color: #475569;
  min-height: 40px;
  border-right: 1px solid #cbd5e1;
  text-align: center;
}

.pm-segmented-option:last-child span { border-right: none; }

.pm-segmented-option input:checked + span {
  background: #2f6fb0;
  color: #fff;
}

.pm-segmented-option input:focus-visible + span {
  outline: 2px solid #2f6fb0;
  outline-offset: -2px;
}

/* ── ボタン群 ─────────────────────────────────────────────────────── */
.pm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 16px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  color: #333;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s;
  min-height: 42px;
}

.pm-btn:hover { background: #eef2f7; }

.pm-btn-primary {
  background: #2f6fb0;
  border-color: #2f6fb0;
  color: #fff;
}

.pm-btn-primary:hover { background: #245a91; }

.pm-btn-outline {
  background: #fff;
  border-color: #2f6fb0;
  color: #2f6fb0;
}

.pm-btn-outline:hover { background: #eaf2fb; }

.pm-btn-create {
  width: 100%;
  min-height: 48px;
  font-size: 1rem;
  box-shadow: 0 2px 5px rgba(47, 111, 176, 0.16);
  margin-bottom: 8px;
}

.pm-print-hint {
  margin: 0 0 4px;
}

.pm-btn-text-danger {
  background: none;
  border: none;
  color: #a83232;
  font-size: 0.82rem;
  text-decoration: underline;
  cursor: pointer;
  padding: 10px 4px;
  min-height: 40px;
}

.pm-btn-text-danger:hover { color: #7a1f1f; }

.pm-clear-row {
  display: flex;
  justify-content: flex-end;
}

/* ── プレビュー・ツールバー ───────────────────────────────────────── */
.pm-preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.pm-preview-toolbar .pm-section-title { margin: 0; }

.pm-preview-guide {
  margin: 0 0 10px;
  padding: 7px 9px;
  border-radius: 7px;
  background: #f6f9fc;
  color: #64748b;
  font-size: 0.78rem;
  line-height: 1.55;
}

.pm-preview-zoom-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #64748b;
  flex-wrap: wrap;
}

.pm-zoom-buttons {
  display: inline-flex;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  overflow: hidden;
  background: #fff;
}

.pm-zoom-btn {
  min-height: 34px;
  padding: 6px 10px;
  border: 0;
  border-right: 1px solid #cbd5e1;
  background: #fff;
  color: #475569;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.pm-zoom-btn:last-child { border-right: 0; }

.pm-zoom-btn:hover { background: #f1f5f9; }

.pm-zoom-btn.is-active {
  background: #2f6fb0;
  color: #fff;
}

.pm-zoom-btn:focus-visible {
  position: relative;
  z-index: 1;
  outline: 2px solid #2f6fb0;
  outline-offset: -2px;
}

.pm-visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}


/* ── 掲示物フォント ─────────────────────────────────────────────────
   Klee One は既存の @font-face 定義を再利用する前提。
   font-family 名が異なる場合は "Klee One" の部分だけ合わせて変更する。
   ------------------------------------------------------------------ */
.pm-poster-inner[data-font="gothic"] {
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
}

.pm-poster-inner[data-font="mincho"] {
  font-family: "Yu Mincho", "Hiragino Mincho ProN", "MS PMincho", serif;
}

.pm-poster-inner[data-font="klee"] {
  font-family: "Klee One", "Yu Mincho", serif;
}

/* ── 用紙プレビュー ───────────────────────────────────────────────── */
.pm-col-preview .pm-section-card {
  background: #fbfcfe;
}

.pm-paper-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 6px;
  border-radius: 8px;
  background: #eef2f6;
}

.pm-paper-stage {
  position: relative;
  margin: 0 auto;
}

.pm-paper {
  background: #fff;
  border: 1px solid #dbe3ec;
  border-radius: 2px;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
  transform-origin: top left;
  overflow: hidden;
}

.pm-poster-inner {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0;
}

.pm-poster-inner[data-align="center"] {
  text-align: center;
  align-items: center;
}

.pm-poster-inner[data-align="left"] {
  text-align: left;
  align-items: flex-start;
}

.pm-poster-title {
  margin: 0 0 0.6em;
  font-weight: 700;
  color: #111827;
  white-space: pre-wrap;
  word-break: break-word;
}

.pm-poster-title[data-titlesize="sm"] { font-size: 1.7rem; }
.pm-poster-title[data-titlesize="md"] { font-size: 2.3rem; }
.pm-poster-title[data-titlesize="lg"] { font-size: 3rem; }

.pm-poster-title[data-emphasis="boxed"] {
  padding: 0.35em 0.9em;
  border: 3px solid #1f2937;
  border-radius: 6px;
}

.pm-poster-title[data-emphasis="emphasis"] {
  padding: 0.15em 0.5em 0.3em;
  background: #eaf2fb;
  border-bottom: 6px solid #2f6fb0;
}

.pm-poster-body {
  margin: 0;
  color: #1f2937;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.9;
}

.pm-poster-body[data-bodysize="sm"] { font-size: 1rem; }
.pm-poster-body[data-bodysize="md"] { font-size: 1.25rem; }
.pm-poster-body[data-bodysize="lg"] { font-size: 1.55rem; }

.pm-poster-datetime {
  margin: 1.4em 0 0;
  padding: 0.3em 0.8em;
  color: #174f88;
  font-weight: 700;
  font-size: 1.15rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.pm-poster-note {
  margin-top: auto;
  padding-top: 1.6em;
  color: #4b5563;
  font-size: 0.95rem;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── スマートフォン固定操作バー ───────────────────────────────────── */
.pm-mobile-action-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 900;
  display: flex;
  gap: 8px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
  background: #fff;
  border-top: 1px solid #e4e9f0;
  box-shadow: 0 -4px 14px rgba(0, 0, 0, 0.1);
}

.pm-mobile-action-bar .pm-btn {
  flex: 1 1 0;
  min-height: 40px;
  padding: 8px 10px;
  font-size: 0.86rem;
}

@media (min-width: 992px) {
  .pm-mobile-action-bar { display: none; }
}

/* ── 解説エリア ───────────────────────────────────────────────────── */
.pm-doc-section {
  max-width: 1180px;
  margin: 40px auto 60px;
  padding: 0 16px;
  line-height: 1.8;
  color: #374151;
}

.pm-doc-section h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 40px 0 14px;
  color: #111827;
  border-left: 4px solid #2f6fb0;
  padding-left: 10px;
}

.pm-doc-section h2:first-of-type { margin-top: 0; }

.pm-doc-section h3 {
  font-size: 1.02rem;
  font-weight: 700;
  margin: 18px 0 8px;
  color: #1f2937;
}

.pm-doc-section p,
.pm-doc-section li {
  font-size: 0.92rem;
  line-height: 1.85;
  color: #374151;
}

.pm-doc-section p { margin: 0 0 12px; }

.pm-faq-item {
  border-bottom: 1px solid #f3f4f6;
  padding: 12px 0;
}

.pm-faq-item:last-child { border-bottom: none; }

.pm-faq-q {
  font-weight: 700;
  color: #111827;
  margin: 0 0 6px;
}

.pm-faq-a {
  margin: 0;
}

/* 関連ページ */
.pm-related-link-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pm-related-link-list li {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 12px 14px;
  background: #fff;
}

.pm-related-link-list a {
  color: #1d4ed8;
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 600;
}

.pm-related-link-list a:hover { text-decoration: underline; }

.pm-related-link-list .pm-note {
  display: block;
  font-size: 0.8rem;
  color: #6b7280;
  font-weight: 400;
  margin-top: 2px;
}

/* ── レスポンシブ ─────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .pm-section-card { padding: 14px 14px 16px; }
  .pm-setting-section { padding: 14px 12px; }
  .pm-preview-toolbar { align-items: stretch; flex-direction: column; }
  .pm-preview-toolbar .pm-btn { width: 100%; }
  .pm-preview-zoom-row { justify-content: flex-start; }
  .pm-zoom-buttons { flex: 1 1 auto; }
  .pm-zoom-btn { flex: 1 1 0; }
  .pm-sample-menu-list { flex-direction: column; align-items: stretch; }
  .pm-sample-chip { text-align: center; }
}

/* ── 印刷 ─────────────────────────────────────────────────────────── */
@media print {
  .no-print { display: none !important; }

  body {
    background: #fff;
    padding-bottom: 0;
    margin: 0;
  }

  /* .pm-paperは用紙の実寸そのものの幅で配置するため、外側のmax-width/centering
     コンテナが挟まっていると用紙がコンテナ内で右寄りにはみ出してしまう。
     印刷時は全ての外枠制約を解除し、用紙をページ左上にそのまま合わせる */
  .pm-main-container {
    max-width: none;
    margin: 0;
    padding: 0;
  }

  .pm-main-grid { display: block; }

  .pm-col-preview .pm-section-card {
    position: static;
    box-shadow: none;
    border: none;
    padding: 0;
    background: #fff;
  }

  .pm-paper-wrap {
    overflow: visible;
    padding: 0;
    background: transparent;
  }

  .pm-paper-stage {
    width: auto !important;
    height: auto !important;
  }

  .pm-paper {
    border: none;
    box-shadow: none;
    border-radius: 0;
    /* width/heightはJSが設定した実寸px(mm換算)のまま使う。
       @pageの用紙サイズと1px=1/96inchで一致するため、ここをautoにすると
       用紙いっぱいのレイアウト（中央寄せ・補足の下寄せ）が崩れる */
    transform: none !important;
    margin: 0 !important;
  }

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