/* ============================================================================
   cheer-print.com のデザイン言語を踏襲
   - ベース: 背景 #F7F7F7 / 面 #fff / 文字 #3A3A3A (Noto Sans JP)
   - アクセント: 黄 #F6D85C（ボタン・下線・ドット） / 青 #23509B（見出し・フッター）
   - ボタンはピル型。黄塗り→ホバー白 / 白+黒枠→ホバーで黄が左からスイープ
   - 見出しは中央揃え・青太字＋青黄交互ドット、背後に半透明黄の英字（Exo 2）
   ========================================================================== */
:root {
  --bg: #F7F7F7;
  --surface: #ffffff;
  --ink: #3A3A3A;
  --muted: #9FA3A7;
  --blue: #23509B;
  --yellow: #F6D85C;
  --yellow-pale: rgba(246, 216, 92, 0.3);
  --line-dark: #212121;
  --line: #D6D6D6;
  --line-soft: #E0E0E0;
  --radius: 10px;
  --pill: 30px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { overflow-x: hidden; }

::selection { background: #DCDEE3; color: #303338; }

body {
  margin: 0;
  font-family: "Noto Sans JP", -apple-system, "Hiragino Sans", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  /* コンテンツが短くてもフッターが画面下部にくるように */
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* ===== ヘッダー ===== */
.appbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 56px;
  padding: 0 14px;
  background: var(--surface);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.appbar .back {
  border: none;
  background: none;
  font-size: 30px;
  line-height: 1;
  color: var(--blue);
  padding: 0 4px;
  cursor: pointer;
}
.appbar .title {
  font-size: 15px;
  font-weight: 700;
  color: var(--blue);
  letter-spacing: 0.06em;
  cursor: pointer;
}
.appbar .title:active { opacity: .6; }
.appbar .my-prints {
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  cursor: pointer;
  width: 40px;
  height: 40px;
  padding: 0;
  transition: 0.3s;
}
.appbar .my-prints:hover,
.appbar .my-prints:active { border-color: var(--yellow); background: var(--yellow); }
/* ハンバーガーアイコン（中央線＋擬似要素で上下の線） */
.hamburger, .hamburger::before, .hamburger::after {
  display: block;
  width: 16px;
  height: 2px;
  border-radius: 1px;
  background: var(--ink);
}
.hamburger { position: relative; }
.hamburger::before, .hamburger::after { content: ""; position: absolute; left: 0; }
.hamburger::before { top: -5px; }
.hamburger::after { top: 5px; }

.container { width: 100%; max-width: 640px; margin: 0 auto; padding: 26px 16px 48px; flex: 1; }

/* ===== 見出し（青太字＋青黄ドット、背後に半透明黄の英字） ===== */
.screen-title {
  position: relative;
  z-index: 0;
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  color: var(--blue);
  margin: 10px 0 30px;
  padding: 18px 0 20px;
}
/* 背後の英字ウォーターマーク（data-en 属性） */
.screen-title::before {
  content: attr(data-en);
  font-family: "Exo 2", sans-serif;
  position: absolute;
  z-index: -1;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -58%);
  width: 100%;
  font-size: clamp(40px, 13vw, 60px);
  font-weight: 700;
  color: var(--yellow-pale);
  letter-spacing: 4px;
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
}
/* 青→黄→青の交互ドット */
.screen-title::after {
  content: "";
  position: absolute;
  bottom: 4px;
  left: 50%;
  margin-left: -14px;
  width: 6px;
  height: 6px;
  border-radius: 2px;
  background: var(--blue);
  box-shadow: 11px 0 0 var(--yellow), 22px 0 0 var(--blue);
}

/* ===== 写真選択 ===== */
/* 編集画面の .stage と同じ表示サイズに合わせる */
.selected-frame { position: relative; width: 100%; max-width: 360px; margin: 0 auto 18px; }
.selected-frame img { width: 100%; height: auto; display: block; }

/* ===== SAMPLE 透かし（表示用CSSオーバーレイ。操作を妨げないよう pointer-events:none） ===== */
/* 確認画面・マイプリントは compose が焼き込んだ透かし付き画像を使うため CSS オーバーレイは不要。
   写真選択・位置合わせはライブ表示（サーバ画像が無い）なので CSS オーバーレイで透かしを重ねる。 */
.selected-frame::after,
.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background-repeat: repeat;
  background-position: center;
  /* 確認画面（compose 焼き込み）と同じ見た目にそろえる：白文字＋黒縁の斜めタイル */
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='150'%20height='96'%3E%3Ctext%20x='75'%20y='52'%20fill='%23ffffff'%20fill-opacity='0.5'%20stroke='%23000000'%20stroke-opacity='0.5'%20stroke-width='1.5'%20paint-order='stroke'%20font-family='Arial,sans-serif'%20font-size='20'%20font-weight='bold'%20letter-spacing='2'%20text-anchor='middle'%20transform='rotate(-30%2075%2052)'%3ESAMPLE%3C/text%3E%3C/svg%3E");
}
.photo-pick {
  display: block;
  text-align: center;
  padding: 30px 14px;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
}
.photo-pick span {
  display: inline-block;
  padding: 12px 40px;
  background: var(--yellow);
  border: 1px solid var(--yellow);
  border-radius: var(--pill);
  font-weight: 700;
  transition: 0.3s;
}
.photo-pick:hover span { background: var(--surface); }
.photo-pick input { display: none; }

.hint {
  color: #777;
  font-size: 12px;
  margin-top: 18px;
  line-height: 1.8;
}
/* 見落とすと復旧できない注意書き（コンテンツ番号の控えなど） */
.hint-alert { color: #B03A2E; font-weight: 700; }

/* ===== 編集ステージ ===== */
.stage {
  position: relative;
  width: 100%;
  max-width: 360px;
  margin: 0 auto 20px;
  aspect-ratio: 89 / 127;
  background: #F0F0F0;
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  overflow: hidden;
  touch-action: none;
  user-select: none;
}
.stage-hint {
  max-width: 360px;
  margin: -8px auto 18px;
  text-align: center;
  font-size: 12px;
  color: #777;
}
.editor-photo { position: absolute; transform-origin: 50% 50%; will-change: transform; pointer-events: none; }
.editor-frame { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.controls { max-width: 360px; margin: 0 auto; }
.ctl { display: flex; align-items: center; gap: 12px; margin: 14px 0; font-size: 12px; color: var(--ink); }
.ctl span { width: 42px; font-weight: 700; }
/* スライダー: 細いグレーのバー ＋ 黄色いつまみ */
.ctl input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 24px;
  background: transparent;
  margin: 0;
  cursor: pointer;
}
.ctl input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  background: var(--line-soft);
  border-radius: 3px;
}
.ctl input[type="range"]::-moz-range-track {
  height: 6px;
  background: var(--line-soft);
  border-radius: 3px;
}
.ctl input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--yellow);
  border: 2px solid #fff;
  box-sizing: border-box;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
  margin-top: -9px; /* 6px トラックに対して中央寄せ */
}
.ctl input[type="range"]::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--yellow);
  border: 2px solid #fff;
  box-sizing: border-box;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
}
.ctl output { width: 50px; text-align: right; font-variant-numeric: tabular-nums; }

/* ===== ボタン（ピル型） ===== */
/* primary: 黄塗り→ホバーで白（common-button02 相当） */
/* ghost: 白＋黒枠→ホバーで黄が左からスイープ（common-button 相当） */
.primary, .ghost {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 52px;
  margin-top: 14px;
  padding: 0 16px;
  border-radius: var(--pill);
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  letter-spacing: 0.06em;
  color: var(--ink);
  cursor: pointer;
  transition: 0.3s;
}
.primary {
  background: var(--yellow);
  border: 1px solid var(--yellow);
}
.primary:hover { background: var(--surface); }
.primary:active { transform: translateY(1px); }
.ghost {
  background-color: var(--surface);
  border: 1px solid var(--line-dark);
  /* 黄色の塗りを background-size で左からスイープ */
  background-image: linear-gradient(var(--yellow), var(--yellow));
  background-repeat: no-repeat;
  background-size: 0% 100%;
  transition: background-size 0.25s cubic-bezier(0.45, 0, 0.55, 1);
}
.ghost:hover, .ghost:active { background-size: 100% 100%; }

.primary:disabled {
  background: #F0F0F0;
  border-color: var(--line-soft);
  color: #aaa;
  cursor: not-allowed;
}
.primary:disabled:hover { background: #F0F0F0; }
.primary:disabled:active { transform: none; }

/* ===== ローディング（下端の青ストライプバー） ===== */
.primary.is-loading, .ghost.is-loading { pointer-events: none; color: #777; overflow: hidden; }
.primary.is-loading::after, .ghost.is-loading::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 4px;
  background: repeating-linear-gradient(45deg, var(--blue) 0 6px, transparent 6px 12px);
  background-size: 17px 100%;
  animation: loading-bar .5s linear infinite;
}
@keyframes loading-bar {
  from { background-position: 0 0; }
  to { background-position: 17px 0; }
}

/* ===== 確認 ===== */
/* 編集画面の .stage と同じ表示サイズに合わせる（透かしオーバーレイの基準にもなる） */
.preview-wrap { position: relative; width: 100%; max-width: 360px; margin: 0 auto; }
.preview-img { display: block; width: 100%; border: 1px solid var(--line-soft); border-radius: 4px; }

/* ===== 完了 ===== */
.done-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 3px 0 0 #EAEAEA;
  padding: 28px 24px;
  text-align: center;
}
.done-label { font-size: 11px; color: var(--muted); letter-spacing: 0.14em; }
.print-number {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: .12em;
  margin: 10px 0;
  color: var(--blue);
  font-family: ui-monospace, monospace;
}
.print-expiry { font-size: 13px; color: #777; }

/* 完了画面: QRコード表示（コンビニ別） */
.qr-lead { font-size: 13px; margin: 20px 0 12px; }
.qr-vendor {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 3px 0 0 #EAEAEA;
  padding: 16px 18px;
  margin-bottom: 12px;
  text-align: center;
}
.qr-vendor-name { font-size: 14px; font-weight: 700; color: var(--blue); }
.qr-show-btn { max-width: 260px; margin: 12px auto 0; height: 44px; }

/* 完了画面: 価格・用紙・期限の一覧 */
.done-info { margin: 22px 0 8px; padding: 0; }
.done-info-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line-soft);
}
.done-info-row:first-child { border-top: 1px solid var(--line-soft); }
.done-info-row dt { font-size: 13px; font-weight: 700; margin: 0; }
.done-info-row dd { font-size: 14px; margin: 0; text-align: right; }

/* ===== QRコードモーダル ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.55);
}
/* display:flex が UA の [hidden]{display:none} より優先されてしまうため明示する */
.modal-overlay[hidden] { display: none; }
.modal {
  width: 100%;
  max-width: 360px;
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px 20px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}
.modal-title { font-size: 15px; font-weight: 700; color: var(--blue); margin: 0 0 14px; }
.qr-img {
  display: block;
  width: 200px;
  height: 200px;
  margin: 0 auto;
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  image-rendering: pixelated; /* QR の縁をぼかさない */
}
.qr-modal-note { margin-top: 12px; }
.modal .print-number { font-size: 26px; }
.modal .primary { margin-top: 16px; }

/* ===== マイプリント ===== */
.my-prints-list { display: flex; flex-direction: column; gap: 12px; }
.print-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 3px 0 0 #EAEAEA;
  padding: 14px 16px;
}
.print-row.expired { opacity: .5; }
.print-no { font-family: ui-monospace, monospace; font-weight: 700; letter-spacing: .08em; color: var(--blue); }
.print-sub { font-size: 12px; color: #777; margin-top: 3px; }
.print-row.soon .print-sub { color: var(--ink); font-weight: 700; }
.print-row.expired .print-sub { color: var(--muted); }

/* ===== 状態表示 ===== */
.loading, .empty { color: var(--muted); text-align: center; padding: 28px 0; }
.error {
  background: #FDECEA;
  color: #B03A2E;
  border: 1px solid #F1B7B1;
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 600;
  margin-top: 18px;
}
.footer {
  background: var(--blue);
  text-align: center;
  color: #fff;
  padding: 24px;
  font-size: 11px;
  letter-spacing: 0.1em;
}

/* ===== サイズ選択（価格表示） ===== */
.paper-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.paper-option {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
  transition: 0.2s;
}
/* 先頭のチェックインジケーター（利用規約チェックボックスと同テイスト） */
.paper-option::before {
  content: "";
  flex: none;
  width: 24px; height: 24px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--surface) center / 14px no-repeat;
  transition: 0.2s;
}
.paper-option-name { flex: 1; text-align: left; }
.paper-option:hover { border-color: var(--yellow); }
.paper-option.is-selected {
  border-color: var(--yellow);
  background: #FFFBEB;
  font-weight: 700;
}
.paper-option.is-selected::before {
  border-color: var(--yellow);
  background-color: var(--yellow);
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2014%2014'%3E%3Cpath%20d='M2.5%207.5l3%203%206-7'%20stroke='%233A3A3A'%20stroke-width='3'%20fill='none'%20stroke-linecap='round'%20stroke-linejoin='round'/%3E%3C/svg%3E");
  animation: check-pop 0.25s ease-out;
}
.paper-option-price { color: var(--blue); font-weight: 700; }

/* ===== 利用規約 ===== */
.terms-agree {
  display: flex; align-items: center; justify-content: center;
  width: fit-content; gap: 18px;
  margin: 6px auto 16px; padding: 4px 0; font-size: 14px; cursor: pointer;
}
/* カジュアルなカスタムチェックボックス（角丸＋黄色＋ポップ） */
.terms-agree input {
  -webkit-appearance: none;
  appearance: none;
  flex: none;
  width: 26px; height: 26px; margin: 0;
  display: grid; place-content: center;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
  transition: 0.2s;
}
.terms-agree input:hover { border-color: var(--yellow); }
.terms-agree input:checked {
  background: var(--yellow);
  border-color: var(--yellow);
  animation: check-pop 0.25s ease-out;
}
/* チェックマーク（回転させたL字ボーダー） */
.terms-agree input::after {
  content: "";
  width: 6px; height: 12px;
  margin-top: -3px;
  border: solid var(--ink);
  border-width: 0 3px 3px 0;
  border-radius: 1px;
  transform: rotate(45deg) scale(0);
  transition: transform 0.15s ease-out;
}
.terms-agree input:checked::after { transform: rotate(45deg) scale(1); }
@keyframes check-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.25); }
  100% { transform: scale(1); }
}
.link-btn {
  border: none; background: none; padding: 0; color: var(--blue);
  text-decoration: underline; font-size: inherit; font-family: inherit; cursor: pointer;
  transition: 0.3s;
}
.link-btn:hover { opacity: 0.6; text-decoration: none; }
.terms-body {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 3px 0 0 #EAEAEA;
  padding: 18px; margin-bottom: 18px; max-height: 60vh; overflow-y: auto;
  font-size: 13px; line-height: 1.8; text-align: left;
}
.terms-body h3 { font-size: 14px; margin: 16px 0 4px; color: var(--blue); }
.terms-body h3:first-child { margin-top: 0; }
.terms-body p { margin: 4px 0; }
.terms-body .terms-lead { margin-bottom: 8px; }
.terms-body ol { margin: 4px 0; padding-left: 1.9em; }
.terms-body ol > li { margin: 4px 0; }
/* 入れ子は (1)(2)… 形式 */
.terms-body ol.paren { counter-reset: paren; list-style: none; padding-left: 1.6em; }
.terms-body ol.paren > li { counter-increment: paren; position: relative; }
.terms-body ol.paren > li::before {
  content: "(" counter(paren) ")";
  position: absolute; left: -1.6em;
}
.terms-body .terms-sub { margin: 4px 0 0 0.5em; }
.terms-body .terms-date { margin-top: 20px; color: var(--muted); font-size: 12px; }
