/* ============================================================
   フォームUI（左パネル）+ プレビュー枠（右パネル）
   ============================================================ */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, 'Helvetica Neue', 'Hiragino Sans', 'Yu Gothic', sans-serif;
  color: #2a2231;
  background: #f5f3f7;
  -webkit-font-smoothing: antialiased;
}

/* --- パスワードゲート --- */
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: linear-gradient(160deg, #d785b5, #9d6a98);
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-card {
  background: #fff;
  padding: 48px 56px;
  border-radius: 16px;
  box-shadow: 0 30px 60px rgba(0,0,0,0.18);
  text-align: center;
  width: 360px;
}
.auth-logo {
  width: 220px;
  margin-bottom: 16px;
}
.auth-card h1 {
  font-size: 18px;
  margin: 0 0 6px;
  letter-spacing: 0.05em;
}
.auth-card p {
  font-size: 13px;
  color: #6b5e72;
  margin: 0 0 18px;
}
.auth-card input {
  width: 100%;
  padding: 14px 16px;
  min-height: 48px;          /* タッチターゲット */
  font-size: 16px;           /* iOS で 16px 未満だと自動ズームかかる */
  border: 1px solid #d8d0e0;
  border-radius: 8px;
  margin-bottom: 12px;
}
.auth-card button {
  width: 100%;
  padding: 14px;
  min-height: 48px;
  font-size: 15px;
  background: #6a3d6f;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  letter-spacing: 0.1em;
}
.auth-card button:hover { background: #4f2a55; }
.auth-error {
  color: #c44;
  font-size: 12px;
  margin: 10px 0 0;
  min-height: 16px;
}

/* --- アプリレイアウト --- */
.app {
  display: grid;
  grid-template-columns: 460px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* --- 左パネル: フォーム --- */
.panel-form {
  background: #fff;
  border-right: 1px solid #e7e1ed;
  overflow-y: auto;
  padding: 0 24px 40px;
}
.panel-form__header {
  position: sticky;
  top: 0;
  background: #fff;
  padding: 18px 0 14px;
  border-bottom: 1px solid #eee5f0;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 10;
  margin-bottom: 12px;
}
.panel-form__logo {
  width: 130px;
  height: auto;
}
.panel-form__header h1 {
  font-size: 14px;
  font-weight: 500;
  margin: 0;
  letter-spacing: 0.04em;
  flex: 1;
}
.panel-form__header h1 span {
  display: block;
  font-size: 11px;
  color: #8b7a96;
  margin-top: 3px;
  letter-spacing: 0.08em;
}

/* リセットボタン */
.btn-reset {
  background: #fff5e6;
  color: #8a5a1c;
  border: 1px solid #f0d8a8;
  border-radius: 8px;
  padding: 10px 14px;
  min-height: 44px;
  min-width: 44px;
  font-size: 12px;
  cursor: pointer;
  letter-spacing: 0.04em;
  font-weight: 500;
}
.btn-reset:hover { background: #fae8c8; }
.btn-reset:focus-visible {
  outline: 2px solid #8a5a1c;
  outline-offset: 2px;
}

/* 一括アップロード */
.bulk-upload {
  display: block;
  margin-bottom: 10px;
  cursor: pointer;
}
.bulk-upload input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}
.bulk-upload__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 12px 18px;
  background: #6a3d6f;
  color: #fff;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.15s;
}
.bulk-upload:hover .bulk-upload__btn { background: #4f2a55; }
.bulk-upload__hint {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: #8b7a96;
  letter-spacing: 0.03em;
}
.bulk-upload input[type="file"]:focus-visible + .bulk-upload__btn {
  outline: 2px solid #6a3d6f;
  outline-offset: 2px;
}

/* QR フォールバック（画像アップロード方式） */
.qr-fallback__label {
  display: block;
  font-size: 11px;
  color: #8b7a96;
  margin-bottom: 4px;
  letter-spacing: 0.03em;
}

.panel-form fieldset {
  border: none;
  border-top: 1px solid #f0e8f5;
  padding: 18px 0 8px;
  margin: 0;
}
.panel-form legend {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: #6a3d6f;
  padding: 0 0 10px;
}
.panel-form label {
  display: block;
  font-size: 12px;
  color: #5a4e63;
  margin-bottom: 12px;
  letter-spacing: 0.03em;
}
.panel-form label.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.panel-form input[type="text"],
.panel-form input[type="number"],
.panel-form input[type="email"],
.panel-form textarea {
  display: block;
  width: 100%;
  padding: 12px 12px;          /* タッチターゲット拡大 */
  min-height: 44px;            /* Apple HIG 44px */
  margin-top: 4px;
  font-size: 14px;             /* 13px → 14px 可読性UP */
  border: 1px solid #ddd3e3;
  border-radius: 6px;
  background: #fafafd;
}
.panel-form textarea {
  min-height: 60px;            /* textarea は複数行なので高め */
}
.panel-form input[type="file"] {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  width: 100%;
  min-height: 44px;            /* タッチターゲット */
  padding: 10px 0;
}
.panel-form input:focus,
.panel-form textarea:focus {
  outline: none;
  border-color: #9c6aa3;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(156, 106, 163, 0.15); /* focus-visible 強化 */
}
.panel-form input:focus-visible,
.panel-form textarea:focus-visible,
.panel-form button:focus-visible {
  outline: 2px solid #6a3d6f;
  outline-offset: 2px;
}
.panel-form textarea { resize: vertical; }
.panel-form .hint {
  font-size: 12px;
  color: #8b7a96;
  margin: 0 0 10px;
  line-height: 1.5;
}

/* 写真アップロードのリスト */
.photo-uploads {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.photo-slot {
  border: 1px dashed #d8cce0;
  border-radius: 6px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #fafafd;
  position: relative;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.photo-slot.dragging {
  opacity: 0.5;
  transform: scale(0.95);
}
.photo-slot.drop-target {
  border-color: #6a3d6f;
  border-style: solid;
  box-shadow: 0 0 0 3px rgba(106, 61, 111, 0.15);
}
.photo-slot__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.photo-slot__label {
  font-size: 11px;
  color: #6b5e72;
  letter-spacing: 0.08em;
}
.photo-slot__drag {
  color: #b8a8c0;
  font-size: 14px;
  cursor: grab;
  user-select: none;
  padding: 4px;
}
.photo-slot__drag:active { cursor: grabbing; }
.photo-slot__thumb {
  width: 100%;
  aspect-ratio: 4 / 5;
  background: #fff;
  border-radius: 3px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #b8a8c0;
  font-size: 10px;
}
.photo-slot__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* 写真スロット内：file input を label でラップして領域拡大想定 */
.photo-slot input[type="file"] {
  font-size: 12px;
  width: 100%;
  min-height: 44px;       /* タッチターゲット */
  padding: 10px 0;
  cursor: pointer;
}

/* 詳細リスト */
.details-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}
.detail-row {
  display: grid;
  grid-template-columns: 1fr 1.5fr auto;
  gap: 6px;
  align-items: center;
}
.detail-row input {
  margin-top: 0 !important;
}
.detail-row button {
  background: #f5e9f7;
  color: #6a3d6f;
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  min-height: 44px;        /* タッチターゲット */
  min-width: 44px;
  font-size: 13px;
  cursor: pointer;
}
.detail-row button:hover { background: #e8d4ed; }

/* 書き出しボタン */
.actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 24px;
  position: sticky;
  bottom: 0;
  background: linear-gradient(180deg, transparent, #fff 30%);
  padding: 16px 0 8px;
}

/* フォーマット選択 */
.format-selector {
  border: 1px solid #e7e1ed !important;
  border-radius: 8px !important;
  padding: 12px !important;
  margin: 0 0 8px !important;
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  background: #faf6fc;
}
.format-selector legend {
  font-size: 12px !important;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: #6a3d6f;
  padding: 0 8px !important;
}
.format-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1.5px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  background: #fff;
  margin-bottom: 0 !important;
}
.format-opt input[type="radio"] {
  width: 18px;
  height: 18px;
  margin: 0;
  cursor: pointer;
  flex-shrink: 0;
}
.format-opt span {
  font-size: 13px;
  color: #2a2231;
  line-height: 1.4;
}
.format-opt span small {
  font-size: 11px;
  color: #8b7a96;
}
.format-opt:has(input:checked) {
  border-color: #6a3d6f;
  background: #f5edf7;
}
.btn-primary,
.btn-secondary {
  padding: 14px 16px;
  min-height: 48px;        /* 主要ボタンは48px（タッチ最低限+α） */
  font-size: 14px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  letter-spacing: 0.08em;
  font-weight: 500;
}
.btn-primary {
  background: #6a3d6f;
  color: #fff;
}
.btn-primary:hover { background: #4f2a55; }
.btn-primary:disabled {
  background: #b8a8c0;
  cursor: wait;
}
.btn-secondary {
  background: #f0e6f5;
  color: #6a3d6f;
}
.btn-secondary:hover { background: #e2d2ec; }

.footer-note {
  font-size: 11px;
  color: #8b7a96;
  line-height: 1.6;
  margin: 14px 0 0;
}

/* --- 右パネル: プレビュー --- */
.panel-preview {
  background: #ece5f1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.preview-toolbar {
  background: #fff;
  border-bottom: 1px solid #ddd3e3;
  padding: 10px 18px;
  font-size: 12px;
  color: #5a4e63;
  display: flex;
  align-items: center;
  gap: 18px;
  letter-spacing: 0.04em;
}
.preview-toolbar label {
  display: flex;
  align-items: center;
  gap: 8px;
}
.preview-toolbar input[type="range"] {
  width: 180px;
  height: 32px;             /* つまみ含めた全体高さ確保 */
  cursor: pointer;
  /* タッチ操作対応：thumb大きく */
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
}
.preview-toolbar input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  background: #ddd3e3;
  border-radius: 3px;
}
.preview-toolbar input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #6a3d6f;
  cursor: pointer;
  margin-top: -9px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}
.preview-toolbar input[type="range"]::-moz-range-track {
  height: 6px;
  background: #ddd3e3;
  border-radius: 3px;
}
.preview-toolbar input[type="range"]::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: #6a3d6f;
  cursor: pointer;
}
.preview-wrap {
  flex: 1;
  overflow: auto;
  padding: 24px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

/* プレビュー時のポスター縮小 */
#poster {
  transform-origin: top center;
  box-shadow: 0 10px 40px rgba(0,0,0,0.15);
}

/* 書き出し時はスケールを外す（JSで一時的にtransform解除） */
