/* ── RESET & BASE ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 13px;
  color: #1a1a1a;
  background: #f5f5f5;
  height: 100vh;
  overflow: hidden;
}

/* ── LAYOUT ────────────────────────────────────────────────────────────────── */
.app {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* ── LEFT PANEL ────────────────────────────────────────────────────────────── */
.panel {
  width: 300px;
  min-width: 300px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-right: 1px solid #e0e0e0;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e0e0e0;
  flex-shrink: 0;
  background: #fff;
}

.panel-title {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  color: #1a1a1a;
}

.copy-btn {
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  padding: 4px 12px;
  background: #1a1a1a;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}

.copy-btn:hover { background: #333; }
.copy-btn.copied { background: #2a6e42; }

.panel-body {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #e0e0e0 transparent;
}

.panel-body::-webkit-scrollbar { width: 4px; }
.panel-body::-webkit-scrollbar-track { background: transparent; }
.panel-body::-webkit-scrollbar-thumb { background: #e0e0e0; }

/* ── SECTIONS ──────────────────────────────────────────────────────────────── */
.section {
  padding: 20px;
  border-bottom: 1px solid #e0e0e0;
}

.section-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.10em;
  color: #999;
  margin-bottom: 16px;
}

.subsection-label {
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.10em;
  color: #bbb;
  margin-bottom: 10px;
}

.control-group {
  margin-bottom: 20px;
}

.control-group:last-child { margin-bottom: 0; }

/* ── CONTROLS ──────────────────────────────────────────────────────────────── */
.control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.control:last-child { margin-bottom: 0; }

.control-label {
  font-size: 12px;
  color: #555;
  line-height: 1.4;
}

/* ── COLOR INPUTS ──────────────────────────────────────────────────────────── */
.color-input-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.color-swatch {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  cursor: pointer;
  background: none;
  flex-shrink: 0;
}

.color-swatch::-webkit-color-swatch-wrapper { padding: 0; }
.color-swatch::-webkit-color-swatch { border: none; }

.hex-input {
  width: 72px;
  font-size: 11px;
  font-family: 'SF Mono', 'Fira Code', 'Fira Mono', 'Courier New', monospace;
  padding: 4px 6px;
  border: 1px solid #e0e0e0;
  color: #1a1a1a;
  background: #fff;
  outline: none;
  border-radius: 4px;
  transition: border-color 0.1s;
}

.hex-input:focus { border-color: #1a1a1a; }

/* ── SLIDER ────────────────────────────────────────────────────────────────── */
.slider-control {
  flex-direction: column;
  align-items: stretch;
  gap: 0;
}

.slider-control .control-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  margin-right: 0;
}

.slider-value {
  font-variant-numeric: tabular-nums;
  color: #1a1a1a;
  font-weight: 500;
}

.slider {
  -webkit-appearance: none;
  width: 100%;
  height: 2px;
  background: #e0e0e0;
  outline: none;
  border-radius: 2px;
  margin-bottom: 12px;
  cursor: pointer;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  background: #1a1a1a;
  cursor: pointer;
  border-radius: 50%;
}

.slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: #1a1a1a;
  cursor: pointer;
  border: none;
  border-radius: 50%;
}

.presets {
  display: flex;
  gap: 6px;
}

.preset-btn {
  font-size: 10px;
  font-family: inherit;
  padding: 3px 8px;
  border: 1px solid #e0e0e0;
  background: #fff;
  color: #888;
  cursor: pointer;
  transition: all 0.1s;
  border-radius: 4px;
}

.preset-btn:hover { border-color: #1a1a1a; color: #1a1a1a; }
.preset-btn.active { border-color: #1a1a1a; color: #1a1a1a; background: #f5f5f5; }

/* ── SELECT ────────────────────────────────────────────────────────────────── */
.select-input {
  width: 100%;
  font-size: 12px;
  font-family: inherit;
  padding: 7px 28px 7px 8px;
  border: 1px solid #e0e0e0;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23999'/%3E%3C/svg%3E") no-repeat right 8px center;
  color: #1a1a1a;
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  border-radius: 4px;
  transition: border-color 0.1s;
}

.select-input:focus { border-color: #1a1a1a; }

/* ── TEMPLATES ─────────────────────────────────────────────────────────────── */
.template-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.template-btn {
  width: 100%;
  font-size: 12px;
  font-family: inherit;
  padding: 9px 12px;
  border: 1px solid #e0e0e0;
  background: #fff;
  color: #555;
  cursor: pointer;
  text-align: left;
  transition: all 0.1s;
  border-radius: 4px;
}

.template-btn:hover { border-color: #888; color: #1a1a1a; }
.template-btn.active { border-color: #1a1a1a; color: #1a1a1a; background: #f5f5f5; }

/* ── TOGGLE ────────────────────────────────────────────────────────────────── */
.toggle-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toggle {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 18px;
  cursor: pointer;
  flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }

.toggle-track {
  position: absolute;
  inset: 0;
  background: #e0e0e0;
  border-radius: 999px;
  transition: background 0.2s;
}

.toggle-track::after {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  top: 3px;
  left: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle input:checked + .toggle-track { background: #1a1a1a; }
.toggle input:checked + .toggle-track::after { transform: translateX(16px); }

/* ── RIGHT MAIN ────────────────────────────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  min-width: 0;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid #e0e0e0;
  background: #fff;
  flex-shrink: 0;
}

.preview-header-left {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.preview-disclaimer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: 4px;
  color: #b91c1c;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.preview-width-toggle {
  display: flex;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  overflow: hidden;
}

.width-btn {
  font-size: 11px;
  font-family: inherit;
  padding: 5px 14px;
  background: #fff;
  border: none;
  cursor: pointer;
  color: #888;
  transition: all 0.1s;
  border-radius: 0;
}

.width-btn + .width-btn { border-left: 1px solid #e0e0e0; }
.width-btn.active { background: #1a1a1a; color: #fff; }

/* ── PREVIEW AREA ──────────────────────────────────────────────────────────── */
.preview-area {
  flex: 1;
  padding: 24px;
  overflow: hidden;
  display: flex;
  align-items: stretch;
  min-height: 0;
}

.preview-frame-wrapper {
  flex: 1;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
  transition: max-width 0.3s ease;
  display: flex;
}

.preview-frame-wrapper.mobile {
  max-width: 390px;
  margin: 0 auto;
}

.preview-iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  flex: 1;
}

/* ── CSS OUTPUT ────────────────────────────────────────────────────────────── */
.output-area {
  height: 180px;
  border-top: 1px solid #e0e0e0;
  background: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  border-bottom: 1px solid #e0e0e0;
  flex-shrink: 0;
}

.output-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.10em;
  color: #999;
}

.css-output {
  flex: 1;
  overflow-y: auto;
  padding: 12px 24px;
  font-family: 'SF Mono', 'Fira Code', 'Fira Mono', 'Courier New', monospace;
  font-size: 11px;
  line-height: 1.8;
  color: #444;
  white-space: pre;
  margin: 0;
  background: #fff;
  scrollbar-width: thin;
  scrollbar-color: #e0e0e0 transparent;
}

.css-output::-webkit-scrollbar { height: 4px; width: 4px; }
.css-output::-webkit-scrollbar-track { background: transparent; }
.css-output::-webkit-scrollbar-thumb { background: #e0e0e0; }

/* ── MODE TOGGLE ───────────────────────────────────────────────────────────── */
.mode-toggle {
  display: flex;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  overflow: hidden;
  width: 100%;
}

.mode-btn {
  flex: 1;
  font-size: 11px;
  font-family: inherit;
  font-weight: 500;
  letter-spacing: 0.05em;
  padding: 7px 12px;
  background: #fff;
  border: none;
  cursor: pointer;
  color: #888;
  transition: all 0.1s;
  border-radius: 0;
  text-align: center;
}

.mode-btn + .mode-btn { border-left: 1px solid #e0e0e0; }
.mode-btn.active { background: #1a1a1a; color: #fff; }

/* ── TRANSPARENT BUTTON ────────────────────────────────────────────────────── */
.transparent-btn {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid #e0e0e0;
  background: #fff;
  color: #bbb;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.1s;
}

.transparent-btn:hover { border-color: #1a1a1a; color: #1a1a1a; }
.transparent-btn.active { border-color: #1a1a1a; background: #1a1a1a; color: #fff; }

/* Dim inputs when transparent is active */
.color-swatch:disabled { opacity: 0.3; cursor: not-allowed; }
.hex-input:disabled { opacity: 0.4; cursor: not-allowed; color: #888; }
