:root {
  --bg: #eef5fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #64748b;
  --primary: #1565c0;
  --primary-dark: #0d47a1;
  --line: #dbe7f3;
  --soft: #f6faff;
  --danger: #b91c1c;
  --shadow: 0 16px 40px rgba(15, 68, 117, 0.12);
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top, #ffffff 0%, var(--bg) 46%, #e8f1f8 100%);
}

a { color: inherit; }

button,
input,
select,
textarea { font: inherit; }

.app-shell {
  width: min(1120px, calc(100% - 24px));
  margin: 22px auto 12px;
}

.hero {
  background: linear-gradient(135deg, #ffffff 0%, #f4f9ff 100%);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 24px;
  box-shadow: var(--shadow);
  text-align: center;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(1.7rem, 5vw, 2.6rem);
  letter-spacing: 0.04em;
}

.lead {
  max-width: 760px;
  margin: 0 auto;
  color: var(--muted);
  line-height: 1.8;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
  gap: 18px;
  margin-top: 18px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 1.15rem;
}

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

.field {
  display: grid;
  gap: 7px;
  text-align: left;
}

.field span,
.field legend {
  color: #334155;
  font-weight: 700;
  font-size: 0.94rem;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
input[type="password"],
select,
textarea {
  width: 100%;
  border: 1px solid #cdddea;
  border-radius: 13px;
  padding: 12px 13px;
  background: #fff;
  color: var(--text);
  outline: none;
}

textarea {
  min-height: 160px;
  resize: vertical;
  line-height: 1.65;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(21, 101, 192, 0.13);
}

.input-field[hidden] { display: none !important; }

.mini-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.check-line {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #334155;
  font-weight: 700;
}

.check-line input { width: 18px; height: 18px; }

.option-box {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  background: var(--soft);
}

.option-box legend {
  padding: 0 7px;
}

.option-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.option-grid label {
  display: grid;
  gap: 6px;
  color: #334155;
  font-weight: 700;
  font-size: 0.9rem;
}

input[type="color"] {
  width: 100%;
  height: 44px;
  border: 1px solid #cdddea;
  border-radius: 12px;
  padding: 4px;
  background: #fff;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 11px 18px;
  min-height: 44px;
  color: #fff;
  background: var(--primary);
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.05s ease, background 0.2s ease, opacity 0.2s ease;
}

.btn:hover { background: var(--primary-dark); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn.sub {
  color: #1d4f8f;
  background: #e4f0ff;
  border: 1px solid #bdd8f6;
}

.btn.sub:hover { background: #d7e9ff; }

.preview-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}

.qr-stage {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 360px;
  border: 1px dashed #bad0e8;
  border-radius: 20px;
  background:
    linear-gradient(45deg, rgba(21, 101, 192, 0.05) 25%, transparent 25%, transparent 75%, rgba(21, 101, 192, 0.05) 75%),
    linear-gradient(45deg, rgba(21, 101, 192, 0.05) 25%, transparent 25%, transparent 75%, rgba(21, 101, 192, 0.05) 75%);
  background-position: 0 0, 12px 12px;
  background-size: 24px 24px;
  padding: 18px;
}

#qrCanvas {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  image-rendering: pixelated;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

.status-card {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fbfdff;
  padding: 12px;
  text-align: left;
}

#statusText {
  margin: 0 0 4px;
  font-weight: 800;
}

#detailText {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.7;
}

.download-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  width: 100%;
}

.note {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.7;
}

.warning {
  color: var(--danger);
  font-weight: 700;
}

.visually-hidden,
#svgHolder {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-footer {
  width: min(1120px, calc(100% - 24px));
  margin: 8px auto 0;
  padding: 8px 0 14px;
  text-align: center;
  color: #1565c0;
  font-size: 0.88rem;
  border-top: 1px solid #d7e6f8;
}

.site-footer a {
  color: #1565c0;
  text-decoration: none;
  font-weight: 700;
}

.site-footer a:hover { color: #0d47a1; }

.ad-panel {
  width: min(1120px, calc(100% - 24px));
  margin: 10px auto 0;
  padding: 0;
  border: 1px solid #d7e6f8;
  border-radius: 12px;
  background: #ffffff;
  overflow: hidden;
}

.ad-panel[hidden] {
  display: none !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
}

.ad-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 8px;
  background: #f4f8ff;
  border-bottom: 1px solid #d7e6f8;
}

.ad-label,
.ad-wait-text {
  font-size: 0.72rem;
  color: #4f6f91;
  line-height: 1.2;
}

.ad-head-spacer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.ad-close-btn {
  margin: 0;
  padding: 3px 8px;
  min-height: 0;
  height: auto;
  line-height: 1.2;
  border: none;
  border-radius: 999px;
  background: #1565c0;
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.ad-close-btn:hover { background: #0d47a1; }
.ad-close-btn[hidden] { display: none !important; }

.ad-body {
  padding: 8px;
  background: #ffffff;
}

@media (max-width: 840px) {
  .main-grid { grid-template-columns: 1fr; }
  .hero { padding: 20px 16px; }
  .panel { padding: 15px; }
  .mini-grid,
  .option-grid { grid-template-columns: 1fr; }
  .qr-stage { min-height: 300px; }
}
