
/* === Reset & base === */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  color: #0f172a;
  background: #f8fafc;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
img, svg { max-width: 100%; }
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: #64748b; }
.small { font-size: 12.5px; }
.sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.hint { color: #64748b; font-size: 12.5px; margin: 6px 0 0; }
.error { color: #b91c1c; background: #fef2f2; border: 1px solid #fecaca; padding: 10px 12px; border-radius: 8px; margin: 12px 0 0; font-size: 14px; }

/* === Topbar === */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px; background: #fff; border-bottom: 1px solid #e2e8f0;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: #0f172a; }
.brand img { width: 32px; height: 32px; }
.help-link { display: inline-flex; align-items: center; gap: 6px; color: #475569; font-size: 14px; padding: 6px 10px; border-radius: 8px; }
.help-link:hover { background: #f1f5f9; text-decoration: none; }

/* === Layout === */
.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  padding: 22px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  flex: 1 0 auto;
}

/* === Side card === */
.side-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 22px;
  align-self: start;
}
.side-illus {
  background: linear-gradient(135deg, #eff6ff 0%, #eef2ff 100%);
  border-radius: 12px;
  padding: 18px 12px;
  margin-bottom: 18px;
  display: flex; align-items: center; justify-content: center;
}
.side-title { font-size: 20px; font-weight: 700; margin: 0 0 8px; color: #0f172a; line-height: 1.25; }
.side-sub { color: #64748b; margin: 0 0 18px; font-size: 14px; }
.feature-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.feature-list li { display: flex; align-items: flex-start; gap: 12px; }
.feat-ic {
  flex: 0 0 36px; width: 36px; height: 36px;
  border-radius: 10px;
  background: #eff6ff;
  display: inline-flex; align-items: center; justify-content: center;
}
.feature-list strong { display: block; font-size: 14px; color: #0f172a; }
.feat-sub { color: #64748b; font-size: 13px; margin-top: 2px; }

/* === Main card === */
.main-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 32px 36px;
}
.page-title { font-size: 22px; font-weight: 700; margin: 0 0 6px; color: #0f172a; }
.page-sub { color: #64748b; margin: 0 0 26px; font-size: 14px; }

.step { margin-bottom: 22px; }
.step-label { display: block; font-weight: 600; font-size: 14.5px; color: #0f172a; margin-bottom: 10px; }
.step-num { color: #0f172a; font-weight: 700; margin-right: 4px; }

/* Input with leading icon */
.input-wrap { position: relative; }
.input-ic { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); display: inline-flex; pointer-events: none; }
.input-wrap input {
  width: 100%; height: 48px;
  padding: 0 14px 0 42px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font-size: 14.5px;
  background: #fff; color: #0f172a;
  transition: border-color .15s, box-shadow .15s;
}
.input-wrap input:focus { outline: 0; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.15); }

/* === Mode cards === */
.modes { border: 0; padding: 0; margin: 0; }
.mode-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.mode-card {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 14px 14px;
  cursor: pointer;
  background: #fff;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.mode-card input { accent-color: #2563eb; margin: 0; flex: 0 0 auto; }
.mode-card:hover { border-color: #93c5fd; }
.mode-card:has(input:checked) { border-color: #2563eb; background: #eff6ff; box-shadow: 0 0 0 3px rgba(37,99,235,.08); }
.mc-body { display: flex; flex-direction: column; line-height: 1.25; }
.mc-title { font-weight: 600; font-size: 14px; color: #0f172a; }
.mc-sub { color: #64748b; font-size: 12.5px; margin-top: 2px; }

/* === Theme picker === */
.theme-picker { margin: 0; }
.theme-list {
  display: flex; gap: 10px;
  overflow-x: auto; padding-bottom: 6px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}
.theme-list::-webkit-scrollbar { height: 6px; }
.theme-list::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
.theme-card {
  flex: 0 0 auto;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 12px;
  background: #fff;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  cursor: pointer;
  transition: border-color .15s, transform .15s, box-shadow .15s;
  scroll-snap-align: start;
  min-width: 78px;
}
.theme-card:hover { border-color: #93c5fd; transform: translateY(-1px); }
.theme-card.selected { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.theme-swatch {
  display: flex; align-items: center; justify-content: center; gap: 4px;
  width: 56px; height: 56px;
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.06);
}
.theme-swatch .sw-dot { width: 18px; height: 18px; border-radius: 50%; }
.theme-swatch .sw-dot.small { width: 12px; height: 12px; }
.theme-name { font-size: 12px; color: #374151; font-weight: 500; }

/* === Disclosures (Optional fields) === */
.disclosure { border: 1px solid #cbd5e1; border-radius: 10px; margin-top: 10px; background: #fff; overflow: hidden; }
.disclosure summary { display: flex; align-items: center; gap: 10px; list-style: none; padding: 14px 16px; cursor: pointer; color: #334155; font-size: 14px; }
.disclosure summary::-webkit-details-marker { display: none; }
.disclosure .d-ic { display: inline-flex; }
.disclosure .d-arrow { margin-left: auto; color: #94a3b8; transition: transform .2s; font-size: 18px; line-height: 1; }
.disclosure[open] .d-arrow { transform: rotate(90deg); }
.disclosure .d-body { padding: 0 16px 14px; }
.disclosure .d-body label { display: block; font-size: 13px; color: #475569; margin-bottom: 6px; }
.disclosure .d-body input { width: 100%; height: 42px; padding: 0 12px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 14px; }
.disclosure .d-body input:focus { outline: 0; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.15); }

/* === CTA button === */
.primary.cta {
  width: 100%;
  margin-top: 18px;
  background: #2563eb; color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 15px; font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .05s;
}
.primary.cta:hover { background: #1d4ed8; }
.primary.cta:active { transform: translateY(1px); }
.primary.cta:disabled { background: #94a3b8; cursor: not-allowed; }

/* === Generic buttons (ghost/small) === */
button.ghost, a.ghost {
  background: #fff; color: #0f172a;
  border: 1px solid #cbd5e1; border-radius: 8px;
  padding: 8px 12px; font-size: 14px; cursor: pointer;
  display: inline-block; text-align: center;
}
button.ghost:hover, a.ghost:hover { background: #f1f5f9; text-decoration: none; }
button.small, .small.ghost { padding: 6px 10px; font-size: 13px; }

/* === Result + history === */
.card { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 18px; margin-top: 18px; }
.card h2 { margin: 0 0 12px; font-size: 16px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.short-block input { flex: 1 1 200px; min-width: 0; height: 40px; padding: 0 10px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 14px; }
.qr-block { margin-top: 14px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.qr-block img { max-width: 240px; width: 100%; height: auto; }
#history-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
#history-list li { display: flex; gap: 8px; padding: 8px 0; border-bottom: 1px solid #f1f5f9; font-size: 13.5px; }

/* === Footer === */
.footer { text-align: center; padding: 20px; color: #94a3b8; font-size: 13px; }

/* === Responsive === */
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; padding: 16px; gap: 14px; }
  .side-card { order: 2; }
  .main-card { order: 1; padding: 22px 18px; }
}
@media (max-width: 640px) {
  .topbar { padding: 12px 16px; }
  .brand span { font-size: 15px; }
  .page-title { font-size: 19px; }
  .mode-cards { grid-template-columns: 1fr; }
  .input-wrap input { font-size: 16px; /* iOS no-zoom */ }
  .disclosure .d-body input { font-size: 16px; }
  .main-card { padding: 18px 14px; }
  .side-card { padding: 18px; }
}
@media (max-width: 380px) {
  .theme-swatch { width: 48px; height: 48px; }
  .theme-swatch .sw-dot { width: 16px; height: 16px; }
  .theme-swatch .sw-dot.small { width: 10px; height: 10px; }
  .theme-name { font-size: 11px; }
}

/* Hide leftover install banner if present */
#install-banner, .install-banner { display: none !important; }

/* === Fix: prevent main card overflow on grid layout === */
.layout > * { min-width: 0; }
.main-card, .side-card { max-width: 100%; overflow: hidden; }
.theme-list, .mode-cards, .input-wrap, .disclosure { max-width: 100%; }

/* === Stronger mobile responsive overrides === */
@media (max-width: 960px) {
  body { font-size: 14.5px; }
  .layout { grid-template-columns: 1fr !important; padding: 12px !important; gap: 12px !important; max-width: 100%; }
  .side-card, .main-card { width: 100%; max-width: 100%; padding: 18px !important; border-radius: 12px; }
  .side-card { order: 2; }
  .main-card { order: 1; }
  .topbar { padding: 12px 16px; }
  .help-link span { display: none; }
  .page-title { font-size: 18px; line-height: 1.3; }
  .page-sub { font-size: 13.5px; margin-bottom: 18px; }
  .step { margin-bottom: 18px; }
  .input-wrap input { height: 46px; font-size: 16px; }
  .mode-cards { grid-template-columns: 1fr !important; gap: 8px; }
  .mode-card { padding: 12px; }
  .mc-title { font-size: 13.5px; }
  .mc-sub { font-size: 12px; }
  .theme-list { gap: 8px; padding: 0 2px 6px; margin: 0 -2px; }
  .theme-card { min-width: 70px; padding: 8px 10px; }
  .theme-swatch { width: 48px; height: 48px; }
  .theme-swatch .sw-dot { width: 16px; height: 16px; }
  .theme-swatch .sw-dot.small { width: 10px; height: 10px; }
  .theme-name { font-size: 11px; }
  .disclosure summary { padding: 12px 14px; font-size: 13.5px; }
  .disclosure .d-body { padding: 0 14px 12px; }
  .disclosure .d-body input { font-size: 16px; height: 44px; }
  .primary.cta { padding: 13px 14px; font-size: 15px; margin-top: 14px; }
  .side-illus { padding: 14px 8px; margin-bottom: 14px; }
  .side-illus svg { max-width: 260px; }
  .side-title { font-size: 17px; }
  .side-sub { font-size: 13px; margin-bottom: 14px; }
  .feature-list { gap: 12px; }
  .feat-ic { flex-basis: 32px; width: 32px; height: 32px; }
  .feature-list strong { font-size: 13.5px; }
  .feat-sub { font-size: 12.5px; }
  .footer { padding: 14px 12px; font-size: 12.5px; }
}

@media (max-width: 420px) {
  .topbar { padding: 10px 12px; }
  .brand span { font-size: 14px; }
  .brand img { width: 26px; height: 26px; }
  .layout { padding: 10px !important; gap: 10px !important; }
  .side-card, .main-card { padding: 14px !important; }
  .page-title { font-size: 17px; }
  .step-label { font-size: 13.5px; }
  .input-wrap input { padding-left: 38px; }
  .input-ic { left: 12px; }
  .theme-card { min-width: 64px; padding: 6px 8px; }
  .theme-swatch { width: 42px; height: 42px; }
  .theme-name { font-size: 10.5px; }
}
