/* ===== Liquid Glass Studio — dark theme ===== */
* { box-sizing: border-box; }
:root {
  --bg: #0d0d0d;
  --bg-2: #141414;
  --bg-3: #1a1a1a;
  --line: #262626;
  --line-2: #333;
  --text: #ededed;
  --text-dim: #8a8a8a;
  --text-faint: #5a5a5a;
  --accent: #7c5cff;
  --accent-2: #4f8bff;
  --danger: #ff5577;
  --ok: #58d68d;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 10px 30px rgba(0,0,0,.45);
  --panel-w: 280px;
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 13px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; color: inherit; }

/* ===== iOS warning ===== */
#ios-warning {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 1000;
  display: flex; align-items: center; gap: 12px;
  padding: 8px 14px;
  background: linear-gradient(90deg, #4a2900, #5a1a1a);
  border-bottom: 1px solid #6a3a00;
  font-size: 12.5px;
}
#ios-warning button {
  margin-left: auto;
  background: transparent; border: 0;
  font-size: 18px; line-height: 1;
  padding: 4px 8px; border-radius: 4px;
}
#ios-warning button:hover { background: rgba(255,255,255,.1); }

/* ===== Topbar ===== */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  height: 52px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff, #7c5cff 60%, #2a1466 100%);
  box-shadow: 0 0 12px rgba(124,92,255,.5), inset -2px -3px 6px rgba(0,0,0,.4);
}
.brand-name { font-weight: 600; letter-spacing: .2px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

/* ===== Buttons ===== */
.btn {
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  transition: background .15s, border-color .15s, transform .05s;
  font-size: 12.5px;
}
.btn:hover { background: #232323; border-color: var(--line-2); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--bg-3); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover { background: #6a4cff; }
.btn.full { width: 100%; }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn.danger { color: var(--danger); border-color: #3a1a22; }
.btn.danger:hover { background: #2a1014; }

/* ===== Dropdown ===== */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 180px;
  padding: 6px;
  display: none;
  z-index: 50;
}
.dropdown-menu.open { display: block; }
.dropdown-menu button {
  width: 100%; text-align: left;
  background: transparent; border: 0;
  padding: 7px 10px; border-radius: 5px;
  font-size: 12.5px;
}
.dropdown-menu button:hover { background: var(--bg-3); }
.dropdown-menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

/* ===== Layout ===== */
.layout {
  display: grid;
  grid-template-columns: var(--panel-w) 1fr var(--panel-w);
  height: calc(100vh - 52px - 78px); /* topbar + presets bar */
}
.panel {
  background: var(--bg);
  overflow-y: auto;
  scrollbar-width: thin;
}
.panel-left { border-right: 1px solid var(--line); }
.panel-right { border-left: 1px solid var(--line); }
.panel-section { padding: 16px 16px 8px; border-bottom: 1px solid var(--line); }
.panel-section h3 {
  margin: 0 0 12px 0;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-dim);
}
.panel-section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.panel-section-head h3 { margin: 0; }

.section-title {
  margin: 12px 0 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-faint);
  font-weight: 600;
}

/* ===== Background tabs ===== */
.bg-tabs {
  display: flex; gap: 4px;
  background: var(--bg-2);
  padding: 3px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}
.bg-tab {
  flex: 1;
  padding: 6px 8px;
  background: transparent;
  border: 0;
  color: var(--text-dim);
  border-radius: 4px;
  font-size: 12px;
}
.bg-tab.active { background: var(--bg-3); color: var(--text); }
.bg-pane.hidden { display: none; }

.dropzone {
  border: 1.5px dashed var(--line-2);
  border-radius: var(--radius);
  padding: 28px 14px;
  text-align: center;
  cursor: pointer;
  background: var(--bg-2);
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.drag {
  border-color: var(--accent);
  background: rgba(124,92,255,.06);
}
.dz-icon { font-size: 26px; margin-bottom: 6px; opacity: .7; }
.dz-title { font-weight: 500; margin-bottom: 3px; }
.dz-sub { color: var(--text-dim); font-size: 11.5px; }

/* ===== Rows ===== */
.row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0;
  font-size: 12.5px;
}
.row > span { color: var(--text-dim); font-size: 12px; }
.row select {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  font-size: 12px;
}
.row input[type="color"] {
  width: 36px; height: 26px;
  background: transparent; border: 1px solid var(--line);
  border-radius: 5px; padding: 0; cursor: pointer;
}
.row input[type="range"] { flex: 1; max-width: 60%; }

/* ===== Sliders ===== */
.slider-row {
  display: flex; flex-direction: column; gap: 6px;
  padding: 8px 0;
}
.slider-row label {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--text-dim);
}
.slider-row label .val { color: var(--text); font-variant-numeric: tabular-nums; }
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  background: var(--line);
  height: 3px;
  border-radius: 2px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px; height: 14px;
  background: #fff;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 0 1px rgba(255,255,255,.1);
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px;
  background: #fff;
  border-radius: 50%;
  cursor: pointer;
  border: 0;
}

/* ===== Switch ===== */
.switch {
  display: inline-flex; align-items: center; gap: 8px;
  cursor: pointer;
  font-size: 12.5px;
}
.switch input { display: none; }
.slider-track {
  width: 32px; height: 18px;
  background: var(--line);
  border-radius: 99px;
  position: relative;
  transition: background .15s;
}
.slider-track::after {
  content: "";
  position: absolute;
  width: 14px; height: 14px;
  background: #fff;
  border-radius: 50%;
  top: 2px; left: 2px;
  transition: transform .15s;
}
.switch input:checked + .slider-track { background: var(--accent); }
.switch input:checked + .slider-track::after { transform: translateX(14px); }

/* ===== Anim row ===== */
.anim-row { display: flex; align-items: center; gap: 8px; padding-top: 12px; flex-wrap: wrap; }
.anim-row .switch { margin-right: auto; }

/* ===== Gradient grid ===== */
.gradient-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
}
.gradient-swatch {
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform .15s, border-color .15s;
}
.gradient-swatch:hover { transform: scale(1.04); border-color: var(--accent); }
.gradient-builder { display: flex; flex-direction: column; gap: 4px; }
.gradient-builder .btn { margin-top: 8px; }

/* ===== Stage ===== */
.stage-wrap {
  display: flex; flex-direction: column;
  background: #050505;
  position: relative;
  overflow: hidden;
}
.stage-toolbar {
  height: 38px;
  display: flex; align-items: center; gap: 12px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.stage-hint { color: var(--text-faint); font-size: 11.5px; }

.stage {
  flex: 1;
  position: relative;
  overflow: hidden;
  user-select: none;
}
.stage-bg {
  position: absolute; inset: 0;
  background: #1a1d2e;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
.stage-layers {
  position: absolute; inset: 0;
}

/* Glass layer */
.glass-layer {
  position: absolute;
  border: 1px solid rgba(255,255,255,0.18);
  cursor: grab;
  touch-action: none;
  will-change: transform, backdrop-filter;
}
.glass-layer.selected { outline: 2px dashed rgba(124,92,255,.8); outline-offset: 4px; }
.glass-layer:active { cursor: grabbing; }

.resize-handle {
  position: absolute;
  width: 14px; height: 14px;
  right: -7px; bottom: -7px;
  background: var(--accent);
  border: 2px solid #fff;
  border-radius: 50%;
  cursor: nwse-resize;
  display: none;
  box-shadow: 0 0 0 1px rgba(0,0,0,.3);
}
.glass-layer.selected .resize-handle { display: block; }

/* ===== Layer list ===== */
.layer-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 4px;
  max-height: 200px; overflow-y: auto;
}
.layer-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 9px;
  background: var(--bg-2);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12.5px;
}
.layer-item:hover { background: var(--bg-3); }
.layer-item.selected { border-color: var(--accent); background: rgba(124,92,255,.08); }
.layer-item .layer-shape-icon {
  width: 14px; height: 14px;
  background: linear-gradient(135deg, rgba(255,255,255,.45), rgba(124,92,255,.55));
  border-radius: 4px;
  flex-shrink: 0;
}
.layer-item .layer-name { flex: 1; }
.layer-item .layer-actions { display: flex; gap: 2px; }
.layer-item .icon-btn {
  background: transparent; border: 0;
  padding: 2px 5px; border-radius: 3px;
  color: var(--text-dim);
  font-size: 11px;
}
.layer-item .icon-btn:hover { color: var(--text); background: rgba(255,255,255,.06); }

/* ===== Presets bar ===== */
.presets-bar {
  height: 78px;
  border-top: 1px solid var(--line);
  background: var(--bg);
  display: flex; align-items: center; gap: 8px;
  padding: 0 14px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.presets-row { display: flex; gap: 6px; flex-shrink: 0; }
.presets-divider {
  width: 1px;
  height: 32px;
  background: var(--line);
  flex-shrink: 0;
}
.preset-btn {
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 7px 12px;
  border-radius: 99px;
  font-size: 12px;
  white-space: nowrap;
  display: flex; align-items: center; gap: 6px;
}
.preset-btn:hover { background: var(--bg-3); border-color: var(--line-2); }
.preset-btn .preset-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.2);
}
.preset-btn.custom { padding-right: 6px; }
.preset-btn .x {
  background: transparent; border: 0;
  width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: var(--text-dim);
  margin-left: 2px;
}
.preset-btn .x:hover { background: rgba(255,255,255,.08); color: var(--danger); }

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 12.5px;
  box-shadow: var(--shadow);
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 999;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

/* ===== Scrollbars ===== */
.panel::-webkit-scrollbar, .presets-bar::-webkit-scrollbar, .layer-list::-webkit-scrollbar { width: 6px; height: 6px; }
.panel::-webkit-scrollbar-thumb, .presets-bar::-webkit-scrollbar-thumb, .layer-list::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border-radius: 99px;
}

/* ===== Mobile ===== */
@media (max-width: 900px) {
  :root { --panel-w: 100%; }
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 50vh auto;
    height: auto;
    min-height: calc(100vh - 52px - 78px);
  }
  .panel-left, .panel-right {
    border: 0;
    border-bottom: 1px solid var(--line);
    max-height: 240px;
  }
  .stage-wrap { min-height: 50vh; }
  .topbar-actions .btn:not(.primary) { display: none; }
  .topbar-actions #btn-share { display: inline-flex; }
  .presets-bar { height: 64px; }
}
