@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500&family=Nunito:wght@400;600;700;800;900&family=Kantumruy+Pro:wght@400;600;700&display=swap');

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

:root {
  /* Dark mode (default) - Deep, polished, balanced */
  --bg: #0a0a0b;
  --bg2: #121214;
  --bg3: #1a1a1d;
  --bg4: #242529;
  --border: rgba(255, 255, 255, 0.06);
  --border2: rgba(255, 255, 255, 0.1);
  --text: #e2e2e7;
  --muted: #71717a;
  --muted2: #a1a1aa;
  --accent: #10b981; /* Emerald 500 - Sophisticated Green */
  --accent2: #34d399; /* Emerald 400 */
  --danger: #ef4444; /* Red 500 */
  --editor-text: #d4d4d8;
  --shadow: rgba(0, 0, 0, 0.8);
  --grid-line: rgba(255, 255, 255, 0.015);
  --loading-bg: rgba(10, 10, 11, 0.8);
  --mono: 'JetBrains Mono', monospace;
  --sans: 'Nunito', sans-serif;
}

html.light {
  /* Light mode - Premium Paper feel */
  --bg: #fcfcfc;
  --bg2: #ffffff;
  --bg3: #f1f5f9;
  --bg4: #e2e8f0;
  --border: rgba(0, 0, 0, 0.05); /* Softer borders */
  --border2: rgba(0, 0, 0, 0.08);
  --text: #0f172a;
  --muted: #64748b;
  --muted2: #94a3b8;
  --accent: #10b981;
  --accent2: #059669;
  --danger: #ef4444;
  --editor-text: #334155;
  --shadow: rgba(15, 23, 42, 0.05);
  --grid-line: rgba(0, 0, 0, 0.03);
  --loading-bg: rgba(252, 252, 252, 0.85);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Top bar ── */
.topbar {
  display: flex;
  align-items: center;
  gap: 0;
  height: 48px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg2);
}

.logo {
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.03em;
  padding: 0 16px;
  border-right: 1px solid var(--border);
  height: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.logo-img {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

.topbar-section {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  height: 100%;
  border-right: 1px solid var(--border);
}

.topbar-label {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-family: var(--sans);
  font-weight: 700;
}

.dim-input {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 4px;
  padding: 4px 8px;
  color: var(--text);
  width: 70px;
  text-align: center;
}

.dim-input:focus {
  outline: none;
  border-color: var(--accent);
}

.dim-input:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.auto-h-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  user-select: none;
}

.auto-h-toggle input[type="checkbox"] {
  display: none;
}

.auto-h-label {
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 20px;
  border: 1px solid var(--border2);
  color: var(--muted);
  background: var(--bg3);
  transition: all 0.15s;
  text-transform: uppercase;
  cursor: pointer;
}

.auto-h-toggle input:checked+.auto-h-label {
  background: rgba(127, 255, 110, 0.1);
  border-color: rgba(127, 255, 110, 0.35);
  color: var(--accent);
}

.dim-x {
  color: var(--muted);
  font-size: 11px;
}

.scale-select, .topbar-select {
  font-family: var(--sans);
  font-size: 11.5px;
  font-weight: 600;
  background-color: var(--bg3);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23888888' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  border: 1px solid var(--border2);
  border-radius: 6px;
  padding: 4px 20px 4px 8px;
  color: var(--text);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: all 0.2s ease;
}

.scale-select:hover, .topbar-select:hover {
  background-color: var(--bg4);
  border-color: var(--muted2);
}

.scale-select:focus, .topbar-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.spacer {
  flex: 1;
}

.btn {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--border2);
  cursor: pointer;
  background: transparent;
  color: var(--muted2);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  outline: none;
}

.btn:hover {
  background: var(--bg4);
  color: var(--text);
  border-color: var(--border2);
}

.btn.undo-mode {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(127, 255, 110, 0.25);
}

.btn.undo-mode:hover {
  background: var(--accent2);
  border-color: var(--accent2);
  color: #000;
  transform: translateY(-1px);
}

.btn-export {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  font-weight: 800;
  letter-spacing: 0.03em;
  margin-right: 12px;
  padding: 8px 18px;
  box-shadow: 0 4px 12px rgba(127, 255, 110, 0.15);
}

.btn-export:hover {
  background: var(--accent2);
  border-color: var(--accent2);
  color: #000;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(127, 255, 110, 0.25);
}

.btn-export svg,
.btn-export i {
  width: 14px;
  height: 14px;
  stroke-width: 3;
}

.btn-copy {
  margin-left: 4px;
  margin-right: 4px;
}

.btn-theme {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 8px;
  margin-right: 4px;
  flex-shrink: 0;
}

.lucide {
  width: 14px;
  height: 14px;
  stroke-width: 2.25;
}

.btn i,
.btn svg {
  margin-right: 0; /* Handled by gap: 8px in .btn */
}

.btn-theme i,
.btn-theme svg {
  margin-right: 0;
}

.mobile-fab i,
.mobile-fab svg {
  width: 20px;
  height: 20px;
  margin-right: 8px;
}

/* ── Main layout ── */
.main {
  display: grid;
  grid-template-columns: 4fr 6fr;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ── Editor pane ── */
.editor-pane {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  min-height: 0;
  min-width: 0;
}

.pane-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  height: 36px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
}

.pane-title {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.pane-badge {
  font-size: 9px;
  padding: 2px 7px;
  border-radius: 20px;
  background: var(--bg4);
  color: var(--muted2);
  border: 1px solid var(--border);
  letter-spacing: 0.05em;
}

.pane-badge.live {
  background: rgba(127, 255, 110, 0.1);
  color: var(--accent);
  border-color: rgba(127, 255, 110, 0.25);
  display: flex;
  align-items: center;
  gap: 4px;
}

.live-dot {
  width: 6px !important;
  height: 6px !important;
  fill: currentColor;
}

.editor-area {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

#html-editor {
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--editor-text);
  border: none;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.7;
  padding: 20px 20px 20px 58px;
  outline: none;
  tab-size: 2;
  white-space: pre;
  overflow: auto;
  caret-color: var(--accent);
}

#html-editor * {
  font-family: inherit !important;
}

/* Line numbers overlay */
.editor-lines {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 44px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  padding: 20px 8px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--muted);
  text-align: right;
  pointer-events: none;
  overflow: hidden;
  user-select: none;
  white-space: pre;
  z-index: 5;
}

/* Prism overrides */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
  color: #5c6370;
}

.token.punctuation {
  color: #abb2bf;
}

.token.namespace {
  opacity: .7;
}

.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
  color: #e06c75;
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
  color: #98c379;
}

.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
  color: #56b6c2;
}

.token.atrule,
.token.attr-value,
.token.keyword {
  color: #c678dd;
}

.token.function,
.token.class-name {
  color: #61afef;
}

.token.regex,
.token.important,
.token.variable {
  color: #e06c75;
}

.editor-status {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 5px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
  font-size: 10px;
  color: var(--muted);
}

.status-pill {
  padding: 1px 7px;
  border-radius: 10px;
  background: var(--bg4);
  font-size: 9px;
  border: 1px solid var(--border);
}

#status-msg {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 20px;
}

.btn-undo {
  background: var(--accent);
  color: #000;
  border: none;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  line-height: 1;
  box-shadow: 0 2px 8px rgba(127, 255, 110, 0.2);
}

.btn-undo:hover {
  background: var(--accent2);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(127, 255, 110, 0.3);
}

.btn-undo:active {
  transform: translateY(0);
}

/* Template chips */
.tpl-row {
  display: flex;
  gap: 6px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
}

.tpl-row::-webkit-scrollbar {
  display: none;
}

.tpl-chip {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border2);
  background: var(--bg3);
  color: var(--muted2);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  letter-spacing: 0.01em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  outline: none;
}

.tpl-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(127, 255, 110, 0.07);
}

/* ── Preview pane ── */
.preview-pane {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  min-height: 0;
  min-width: 0;
}

.preview-viewport {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 32px;
  background: var(--bg);
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 24px 24px;
  position: relative;
}

.preview-frame-label {
  position: absolute;
  top: -22px;
  left: 0;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.08em;
  white-space: nowrap;
}

#preview-iframe {
  display: block;
  border: none;
  box-shadow: 0 0 0 1px var(--border2), 0 20px 60px var(--shadow);
}

/* Loading overlay */
.preview-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--loading-bg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  font-size: 11px;
  color: var(--muted2);
  gap: 8px;
}

.preview-loading.show {
  opacity: 1;
  pointer-events: all;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Output panel ── */
.output-bar {
  border-top: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
}

.output-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  user-select: none;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  transition: background 0.2s;
  outline: none;
}

.output-header:hover {
  background: var(--bg3);
}

.out-icon {
  width: 12px;
  height: 12px;
  color: var(--muted);
  transition: transform 0.2s;
}

.out-icon.open {
  transform: rotate(90deg);
}

.output-body {
  display: none;
  padding: 0 16px 14px;
  gap: 10px;
}

.output-body.open {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

#output-thumb {
  width: 160px;
  height: auto;
  border-radius: 4px;
  border: 1px solid var(--border2);
  flex-shrink: 0;
  display: none;
}

.output-info {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.output-info-row {
  font-size: 10px;
  color: var(--muted2);
  display: flex;
  gap: 6px;
}

.output-info-row span {
  color: var(--text);
}

/* ── Scrollbars ── */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

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

::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* ── Pretty Alert Dialog ── */
.alert-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.alert-overlay.show {
  opacity: 1;
  pointer-events: all;
}

.alert-box {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 24px;
  padding: 0;
  width: 420px;
  max-width: calc(100vw - 40px);
  box-shadow: 
    0 20px 50px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(255, 255, 255, 0.05);
  transform: translateY(20px) scale(0.95);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}

.alert-overlay.show .alert-box {
  transform: translateY(0) scale(1);
}

/* Top coloured stripe based on type */
.alert-stripe {
  height: 4px;
  width: 100%;
  background: var(--accent);
  flex-shrink: 0;
}

.alert-stripe.danger {
  background: linear-gradient(90deg, #ff5a5a, #ff8c42);
}

.alert-stripe.warn {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.alert-stripe.success {
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}

.alert-stripe.info {
  background: linear-gradient(90deg, #60a5fa, #818cf8);
}

.alert-body {
  padding: 32px 32px 24px;
}

.alert-header {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 24px;
}

.alert-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
  margin-top: -2px;
}

.alert-icon svg {
  width: 24px;
  height: 24px;
  stroke-width: 2.5;
}

.alert-icon.warn {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.alert-icon.danger {
  background: rgba(255, 90, 90, 0.12);
  border: 1px solid rgba(255, 90, 90, 0.25);
}

.alert-icon.success {
  background: rgba(127, 255, 110, 0.1);
  border: 1px solid rgba(127, 255, 110, 0.25);
}

.alert-icon.info {
  background: rgba(96, 165, 250, 0.1);
  border: 1px solid rgba(96, 165, 250, 0.25);
}

.alert-text {
  flex: 1;
  min-width: 0;
}

.alert-title {
  font-family: var(--sans);
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.alert-msg {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--muted2);
  line-height: 1.6;
}

.alert-footer {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  padding: 20px 32px 28px;
  background: rgba(0, 0, 0, 0.1);
}

.alert-btn {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 700;
  padding: 11px 24px;
  border-radius: 12px;
  border: 1px solid var(--border2);
  cursor: pointer;
  background: var(--bg3);
  color: var(--muted2);
  transition: all 0.2s;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  justify-content: center;
}

.alert-btn:hover {
  background: var(--bg4);
  color: var(--text);
  transform: translateY(-1px);
}

.alert-btn.primary {
  background: var(--accent);
  color: #000;
  border: none;
  box-shadow: 0 4px 12px rgba(127, 255, 110, 0.2);
}

.alert-btn.primary:hover {
  background: var(--accent2);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(127, 255, 110, 0.3);
}

.alert-btn.danger-btn {
  background: rgba(255, 90, 90, 0.13);
  color: var(--danger);
  border-color: rgba(255, 90, 90, 0.28);
}

.alert-btn.danger-btn:hover {
  background: rgba(255, 90, 90, 0.22);
}

/* ── Footer ── */
.app-footer {
  flex-shrink: 0;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: var(--bg2);
  letter-spacing: 0.02em;
  user-select: none;
}

.app-footer .sep {
  opacity: 0.4;
}

.app-footer .author {
  color: var(--muted2);
  font-weight: 700;
}

.footer-highlight {
  background: rgba(127, 255, 110, 0.08);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 700;
}

/* ── Auto-height preview ── */
.preview-wrap {
  position: relative;
  transition: transform 0.2s;
  transform-origin: top center;
}

.mobile-fab-wrap {
  display: none;
}

.btn-copy-html {
  margin: 0 6px;
}

/* ── Effects Panel ── */
.preview-pane { position: relative; }

.effects-panel {
  position: absolute;
  top: 64px;
  right: 20px;
  width: 260px;
  background: rgba(17, 17, 17, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 12px;
  padding: 20px 16px;
  box-shadow: 0 16px 32px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.1);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 18px;
  transition: opacity 0.2s ease, transform 0.2s ease;
  color: #fff;
}

.effects-panel.hidden,
#features-panel.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-10px) scale(0.98);
}

#features-panel {
  top: 64px;
}

.ep-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  padding: 8px 10px;
  color: #fff;
  font-family: var(--sans);
  font-size: 11.5px;
  outline: none;
  transition: border-color 0.2s;
}

.ep-input:focus {
  border-color: var(--accent);
}

.feat-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.feat-toggle input[type="checkbox"] {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
}

.feat-label {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

.feat-desc {
  font-size: 10px;
  color: #888;
  margin-top: -4px;
  padding-left: 25px;
}

.ep-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}

.ep-title {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.ep-reset {
  background: transparent;
  border: none;
  color: #888;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
  display: flex;
}

.ep-reset:hover {
  color: #fff;
  background: rgba(255,255,255,0.1);
}

.ep-reset i, .ep-reset svg {
  width: 14px;
  height: 14px;
}

.ep-control {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ep-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ep-label {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  color: #fff;
}

.ep-value {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  background: rgba(255,255,255,0.1);
  padding: 2px 6px;
  border-radius: 10px;
  color: #ccc;
}

.ep-slider {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  background: #333;
  border-radius: 2px;
  outline: none;
  accent-color: #00C9B1;
}

.ep-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.5);
  border: none;
}

.ep-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.5);
  border: none;
}

/* ── Responsive Overhaul ── */
.hidden-desktop {
  display: none !important;
}

@media (max-width: 768px) {
  .main {
    grid-template-columns: 1fr;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: var(--bg);
    flex: 1;
    min-height: 0;
  }

  .editor-pane {
    border-right: none;
    border-bottom: 1px solid var(--border);
    height: auto;
    min-height: 500px;
    flex: none;
  }

  .preview-pane {
    height: auto;
    min-height: 500px;
    flex: none;
  }

  .preview-viewport {
    flex: 1;
    min-height: 400px;
    padding: 20px 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
  }

  .topbar {
    height: auto;
    padding: 6px 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    background: var(--bg2);
    align-items: stretch;
  }

  .logo {
    width: 100% !important; /* Take full top row so theme toggle goes to far right */
    justify-content: flex-start;
    border-right: none;
    height: 32px;
    padding: 0;
    margin-bottom: 2px;
    border-bottom: none;
  }

  .btn-theme {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    margin: 0;
    position: static;
    background: var(--bg3);
    border: 1px solid var(--border);
    z-index: auto;
    flex: none;
    margin-left: auto;
  }

  .topbar-section {
    border: 1px solid var(--border);
    background: var(--bg3);
    border-radius: 6px;
    height: 32px;
    padding: 0 6px;
    margin: 0;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0px;
    min-width: 0;
  }

  /* Compact Flex-basis strategy */
  /* Logo is nth-of-type(1) div */
  .topbar-section:nth-of-type(2) { flex-basis: 100%; } /* Preset list */
  .topbar-section:nth-of-type(3) { flex-basis: 100%; flex-direction: row; gap: 8px; align-items: center; } /* W x H */
  .topbar-section:nth-of-type(4) { flex-basis: 25%; } /* Scale */
  .topbar-section:nth-of-type(5) { flex-basis: 55%; flex-grow: 2; } /* Export@ */
  .topbar-section:nth-of-type(6) { flex-basis: 35%; flex-grow: 1; } /* Watermark */

  .topbar-section .topbar-label {
    display: block;
    font-size: 7.5px;
    opacity: 0.5;
    margin-left: 0;
    text-align: center;
  }

  .topbar-section .topbar-input {
    width: 100%;
    text-align: center;
    font-size: 12px;
    background: transparent;
    border: none;
    padding: 0;
    height: 16px;
    font-weight: 700;
  }

  .topbar-section .topbar-select,
  .topbar-section .scale-select {
    width: 100%;
    font-size: 11px;
    padding: 2px 20px 2px 6px;
    text-align: left;
    height: auto;
  }

  .btn-copy-html {
    display: none; /* Hidden on mobile screen */
  }

  /* Hide original items */
  .topbar .btn-export,
  .pane-header .btn-clear-action,
  .pane-header .btn[onclick="formatHTML()"] {
    display: none !important;
  }

  .hidden-desktop {
    display: flex !important;
  }

  .mobile-action-bar {
    position: fixed;
    bottom: 24px;
    left: 16px;
    right: 16px;
    z-index: 1000;
    gap: 8px;
    padding: 8px;
    border-radius: 12px;
    background: rgba(10, 10, 11, 0.6);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  }

  html.light .mobile-action-bar {
    background: rgba(252, 252, 252, 0.75);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
  }

  .mobile-action-bar > .btn {
    height: 48px;
  }
  
  .mobile-action-bar .btn-text {
    display: none; /* Icon only for Format and Clear */
  }

  .btn-export {
    flex: 1; /* Take full width on mobile */
    margin: 0;
    border-radius: 8px;
    height: 44px;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(127, 255, 110, 0.15);
    justify-content: center;
    gap: 8px;
    font-weight: 800;
  }

  .btn-export i { width: 12px; height: 12px; }

  .pane-header {
    padding: 0 12px;
    height: 48px;
    gap: 8px;
    background: var(--bg2);
  }

  .pane-header .btn {
    height: 34px;
    padding: 0 12px;
    font-size: 12px;
    border-radius: 6px;
  }
  
  /* Make room for bottom action bar */
  .main {
    padding-bottom: 80px; 
  }

  .app-footer {
    display: flex; /* Display one line on mobile */
    flex-direction: row;
    justify-content: center;
    align-items: center;
    padding: 8px 10px 16px;
    gap: 8px;
    height: auto;
    background: var(--bg);
  }

  .spacer { display: none; }
}

@media (max-width: 480px) {
  .logo span:nth-child(2) { display: none; }
  .topbar-section { height: 32px; }
  .btn-export { height: 44px; font-size: 14px; }
}
