/* ─────────────────────────────────────────────
   Themer — UI Theme Generator
   App-shell styles (always light UI chrome)
   ───────────────────────────────────────────── */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── CSS CUSTOM PROPERTIES ── */
:root {
  /* Colors — app shell chrome (not the preview) */
  --shell-background:   #f4f4f2;   /* outermost canvas / page background      */
  --shell-surface:      #ffffff;   /* panels, cards, modal backgrounds         */
  --shell-border:       #e2e2df;   /* primary borders and dividers             */
  --shell-border-subtle:#ececea;   /* lighter secondary borders                */
  --shell-text:         #111110;   /* primary / high-contrast text             */
  --shell-text-muted:   #8a8a85;   /* secondary / helper text                  */
  --shell-text-faint:   #b8b8b2;   /* labels and placeholder text              */
  --shell-hover:        #f0f0ee;   /* background tint on hover                 */
  --shell-active:       #eaeae8;   /* background tint on active / selected     */

  /* Typography */
  --shell-font:         'DM Sans', sans-serif;      /* UI sans-serif font      */
  --shell-font-mono:    'Space Mono', monospace;    /* code / monospaced font  */

  /* Layout dimensions */
  --titlebar-height:    48px;   /* height of the top title bar                */
  --left-panel-width:   224px; /* width of the left theme-list panel          */
  --right-panel-width:  264px; /* width of the right customisation panel      */
}

html,
body {
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

body {
  background: var(--shell-background);
  color: var(--shell-text);
  font-family: var(--shell-font);
  font-size: 13px;
  line-height: 1.5;
}

/* ── TITLEBAR ── */
.tb {
  height: var(--titlebar-height);
  background: var(--shell-surface);
  border-bottom: 1px solid var(--shell-border);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 12px;
  position: relative;
  z-index: 40;
}

.tb-logo {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--shell-text);
  flex-shrink: 0;
}

.tb-mark {
  width: 22px;
  height: 22px;
  background: var(--shell-text);
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 11px;
  font-weight: 700;
}

.tb-sep {
  width: 1px;
  height: 18px;
  background: var(--shell-border);
  flex-shrink: 0;
}

.tb-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--shell-text);
  flex: 1;
}

.tb-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ── MODE TOGGLE TOOLTIP ── */
.mode-toggle-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.mode-shortcut-tooltip {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(-4px);
  background: #1a1a1a;
  color: #f0f0ee;
  border-radius: 7px;
  padding: 7px 11px;
  font-size: 11px;
  font-family: var(--s-font);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
  z-index: 1000;
}

.mode-shortcut-tooltip::before {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-bottom-color: #1a1a1a;
}

.mode-toggle-wrap:hover .mode-shortcut-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.shortcut-badge {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 10.5px;
  font-family: var(--s-mono);
  letter-spacing: 0.5px;
  color: #c8c8c4;
}

/* ── SEGMENTED CONTROL ── */
.seg {
  display: flex;
  background: var(--shell-background);
  border: 1px solid var(--shell-border);
  border-radius: 7px;
  padding: 2px;
  gap: 1px;
}

.seg button {
  display: flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  padding: 3px 11px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 500;
  color: var(--shell-text-muted);
  cursor: pointer;
  font-family: var(--shell-font);
  transition: all .12s;
  white-space: nowrap;
}

.seg button.on {
  background: var(--shell-surface);
  color: var(--shell-text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 0 0 0.5px rgba(0, 0, 0, 0.05);
}

.btn-export {
  height: 28px;
  padding: 0 13px;
  background: var(--shell-text);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--shell-font);
  display: flex;
  align-items: center;
  gap: 5px;
  letter-spacing: -0.1px;
  transition: opacity .15s;
}

.btn-export:hover {
  opacity: 0.78;
}

.btn-save {
  height: 28px;
  padding: 0 13px;
  background: var(--shell-surface);
  color: var(--shell-text);
  border: 1px solid var(--shell-border);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--shell-font);
  display: flex;
  align-items: center;
  gap: 5px;
  letter-spacing: -0.1px;
  transition: background .15s;
}

.btn-save:hover {
  background: var(--shell-hover);
}

/* ── WORKSPACE ── */
.ws {
  display: flex;
  height: calc(100vh - var(--titlebar-height));
  overflow: hidden;
}

/* ── LEFT PANEL ── */
.lp {
  width: var(--left-panel-width);
  flex-shrink: 0;
  background: var(--shell-surface);
  border-right: 1px solid var(--shell-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.lp-head {
  padding: 13px 12px 9px;
  flex-shrink: 0;
}

.panel-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: var(--shell-text-faint);
}

.theme-list {
  overflow-y: auto;
  flex: 1;
  padding: 0 6px 10px;
}

.theme-list::-webkit-scrollbar {
  width: 3px;
}

.theme-list::-webkit-scrollbar-thumb {
  background: var(--shell-border);
  border-radius: 2px;
}

/* Theme list item */
.ti {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 4px;
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.ti:hover {
  background: var(--shell-hover);
}

.ti.on {
  background: var(--shell-active);
  border-color: var(--shell-border-subtle);
}

.ti-thumb {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: var(--shell-background);
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid var(--shell-border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.ti-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.ti:hover .ti-thumb img {
  transform: scale(1.05);
}

.ti-thumb.no-img {
  background: linear-gradient(135deg, var(--sw1), var(--sw2));
  position: relative;
}

.ti-thumb.no-img::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.1);
}

.ti-sw {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2px;
  flex-shrink: 0;
  z-index: 1;
}
/* ── BROWSER BAR URL INPUT ── */
.burl-container {
  display: flex;
  align-items: center;
  background: var(--mu-bg, rgba(0,0,0,0.05));
  border-radius: 6px;
  padding: 2px 8px;
  width: 250px;
  transition: width 0.3s;
  border: 1px solid transparent;
}
.burl-container:focus-within {
  width: 350px;
  background: var(--sf);
  border-color: var(--shell-border-subtle);
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}
.burl-input {
  border: none;
  background: transparent;
  color: var(--shell-text);
  font-size: 11px;
  font-family: inherit;
  width: 100%;
  outline: none;
  padding: 4px 0;
}
.btn-scan {
  border: none;
  background: transparent;
  color: var(--shell-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s;
}
.btn-scan:hover {
  color: var(--shell-text);
  background: rgba(0,0,0,0.05);
}

/* ── ANALYZE THEME BUTTON ── */
.btn-analyze {
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
  background: var(--shell-text);
  color: white;
  border: none;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  margin-left: 12px;
  transition: opacity 0.2s;
}
.btn-analyze:hover {
  opacity: 0.9;
}

.btn-tooltip {
  position: fixed;
  transform: translateX(-50%) translateY(-4px);
  background: #1a1a1a;
  color: white;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 11px;
  line-height: 1.35;
  max-width: 220px;
  white-space: normal;
  text-align: left;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
  z-index: 10000;
}

.btn-tooltip.visible {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.btn-tooltip::after {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 5px;
  border-style: solid;
  border-color: transparent transparent #1a1a1a transparent;
}

/* ── BACK BUTTON ── */
.btn-back {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--shell-surface);
  border: 1px solid var(--shell-border-subtle);
  color: var(--shell-text);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  margin-left: 12px;
  transition: all 0.2s;
}
.btn-back:hover {
  background: var(--shell-background);
  border-color: var(--shell-border);
}

/* ── SCANNING OVERLAY ── */
.scan-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255,255,255,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.scan-overlay.active {
  opacity: 1;
  pointer-events: all;
}
.scan-content {
  text-align: center;
}
.scan-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(0,0,0,0.1);
  border-top-color: var(--shell-text);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}
.scan-text {
  font-weight: 600;
  color: var(--shell-text);
  font-size: 14px;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── SITE IFRAME ── */
.site-iframe {
  width: 100%;
  height: 800px; /* Fixed large height to ensure content is visible and scrollable */
  border: none;
  background: white;
  display: block;
}

/* ── PREVIEW WINDOW RESPONSIVENESS ── */
.pw.desktop {
  max-width: 1100px; /* Wider view for desktop sites */
  transition: max-width 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.pw.desktop .site-iframe {
  height: 900px;
}

.ti-s {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  border: 0.5px solid rgba(0, 0, 0, 0.07);
}

.ti-info {
  flex: 1;
  min-width: 0;
}

.ti-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--shell-text);
  overflow-wrap: anywhere;
}

.ti-desc {
  font-size: 11px;
  color: var(--shell-text-muted);
}

.ti-check {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--shell-text);
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.ti.on .ti-check {
  display: flex;
}

/* ── CENTER / CANVAS ── */
.cv {
  flex: 1;
  overflow: hidden;
  background: var(--shell-background);
  display: flex;
  flex-direction: column;
}

.cv-bar {
  height: 36px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 8px;
  border-bottom: 1px solid var(--shell-border-subtle);
  background: var(--shell-background);
  position: relative;
  z-index: 2;
}

.cv-lbl {
  font-size: 11px;
  color: var(--shell-text-muted);
  font-weight: 500;
}

.cv-chip {
  background: var(--shell-surface);
  border: 1px solid var(--shell-border);
  border-radius: 5px;
  padding: 2px 8px;
  font-size: 11px;
  color: var(--shell-text-muted);
  font-family: var(--shell-font-mono);
}

.cv-body {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 20px;
}

.cv-body::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

.cv-body::-webkit-scrollbar-thumb {
  background: var(--shell-border);
  border-radius: 3px;
}

/* Preview window wrapper */
.pw {
  width: 100%;
  max-width: 860px;
  background: transparent;
  border-radius: 10px;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.05),
    0 6px 24px rgba(0, 0, 0, 0.07),
    0 0 0 1px rgba(0, 0, 0, 0.05);
  overflow: hidden;
  position: relative;
  transition: max-width 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ── Browser mockup chrome ── */
.bbar {
  height: 36px;
  background: #f8f8f7;
  border-bottom: 1px solid #e8e8e6;
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 9px;
  flex-shrink: 0;
}

.bdots {
  display: flex;
  gap: 5px;
}

.bd {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.bd.r {
  background: #ff5f56;
}

.bd.y {
  background: #ffbd2e;
}

.bd.g {
  background: #27c93f;
}

.burl {
  flex: 1;
  background: #efefed;
  border-radius: 4px;
  height: 20px;
  display: flex;
  align-items: center;
  padding: 0 9px;
  font-size: 11px;
  color: #999;
  font-family: var(--shell-font-mono);
  max-width: 300px;
  margin: 0 auto;
}

#preview-root {
  width: 100%;
  min-height: 560px;
}

/* ── RIGHT PANEL ── */
.rp {
  width: var(--right-panel-width);
  flex-shrink: 0;
  background: var(--shell-surface);
  border-left: 1px solid var(--shell-border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.rp::-webkit-scrollbar {
  width: 3px;
}

.rp::-webkit-scrollbar-thumb {
  background: var(--shell-border);
  border-radius: 2px;
}

.rp-sec {
  border-bottom: 1px solid var(--shell-border-subtle);
  padding: 13px;
}

.rp-sec:last-child {
  border-bottom: none;
}

.sec-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 11px;
}

.btn-reset {
  background: none;
  border: none;
  font-size: 11px;
  color: var(--shell-text-muted);
  cursor: pointer;
  font-family: var(--shell-font);
  text-decoration: underline;
  text-underline-offset: 2px;
  padding: 0;
}

.btn-reset:hover {
  color: var(--shell-text);
}

/* ── COLOR ROWS ── */
.cr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid var(--shell-border-subtle);
}

.cr:last-child {
  border-bottom: none;
}

.cr-lbl {
  font-size: 12px;
  color: var(--shell-text);
  flex: 1;
}

.cr-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cp {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.09);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.cp input[type="color"] {
  position: absolute;
  inset: -4px;
  width: calc(100% + 8px);
  height: calc(100% + 8px);
  border: none;
  padding: 0;
  cursor: pointer;
  opacity: 0;
}

.hx {
  width: 62px;
  font-size: 11px;
  font-family: var(--shell-font-mono);
  color: var(--shell-text-muted);
  background: none;
  border: none;
  outline: none;
  padding: 0;
}

.hx:focus {
  color: var(--shell-text);
}

/* ── PROPERTY ROWS (typography / selects) ── */
.pr-row {
  margin-bottom: 9px;
}

.pr-row:last-child {
  margin-bottom: 0;
}

.pr-lbl {
  font-size: 11px;
  color: var(--shell-text-muted);
  margin-bottom: 4px;
  font-weight: 500;
}

.pr-sel {
  width: 100%;
  background: var(--shell-background);
  border: 1px solid var(--shell-border);
  border-radius: 6px;
  color: var(--shell-text);
  padding: 6px 8px;
  font-size: 12px;
  font-family: var(--shell-font);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23999' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");

  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 24px;
}

.pr-sel:focus {
  outline: 1px solid #d8d8d4;
}

/* ── SLIDER ROWS ── */
.sl-row {
  margin-bottom: 10px;
}

.sl-row:last-child {
  margin-bottom: 0;
}

.sl-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

.sl-name {
  font-size: 12px;
  color: var(--shell-text);
}

.sl-val {
  font-size: 11px;
  font-family: var(--shell-font-mono);
  color: var(--shell-text-muted);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  border-radius: 2px;
  background: var(--shell-border);
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--shell-text);
  box-shadow: 0 0 0 2px white, 0 0 0 3px rgba(0, 0, 0, 0.1);
  cursor: grab;
}

input[type="range"]:active::-webkit-slider-thumb {
  cursor: grabbing;
}

/* ── EXPORT MODAL ── */
.mo {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s;
}

.mo.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: white;
  border-radius: 12px;
  width: 490px;
  max-width: 92vw;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05), 0 20px 50px rgba(0, 0, 0, 0.12);
  transform: translateY(10px) scale(0.985);
  transition: transform .18s;
  overflow: hidden;
}

.mo.open .modal {
  transform: none;
}

.mo-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 14px;
  border-bottom: 1px solid #f0f0ee;
}

.mo-head-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.export-seg {
  padding: 1px;
}

.mo-head h3 {
  font-size: 14px;
  font-weight: 600;
  color: #111110;
}

.mo-x {
  width: 24px;
  height: 24px;
  background: var(--shell-background);
  border: 1px solid var(--shell-border);
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: var(--shell-text-muted);
  line-height: 1;
}

.mo-x:hover {
  background: #e8e8e6;
}

.mo-body {
  padding: 14px 18px 16px;
}

.mo-input-group {
  margin-bottom: 8px;
}

.mo-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--shell-text);
  margin-bottom: 6px;
}

.mo-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--shell-border);
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--shell-font);
  color: var(--shell-text);
  outline: none;
  transition: border-color .15s;
}

.mo-input:focus {
  border-color: #a0a09a;
}

.mo-hint {
  font-size: 11px;
  color: var(--shell-text-muted);
  margin-top: 6px;
}

.mo-pre {
  background: #fafaf8;
  border: 1px solid #ebebea;
  border-radius: 7px;
  padding: 13px 15px;
  font-family: var(--shell-font-mono);
  font-size: 11px;
  line-height: 1.8;
  color: #555;
  overflow: auto;
  max-height: 320px;
  white-space: pre;
}

.mo-pre::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

.mo-pre::-webkit-scrollbar-thumb {
  background: #ddd;
  border-radius: 2px;
}

.mo-foot {
  display: flex;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid #f0f0ee;
  background: #fafaf8;
}

.btn-cp {
  height: 30px;
  padding: 0 14px;
  background: var(--shell-text);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--shell-font);
  transition: opacity .15s;
}

.btn-cp:hover {
  opacity: 0.8;
}

.btn-cl {
  height: 30px;
  padding: 0 12px;
  background: none;
  border: 1px solid var(--shell-border);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--shell-text);
  cursor: pointer;
  font-family: var(--shell-font);
}