:root {
  --bg: #0e0f13;
  --panel: #16181f;
  --panel-border: #262932;
  --text: #eef0f4;
  --text-dim: #9aa0ac;
  --accent: #7c5cff;
  --accent-2: #56d6ff;
  --radius: 14px;
  font-size: 15px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  height: 100%;
}

/* ---------------- topbar ---------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--panel-border);
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: inline-block;
}

.topbar h1 { font-size: 17px; margin: 0; font-weight: 600; }

/* ---------------- layout ---------------- */

.layout {
  display: grid;
  grid-template-columns: 300px 1fr 320px;
  gap: 20px;
  padding: 20px 24px;
  align-items: start;
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 18px;
}

.panel h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-dim);
  margin: 0 0 14px;
}

/* ---------------- fields ---------------- */

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
.field label small { color: #666; font-weight: 400; }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

select, input[type="number"], input[type="text"], textarea {
  width: 100%;
  background: #1e212b;
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.resolution-readout {
  font-size: 12.5px;
  color: var(--text-dim);
  background: #1e212b;
  border-radius: 8px;
  padding: 10px;
  line-height: 1.5;
}

/* ---------------- detected box ---------------- */

.detected-box {
  background: linear-gradient(135deg, rgba(124,92,255,.15), rgba(86,214,255,.1));
  border: 1px solid rgba(124,92,255,.35);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.detected-info { display: flex; flex-direction: column; gap: 2px; }
.detected-info strong { font-size: 13px; }
.detected-info span { font-size: 11.5px; color: var(--text-dim); }

/* ---------------- buttons ---------------- */

.btn {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 13.5px;
  font-weight: 500;
  font-family: inherit;
  transition: transform .1s ease, opacity .15s ease;
}
.btn:active { transform: scale(0.97); }

.btn-ghost {
  background: #1e212b;
  color: var(--text);
  border: 1px solid var(--panel-border);
}
.btn-ghost:hover { background: #262a36; }

.btn-small { padding: 6px 10px; font-size: 12.5px; }

.btn-outline {
  background: transparent;
  color: var(--accent-2);
  border: 1px solid rgba(86,214,255,.4);
  width: 100%;
}
.btn-outline:hover { background: rgba(86,214,255,.08); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #0b0b0f;
  font-weight: 600;
}
.btn-primary:hover { opacity: .92; }

.btn-block { width: 100%; margin-top: 6px; }

/* ---------------- preview ---------------- */

.preview-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-height: 560px;
}

.preview-stage {
  width: 100%;
  height: 560px;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(45deg, #1a1c22 25%, transparent 25%) -8px 0/16px 16px,
    linear-gradient(-45deg, #1a1c22 25%, transparent 25%) -8px 0/16px 16px,
    linear-gradient(45deg, transparent 75%, #1a1c22 75%) -8px 0/16px 16px,
    linear-gradient(-45deg, transparent 75%, #1a1c22 75%) -8px 0/16px 16px,
    #101218;
  border-radius: var(--radius);
  border: 1px solid var(--panel-border);
}

.hint { font-size: 12px; color: var(--text-dim); margin: 0; }

/* device frame */

.device-frame {
  position: relative;
  background: #08090c;
  box-shadow: 0 20px 60px rgba(0,0,0,.55);
  transition: width .15s ease, height .15s ease;
}

.device-screen {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background-size: cover;
}

.device-screen canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  mix-blend-mode: overlay;
  pointer-events: none;
}

/* smartphone chrome */
.device-smartphone {
  border-radius: 46px;
  padding: 14px;
  border: 2px solid #26282f;
}
.device-smartphone .device-screen { border-radius: 32px; }
.device-smartphone .device-notch {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: 40%;
  height: 22px;
  background: #08090c;
  border-radius: 0 0 16px 16px;
  z-index: 2;
}
.device-smartphone .device-home {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 34%;
  height: 4px;
  border-radius: 4px;
  background: #3a3d47;
  z-index: 2;
}

/* tablet chrome */
.device-tablet {
  border-radius: 26px;
  padding: 20px 16px;
  border: 2px solid #26282f;
}
.device-tablet .device-screen { border-radius: 10px; }
.device-tablet .device-notch {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2c2f38;
  z-index: 2;
}
.device-tablet .device-home { display: none; }

/* laptop chrome */
.device-laptop {
  border-radius: 12px 12px 0 0;
  padding: 12px 12px 4px;
  border: 2px solid #26282f;
  border-bottom: none;
}
.device-laptop .device-screen { border-radius: 4px; }
.device-laptop .device-notch { display: none; }
.device-laptop .device-home {
  position: absolute;
  bottom: -18px;
  left: 50%;
  transform: translateX(-50%);
  width: 40%;
  height: 14px;
  background: linear-gradient(#26282f, #1a1c22);
  border-radius: 0 0 8px 8px;
  z-index: 2;
}
.device-laptop .device-home::after {
  content: "";
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  max-width: 40%;
  height: 4px;
  border-radius: 4px;
  background: #0d0e12;
}

/* desktop chrome */
.device-desktop, .device-custom {
  border-radius: 10px;
  padding: 10px;
  border: 2px solid #26282f;
}
.device-desktop .device-screen, .device-custom .device-screen { border-radius: 3px; }
.device-desktop .device-notch, .device-custom .device-notch { display: none; }
.device-desktop .device-home {
  position: absolute;
  bottom: -34px;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 26px;
  background: #26282f;
  z-index: 2;
}
.device-desktop .device-home::after, .device-custom .device-home::after {
  content: "";
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 90px;
  max-width: 200%;
  height: 8px;
  border-radius: 6px;
  background: #1c1e25;
}
.device-custom .device-home { display: none; }

/* ---------------- gradient controls ---------------- */

.position-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  max-width: 140px;
}
.position-grid button {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
  background: #1e212b;
  cursor: pointer;
}
.position-grid button.active {
  background: var(--accent);
  border-color: var(--accent);
}

.stops-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}
.stop-row {
  display: grid;
  grid-template-columns: 34px 1fr 40px 28px;
  align-items: center;
  gap: 8px;
}
.stop-row input[type="color"] {
  width: 34px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  background: none;
  cursor: pointer;
}
.stop-pos-value {
  font-size: 11.5px;
  color: var(--text-dim);
  text-align: right;
}
.btn-remove-stop {
  background: #1e212b;
  border: 1px solid var(--panel-border);
  color: var(--text-dim);
  border-radius: 6px;
  cursor: pointer;
  height: 28px;
}
.btn-remove-stop:disabled { opacity: .3; cursor: not-allowed; }
.btn-remove-stop:not(:disabled):hover { color: #ff6a6a; border-color: #ff6a6a55; }

.presets-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}
.preset-swatch {
  aspect-ratio: 1;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  cursor: pointer;
  padding: 0;
}
.preset-swatch:hover { outline: 2px solid var(--accent); }

.checkbox-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.checkbox-field label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 13.5px;
}

/* ---------------- export ---------------- */

.css-output-wrap { margin-bottom: 16px; }
#cssOutput {
  resize: none;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12.5px;
  margin-bottom: 8px;
}

/* ---------------- footer ---------------- */

.footer {
  text-align: center;
  padding: 18px;
  font-size: 12px;
  color: var(--text-dim);
  border-top: 1px solid var(--panel-border);
}

.footer a { color: var(--accent-2); }

/* ---------------- ad slots ---------------- */

.ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 24px;
  min-height: 90px;
  border: 1px dashed var(--panel-border);
  border-radius: 10px;
  background: #14161c;
  color: var(--text-dim);
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.ad-slot-banner { margin-top: 18px; }

.ad-slot:empty::before,
.ad-slot .ad-slot-label { opacity: .6; }

/* once a real ad network fills the slot, hide the placeholder label */
.ad-slot.ad-filled .ad-slot-label { display: none; }

/* ---------------- consent banner ---------------- */

.consent-banner {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 50;
  max-width: 640px;
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,.5);
}

.consent-banner p {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-dim);
  flex: 1 1 260px;
}

.consent-banner a { color: var(--accent-2); }

.consent-actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}
