
/* === 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; }
}

/* === REDESIGN-V2 === */
/* Hide top-bar nav links — they moved to sidebar */
.topbar .tb-nav-hidden { display: none !important; }

/* Side card stack: nav + illustration + features */
.side-card { display: flex; flex-direction: column; gap: 18px; padding: 16px; }
.side-card .side-illus { margin-bottom: 0; order: 2; }
.side-card .side-title { order: 3; margin-top: 6px; }
.side-card .side-sub { order: 4; }
.side-card .feature-list { order: 5; }
.side-card .side-nav { order: 1; }

/* Vertical sidebar nav */
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  color: #475569; font-size: 14.5px; font-weight: 600;
  text-decoration: none; transition: background .15s, color .15s;
}
.side-nav-link:hover { background: #f1f5f9; color: #0f172a; }
.side-nav-link .sn-ic {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; background: #f1f5f9; color: #475569;
  flex: 0 0 32px;
}
.side-nav-link.active {
  background: #eef4ff; color: #2563eb;
}
.side-nav-link.active .sn-ic {
  background: #2563eb; color: #fff;
}

/* Numbered step badges (circle, blue, white text) */
.step-label { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; color: #0f172a; margin: 0 0 10px; }
.step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: #2563eb; color: #fff !important;
  font-size: 12.5px; font-weight: 700;
  margin-right: 0 !important;
  line-height: 1;
}
.step-num::after { content: ''; }

/* Mode-card icons (left-side icon block) */
.mode-card { gap: 12px; padding: 16px 14px; }
.mode-card .mc-ic {
  width: 36px; height: 36px; flex: 0 0 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; background: #f1f5f9; color: #475569;
  transition: background .15s, color .15s;
}
.mode-card:has(input:checked) .mc-ic { background: #2563eb; color: #fff; }
.mode-card input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }

/* Topbar refinement: right-side help/sign-out group */
.topbar { padding: 14px 32px; }
.help-link { font-weight: 500; }

/* Tighten side-illus to match design proportions */
.side-illus { padding: 14px; }
.side-illus svg { max-width: 200px; }

/* Mobile: collapse side-nav to horizontal */
@media (max-width: 760px) {
  .side-card { gap: 12px; padding: 12px; }
  .side-nav { flex-direction: row; flex-wrap: wrap; }
  .side-nav-link { flex: 1 1 auto; justify-content: center; padding: 8px 10px; }
  .side-nav-link span:not(.sn-ic) { font-size: 13px; }
}

/* === NEW-PROJECT-INLINE === */
.new-project-row {
  display: none;
  gap: 8px; margin-top: 8px; align-items: center;
}
.new-project-row.np-show { display: flex; }
.new-project-row input {
  flex: 1 1 auto; height: 42px; padding: 0 12px;
  border: 1px solid #cbd5e1; border-radius: 10px;
  background: #fff; color: #0f172a; font-size: 14.5px;
  transition: border-color .15s, box-shadow .15s;
}
.new-project-row input:focus {
  outline: 0; border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.new-project-row .primary.small,
.new-project-row .ghost.small {
  height: 42px; padding: 0 14px; font-size: 14px;
  border-radius: 10px; flex: 0 0 auto;
}
.new-project-row .primary.small { background: #2563eb; color: #fff; border: 0; cursor: pointer; }
.new-project-row .primary.small:hover { background: #1d4fd1; }
.new-project-row .primary.small:disabled { background: #93c5fd; cursor: default; }
.new-project-row .ghost.small {
  background: #fff; color: #475569; border: 1px solid #cbd5e1; cursor: pointer;
}
.new-project-row .ghost.small:hover { background: #f1f5f9; }
#new-project-error { margin-top: 6px; }
@media (max-width: 480px) {
  .new-project-row.np-show { flex-wrap: wrap; }
  .new-project-row input { flex: 1 1 100%; }
}

/* === PWA-INSTALL === */
.pwa-banner {
  position: sticky; top: 0; z-index: 50;
  background: linear-gradient(135deg, #2563eb, #1d4fd1);
  color: #fff; padding: 0;
  box-shadow: 0 2px 8px rgba(15,23,42,.08);
}
.pwa-banner[hidden] { display: none; }
.pwa-banner-inner {
  max-width: 1400px; margin: 0 auto;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 32px;
}
.pwa-banner-ic {
  width: 40px; height: 40px; flex: 0 0 40px;
  border-radius: 10px; background: rgba(255,255,255,.16);
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff;
}
.pwa-banner-text { flex: 1 1 auto; display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.pwa-banner-text strong { font-size: 14.5px; font-weight: 700; }
.pwa-banner-text span { font-size: 13px; opacity: .9; }
.pwa-banner-cta {
  flex: 0 0 auto; height: 38px; padding: 0 18px;
  background: #fff; color: #1d4fd1; border: 0; border-radius: 10px;
  font-weight: 700; font-size: 14px; cursor: pointer;
  transition: background .15s, transform .1s;
}
.pwa-banner-cta:hover { background: #f1f5f9; }
.pwa-banner-cta:active { transform: scale(.97); }
.pwa-banner-x {
  flex: 0 0 auto; width: 32px; height: 32px;
  background: transparent; border: 0; color: rgba(255,255,255,.85);
  border-radius: 8px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.pwa-banner-x:hover { background: rgba(255,255,255,.15); color: #fff; }
@media (max-width: 600px) {
  .pwa-banner-inner { padding: 10px 14px; gap: 10px; }
  .pwa-banner-text strong { font-size: 13.5px; }
  .pwa-banner-text span { font-size: 12px; }
  .pwa-banner-cta { height: 36px; padding: 0 14px; font-size: 13px; }
}

/* iOS install modal */
.pwa-ios-modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15,23,42,.55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.pwa-ios-modal[hidden] { display: none; }
.pwa-ios-card {
  position: relative; max-width: 420px; width: 100%;
  background: #fff; color: #0f172a;
  border-radius: 16px; padding: 24px 22px 22px;
  box-shadow: 0 24px 60px rgba(15,23,42,.32);
}
.pwa-ios-card h3 { margin: 0 0 14px; font-size: 18px; font-weight: 700; padding-right: 28px; }
.pwa-ios-close {
  position: absolute; top: 14px; right: 14px;
  width: 32px; height: 32px; padding: 0;
  border: 0; background: transparent; color: #64748b;
  border-radius: 8px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.pwa-ios-close:hover { background: #f1f5f9; color: #0f172a; }
.pwa-ios-steps { margin: 0 0 16px; padding-left: 22px; color: #334155; font-size: 14.5px; line-height: 1.55; }
.pwa-ios-steps li { margin-bottom: 8px; }
.pwa-ios-steps strong { color: #0f172a; }
.pwa-ios-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; margin: 0 1px -5px; vertical-align: baseline;
  background: #eef4ff; color: #2563eb; border-radius: 6px;
}
.pwa-ios-ok {
  width: 100%; height: 42px; padding: 0;
  background: #2563eb; color: #fff; border: 0; border-radius: 10px;
  font-weight: 700; font-size: 14.5px; cursor: pointer;
}
.pwa-ios-ok:hover { background: #1d4fd1; }

/* DOMAIN-SELECT */
.step-card.domain-step{margin-bottom:14px}
.domain-row{display:flex;flex-direction:column;gap:6px}
.domain-label{font-weight:600;color:#0f172a;font-size:14px}
.domain-select{appearance:none;-webkit-appearance:none;background:#fff url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2364748b'><path d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z'/></svg>") no-repeat right 12px center;border:1px solid #e2e8f0;border-radius:10px;padding:12px 40px 12px 14px;font-size:15px;color:#0f172a;cursor:pointer;transition:border-color .15s,box-shadow .15s;width:100%;max-width:340px}
.domain-select:focus{outline:none;border-color:#2563eb;box-shadow:0 0 0 3px rgba(37,99,235,.15)}
.domain-hint{margin:2px 0 0;font-size:12.5px;color:#64748b}
.domain-hint #domainPreview{color:#0f172a;font-weight:500}
