:root {
  color-scheme: light;
  --app-bg: #f3f5f8;
  --panel-bg: rgba(255, 255, 255, 0.92);
  --panel-border: #dfe3e8;
  --text: #172033;
  --muted: #6b7280;
  --input-bg: #ffffff;
  --soft-bg: #eef1f5;
  --accent: #f97316;
  --accent-hover: #ea580c;
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.07);
  --radius: 18px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --app-bg: #0c0f14;
  --panel-bg: rgba(20, 24, 32, 0.94);
  --panel-border: #2a303b;
  --text: #eef2f7;
  --muted: #98a2b3;
  --input-bg: #11151c;
  --soft-bg: #202630;
  --accent: #fb923c;
  --accent-hover: #fdba74;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(circle at top left, rgba(249, 115, 22, 0.11), transparent 34rem),
    var(--app-bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "Noto Sans JP", sans-serif;
}

button,
select,
textarea {
  font: inherit;
}

button,
select {
  min-height: 42px;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1800px, 100%);
  margin: 0 auto;
  padding: 20px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 15px;
  background: linear-gradient(145deg, #fb923c, #ea580c);
  box-shadow: 0 10px 24px rgba(249, 115, 22, 0.28);
}

.brand-mark svg {
  width: 34px;
  height: 34px;
}

.brand-mark path:first-child {
  fill: rgba(255, 255, 255, 0.14);
  stroke: rgba(255, 255, 255, 0.72);
  stroke-width: 1.5;
}

.brand-mark .brand-glyph {
  fill: none;
  stroke: #fff;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand h1,
.brand p,
.panel-header h2,
.dialog-header h2 {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
  letter-spacing: -0.02em;
}

.brand p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.card {
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  background: var(--panel-bg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.toolbar {
  margin-bottom: 18px;
  padding: 0;
  overflow: hidden;
}

.toolbar-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--panel-border);
}

.toolbar-titlebar > div {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.toolbar-titlebar h2 {
  margin: 0;
  font-size: 15px;
}

.toolbar-titlebar p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.toolbar-kicker {
  color: var(--muted);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.control-layout {
  display: grid;
  grid-template-columns: minmax(270px, 1.15fr) minmax(260px, 1fr) minmax(330px, 1.2fr) minmax(300px, 1.05fr);
  gap: 0;
}

.control-block {
  min-width: 0;
  padding: 20px 22px 22px;
}

.control-block + .control-block {
  border-left: 1px solid var(--panel-border);
}

.control-block-heading {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}

.control-step {
  display: grid;
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  place-items: center;
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 13%, transparent);
  color: var(--accent);
  font-size: 10px;
  font-weight: 900;
}

.control-block-heading h3,
.control-block-heading p {
  margin: 0;
}

.control-block-heading h3 {
  font-size: 13px;
  line-height: 1.2;
}

.control-block-heading p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.field-group {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.field-group label,
.eyebrow {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

select {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: var(--input-bg);
  color: var(--text);
  padding: 0 40px 0 14px;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

select:hover {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--panel-border));
}

select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

.template-loader {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
}

.load-template-button {
  min-width: 94px;
  min-height: 48px;
  white-space: nowrap;
}

.appearance-fields {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 10px;
}

.appearance-css-button {
  display: flex;
  grid-column: 1 / -1;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 14px;
}

.appearance-css-button > span:last-child {
  display: grid;
  gap: 2px;
  text-align: left;
}

.appearance-css-button strong {
  font-size: 13px;
  line-height: 1.1;
}

.appearance-css-button small {
  color: var(--muted);
  font-size: 9px;
  font-weight: 600;
}

.page-fields {
  display: grid;
  grid-template-columns: minmax(80px, 0.72fr) minmax(80px, 0.72fr) minmax(150px, 1.35fr);
  gap: 10px;
}

.export-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.pwa-install-area {
  grid-column: 1 / -1;
  margin-top: 2px;
  padding-top: 14px;
  border-top: 1px solid var(--panel-border);
}

.pwa-install-button {
  width: 100%;
  min-height: 48px;
}

.export-button {
  display: flex;
  min-width: 0;
  min-height: 68px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 8px 10px;
}

.export-button-icon {
  display: grid;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  place-items: center;
}

.export-button-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.export-button > span:last-child {
  display: grid;
  gap: 2px;
  text-align: left;
}

.export-button strong {
  font-size: 13px;
  line-height: 1;
}

.export-button small {
  color: var(--muted);
  font-size: 9px;
  font-weight: 600;
  white-space: nowrap;
}

.primary-button.export-button small {
  color: rgba(255, 255, 255, 0.78);
}

.icon-button,
.primary-button,
.secondary-button,
.ghost-button {
  border-radius: 11px;
  font-weight: 700;
}

.icon-button {
  display: grid;
  width: 42px;
  min-width: 42px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--panel-border);
  background: var(--panel-bg);
  color: var(--text);
}

.primary-button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  padding: 0 17px;
}

.primary-button:hover {
  background: var(--accent-hover);
}

.secondary-button {
  border: 1px solid var(--panel-border);
  background: var(--input-bg);
  color: var(--text);
  padding: 0 15px;
}

.ghost-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0 12px;
}

.editor-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.88fr) minmax(420px, 1.12fr);
  gap: 16px;
  min-height: calc(100vh - 152px);
}

.panel {
  display: flex;
  min-width: 0;
  min-height: 680px;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--panel-border);
}

.panel-header h2,
.dialog-header h2 {
  margin-top: 3px;
  font-size: 15px;
}

.status-text,
.status-pill {
  color: var(--muted);
  font-size: 11px;
}

.status-pill {
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 5px 9px;
}

.preview-header-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.preview-zoom-control {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.preview-zoom-control select {
  min-height: 34px;
  padding: 5px 28px 5px 9px;
  border: 1px solid var(--panel-border);
  border-radius: 9px;
  background: var(--input-bg);
  color: var(--text);
  font-size: 12px;
}

#markdownInput {
  width: 100%;
  min-height: 0;
  flex: 1;
  resize: none;
  border: 0;
  outline: 0;
  background: var(--input-bg);
  color: var(--text);
  padding: 22px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  line-height: 1.75;
  tab-size: 2;
}

.preview-viewport {
  flex: 1;
  overflow: auto;
  padding: 28px;
  background:
    linear-gradient(45deg, var(--soft-bg) 25%, transparent 25%),
    linear-gradient(-45deg, var(--soft-bg) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--soft-bg) 75%),
    linear-gradient(-45deg, transparent 75%, var(--soft-bg) 75%);
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
}

.portrait-preview-stage {
  width: 100%;
  margin: 0 auto;
}

.portrait-preview-stage[hidden] {
  display: none !important;
}

.portrait-paged-preview {
  display: grid;
  gap: 28px;
  justify-items: center;
}

.portrait-paged-preview.is-rendering::before {
  color: var(--muted-text);
  content: "PDFプレビューを生成中…";
}

.preview-portrait-sheet {
  width: var(--preview-page-width, 794px);
  aspect-ratio: 210 / 297;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.16);
}

.preview-portrait-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
}

.export-surface {
  width: 794px;
  min-height: 1123px;
  margin: 0;
  background: #fff;
  color: #1f2937;
}

.preview-render-source {
  position: fixed !important;
  left: -20000px !important;
  top: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.markdown-body {
  padding: 64px;
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.82;
}

.markdown-body > :first-child {
  margin-top: 0;
}

.markdown-body > :last-child {
  margin-bottom: 0;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  line-height: 1.3;
  letter-spacing: -0.025em;
}

.markdown-body h1 {
  margin: 0 0 28px;
  font-size: 34px;
}

.markdown-body h2 {
  margin: 40px 0 16px;
  font-size: 23px;
}

.markdown-body h3 {
  margin: 30px 0 12px;
  font-size: 18px;
}

.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body blockquote,
.markdown-body pre,
.markdown-body table {
  margin: 0 0 18px;
}

.markdown-body a {
  color: #f97316;
}

.markdown-body img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 24px auto;
  border-radius: 10px;
}

.markdown-body blockquote {
  margin-left: 0;
  padding: 4px 0 4px 18px;
  border-left: 4px solid #cbd5e1;
  color: #64748b;
}

.markdown-body code {
  border-radius: 5px;
  background: #f1f5f9;
  padding: 0.15em 0.38em;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.9em;
}

.markdown-body pre {
  overflow: auto;
  border-radius: 12px;
  background: #111827;
  color: #e5e7eb;
  padding: 18px;
}

.markdown-body pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
}

.markdown-body th,
.markdown-body td {
  border: 1px solid #d7dce2;
  padding: 9px 11px;
  text-align: left;
}

.markdown-body th {
  background: #f4f6f8;
}











.export-surface.export-landscape {
  width: 1123px;
  min-height: 794px;
}

/* 画面プレビューでは横用紙の幅だけを表示する。
   実際の2段組みはPDF生成時にページ単位で構成する。 */
.export-surface.export-landscape .markdown-body {
  columns: initial;
}

.export-surface.exporting {
  box-shadow: none !important;
}

dialog {
  width: min(760px, calc(100vw - 32px));
  border: 0;
  border-radius: 18px;
  background: transparent;
  padding: 0;
}

dialog::backdrop {
  background: rgba(2, 6, 23, 0.66);
  backdrop-filter: blur(4px);
}

.dialog-card {
  display: grid;
  gap: 16px;
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  background: var(--panel-bg);
  color: var(--text);
  padding: 20px;
  box-shadow: var(--shadow);
}

.dialog-header,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-description {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

#customCssInput {
  width: 100%;
  min-height: 360px;
  resize: vertical;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  outline: none;
  background: var(--input-bg);
  color: var(--text);
  padding: 16px;
  font-family: "SFMono-Regular", Consolas, monospace;
  line-height: 1.6;
}

.dialog-actions {
  justify-content: flex-end;
}

@media (max-width: 1380px) {
  .control-layout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .control-block:nth-child(3) {
    border-left: 0;
  }

  .control-block:nth-child(n + 3) {
    border-top: 1px solid var(--panel-border);
  }
}

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

  .panel {
    min-height: 620px;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 12px;
  }

  .brand p {
    display: none;
  }

  .toolbar-titlebar {
    align-items: flex-start;
    padding: 15px 16px;
  }

  .toolbar-titlebar p {
    display: none;
  }

  .control-layout {
    grid-template-columns: 1fr;
  }

  .control-block {
    padding: 18px 16px 20px;
  }

  .control-block + .control-block,
  .control-block:nth-child(3) {
    border-left: 0;
    border-top: 1px solid var(--panel-border);
  }

  .preview-viewport {
    padding: 12px;
  }

  /* 画面幅に応じてA4用紙全体を縮小し、改行位置と余白を維持する。 */
}

@media (max-width: 480px) {
  .template-loader,
  .appearance-fields,
  .page-fields {
    grid-template-columns: 1fr;
  }

  .load-template-button {
    width: 100%;
  }

  .export-buttons {
    grid-template-columns: 1fr;
  }

  .appearance-css-button {
    justify-content: flex-start;
    padding-inline: 18px;
  }

  .export-button {
    min-height: 54px;
    justify-content: flex-start;
    padding-inline: 18px;
  }
}

.is-hidden {
  display: none !important;
}





/* =========================================================
   出力共通設定：ここから
   テンプレート固有の装飾は templates/*.css に配置
   ========================================================= */
.export-surface.font-gothic .markdown-body {
  font-family: "Noto Sans JP", "Yu Gothic", "Hiragino Kaku Gothic ProN",
    Meiryo, sans-serif;
}

.export-surface.font-mincho .markdown-body {
  font-family: "Noto Serif JP", "Yu Mincho", "Hiragino Mincho ProN",
    "MS PMincho", serif;
}

.export-surface.font-size-small .markdown-body {
  font-size: 13px;
  line-height: 1.7;
}

.export-surface.font-size-medium .markdown-body {
  font-size: 15px;
  line-height: 1.8;
}

.export-surface.font-size-large .markdown-body {
  font-size: 17px;
  line-height: 1.9;
}
/* 出力共通設定：ここまで */


/* =========================================================
   出力余白
   ========================================================= */
.export-surface.margin-narrow .markdown-body{
  padding:40px;
}
.export-surface.margin-normal .markdown-body{
  padding:64px;
}
.export-surface.margin-wide .markdown-body{
  padding:88px;
}


/* =========================================================
   PDF PAGE ENGINE
   ========================================================= */
.pdf-workspace {
  position: fixed;
  top: 0;
  left: -50000px;
  z-index: -1;
  display: block;
  width: max-content;
  background: #fff;
}

/* 1枚の縦A4ページ */
.export-surface.pdf-portrait-sheet {
  position: relative;
  display: block;
  width: 794px;
  height: 1123px;
  min-height: 1123px;
  margin: 0;
  overflow: hidden;
  background: #fff;
  box-shadow: none;
}

.pdf-portrait-sheet .pdf-page-content {
  width: 100%;
  height: 100%;
  overflow: hidden;
  box-sizing: border-box;
}

/* PDFでは画面より少し小さめ */
.pdf-portrait-sheet.font-size-small .pdf-page-content {
  font-size: 11.5px;
  line-height: 1.58;
}

.pdf-portrait-sheet.font-size-medium .pdf-page-content {
  font-size: 13px;
  line-height: 1.64;
}

.pdf-portrait-sheet.font-size-large .pdf-page-content {
  font-size: 14.5px;
  line-height: 1.7;
}

/* 余白 */
.pdf-portrait-sheet.margin-narrow .pdf-page-content {
  padding: 42px;
}

.pdf-portrait-sheet.margin-normal .pdf-page-content {
  padding: 64px;
}

.pdf-portrait-sheet.margin-wide .pdf-page-content {
  padding: 88px;
}

/* A4横の1枚。中に縦A4を2枚縮小配置する */
.pdf-landscape-sheet {
  position: relative;
  display: grid;
  width: 1123px;
  height: 794px;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: center;
  padding: 12px;
  overflow: hidden;
  box-sizing: border-box;
  background: #fff;
}

.pdf-landscape-sheet::after {
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: 50%;
  width: 1px;
  background: #d9dde3;
  content: "";
}

.pdf-two-up-slot {
  position: relative;
  display: flex;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* 794x1123 を 0.68倍すると約540x764。A4横の半分へ収まる */
.pdf-two-up-page {
  flex: none;
  transform: scale(.68);
  transform-origin: center center;
  box-shadow: none !important;
}

/* ページ分割時の見出し孤立を抑える */
.pdf-page-content h1,
.pdf-page-content h2,
.pdf-page-content h3,
.pdf-page-content h4 {
  break-after: avoid;
}

.pdf-page-content table,
.pdf-page-content pre,
.pdf-page-content blockquote,
.pdf-page-content img {
  break-inside: avoid;
}

/* PDF v2: 画面外で縦A4原稿だけをレンダリングする */
.pdf-raster-workspace {
  position: fixed;
  top: 0;
  left: -100000px;
  z-index: -1;
  width: max-content;
  height: auto;
  overflow: visible;
  background: #fff;
  pointer-events: none;
}

.export-surface.pdf-raster-source {
  width: 794px !important;
  min-height: 0 !important;
  height: auto !important;
  margin: 0 !important;
  overflow: visible !important;
  box-shadow: none !important;
}

.pdf-raster-content {
  min-height: 0 !important;
  overflow: visible !important;
}


/* A4横・2段組みプレビュー。PDFと同じ縦ページ画像を左右に面付けする。 */
.landscape-preview {
  display: grid;
  width: 100%;
  gap: 28px;
  justify-items: center;
}

.landscape-preview[hidden] {
  display: none !important;
}

.landscape-preview.is-rendering::before {
  display: block;
  color: var(--muted-text);
  content: "2段組みプレビューを生成中…";
}

.preview-landscape-sheet {
  position: relative;
  display: grid;
  width: min(100%, 1123px);
  aspect-ratio: 297 / 210;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.16);
}

.preview-landscape-sheet::after {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  background: #d9dde3;
  content: "";
}

.preview-two-up-slot {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #fff;
}

.preview-two-up-slot.is-empty {
  background: #fff;
}

.preview-two-up-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
}


/* Local image import */
.editor-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.compact-action-button {
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-muted);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.compact-action-button:hover { border-color: var(--accent); }
.compact-action-button:disabled { opacity: .55; cursor: wait; }
.image-status { color: var(--muted); font-size: .78rem; white-space: nowrap; }
.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;
}

#markdownInput.is-image-dragover {
  outline: 3px dashed var(--accent);
  outline-offset: -8px;
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}

.markdown-body img[data-mdlab-image-id] {
  display: block;
  max-width: 100%;
  height: auto;
}

.markdown-body img.missing-local-image {
  min-height: 96px;
  border: 2px dashed #d1d5db;
  background: #f8fafc;
}

@media (max-width: 640px) {
  .editor-header-actions { gap: 7px; }
  .image-status { display: none; }
  .compact-action-button { padding-inline: 10px; }
}


/* =========================================================
   PDF画像・ブロック改ページ
   ========================================================= */
.pdf-raster-content img {
  display: block;
  max-width: 100%;
  max-height: var(--pdf-printable-height, 995px);
  width: auto;
  height: auto;
  margin-right: auto;
  margin-left: auto;
  object-fit: contain;
}

.pdf-raster-content .pdf-atomic-block,
.pdf-raster-content figure,
.pdf-raster-content p:has(> img) {
  break-inside: avoid;
  page-break-inside: avoid;
}

.pdf-page-spacer {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
}


/* =========================================================
   PDF 読みやすい改ページ
   ========================================================= */
.pdf-raster-content .pdf-table-fragment {
  width: 100%;
  margin-top: 0;
  margin-bottom: 1em;
}

.pdf-raster-content .pdf-table-fragment thead {
  display: table-header-group;
}

.pdf-raster-content .pdf-list-fragment {
  margin-top: 0;
}

.pdf-raster-content h1,
.pdf-raster-content h2,
.pdf-raster-content h3,
.pdf-raster-content h4,
.pdf-raster-content h5,
.pdf-raster-content h6 {
  break-after: avoid;
  page-break-after: avoid;
}

.pdf-raster-content figure,
.pdf-raster-content pre,
.pdf-raster-content blockquote,
.pdf-raster-content details,
.pdf-raster-content .pdf-table-fragment,
.pdf-raster-content .pdf-list-fragment,
.pdf-raster-content p:has(> img) {
  break-inside: avoid;
  page-break-inside: avoid;
}

.inline-field-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.inline-field-actions select {
  min-width: 0;
}

.inline-field-actions .secondary-button {
  min-width: 72px;
  white-space: nowrap;
  padding-inline: 14px;
}

.preview-error-message {
  width: min(100%, 560px);
  margin: 24px auto;
  padding: 18px 20px;
  border: 1px solid rgba(220, 38, 38, 0.25);
  border-radius: 12px;
  background: #fff;
  color: #991b1b;
  text-align: center;
}

/* 複数ページPDFプレビュー */
.preview-portrait-sheet,
.preview-landscape-sheet {
  position: relative;
  flex: 0 0 auto;
}

.preview-portrait-sheet::after,
.preview-landscape-sheet::after {
  position: absolute;
  right: 8px;
  bottom: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  content: attr(data-page-label);
  font: 10px/1.5 system-ui, sans-serif;
  pointer-events: none;
}

.portrait-paged-preview.is-rendering,
.landscape-preview.is-rendering {
  min-height: 180px;
}

/* Schedule専用のコンパクトな設定バー */
.schedule-toolbar {
  padding-bottom: 0;
}

.schedule-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr)) minmax(280px, 1.55fr);
  gap: 12px;
  align-items: end;
  padding: 20px 22px 22px;
}

.schedule-export-buttons {
  height: 100%;
  align-items: end;
}

.schedule-export-buttons .export-button {
  width: 100%;
  min-width: 0;
  min-height: 68px;
  border-radius: 12px;
}

.schedule-export-buttons .export-button > span:last-child {
  min-width: 64px;
}

.schedule-export-buttons .export-button[aria-busy="true"] {
  cursor: wait;
  opacity: 0.72;
}

.schedule-controls .pwa-install-button {
  grid-column: 1 / -1;
  min-height: 48px;
}

@media (max-width: 980px) {
  .schedule-controls {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .schedule-export-buttons {
    grid-column: 1 / -1;
  }

  .schedule-export-buttons .export-button {
    flex: 1;
  }
}

@media (max-width: 640px) {
  .schedule-controls {
    grid-template-columns: 1fr;
  }

  .schedule-export-buttons {
    grid-column: auto;
  }
}
