:root {
  --bg: #0d1a2e; --text: #fff; --accent: #00b0ff;
  --panel: rgba(255,255,255,0.03); --border: rgba(255,255,255,0.08);
}
html.theme-balance    { --bg:#001220; --text:#e0f2f1; --accent:#00dffd; --border:rgba(0,176,255,0.14); }
html.theme-celestial  { --bg:#f0f2f8; --text:#111;   --accent:#3060b0; --border:rgba(48,96,176,0.16); }
html.theme-baroque    { --bg:#0a0800; --text:#f7ede2; --accent:#d4a050; --border:rgba(212,160,80,0.18); }
html.theme-umbral     { --bg:#080008; --text:#ffebee; --accent:#e91e63; --border:rgba(233,30,99,0.18); }
html.theme-samurai    { --bg:#1c0d0d; --text:#f5e6e6; --accent:#ff3b30; --border:rgba(255,59,48,0.2); }

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

html, body {
  height: 100%;
  overflow: hidden;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background 0.08s ease, color 0.08s ease;
}

.demo-header {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 26px 24px;
  background: rgba(0,0,0,0.30);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 100;
  transition: border-color 0.08s ease;
}
html.theme-celestial .demo-header { background: rgba(240,242,248,0.90); }
.brand-name { font-size: 1.05rem; font-weight: 800; letter-spacing: -0.03em; }
.brand-dot  { color: var(--accent); }
.header-logo { position: absolute; top: 50%; right: 24px; transform: translateY(-50%); height: 137px; z-index: 1000; display: block; object-fit: contain; }

/* ====== MAIN ====== */
.demo-main {
  flex: 1;
  min-height: 0;
  padding: 16px 20px;
  overflow: hidden;
}
.demo-grid {
  display: grid;
  grid-template-columns: 260px 290px 1fr;
  grid-template-rows: 1fr;
  gap: 18px;
  height: 100%;
  align-items: stretch;
}

/* ====== SIDEBAR ====== */
.sidebar {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  transition: border-color 0.08s ease;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.sidebar h2 { font-size: 1.1rem; font-weight: 800; color: var(--accent); transition: color 0.08s ease; flex-shrink: 0; }
.sidebar > p { font-size: 0.82rem; opacity: 0.55; line-height: 1.5; flex-shrink: 0; }

.element-group { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.element-group > label { font-size: 0.72rem; font-weight: 600; opacity: 0.5; letter-spacing: 0.02em; }

.test-element {
  width: 100%; padding: 8px 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 10px; color: inherit;
  font-family: inherit; font-size: 0.86rem;
  outline: none; transition: all 0.08s ease;
}
html.theme-celestial .test-element { background: rgba(0,0,0,0.04); }
.test-element:focus { border-color: var(--accent); background: rgba(255,255,255,0.08); }
html.theme-celestial .test-element:focus { background: rgba(0,0,0,0.07); }
button.test-element {
  background: transparent; border: 1.5px solid var(--accent);
  color: var(--accent); font-weight: 700; cursor: pointer;
}
button.test-element:hover { background: var(--accent); color: var(--bg); }
.checkbox-container { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 0.86rem; }
.checkbox-container input { width: 16px; height: 16px; cursor: pointer; }
.radio-group { display: flex; gap: 12px; flex-wrap: wrap; }
.radio-group label { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 0.86rem; }
.radio-group input { width: 14px; height: 14px; cursor: pointer; }
textarea.test-element { min-height: 65px; resize: vertical; }

.admin-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  transition: border-color 0.08s ease;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.admin-title {
  display: flex; align-items: center; gap: 9px;
  font-size: 0.78rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  opacity: 0.55; flex-shrink: 0;
}
.admin-icon { font-size: 1rem; }
.admin-group { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.admin-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.74rem; font-weight: 600; opacity: 0.65;
}
.admin-hint-inline { font-size: 0.66rem; opacity: 0.5; font-weight: 400; }
.pro-badge {
  background: rgba(255,180,0,0.18); color: rgba(255,200,0,0.9);
  font-size: 8px; font-weight: 800; padding: 2px 5px;
  border-radius: 4px; letter-spacing: 0.1em;
}
.admin-hint { font-size: 0.72rem; opacity: 0.4; line-height: 1.4; }
.admin-hint code {
  background: rgba(255,255,255,0.08); padding: 1px 5px;
  border-radius: 4px; font-family: monospace; font-size: 0.68rem;
}
html.theme-celestial .admin-hint code { background: rgba(0,0,0,0.07); }

.admin-select {
  width: 100%; padding: 7px 12px;
  background: rgba(255,255,255,0.06); border: 1px solid var(--border);
  border-radius: 10px; color: inherit; font-family: inherit;
  font-size: 0.86rem; font-weight: 600; outline: none; cursor: pointer;
  transition: border-color 0.08s;
}
.admin-select option {
  background: #0f172a;
  color: #f8fafc;
}
html.theme-celestial .admin-select { background: rgba(0,0,0,0.05); }
html.theme-celestial .admin-select option {
  background: #ffffff;
  color: #0f172a;
}
.admin-select:focus { border-color: var(--accent); }

.color-row { display: flex; align-items: center; gap: 10px; }
.admin-color-input { width: 34px; height: 34px; border: none; border-radius: 8px; cursor: pointer; background: none; padding: 2px; }
.color-display { font-family: monospace; font-size: 0.78rem; opacity: 0.6; }

.admin-range {
  width: 100%; height: 3px; -webkit-appearance: none; appearance: none;
  background: rgba(255,255,255,0.14); outline: none; border-radius: 3px; cursor: pointer;
}
html.theme-celestial .admin-range { background: rgba(0,0,0,0.1); }
.admin-range::-webkit-slider-thumb {
  -webkit-appearance: none; width: 13px; height: 13px;
  border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 8px var(--accent); cursor: pointer;
  transition: transform 0.08s;
}
.admin-range::-webkit-slider-thumb:hover { transform: scale(1.25); }
.range-labels {
  display: flex; justify-content: space-between;
  font-size: 0.66rem; opacity: 0.32; margin-top: 2px;
}
.speed-display {
  margin-left: auto; font-size: 0.74rem; font-weight: 700;
  color: var(--accent); font-family: monospace;
}

/* Admin vol row */
.admin-vol-row { display: flex; align-items: center; gap: 8px; }
.admin-vol-row .admin-range { flex: 1; }
.admin-vol-btn {
  background: rgba(255,255,255,0.08); border: 1px solid var(--border);
  border-radius: 7px; color: var(--text);
  font-size: 15px; font-weight: bold; cursor: pointer;
  padding: 2px 9px; flex-shrink: 0;
  transition: background 0.08s, transform 0.08s;
}
.admin-vol-btn:hover { background: rgba(255,255,255,0.18); transform: scale(1.1); }
html.theme-celestial .admin-vol-btn { background: rgba(0,0,0,0.06); }

/* Loop row */
.admin-loop-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.loop-bracket {
  display: flex; align-items: center; gap: 4px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 8px; padding: 4px 8px;
}
html.theme-celestial .loop-bracket { background: rgba(0,0,0,0.04); }
.loop-bracket-label { font-size: 0.64rem; opacity: 0.45; font-weight: 600; text-transform: uppercase; }
.admin-time-input {
  width: 48px; background: none; border: none;
  color: var(--accent); font-family: monospace;
  font-size: 0.88rem; font-weight: 700; outline: none;
  text-align: center; -moz-appearance: textfield;
}
.admin-time-input::-webkit-outer-spin-button,
.admin-time-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.loop-unit { font-size: 0.68rem; opacity: 0.45; }
.loop-sep { font-size: 1rem; opacity: 0.4; }
.admin-loop-btn {
  background: rgba(255,255,255,0.06); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 0.75rem;
  font-weight: 700; cursor: pointer; padding: 5px 10px;
  transition: background 0.08s, border-color 0.08s, color 0.08s;
  white-space: nowrap;
}
.admin-loop-btn:hover { background: rgba(255,255,255,0.14); }
.admin-loop-btn.loop-active {
  background: var(--accent); border-color: var(--accent); color: #000;
}

.admin-divider { border: none; border-top: 1px solid var(--border); margin: 1px 0; flex-shrink: 0; }
.admin-code-block { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.code-label { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.4; }
.admin-code-block pre {
  background: rgba(0,0,0,0.35); border: 1px solid rgba(255,255,255,0.07);
  border-radius: 10px; padding: 9px 12px; overflow-x: auto;
}
html.theme-celestial .admin-code-block pre { background: rgba(0,0,0,0.06); }
.admin-code-block code { font-family: monospace; font-size: 0.71rem; line-height: 1.6; color: var(--accent); opacity: 0.85; }

/* ====== PREVIEW PANEL ====== */
.preview-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow: hidden;
  transition: border-color 0.08s ease;
}
.preview-desc { font-size: 0.78rem; opacity: 0.55; line-height: 1.4; flex-shrink: 0; }
.zoom-hint {
  display: inline-block;
  background: rgba(255,255,255,0.07); border: 1px solid var(--border);
  border-radius: 6px; padding: 1px 7px;
  font-size: 0.70rem; opacity: 0.85;
}
html.theme-celestial .zoom-hint { background: rgba(0,0,0,0.05); }
kbd {
  background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.25);
  border-radius: 4px; padding: 0 4px; font-family: monospace; font-size: 0.66rem;
}
html.theme-celestial kbd { background: rgba(0,0,0,0.08); border-color: rgba(0,0,0,0.2); }

.preview-box {
  display: flex; flex-direction: column; gap: 8px;
  background: rgba(255,255,255,0.02); border: 1px solid var(--border);
  border-radius: 14px; padding: 14px;
}
html.theme-celestial .preview-box { background: rgba(0,0,0,0.02); }

.large-preview {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.small-preview { flex-shrink: 0; }

.preview-label { font-size: 0.72rem; font-weight: 700; opacity: 0.50; flex-shrink: 0; }

.player-preview-wrapper {
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  width: 100%;
}
.player-preview-wrapper.large {
  height: 100%;
  min-height: 0;
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}
.player-preview-wrapper.large .ns-player {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
}
.player-preview-wrapper.large .ns-wrap {
  width: 90% !important;
  height: auto !important;
  aspect-ratio: 1 / 1;
  max-width: 480px;
  max-height: 480px;
  margin: auto;
}
.player-preview-wrapper.small .ns-wrap {
  width: 90px !important;
  height: 90px !important;
}

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

#server-ping-btn {
  font-size:10px; padding:3px 8px;
  background:rgba(0,223,253,0.12); border:1px solid rgba(0,223,253,0.3); color:#00dffd;
  border-radius:4px; cursor:pointer; outline:none; transition: all 0.08s ease;
}
html.theme-celestial #server-ping-btn {
  background:rgba(48,96,176,0.1); border:1px solid rgba(48,96,176,0.25); color:var(--accent);
}

.tooltip {
  position: relative;
  display: inline-block;
}
.tooltip .tooltiptext {
  visibility: hidden;
  width: 140px;
  background-color: rgba(0, 0, 0, 0.85);
  color: #fff;
  text-align: center;
  border-radius: 6px;
  padding: 6px;
  position: absolute;
  z-index: 10;
  bottom: 125%;
  left: 50%;
  margin-left: -70px;
  opacity: 0;
  transition: opacity 0.3s;
  font-size: 0.75rem;
  border: 1px solid var(--border);
  backdrop-filter: blur(8px);
  pointer-events: none;
}
.tooltip:hover .tooltiptext {
  visibility: visible;
  opacity: 1;
}

/* Writable theme select dropdown styling */
.custom-dropdown-list {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.custom-dropdown-list::-webkit-scrollbar {
  width: 4px;
}
.custom-dropdown-list::-webkit-scrollbar-track {
  background: transparent;
}
.custom-dropdown-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
.dropdown-group-label {
  padding: 8px 12px 4px 12px;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.8;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  margin-top: 4px;
}
.dropdown-item {
  padding: 8px 14px;
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text);
  opacity: 0.85;
  transition: background 0.08s, color 0.08s, opacity 0.08s;
}
.dropdown-item:hover, .dropdown-item.selected {
  background: var(--accent);
  color: #000;
  opacity: 1;
}

/* Side navigation buttons styling */
.theme-nav-prev:hover, .theme-nav-next:hover {
  transform: scale(1.2);
}
