:root{
  --bg: #0b0610;
  --panel: #1a1024;
  --panel2: #140c1f;
  --text: #f6efff;
  --muted: rgba(246,239,255,.65);
  --accent: #b04cff;
  --accent2: #ff64ff;
  --danger: #ff4d7d;
}

html, body{
  margin: 0;
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, "Noto Sans", Arial, sans-serif;
  background: radial-gradient(1200px 800px at 20% 10%, rgba(176,76,255,.25), transparent 60%),
              radial-gradient(900px 600px at 90% 20%, rgba(255,100,255,.18), transparent 55%),
              linear-gradient(180deg, #050008 0%, var(--bg) 100%);
  min-height: 100vh;
}

.wrap{
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 18px 40px 18px;
  box-sizing: border-box;
}

.top{
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.brand{
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.brand .title{ font-size: 18px; font-weight: 900; letter-spacing: .3px; }
.brand .sub{ color: var(--muted); font-size: 12px; font-weight: 650; letter-spacing: .2px; }

.btn{
  appearance: none;
  border: 2px solid rgba(176,76,255,.55);
  background: linear-gradient(180deg, rgba(26,16,36,.96) 0%, rgba(20,12,31,.96) 100%);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 850;
  letter-spacing: .2px;
  cursor: pointer;
  box-shadow: 0 0 14px rgba(176,76,255,.18), inset 0 0 0 1px rgba(255,255,255,.06);
}
.btn:hover{ border-color: rgba(255,100,255,.65); box-shadow: 0 0 18px rgba(176,76,255,.28), 0 0 46px rgba(255,100,255,.12), inset 0 0 0 1px rgba(255,255,255,.08); }
.btn.primary{ border-color: rgba(255,255,255,.85); box-shadow: 0 0 10px rgba(255,255,255,.25), 0 0 22px rgba(176,76,255,.22); }
.btn.danger{ border-color: rgba(255,77,125,.65); box-shadow: 0 0 18px rgba(255,77,125,.16); }
.btn:disabled{ opacity: .5; cursor: not-allowed; }

.grid{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: start;
}
@media (max-width: 980px){ .grid{ grid-template-columns: 1fr; } }

.card{
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(26,16,36,.96) 0%, rgba(20,12,31,.96) 100%);
  border: 2px solid rgba(176,76,255,.55);
  box-shadow: 0 0 18px rgba(176,76,255,.18), inset 0 0 0 1px rgba(255,255,255,.06);
  padding: 14px;
}
.card h3{ margin: 0 0 10px 0; font-size: 13px; text-transform: uppercase; letter-spacing: 2px; }
.hint{ color: var(--muted); font-size: 12px; line-height: 1.35; margin-top: 8px; }

.row{ display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > *{ flex: 0 0 auto; }

.input{
  width: 100%;
  box-sizing: border-box;
  border-radius: 12px;
  border: 2px solid rgba(176,76,255,.35);
  background: rgba(0,0,0,.18);
  color: var(--text);
  padding: 10px 12px;
  outline: none;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.04);
  font-weight: 650;
}

textarea.input{
  min-height: 320px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12.5px;
  line-height: 1.35;
  white-space: pre;
}

.copy{
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

iframe.preview{
  width: 100%;
  height: 520px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  box-shadow: 0 0 18px rgba(176,76,255,.10);
}

.pill{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 2px solid rgba(176,76,255,.35);
  color: var(--muted);
  font-weight: 800;
  font-size: 12px;
  letter-spacing: .2px;
}
.pill img{ width: 18px; height: 18px; border-radius: 999px; }

.toast{
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  padding: 10px 12px;
  border-radius: 12px;
  border: 2px solid rgba(176,76,255,.45);
  background: rgba(10,0,16,.92);
  box-shadow: 0 0 18px rgba(176,76,255,.22);
  color: var(--text);
  font-weight: 850;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
}
.toast.show{ opacity: 1; }

/* ===== Style Builder (sections) ===== */
.style-builder{
  border: 2px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.10);
  border-radius: 16px;
  padding: 12px;
  margin-bottom: 12px;
}
.sb-head{ margin-bottom: 10px; }
.sb-title{ font-weight: 900; letter-spacing: .2px; font-size: 14px; }
.sb-sub{ color: var(--muted); font-weight: 700; font-size: 12px; margin-top: 4px; line-height: 1.35; }

.sb-sections{ display:grid; gap: 10px; }
.sb-sec{
  border: 2px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.08);
  border-radius: 14px;
  padding: 10px;
}
.sb-sec > summary{
  cursor: pointer;
  font-weight: 900;
  list-style: none;
}
.sb-sec > summary::-webkit-details-marker{ display:none; }
.sb-sec > summary::after{
  content: "▾";
  float: right;
  opacity: .7;
}
.sb-sec[open] > summary::after{ content: "▴"; }

.sb-grid2{
  margin-top: 10px;
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
}
@media (max-width: 1200px){ .sb-grid2{ grid-template-columns: 1fr; } }

.sb-field{ display:flex; flex-direction: column; gap: 6px; }
.sb-field > span{ color: var(--muted); font-weight: 800; font-size: 12px; letter-spacing: .2px; }

.sb-range{ display:flex; align-items:center; gap: 10px; }
.sb-range input[type="range"]{ flex: 1 1 auto; }
.sb-out{
  min-width: 44px;
  text-align: right;
  font-weight: 900;
  color: rgba(255,255,255,.85);
}

.sb-color{ display:flex; align-items:center; gap: 10px; }
.sb-color input[type="color"]{ width: 44px; height: 34px; border-radius: 10px; border: 2px solid rgba(255,255,255,.25); background: rgba(0,0,0,.25); padding: 2px; }

.sb-border{ display:flex; align-items:center; gap: 10px; }
.sb-border .sb-num{ width: 74px; }
.sb-border .sb-sel{ width: 120px; }

.sb-toggle{ position: relative; width: 48px; height: 28px; }
.sb-toggle input{
  position:absolute; inset:0;
  opacity:0;
  cursor:pointer;
}
.sb-toggle__pill{
  position:absolute; inset:0;
  border-radius: 999px;
  background: rgba(255,255,255,.14);
  border: 2px solid rgba(255,255,255,.18);
  transition: .12s ease;
}
.sb-toggle__pill::after{
  content:"";
  position:absolute;
  top: 50%;
  left: 4px;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  border-radius: 999px;
  background: rgba(255,255,255,.85);
  transition: .12s ease;
}
.sb-toggle input:checked + .sb-toggle__pill{
  background: rgba(176,76,255,.25);
  border-color: rgba(176,76,255,.35);
}
.sb-toggle input:checked + .sb-toggle__pill::after{
  left: 22px;
  background: rgba(255,255,255,.95);
}

.sb-actions{ display:flex; gap: 10px; margin-top: 10px; }

/* ===== Layout changes (3 columns, 90% width) ===== */
.wrap.wide{ max-width: none; width: min(90vw, 1900px); }
.grid3{ display: grid; grid-template-columns: 1.05fr 1.25fr .9fr; gap: 14px; align-items: start; }
@media (max-width: 1200px){ .grid3{ grid-template-columns: 1fr; } }
.col{ min-height: 0; }
.preview.tall{ height: 600px; }

.row.between{ justify-content: space-between; }
.rows{ display: grid; gap: 10px; margin-top: 12px; }
.rowitem{
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(0,0,0,.14) 0%, rgba(0,0,0,.10) 100%);
  border: 2px solid rgba(176,76,255,.30);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.03);
}
.rowitem:hover{ border-color: rgba(255,100,255,.45); box-shadow: 0 0 18px rgba(176,76,255,.16), inset 0 0 0 1px rgba(255,255,255,.05); }
.cbwrap{ display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 800; font-size: 12px; letter-spacing: .2px; }
.cbwrap input{ width: 18px; height: 18px; }
.rowtext{ width: 100%; }
.iconbtn{
  appearance: none;
  border: 2px solid rgba(255,255,255,.15);
  background: rgba(0,0,0,.18);
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.04);
}
.iconbtn:hover{ border-color: rgba(255,77,125,.55); box-shadow: 0 0 18px rgba(255,77,125,.12), inset 0 0 0 1px rgba(255,255,255,.06); }
.iconbtn svg{ width: 18px; height: 18px; }

.summary{
  cursor: pointer;
  font-weight: 900;
  letter-spacing: .2px;
  list-style: none;
}
details > summary::-webkit-details-marker{ display:none; }

textarea.input.css{ min-height: 520px; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; font-size: 12.5px; }


/* Ace editor container */
.css-editor{
  width: 100%;
  min-height: 520px;
  border-radius: 14px;
  border: 2px solid rgba(255,255,255,.15);
  background: rgba(0,0,0,.18);
  overflow: hidden;
}

.colorpick{
  width: 44px;
  height: 34px;
  border-radius: 10px;
  border: 2px solid rgba(255,255,255,.25);
  background: rgba(0,0,0,.25);
  padding: 2px;
}

.col{
  display: flex;
  flex-direction: column;
}

#cssPane{
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
}

#cssPane > div,
#cssPane > textarea,
#cssPane > .css-editor{
  flex: 1 1 auto;
}

.css-editor{
  flex: 1 1 auto;
  height: 100% !important;
  min-height: 0;
}


/* ===== CSS editor: fill column height (without shrinking) ===== */
.grid3{ align-items: stretch; min-height: calc(100vh - 140px); }
@media (max-width: 1200px){ .grid3{ min-height: 0; } }

.grid3 > .card.col{
  height: 100%;
  display: flex;
  flex-direction: column;
}

#cssPane{
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

#cssPane summary{ flex: 0 0 auto; }
#cssPane .css-tools{ flex: 0 0 auto; }
#cssPane #aceHint{ flex: 0 0 auto; }

#cssPane .css-editor{
  flex: 1 1 auto;
  min-height: 520px;
  height: auto !important;
}

textarea.input.css{
  flex: 1 1 auto;
  min-height: 520px;
}
