/* ---- instant tooltip ---- */
.js-tip { position: absolute; z-index: 9999; pointer-events: none;
  background: #0e1116; color: #e6e9ef; border: 1px solid #2a313c;
  font-size: 11px; font-weight: 500; white-space: nowrap;
  padding: 4px 8px; border-radius: 6px;
  transform: translate(-50%, calc(-100% - 8px));
}
.js-tip[hidden] { display: none; }

:root {
  --bg: #0e1116; --panel: #171b22; --card: #1d222b; --border: #2a313c;
  --text: #e6e9ef; --muted: #8a93a3; --primary: #5b8cff; --accent: #34d399;
  --danger: #f87171; --warn: #fbbf24;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
a { color: var(--primary); text-decoration: none; }

/* ---- top bar ---- */
.topbar { display: flex; align-items: center; gap: 18px; padding: 12px 22px;
  border-bottom: 1px solid var(--border); background: var(--panel); position: sticky; top: 0; z-index: 20; }
.logo { font-size: 16px; font-weight: 700; color: var(--text); }
#nav { display: flex; gap: 4px; flex: 1; }
#nav a { padding: 7px 12px; border-radius: 7px; color: var(--muted); font-weight: 500; }
#nav a:hover { color: var(--text); background: var(--card); }
#nav a.active { color: var(--text); background: var(--card); }
.chip { font-size: 11px; padding: 3px 9px; border-radius: 20px; background: var(--card);
  border: 1px solid var(--border); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

#view { max-width: 1100px; margin: 0 auto; padding: 24px 22px 60px; }
#view:has(.brand-workspace) { max-width: 1760px; }
.loading-page { color: var(--muted); padding: 60px; text-align: center; }

/* ---- generic ---- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 18px; margin-bottom: 16px; }
.card h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 620px) { .grid2 { grid-template-columns: 1fr; } }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.muted { color: var(--muted); font-size: 12px; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
input, select, textarea { background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 11px; font-size: 13px; width: 100%; font-family: inherit; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
textarea { font: 12px/1.5 ui-monospace, Menlo, monospace; resize: vertical; }

button { background: var(--primary); color: #fff; border: 0; border-radius: 8px;
  padding: 10px 18px; font-size: 13px; font-weight: 600; cursor: pointer; }
button:hover { filter: brightness(1.08); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.secondary { background: var(--border); color: var(--text); }
button.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
button.mini { padding: 4px 9px; font-size: 12px; }
.filebtn { display: inline-block; background: var(--border); color: var(--text); padding: 9px 16px;
  border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600; }
.inline { flex-direction: row; align-items: center; gap: 6px; color: var(--text); font-size: 13px; }
.inline input { width: auto; }

/* ---- hero / home ---- */
.hero { text-align: center; padding: 40px 10px 30px; }
.hero h1 { font-size: 40px; margin: 0 0 12px; letter-spacing: -.02em; }
.hero p { color: var(--muted); font-size: 16px; max-width: 620px; margin: 0 auto 22px; }
.hero .actions { display: flex; gap: 12px; justify-content: center; }
.featrow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 10px; }
@media (max-width: 760px) { .featrow { grid-template-columns: 1fr; } }
.featrow .card h3 { margin: 0 0 6px; font-size: 15px; }
.featrow .card p { margin: 0; color: var(--muted); font-size: 13px; }

/* ---- tiles ---- */
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 26px 0 12px; }
.section-head h2 { font-size: 16px; margin: 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.tile { background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
  cursor: pointer; transition: border-color .15s, transform .15s; display: flex; flex-direction: column; position: relative; }
.tile:hover { border-color: var(--primary); transform: translateY(-2px); }
.tile .thumb-img { position: relative; aspect-ratio: 16/10; background: #0a0d12; border-bottom: 1px solid var(--border); overflow: hidden; }
.thumb-img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-ph { position: absolute; inset: 0; display: grid; place-items: center; font-size: 30px; font-weight: 700; color: var(--border); }
.tile .body { padding: 12px 14px; }
.tile .body h3 { margin: 0 0 4px; font-size: 14px; }
.tile .meta { color: var(--muted); font-size: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.k { font-size: 10px; text-transform: uppercase; padding: 1px 6px; border-radius: 4px; background: var(--border); color: var(--muted); }
.k.single { background: #3b2f57; color: #c7b6ff; }
.k.hub { background: #1f3a5f; color: #a9cbff; }
.tile-actions { display: flex; gap: 6px; padding: 0 10px 10px; border-top: 1px solid var(--border); margin-top: auto; padding-top: 8px; }
.tile-icon-btn { width: 30px; height: 30px; display: grid; place-items: center; color: var(--muted);
  background: transparent; border: 1px solid var(--border); border-radius: 7px; cursor: pointer;
  transition: color .12s, background .12s, border-color .12s; flex-shrink: 0; text-decoration: none;
  padding: 0; font-size: inherit; font-family: inherit; }
.tile-icon-btn:hover, .tile-icon-btn:focus-visible { color: var(--text); background: var(--border); border-color: transparent; outline: none; }
.tile-icon-btn i { font-size: 13px; pointer-events: none; line-height: 1; }
.empty { color: var(--muted); padding: 30px; text-align: center; border: 1px dashed var(--border); border-radius: 12px; }

/* ---- pricing ---- */
.price-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.price-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 18px; }
.price-card .tier { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.price-card .amt { font-size: 26px; font-weight: 700; margin: 8px 0; }
.price-card .lvl { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.lvl.free { background: var(--accent); } .lvl.low { background: var(--primary); }
.lvl.mid { background: var(--warn); } .lvl.high { background: var(--danger); }

/* ---- wizard ---- */
.wizard-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.stepper { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.stepper .step { display: flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 20px;
  background: var(--card); border: 1px solid var(--border); color: var(--muted); font-size: 12px; cursor: pointer; }
.stepper .step .n { width: 18px; height: 18px; border-radius: 50%; background: var(--border);
  display: grid; place-items: center; font-size: 11px; color: var(--text); }
.stepper .step.active { border-color: var(--primary); color: var(--text); }
.stepper .step.active .n { background: var(--primary); }
.stepper .step.done .n { background: var(--accent); color: #0b1a12; }
.step-panel { display: none; }
.step-panel.active { display: block; }
.wizard-nav { display: flex; justify-content: space-between; margin-top: 18px; }

/* ---- images ---- */
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin-top: 12px; }
.thumb { position: relative; border-radius: 8px; overflow: hidden; aspect-ratio: 4/3; border: 2px solid transparent; cursor: pointer; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.dropped { opacity: .3; border-color: var(--danger); }
.thumb .x { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.6); color: #fff;
  border-radius: 50%; width: 22px; height: 22px; display: grid; place-items: center; font-size: 13px; }
.logo-preview { max-width: 120px; max-height: 120px; margin-top: 10px; border: 1px solid var(--border);
  border-radius: 8px; background: #fff; padding: 6px; }

/* ---- spinner + progress ---- */
.spinner { width: 15px; height: 15px; border: 2px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.bar { height: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; overflow: hidden; margin: 10px 0; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); width: 0; transition: width .3s; }
.bar.indeterminate > i { width: 40%; animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }
.log { background: #0a0d12; border: 1px solid var(--border); border-radius: 8px; padding: 12px;
  font: 12px/1.5 ui-monospace, Menlo, monospace; color: #c7d0dd; height: 240px; overflow: auto; white-space: pre-wrap; margin: 10px 0 0; }

/* build progress checklist */
.build-headline { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 14px 0 8px; }
.buildsteps { list-style: none; padding: 0; margin: 6px 0 12px; display: flex; flex-direction: column; gap: 6px; }
.bstep { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 8px;
  background: var(--card); border: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.bstep .ic { width: 18px; height: 18px; display: grid; place-items: center; font-size: 12px; flex: 0 0 18px; }
.bstep.running { color: var(--text); border-color: var(--primary); }
.bstep.done { color: var(--text); }
.bstep.done .ic { color: var(--accent); }
.bstep.error { color: var(--danger); border-color: var(--danger); }
#toggleLog { margin-top: 4px; }

/* ---- theme designer ---- */
.brand-workspace { display: grid; grid-template-columns: minmax(0, 3fr) minmax(340px, 2fr); gap: 18px; align-items: start; }
.brand-design-column { display: grid; gap: 16px; min-width: 0; }
.brand-sidebar { display: grid; gap: 12px; align-content: start; padding: 16px; border: 1px solid var(--border); border-radius: 10px; background: color-mix(in srgb, var(--card) 82%, var(--bg)); }
.content-sidebar { display: grid; gap: 12px; align-content: start; max-height: calc(100vh - 150px); overflow: auto; padding-right: 4px; }
.content-sidebar { border-left: 1px solid var(--border); padding-left: 18px; }
.preview-pane { min-width: 0; }
.preview-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.preview-head h2, .minihead h2 { margin: 0; }
.minihead { margin: 8px 0 10px; }
.viewport-toggle { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.viewport-toggle .active { border-color: var(--primary); color: var(--text); background: color-mix(in srgb, var(--primary) 18%, var(--card)); }
.grid1 { display: grid; gap: 10px; }
.grid2.compact { gap: 10px; }
.brand-sidebar .grid2.compact { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.brand-sidebar .palette-row { grid-template-columns: repeat(5, minmax(130px, 1fr)); }
.palette-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 12px 0; }
.swatch { display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; }
.swatch input[type=color] { width: 36px; height: 36px; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: none; cursor: pointer; flex: 0 0 36px; }
.swatch .hex { font: 12px ui-monospace, Menlo, monospace; padding: 4px 6px; }
.swatch > div { flex: 1; min-width: 0; }
details.import-rtc, details.content-groups { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; margin-bottom: 6px; }
details.import-rtc summary, details.content-groups summary { cursor: pointer; font-size: 13px; color: var(--muted); }
details.import-rtc textarea, details.content-groups textarea { margin-top: 8px; }
.designer-bar { display: grid; grid-template-columns: 110px minmax(180px, 1fr) auto 42px 42px; gap: 10px; align-items: end; margin: 12px 0; }
.designer-bar label { min-width: 0; }
.designer-bar input[type=color] { height: 38px; padding: 3px; cursor: pointer; }
.iconbtn { min-width: 42px; padding-inline: 0; font-size: 18px; }
.iconbtn:disabled { opacity: .45; cursor: not-allowed; }
.content-editor { display: grid; gap: 8px; padding-top: 2px; }
.content-flags { align-items: center; gap: 12px; }
.design-preview { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; min-height: 430px; background: #fff; transition: width .18s ease; }
.design-preview.size-desktop { width: 100%; }
.design-preview.size-tablet { width: min(768px, 100%); margin-inline: auto; }
.design-preview.size-mobile { width: min(390px, 100%); margin-inline: auto; }
.preview-loading { min-height: 430px; display: grid; place-items: center; color: #687386; font-size: 13px; }
.site-preview-frame { display: block; width: 100%; height: 520px; border: 0; background: #fff; }
@media (max-width: 700px) {
  .brand-workspace { grid-template-columns: 1fr; }
  .brand-sidebar, .content-sidebar { max-height: none; overflow: visible; padding-right: 0; }
  .content-sidebar { border-left: 0; padding-left: 0; }
  .brand-sidebar .grid2.compact,
  .brand-sidebar .palette-row,
  .designer-bar { grid-template-columns: 1fr; }
  .site-preview-frame { height: 620px; }
}
@media (min-width: 701px) and (max-width: 1300px) {
  .brand-workspace { grid-template-columns: 1fr; }
  .content-sidebar { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--border); padding: 18px 0 0; max-height: none; overflow: visible; }
  .brand-sidebar .grid2.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .brand-sidebar .palette-row { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .designer-bar { grid-template-columns: 110px minmax(180px, 1fr) auto 42px 42px; }
}
.badge { background: var(--border); color: var(--text); padding: 4px 10px; border-radius: 6px; font-size: 12px; }
.badge.update { background: var(--accent); color: var(--bg); font-weight: 600; }
.newhub { border: 1px dashed var(--border); border-radius: 8px; padding: 12px; margin-top: 10px; }
.newhub legend { color: var(--muted); font-size: 11px; padding: 0 6px; }
#resultLinks a { display: inline-block; margin: 4px 8px 4px 0; }
.status { font-size: 12px; color: var(--muted); }

.tile.is-disabled .thumb-img, .tile.is-disabled .body { opacity: .55; }
