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

:root {
  /* ── Glassmorphism palette ─────────────────────────────────────── */
  --base:          #07091a;
  --glass-heavy:   rgba(10, 12, 35, 0.88);
  --glass-mid:     rgba(14, 17, 45, 0.72);
  --glass-light:   rgba(18, 22, 55, 0.55);
  --glass-panel:   rgba(11, 14, 38, 0.82);

  --border:        rgba(100, 130, 255, 0.10);
  --border-hi:     rgba(120, 160, 255, 0.22);
  --border-glow:   rgba(100, 140, 255, 0.35);

  --accent:        #4f8ef7;
  --accent-2:      #7b5ea7;
  --accent-glow:   rgba(79, 142, 247, 0.25);

  --text:          #dde1f5;
  --text-dim:      rgba(180, 195, 255, 0.38);
  --text-mid:      rgba(200, 215, 255, 0.60);
  --text-tab:      rgba(190, 205, 255, 0.50);
  --text-tab-act:  #f0f4ff;

  --error:         #ff6b6b;
  --success:       #4ade80;
  --warn:          #fbbf24;

  --font-ui:       -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono:     "Cascadia Code", "Fira Code", "Consolas", monospace;

  --blur:          blur(24px);
  --blur-sm:       blur(12px);
  --blur-xs:       blur(6px);
  --radius:        8px;
  --radius-sm:     5px;
  --radius-xs:     3px;
}

/* ── Base ──────────────────────────────────────────────────────────── */
html, body {
  height: 100%;
  background: var(--base);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13px;
  overflow: hidden;
}

/* Ambient glow blobs behind everything */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 65% 45% at 18% 28%, rgba(79, 70, 229, 0.18) 0%, transparent 70%),
    radial-gradient(ellipse 55% 38% at 82% 68%, rgba(79, 142, 247, 0.14) 0%, transparent 70%),
    radial-gradient(ellipse 42% 32% at 58% 12%, rgba(123, 94, 167, 0.13) 0%, transparent 65%),
    radial-gradient(ellipse 35% 25% at 5%  90%, rgba(56,  100, 220, 0.09) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ── Layout shell ──────────────────────────────────────────────────── */
#shell {
  display: grid;
  grid-template-rows: 38px 36px 1fr 240px 30px;
  height: 100vh;
  width: 100vw;
  position: relative;
  z-index: 1;
}

/* ── Title bar ─────────────────────────────────────────────────────── */
#titlebar {
  background: var(--glass-heavy);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--border-hi);
  display: flex;
  align-items: center;
  padding: 0 18px;
  gap: 10px;
  user-select: none;
  box-shadow: 0 1px 0 rgba(100,140,255,0.08);
}

#titlebar .logo  { font-size: 18px; line-height: 1; }
#titlebar .title {
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.4px;
  background: linear-gradient(90deg, #c8d8ff 0%, #a0b8ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
#titlebar .badge {
  background: linear-gradient(135deg, rgba(79,142,247,0.35) 0%, rgba(123,94,167,0.35) 100%);
  border: 1px solid var(--border-hi);
  color: rgba(180, 210, 255, 0.9);
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
  backdrop-filter: var(--blur-xs);
}
#titlebar .spacer { flex: 1; }
#titlebar a {
  color: var(--text-mid);
  text-decoration: none;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: all 0.18s;
}
#titlebar a:hover {
  color: var(--text-tab-act);
  background: rgba(100,130,255,0.08);
  border-color: var(--border);
}
#titlebar a svg { width: 15px; height: 15px; fill: currentColor; }

/* ── Tab bar ────────────────────────────────────────────────────────── */
#tabbar {
  background: var(--glass-panel);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  overflow: hidden;
}

.tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
  font-size: 12.5px;
  color: var(--text-tab);
  border-right: 1px solid var(--border);
  cursor: default;
  white-space: nowrap;
  position: relative;
  background: transparent;
  min-width: 120px;
  transition: background 0.15s, color 0.15s;
}
.tab:hover { background: rgba(100,130,255,0.06); color: var(--text-mid); }
.tab.active {
  color: var(--text-tab-act);
  background: rgba(79,142,247,0.08);
  border-top: 1px solid var(--accent);
}
.tab.active::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1px;
  background: var(--glass-panel);
}
.tab-icon { font-size: 13px; opacity: 0.7; }
.tab-name { font-size: 12.5px; }

/* ── Editor area ─────────────────────────────────────────────────────── */
#editor-wrap {
  position: relative;
  overflow: hidden;
  background: #0c0e22;
}
#editor-container {
  position: absolute;
  inset: 0;
}

/* ── Output panel ────────────────────────────────────────────────────── */
#panel {
  display: flex;
  flex-direction: column;
  background: var(--glass-panel);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-top: 1px solid var(--border-hi);
  min-height: 80px;
}

#resize-handle {
  height: 4px;
  background: transparent;
  cursor: row-resize;
  flex-shrink: 0;
  transition: background 0.15s;
}
#resize-handle:hover { background: linear-gradient(90deg, transparent, var(--accent), transparent); }

#panel-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 14px;
  height: 31px;
  background: rgba(8, 10, 28, 0.65);
  backdrop-filter: var(--blur-sm);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.panel-tab {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.9px;
  color: var(--text-dim);
  text-transform: uppercase;
  padding: 0 2px;
  cursor: pointer;
  transition: color 0.15s;
}
.panel-tab:hover { color: var(--text-mid); }
.panel-tab.active {
  color: var(--accent);
  border-bottom: 1px solid var(--accent);
}
#panel-header .spacer { flex: 1; }
#btn-clear-panel {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  font-size: 13px;
  line-height: 1;
  transition: all 0.15s;
}
#btn-clear-panel:hover {
  background: rgba(255,100,100,0.12);
  color: var(--error);
}

#output {
  flex: 1;
  overflow-y: auto;
  padding: 10px 16px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-all;
}
#output .line-info    { color: var(--text-mid); }
#output .line-success { color: var(--success); }
#output .line-error   { color: var(--error); }
#output .line-warn    { color: var(--warn); }
#output .line-rs      { color: #c39b78; }

/* ── Status bar ──────────────────────────────────────────────────────── */
#statusbar {
  background: linear-gradient(90deg,
    rgba(8, 12, 40, 0.96) 0%,
    rgba(15, 22, 65, 0.96) 50%,
    rgba(10, 15, 50, 0.96) 100%);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-top: 1px solid var(--border-hi);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 8px;
  box-shadow: 0 -1px 0 rgba(80, 120, 255, 0.08);
}
.status-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--text-mid);
  padding: 0 5px;
  height: 100%;
  transition: background 0.15s;
}
.status-item:hover { background: rgba(100,130,255,0.06); }
#statusbar .spacer { flex: 1; }

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 13px;
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  font-family: var(--font-ui);
  cursor: pointer;
  background: rgba(100, 130, 255, 0.10);
  border: 1px solid rgba(100, 140, 255, 0.18);
  color: rgba(180, 210, 255, 0.85);
  backdrop-filter: var(--blur-xs);
  transition: all 0.18s;
  letter-spacing: 0.2px;
}
.btn:hover:not(:disabled) {
  background: rgba(100, 140, 255, 0.18);
  border-color: rgba(120, 160, 255, 0.35);
  color: #fff;
  box-shadow: 0 0 10px rgba(79, 142, 247, 0.15);
}
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(135deg,
    rgba(79, 142, 247, 0.28) 0%,
    rgba(123, 94, 167, 0.28) 100%);
  border: 1px solid rgba(130, 170, 255, 0.32);
  color: rgba(200, 220, 255, 0.95);
  font-weight: 600;
}
.btn.primary:hover:not(:disabled) {
  background: linear-gradient(135deg,
    rgba(79, 142, 247, 0.42) 0%,
    rgba(123, 94, 167, 0.42) 100%);
  border-color: rgba(150, 185, 255, 0.50);
  box-shadow: 0 0 16px rgba(79, 142, 247, 0.22), 0 0 6px rgba(123, 94, 167, 0.18);
}

/* ── Loading overlay ─────────────────────────────────────────────────── */
#loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(7, 9, 26, 0.65);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  z-index: 200;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 18px;
}
#loading-overlay.visible { display: flex; }

.loading-card {
  background: rgba(14, 17, 48, 0.85);
  border: 1px solid var(--border-hi);
  border-radius: 16px;
  padding: 32px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  box-shadow:
    0 8px 40px rgba(0,0,0,0.5),
    0 0 60px rgba(79, 142, 247, 0.08),
    inset 0 1px 0 rgba(255,255,255,0.06);
}
.loading-spinner {
  width: 40px; height: 40px;
  border: 2px solid rgba(79, 142, 247, 0.12);
  border-top-color: var(--accent);
  border-right-color: rgba(123, 94, 167, 0.6);
  border-radius: 50%;
  animation: spin 0.9s cubic-bezier(0.68,-0.55,0.27,1.55) infinite;
  box-shadow: 0 0 12px rgba(79, 142, 247, 0.25);
}
.loading-text  { color: var(--text); font-size: 14px; font-weight: 600; }
.loading-sub   { color: var(--text-dim); font-size: 11.5px; text-align: center; max-width: 260px; }

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

/* ── Tab close + add ─────────────────────────────────────────────────── */
.tab-close {
  margin-left: 6px;
  padding: 1px 4px;
  border-radius: var(--radius-xs);
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1;
  cursor: pointer;
  transition: all 0.12s;
}
.tab-close:hover { background: rgba(255,80,80,0.15); color: var(--error); }

.tab-add {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  font-size: 18px;
  color: var(--text-dim);
  cursor: pointer;
  background: none;
  border: none;
  flex-shrink: 0;
  transition: all 0.15s;
}
.tab-add:hover { color: var(--accent); background: rgba(79,142,247,0.08); }

/* ── Examples dropdown ───────────────────────────────────────────────── */
.ex-wrap { position: relative; }
.btn-ex {
  background: rgba(100, 130, 255, 0.08);
  border: 1px solid rgba(100, 140, 255, 0.15);
  color: var(--text-mid);
  font-size: 12px;
  font-family: var(--font-ui);
  padding: 4px 11px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  backdrop-filter: var(--blur-xs);
  transition: all 0.18s;
}
.btn-ex:hover {
  background: rgba(100, 140, 255, 0.16);
  border-color: rgba(120, 160, 255, 0.30);
  color: var(--text-tab-act);
}

.ex-backdrop { position: fixed; inset: 0; z-index: 90; }
.ex-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 100;
  background: rgba(10, 13, 38, 0.92);
  border: 1px solid var(--border-hi);
  border-radius: 12px;
  box-shadow:
    0 16px 48px rgba(0,0,0,0.65),
    0 0 40px rgba(79,142,247,0.08),
    inset 0 1px 0 rgba(255,255,255,0.05);
  min-width: 270px;
  padding: 6px 0;
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}
.ex-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 16px;
  cursor: pointer;
  transition: background 0.12s;
  border-radius: 0;
}
.ex-item:hover { background: rgba(79,142,247,0.08); }
.ex-icon { font-size: 18px; flex-shrink: 0; }
.ex-name { font-size: 12.5px; font-weight: 600; color: var(--text); }
.ex-desc { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

/* ── Build target selector ───────────────────────────────────────────── */
.target-group {
  display: flex;
  gap: 2px;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
}
.target-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  width: 28px;
  height: 22px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.target-btn:hover  { background: rgba(100,130,255,0.12); color: var(--text-mid); }
.target-btn.active {
  background: linear-gradient(135deg, rgba(79,142,247,0.30), rgba(123,94,167,0.25));
  color: #fff;
  box-shadow: 0 0 6px rgba(79, 142, 247, 0.20);
}

/* ── Docs overlay ────────────────────────────────────────────────────── */
#docs-backdrop {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(7, 9, 26, 0.50);
  backdrop-filter: var(--blur-xs);
  -webkit-backdrop-filter: var(--blur-xs);
}
#docs-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(520px, 90vw);
  z-index: 160;
  background: rgba(10, 13, 38, 0.92);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-left: 1px solid var(--border-hi);
  display: flex;
  flex-direction: column;
  box-shadow:
    -16px 0 48px rgba(0,0,0,0.55),
    0 0 80px rgba(79, 142, 247, 0.05);
}
#docs-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  height: 38px;
  background: rgba(8, 10, 30, 0.80);
  border-bottom: 1px solid var(--border-hi);
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.3px;
  background: linear-gradient(90deg, #c8d8ff 0%, #a0b8ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
#docs-head {
  background: rgba(8, 10, 30, 0.80);
  -webkit-text-fill-color: unset;
  color: var(--text);
}
#docs-head span {
  background: linear-gradient(90deg, #c8d8ff 0%, #9db8ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 700;
}
#docs-head button {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 16px;
  padding: 3px 7px;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  -webkit-text-fill-color: var(--text-dim);
}
#docs-head button:hover { background: rgba(255,80,80,0.12); color: var(--error); -webkit-text-fill-color: var(--error); }
#docs-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px 36px;
  font-size: 12.5px;
  line-height: 1.60;
  color: var(--text);
}
#docs-body h3 {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--accent);
  margin: 22px 0 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid rgba(79, 142, 247, 0.18);
}
#docs-body h3:first-child { margin-top: 0; }
#docs-body pre {
  background: rgba(8, 10, 28, 0.75);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  overflow-x: auto;
  white-space: pre;
  color: #c8a07a;
  line-height: 1.55;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}
#docs-body code { color: #81b4f0; }

/* ── Scrollbar ───────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(100, 130, 255, 0.18);
  border-radius: 6px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(100, 140, 255, 0.32); }
