:root {
  --bg: #f3f3f3;
  --panel: #ffffff;
  --line: #d6d6d6;
  --line-strong: #a8a8a8;
  --text: #111111;
  --muted: #666666;
  --accent: #2b2b2b;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
  --paper-width: 210mm;
  --paper-height: 297mm;
  --ui-font: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--ui-font);
}

body {
  line-height: 1.5;
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 20px;
  min-height: 100vh;
  padding: 20px;
}

.app-sidebar,
.preview-panel {
  min-width: 0;
}

.app-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.panel-header h1,
.flyer-header h2,
.info-block h3,
.content-block h3 {
  margin: 0;
}

.panel-header p,
.preview-toolbar small {
  margin: 0;
  color: var(--muted);
}

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.toolbar button {
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  background: #111111;
  color: #ffffff;
  cursor: pointer;
}

.toolbar .ghost {
  background: #ffffff;
  color: var(--text);
}

.fit-status {
  padding: 10px 12px;
  border: 1px solid #9f9f9f;
  background: #f1f1f1;
  color: #111111;
  font-size: 0.92rem;
  font-weight: 700;
}

.fit-status p {
  margin: 0;
  line-height: 1.5;
}

.form-grid {
  display: grid;
  gap: 14px;
}

.form-grid label {
  display: grid;
  gap: 6px;
}


.form-grid label span {
  font-size: 0.92rem;
}

.form-grid label strong {
  font-weight: 700;
}

.form-grid input,
.form-grid textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: #fcfcfc;
  color: var(--text);
}

.form-grid textarea {
  resize: vertical;
}

.field-note {
  color: var(--muted);
  font-size: 0.84rem;
}

.customize-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  background: #fafafa;
}

.customize-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 10px;
}

.customize-head h2 {
  margin: 0;
  font-size: 1rem;
}

.customize-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

.customize-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

.customize-actions {
  display: flex;
}

.customize-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  background: #ffffff;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
}

.preview-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 2px 4px;
  color: var(--muted);
}

.paper-frame {
  display: flex;
  justify-content: center;
  padding: 20px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(246, 246, 246, 0.98)),
    repeating-linear-gradient(
      45deg,
      rgba(0, 0, 0, 0.01),
      rgba(0, 0, 0, 0.01) 6px,
      rgba(255, 255, 255, 0.01) 6px,
      rgba(255, 255, 255, 0.01) 12px
    );
}

.flyer-paper {
  width: min(100%, 210mm);
  min-height: 297mm;
  padding: 12mm 12mm 10mm;
  background: #ffffff;
  color: #000000;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 5.5mm;
}

.flyer-header {
  border-bottom: 1px solid #d8d8d8;
  padding-bottom: 3.5mm;
}

.subtitle {
  margin: 0 0 2mm;
  font-size: 3.5mm;
  color: #555555;
}

.flyer-header h2 {
  font-size: clamp(7.5mm, 4vw, 10.5mm);
  line-height: 1.08;
  letter-spacing: 0.02em;
}

.catchcopy {
  margin: 2.5mm 0 0;
  font-size: 3.7mm;
  font-weight: 700;
}

.image-section {
  border: 1px solid #d7d7d7;
  overflow: hidden;
  height: 72mm;
  background: #f1f1f1;
}

.image-section img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  filter: grayscale(100%);
}

.info-block,
.content-block,
.qr-section,
.flyer-footer {
  break-inside: avoid;
}

.info-block h3,
.content-block h3 {
  margin-bottom: 2.2mm;
  font-size: 3.3mm;
  border-left: 3px solid #333333;
  padding-left: 2.4mm;
}

.info-list {
  margin: 0;
  border-top: 1px solid #d9d9d9;
}

.info-row {
  display: grid;
  grid-template-columns: 20mm 1fr;
  gap: 4mm;
  padding: 2.2mm 0;
  border-bottom: 1px solid #e4e4e4;
}

.info-row dt {
  font-weight: 700;
}

.info-row dd {
  margin: 0;
}

.multiline {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
}

.note-block {
  background: #f8f8f8;
  border: 1px solid #dfdfdf;
  padding: 3.2mm;
}

.notes-qr-wrap {
  display: flex;
  gap: 4mm;
  align-items: start;
}

.notes-qr-wrap .note-block,
.notes-qr-wrap .qr-section {
  margin: 0;
}

.notes-qr-wrap .note-block {
  flex: 1 1 auto;
  min-width: 0;
}

.notes-qr-wrap .qr-section {
  flex: 0 0 34mm;
  width: 34mm;
}

.qr-section {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 2mm;
  padding-top: 0;
}

.qr-box {
  display: inline-flex;
  padding: 2.6mm;
  border: 1px solid #cfcfcf;
}

.qr-box canvas {
  width: 24mm;
  height: 24mm;
}

.qr-text {
  margin: 0;
  font-size: 2.9mm;
  text-align: center;
  line-height: 1.35;
}

.flyer-footer {
  margin-top: auto;
  border-top: 1px solid #d8d8d8;
  padding-top: 3.5mm;
}

.footer-line {
  margin: 0;
  font-size: 3.1mm;
  line-height: 1.45;
}

.footer-line + .footer-line {
  margin-top: 2mm;
}

.hidden {
  display: none !important;
}

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

  .paper-frame {
    overflow-x: auto;
    justify-content: flex-start;
  }

  .flyer-paper {
    width: 210mm;
    flex: 0 0 auto;
  }

  .notes-qr-wrap {
    display: block;
  }

  .notes-qr-wrap .qr-section {
    width: auto;
  }
}

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

  html,
  body {
    background: #ffffff;
  }

  .app-sidebar,
  .preview-toolbar,
  .customize-card {
    display: none !important;
  }

  .app-shell,
  .preview-panel,
  .paper-frame {
    display: block;
    padding: 0;
    margin: 0;
    border: 0;
    background: #ffffff;
  }

  .flyer-paper {
    width: 210mm;
    min-height: 297mm;
    margin: 0;
    padding: 12mm 12mm 10mm;
    box-shadow: none;
  }

  .notes-qr-wrap {
    display: flex;
    gap: 4mm;
    align-items: flex-start;
  }

  .notes-qr-wrap .note-block {
    flex: 1 1 auto;
  }

  .notes-qr-wrap .qr-section {
    flex: 0 0 34mm;
    width: 34mm;
  }
}
