:root {
  --bee-black: #2b2620;
  --bee-yellow: #f4c430;
  --bee-yellow-dark: #d9a915;
  --paper: #fdfbf6;
  --gray-line: #cfc9bd;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", sans-serif;
  background: var(--paper);
  color: var(--bee-black);
}

.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

h1 {
  font-size: 1.5rem;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.lead {
  color: #5a5347;
  line-height: 1.7;
  margin-bottom: 24px;
  font-size: 0.95rem;
}

.dropzone {
  border: 2px dashed var(--bee-yellow-dark);
  border-radius: 12px;
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  background: #fffdf5;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.dropzone.drag-over {
  background: #fff6db;
  border-color: var(--bee-black);
}
.dropzone p {
  margin: 0;
  color: #6b6152;
  line-height: 1.8;
}

.status {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #f1efe8;
  font-size: 0.9rem;
  line-height: 1.6;
  white-space: pre-line;
}
.status.error { background: #fbe3e0; color: #9c3b2e; }
.status.ok { background: #eaf5e6; color: #34612a; }

.options {
  margin-top: 24px;
  padding: 18px;
  border: 1px solid var(--gray-line);
  border-radius: 10px;
  background: #fff;
}
.options h2 { font-size: 1rem; margin: 0 0 12px; }
.options label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  font-size: 0.92rem;
}
.options label[hidden] {
  /* the display:flex above wins over the UA [hidden]{display:none} rule
     (author styles beat UA styles regardless of specificity), so restate
     it explicitly here for rows toggled via the hidden attribute */
  display: none;
}
.checkbox-row {
  justify-content: flex-start !important;
  gap: 10px !important;
}
.checkbox-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  accent-color: var(--bee-yellow-dark);
  cursor: pointer;
}

.options input[type="number"] {
  width: 52px;
  padding: 6px 4px;
  border: 1px solid var(--gray-line);
  border-radius: 6px;
  font-size: 0.95rem;
  text-align: center;
  -moz-appearance: textfield;
}
/* hide the native spin buttons: they sit right at the input's edge, next
   to our own +/- buttons and the "mm" label, and are an easy mis-tap */
.options input[type="number"]::-webkit-outer-spin-button,
.options input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.stepper {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.step-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  margin: 0;
  border: 1px solid var(--gray-line);
  border-radius: 6px;
  background: #fff;
  color: var(--bee-black);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.step-btn:hover { background: #f1efe8; }
.step-btn:active { background: #e5e1d6; }
.unit {
  color: #6b6152;
  font-size: 0.85rem;
  /* fixed width regardless of the unit text ("mm" vs "%" etc.), so the
     stepper's overall width - and therefore the -/+ buttons' position -
     stays identical across rows instead of shifting with the label */
  display: inline-block;
  min-width: 1.6em;
}

.label-with-detail {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 2px 8px;
  min-width: 0;
}
/* overrides the generic "button, .download-btn" rule below (same specificity
   tie on :hover, so this needs "button.detail-link" to win reliably) */
button.detail-link {
  display: inline-block;
  appearance: none;
  -webkit-appearance: none;
  width: auto;
  border: none;
  background: none;
  padding: 0;
  margin: 0;
  font-size: 0.8rem;
  color: var(--bee-yellow-dark);
  text-decoration: underline;
  cursor: pointer;
}
button.detail-link:hover,
button.detail-link:focus-visible {
  background: none;
}
.detail-panel-wrap {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.2s ease;
}
.detail-panel-wrap.open { grid-template-rows: 1fr; }
.detail-panel-inner { overflow: hidden; }
.detail-panel-inner .schematic-label { margin: 0 0 12px; }

.schematic { margin: 4px 0 16px; }
.schematic-label {
  margin: 0 0 8px;
  font-size: 0.78rem;
  color: #6b6152;
}
.schematic-preview {
  display: flex;
  align-items: flex-start;
  gap: 0;
  overflow-x: auto;
  padding: 14px;
  background: #f6f4ee;
  border: 1px solid var(--gray-line);
  border-radius: 8px;
}
.schem-tag {
  position: relative;
  flex-shrink: 0;
  border: 1px dashed #b9b2a3;
  border-radius: 2px;
  background: #fff;
  transition: width 0.12s ease, height 0.12s ease;
}
.schem-fold {
  position: absolute;
  left: 2px;
  right: 2px;
  border-top: 1px dashed #b9b2a3;
  transition: top 0.12s ease;
  /* sits at the same y as the card's own top edge by design (like the
     real PDF's fold line), so it needs to stay above .schem-card - it's
     inserted before it in the markup and would otherwise be covered */
  z-index: 1;
}
.schem-cross {
  position: absolute;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #9a9284;
  font-size: 15px;
  line-height: 1;
  transition: top 0.12s ease;
  z-index: 1;
}
.schem-card {
  position: absolute;
  background: repeating-linear-gradient(45deg, #ece8dd, #ece8dd 4px, #f7f5ef 4px, #f7f5ef 8px);
  border-radius: 2px;
  transition: top 0.12s ease;
}
.schem-gap {
  flex-shrink: 0;
  transition: width 0.12s ease;
}

.cards-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.card-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--gray-line);
  border-radius: 8px;
  background: #f6f4ee;
  width: 160px;
}
.card-thumb {
  width: 100%;
  height: auto;
  border: 1px solid var(--gray-line);
  border-radius: 4px;
  background: #fff;
}
.card-item .stepper { justify-content: center; }
.card-item .unit { min-width: 1.4em; }

.restore-settings-row {
  margin-bottom: 14px;
}
.secondary-btn {
  background: #fff;
  color: var(--bee-black);
  border: 1px solid var(--gray-line);
  font-weight: 500;
  font-size: 0.88rem;
}
.secondary-btn:hover { background: #f1efe8; }

.presets-block { margin-bottom: 14px; }
.presets-list {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.preset-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--gray-line);
  border-radius: 8px;
  background: #f6f4ee;
}
.preset-info { min-width: 0; }
.preset-name {
  font-size: 0.9rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.preset-date {
  font-size: 0.75rem;
  color: #6b6152;
}
.preset-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.preset-actions button {
  width: auto;
  margin: 0;
  padding: 6px 10px;
  font-size: 0.82rem;
}
.preset-delete-btn {
  background: #fff;
  color: #9c3b2e;
  border: 1px solid var(--gray-line);
}
.preset-delete-btn:hover { background: #fbe3e0; }
.presets-save-row {
  display: flex;
  gap: 8px;
}
.presets-save-row input[type="text"] {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--gray-line);
  border-radius: 6px;
  font-size: 0.9rem;
}
.presets-save-row button {
  width: auto;
  white-space: nowrap;
  margin: 0;
  padding: 8px 14px;
}

button, .download-btn {
  display: inline-block;
  width: 100%;
  text-align: center;
  padding: 12px 16px;
  border: none;
  border-radius: 8px;
  background: var(--bee-black);
  color: var(--bee-yellow);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  margin-top: 6px;
}
button:hover, .download-btn:hover { background: #45392a; }
button:disabled { background: #ccc; cursor: not-allowed; }

.preview {
  margin-top: 28px;
}
.preview h2 { font-size: 1rem; margin-bottom: 10px; }
.preview-pages {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.preview-page-label {
  margin: 0 0 6px;
  font-size: 0.78rem;
  color: #6b6152;
}
.preview-page-canvas {
  width: 100%;
  border: 1px solid var(--gray-line);
  border-radius: 8px;
  background: white;
}

footer {
  margin-top: 40px;
  font-size: 0.78rem;
  color: #9a9284;
  text-align: center;
  line-height: 1.6;
}

.usage-link {
  display: inline-block;
  margin-bottom: 12px;
  margin-right: 16px;
  font-size: 0.85rem;
  color: var(--bee-black);
  text-decoration: underline;
}

.changelog {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin: 24px 0 32px;
}
.changelog-entry h2 {
  font-size: 0.95rem;
  margin: 0 0 8px;
  color: #6b6152;
}
.changelog-entry ul {
  margin: 0;
  padding-left: 1.3em;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.changelog-entry li {
  line-height: 1.6;
}

.guide-steps {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 24px;
}
.guide-step {
  display: flex;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--gray-line);
  border-radius: 10px;
  background: #fff;
}
.guide-step-body {
  /* without this, the step's img forces the flex item wider than the
     card since a flex item's default min-width is its content size */
  min-width: 0;
}
.guide-step-num {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bee-yellow);
  color: var(--bee-black);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.guide-step-body h2 {
  font-size: 1rem;
  margin: 2px 0 6px;
}
.guide-step-body p {
  margin: 0;
  font-size: 0.9rem;
  color: #5a5347;
  line-height: 1.7;
}
.guide-img {
  /* screenshots already have their own border baked in (they're crops of
     already-bordered UI elements) - adding another one here just doubles
     the line at every edge */
  display: block;
  width: 100%;
  max-width: 320px;
  margin-top: 12px;
}
/* for crops that don't already carry a border in the screenshot itself
   (e.g. a plain row or list with no bordered container of its own) */
.guide-img.bordered {
  border: 1px solid var(--gray-line);
  border-radius: 8px;
}

/* 「このまま印刷する」ボタンと、印刷専用のページ画像 */
.print-btn { margin-top: 10px; }
.print-note {
  margin: 8px 0 0;
  font-size: 0.8rem;
  color: #6b6255;
  line-height: 1.6;
}
.print-area { display: none; }
@media print {
  html, body { margin: 0 !important; padding: 0 !important; background: #fff !important; }
  body > *:not(.print-area) { display: none !important; }
  .print-area { display: block; }
  .print-sheet {
    overflow: hidden;
    break-after: page;
    page-break-after: always;
  }
  .print-sheet:last-child { break-after: auto; page-break-after: auto; }
  .print-sheet img { display: block; width: 100%; height: 100%; }
}

/* カットガイドの選択（点線／トンボ／なし） */
.select-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
  font-size: 0.9rem;
}
.select-row > span { white-space: nowrap; flex-shrink: 0; }
.select-row select {
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid var(--gray-line);
  border-radius: 6px;
  background: #fff;
  font-size: 0.9rem;
  color: var(--bee-black);
}
/* トンボ in the 2-tag illustration */
.schem-group { position: relative; display: flex; align-items: flex-start; }
.schematic-preview.crop { padding: 26px; }
.schematic-preview.crop .schem-tag { border: none; }
.schem-mark { position: absolute; background: #a6a6a6; }
.schem-mark.v { width: 1px; margin-left: -0.5px; }
.schem-mark.h { height: 1px; margin-top: -0.5px; }
.schem-dot { position: absolute; width: 4px; height: 4px; margin: -2px 0 0 -2px; border-radius: 50%; background: #a6a6a6; z-index: 2; }
