:root{
  --bg:#0b1020;
  --panel:#0f1733;
  --panel2:#121c3d;
  --text:#e9ecf4;
  --muted:#a7b0c5;
  --line:rgba(255,255,255,.10);
  --brand:#7c5cff;
  --brand2:#21d4fd;
  --good:#20e3b2;
  --shadow: 0 18px 50px rgba(0,0,0,.35);
  --radius:18px;
  --radius2:24px;
  --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Noto Sans Thai", Arial, sans-serif;
}

*{box-sizing:border-box}
body{
  margin:0;
  font-family:var(--font);
  background: radial-gradient(1200px 800px at 10% 10%, rgba(124,92,255,.25), transparent 60%),
              radial-gradient(1000px 700px at 90% 20%, rgba(33,212,253,.18), transparent 60%),
              var(--bg);
  color:var(--text);
}

.topbar{
  position:sticky; top:0; z-index:10;
  display:flex; align-items:center; justify-content:space-between;
  padding:14px 18px;
  border-bottom:1px solid var(--line);
  background: rgba(11,16,32,.7);
  backdrop-filter: blur(10px);
}

.brand{display:flex; gap:12px; align-items:center}
.logo{
  width:44px; height:44px; border-radius:14px;
  display:grid; place-items:center;
  background: linear-gradient(135deg, var(--brand), var(--brand2));
  box-shadow: var(--shadow);
  font-weight:900;
}
.title{font-weight:800; letter-spacing:.2px}
.subtitle{font-size:12px; color:var(--muted); margin-top:2px}

.actions{display:flex; gap:10px; align-items:center}
.btn{
  border:1px solid rgba(255,255,255,.14);
  background: linear-gradient(135deg, rgba(124,92,255,.25), rgba(33,212,253,.15));
  color:var(--text);
  padding:10px 14px;
  border-radius:14px;
  cursor:pointer;
  font-weight:700;
  transition:.15s transform ease, .15s opacity ease;
}
.btn:hover{transform: translateY(-1px)}
.btn:active{transform: translateY(0px); opacity:.9}
.btn.ghost{
  background: transparent;
}

/* NEW: theme dropdown */
.select{
  border:1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.04);
  color: var(--text);
  padding:10px 12px;
  border-radius:14px;
  font-weight:800;
}

.layout{
  display:grid;
  grid-template-columns: 340px 1fr 360px;
  gap:14px;
  padding:14px;
}

.panel{
  background: linear-gradient(180deg, rgba(18,28,61,.85), rgba(15,23,51,.85));
  border:1px solid var(--line);
  border-radius: var(--radius2);
  box-shadow: var(--shadow);
  min-height: calc(100vh - 130px);
  overflow:hidden;
}

.panel.left, .panel.right{padding:14px}
.panel.center{display:flex; flex-direction:column}

h2{margin:6px 0 8px; font-size:16px}
.hint{margin:0 0 12px; color:var(--muted); font-size:12px; line-height:1.4}
.divider{height:1px; background:var(--line); margin:14px 0}

.library, .outline{
  display:flex; flex-direction:column; gap:10px;
}

.card{
  border:1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.04);
  border-radius: 16px;
  padding:12px;
  cursor:grab;
  display:flex; align-items:center; justify-content:space-between;
  gap:10px;
}
.card:active{cursor:grabbing}
.card .name{font-weight:800}
.card .tag{
  font-size:11px; color:var(--muted);
  border:1px solid rgba(255,255,255,.12);
  padding:3px 8px; border-radius:999px;
}
.card.small{padding:10px}
.card.small.selected{
  outline:2px solid rgba(124,92,255,.6);
  background: rgba(124,92,255,.08);
}
.rowActions{display:flex; gap:8px}
.iconBtn{
  border:1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.04);
  color:var(--text);
  width:34px; height:34px; border-radius:12px;
  display:grid; place-items:center;
  cursor:pointer;
}
.iconBtn:hover{background: rgba(255,255,255,.07)}

.previewHeader{
  display:flex; align-items:center; justify-content:space-between;
  padding:12px 12px 0 12px;
}
.previewTitle{font-weight:900}
.device{display:flex; gap:8px}
.chip{
  border:1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.04);
  color:var(--text);
  padding:8px 10px;
  border-radius: 999px;
  cursor:pointer;
  font-weight:800;
  font-size:12px;
}
.chip.active{
  background: rgba(124,92,255,.18);
  border-color: rgba(124,92,255,.45);
}

.previewWrap{
  padding:12px;
  height:100%;
}
iframe{
  width:100%;
  height:100%;
  border:1px solid rgba(255,255,255,.10);
  border-radius: 18px;
  background:white;
}

.props .field{
  display:flex; flex-direction:column; gap:6px;
  margin-bottom:10px;
}
label{font-size:12px; color:var(--muted); font-weight:700}
input, textarea{
  width:100%;
  border:1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.04);
  color:var(--text);
  padding:10px 12px;
  border-radius: 14px;
  outline:none;
}
textarea{min-height:88px; resize:vertical}
.smallRow{
  display:grid; grid-template-columns: 1fr 1fr;
  gap:10px;
}

.listBox{
  border:1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.03);
  border-radius: 16px;
  padding:10px;
}
.listItem{
  display:flex; gap:8px; align-items:center;
  padding:8px; border-radius:12px;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.03);
  margin-bottom:8px;
}
.listItem input{flex:1}
.listItem .del{
  width:38px; height:38px; border-radius:12px;
  border:1px solid rgba(255,255,255,.12);
  background: rgba(255,60,60,.10);
  cursor:pointer; color:var(--text);
}

.addBtn{
  width:100%;
  margin-top:8px;
  border:1px dashed rgba(255,255,255,.18);
  background: rgba(255,255,255,.03);
  color:var(--text);
  padding:10px 12px;
  border-radius: 14px;
  cursor:pointer;
  font-weight:900;
}
.addBtn:hover{background: rgba(255,255,255,.06)}

.emptyState{
  border:1px dashed rgba(255,255,255,.18);
  background: rgba(255,255,255,.03);
  border-radius: 18px;
  padding:18px;
  text-align:center;
  color:var(--muted);
}
.emptyState .emoji{font-size:34px; margin-bottom:8px}
.emptyState .small{font-size:12px; margin-top:4px}

.footer{
  padding:10px 14px;
  color:var(--muted);
  text-align:center;
  border-top:1px solid var(--line);
  background: rgba(11,16,32,.55);
}

@media (max-width: 1100px){
  .layout{grid-template-columns: 1fr; }
  .panel{min-height:auto}
  iframe{height:70vh}
}
