* {
  box-sizing: border-box;
}

:root {
  --bg: #f3f6fb;
  --card: #ffffff;
  --text: #172033;
  --muted: #687386;
  --line: #dfe5ee;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --soft: #eef4ff;
  --danger: #b42318;
  --shadow: 0 16px 45px rgba(35, 50, 75, 0.08);
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

.site-header {
  min-height: 82px;
  padding: 18px max(24px, calc((100vw - 1400px) / 2));
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  background: #101827;
  color: white;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: white;
  color: #101827;
  font-weight: 800;
  font-size: 24px;
}

.brand h1 {
  margin: 0;
  font-size: clamp(20px, 3vw, 28px);
}

.brand p {
  margin: 3px 0 0;
  color: #aeb9ca;
  font-size: 13px;
}

.back-link {
  color: white;
  text-decoration: none;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 999px;
  padding: 10px 16px;
}

.layout {
  width: min(1400px, calc(100% - 32px));
  margin: 28px auto;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(340px, .85fr) 280px;
  gap: 22px;
  align-items: start;
}

.tool-card,
.preview-card,
.ad-card {
  background: var(--card);
  border-radius: 22px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(223, 229, 238, .8);
}

.tool-card,
.preview-card {
  padding: 26px;
}

.ad-card {
  padding: 18px;
}

.section-heading,
.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 22px;
}

.eyebrow {
  display: block;
  font-size: 11px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: .14em;
  margin-bottom: 6px;
}

h2, h3 {
  margin: 0;
}

.plan-badge {
  background: #fff4e5;
  color: #9a5b00;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
}

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

label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: #354052;
  font-weight: 700;
  font-size: 14px;
}

label.wide,
.wifi-fields {
  grid-column: 1 / -1;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 13px;
  color: var(--text);
  background: white;
  outline: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

textarea {
  resize: vertical;
  min-height: 128px;
}

input[type="color"] {
  height: 46px;
  padding: 5px;
}

.wifi-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 18px;
  border-radius: 16px;
  background: #f8fafc;
  border: 1px solid var(--line);
}

.checkbox-label {
  flex-direction: row;
  align-items: center;
  align-self: end;
  min-height: 46px;
}

.checkbox-label input {
  width: auto;
}

.hidden {
  display: none;
}

.button-row,
.preview-actions {
  display: flex;
  gap: 12px;
  margin-top: 22px;
}

button {
  border: 0;
  border-radius: 12px;
  padding: 12px 18px;
  cursor: pointer;
  font-weight: 800;
}

button:disabled {
  cursor: not-allowed;
  opacity: .45;
}

.primary-btn {
  background: var(--accent);
  color: white;
}

.primary-btn:hover:not(:disabled) {
  background: var(--accent-dark);
}

.secondary-btn {
  background: #eef1f6;
  color: #273247;
}

.qr-preview {
  min-height: 390px;
  display: grid;
  place-items: center;
  border: 1px dashed #cfd7e4;
  border-radius: 18px;
  background:
    linear-gradient(45deg, #f8fafc 25%, transparent 25%),
    linear-gradient(-45deg, #f8fafc 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f8fafc 75%),
    linear-gradient(-45deg, transparent 75%, #f8fafc 75%);
  background-size: 22px 22px;
  background-position: 0 0, 0 11px, 11px -11px, -11px 0;
  overflow: auto;
  padding: 24px;
}

.qr-preview canvas,
.qr-preview img {
  max-width: 100%;
  height: auto !important;
}

.empty-state {
  text-align: center;
  color: var(--muted);
}

.empty-icon {
  width: 76px;
  height: 76px;
  margin: 0 auto 16px;
  border: 3px solid #cad3e0;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 24px;
}

.note,
.message {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
}

.message {
  min-height: 20px;
  margin: 12px 0 0;
}

.message.error {
  color: var(--danger);
}

.ad-label {
  font-size: 10px;
  color: #8b95a6;
  letter-spacing: .13em;
}

.ad-placeholder {
  margin-top: 10px;
  min-height: 260px;
  padding: 22px;
  border-radius: 16px;
  background: #f5f7fb;
  border: 1px dashed #c9d1dc;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
}

.ad-placeholder p,
.pro-promo p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.ad-placeholder a,
.pro-promo a {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.pro-promo {
  margin-top: 18px;
  padding: 20px;
  border-radius: 16px;
  background: #101827;
  color: white;
}

.pro-promo .eyebrow {
  color: #93b4ff;
}

.pro-promo p {
  color: #c8d1df;
}

.site-footer {
  padding: 10px 20px 34px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr 1fr;
  }

  .ad-card {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
  }

  .pro-promo {
    margin-top: 0;
  }

  .ad-placeholder {
    min-height: 180px;
  }
}

@media (max-width: 760px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .layout {
    grid-template-columns: 1fr;
    width: min(100% - 20px, 720px);
    margin-top: 14px;
  }

  .ad-card {
    grid-column: auto;
    grid-template-columns: 1fr;
  }

  .form-grid,
  .wifi-fields {
    grid-template-columns: 1fr;
  }

  .tool-card,
  .preview-card {
    padding: 20px;
  }

  .button-row,
  .preview-actions {
    flex-direction: column;
  }

  .qr-preview {
    min-height: 310px;
  }
}
