* { box-sizing:border-box; margin:0; padding:0; }
body { font-family:sans-serif; background:#f8fafc; color:#1e293b; line-height:1.6; padding:16px; }
.container { max-width:960px; margin:0 auto; }
header { display:flex; justify-content:space-between; align-items:center; margin-bottom:20px; padding-bottom:12px; border-bottom:2px solid #cbd5e1; flex-wrap:wrap; gap:10px; }
.btn-home { text-decoration:none; background:#64748b; color:#fff; padding:8px 16px; border-radius:6px; font-weight:bold; font-size:0.9rem; }
.alert { padding:12px; border-radius:6px; margin-bottom:16px; font-weight:bold; word-break:break-all; }
.alert-ok { background:#dcfce7; color:#166534; border:1px solid #86efac; }
.alert-ng { background:#fee2e2; color:#991b1b; border:1px solid #fca5a5; }
.grid { display:grid; grid-template-columns:1fr; gap:20px; }
.card { background:#fff; border-radius:8px; padding:20px; border:1px solid #e2e8f0; }
.card h2 { font-size:1.1rem; margin-bottom:14px; padding-bottom:8px; border-bottom:1px solid #e2e8f0; }
.fg { margin-bottom:14px; }
label { display:block; font-weight:bold; margin-bottom:4px; font-size:0.9rem; }
.radios { display:grid; grid-template-columns:repeat(2,1fr); gap:8px; }
.r-lbl { display:flex; align-items:center; justify-content:center; padding:8px; border:1px solid #cbd5e1; border-radius:6px; cursor:pointer; font-size:0.9rem; text-align:center; }
.r-lbl input { display:none; }
.r-lbl.active { background:#2563eb; color:#fff; border-color:#2563eb; }
input[type="text"], input[type="email"], input[type="url"], textarea { width:100%; padding:10px; border:1px solid #cbd5e1; border-radius:6px; font-size:1rem; }
.row2 { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.sz-box { display:flex; align-items:center; gap:10px; }
.sz-box input { flex:1; }
.btns { display:flex; gap:10px; margin-top:16px; flex-wrap:wrap; }
button { padding:12px; border:none; border-radius:6px; font-size:1rem; font-weight:bold; cursor:pointer; flex:1; min-width:120px; color:#fff; }
.b-gen { background:#2563eb; }
.b-rst { background:#64748b; }
.b-sav { background:#16a34a; width:100%; margin-top:10px; }
.b-dl { background:#2563eb; width:100%; margin-top:8px; }
.p-box { display:flex; flex-direction:column; align-items:center; justify-content:center; min-height:260px; background:#f1f5f9; border:2px dashed #cbd5e1; border-radius:8px; padding:16px; overflow:auto; }
#qrWrap { background:#fff; padding:12px; border-radius:4px; display:none; }
#qrCanvas { display:block; max-width:100%; height:auto; }
.hidden { display:none; }
.help { font-size:0.8rem; color:#64748b; margin-top:4px; }
footer { margin-top:24px; text-align:center; }

/* =========================================
   レスポンシブ設定（指定の9段階）
   ========================================= */

/* PC（1024px以上） */
@media screen and (min-width: 1024px) {
  .container { max-width: 1000px; }
  .grid { grid-template-columns: 1.2fr 0.8fr; }
  .radios { grid-template-columns: repeat(4, 1fr); }
}

/* タブレット横・大型タブレット（835px〜1023px） */
@media (min-width: 835px) and (max-width: 1023px) {
  .grid { grid-template-columns: 1.2fr 0.8fr; }
  .radios { grid-template-columns: repeat(4, 1fr); }
}

/* iPad mini・標準タブレット縦（744px〜834px：元の768px相当をカバー） */
@media (min-width: 744px) and (max-width: 834px) {
  .grid { grid-template-columns: 1.15fr 0.85fr; gap: 16px; }
  .radios { grid-template-columns: repeat(4, 1fr); }
  .card { padding: 18px; }
}

/* 大型スマホ横・ファブレット（541px〜743px：元の480px以上をカバー） */
@media (min-width: 541px) and (max-width: 743px) {
  .grid { grid-template-columns: 1fr; }
  .radios { grid-template-columns: repeat(4, 1fr); }
}

/* 標準〜大型スマホ縦（441px〜540px） */
@media (min-width: 441px) and (max-width: 540px) {
  .radios { grid-template-columns: repeat(2, 1fr); }
}

/* iPhone Plus / Pro Max 等（391px〜440px） */
@media (min-width: 391px) and (max-width: 440px) {
  body { padding: 14px; }
  .card { padding: 16px; }
  .radios { grid-template-columns: repeat(2, 1fr); }
}

/* iPhone 12 / 13 / 14 / 15 標準サイズ（381px〜390px） */
@media (min-width: 381px) and (max-width: 390px) {
  body { padding: 12px; }
  .card { padding: 15px; }
  .radios { grid-template-columns: repeat(2, 1fr); }
  .r-lbl { font-size: 0.85rem; padding: 8px 4px; }
}

/* iPhone SE (第2・第3世代) / mini（375px〜380px） */
@media (min-width: 375px) and (max-width: 380px) {
  body { padding: 12px; }
  .card { padding: 14px; }
  .radios { grid-template-columns: repeat(2, 1fr); }
  .r-lbl { font-size: 0.85rem; padding: 7px 4px; }
  .row2 { gap: 8px; }
}

/* 小型スマホ・iPhone SE 第1世代等（374px以下） */
@media (max-width: 374px) {
  body { padding: 10px; }
  header h1 { font-size: 1.2rem; }
  .btn-home { padding: 6px 12px; font-size: 0.85rem; }
  .card { padding: 12px; }
  .card h2 { font-size: 1rem; }
  .radios { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .r-lbl { font-size: 0.8rem; padding: 6px 4px; }
  .row2 { grid-template-columns: 1fr; gap: 8px; } /* 狭い画面では2列入力を縦1列に */
  button { min-width: 100%; padding: 10px; font-size: 0.95rem; } /* ボタンを縦積みに */
  .p-box { min-height: 220px; padding: 12px; }
}
