/* =========================================================
   Dreamy Mockups — mobile-first glassmorphic dark theme
   ========================================================= */

:root{
  --bg-base: #08090d;
  --bg-raised: #0f1017;
  --bg-raised-2: #14151f;
  --border-soft: rgba(255,255,255,0.08);
  --border-softer: rgba(255,255,255,0.05);
  --text-primary: #f2f1f7;
  --text-secondary: #a8a6b8;
  --text-muted: #6b6980;
  --accent-primary: #8b5cf6;
  --accent-glow: #06b6d4;
  --danger: #f36a6a;
  --success: #4ade80;
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --shadow-soft: 0 8px 30px rgba(0,0,0,0.45);
  font-size: 16px;
}

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

html, body{
  margin: 0;
  min-height: 100%;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body{
  background-image:
    radial-gradient(circle at 15% -10%, rgba(139,92,246,0.16), transparent 45%),
    radial-gradient(circle at 90% 10%, rgba(6,182,212,0.12), transparent 40%);
  background-attachment: fixed;
}

a{ color: inherit; }
img{ max-width: 100%; display: block; }
button{ font-family: inherit; }
input, select, textarea{ font-family: inherit; }

/* ---------- Glass primitive ---------- */
.glass{
  background: rgba(20, 21, 31, 0.62);
  border: 1px solid var(--border-soft);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
}

/* ---------- Notices / banners ---------- */
.notice{
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  line-height: 1.4;
  margin: 0 0 14px;
  border: 1px solid var(--border-soft);
}
.notice--info{ background: rgba(139,92,246,0.12); border-color: rgba(139,92,246,0.35); }
.notice--error{ background: rgba(243,106,106,0.12); border-color: rgba(243,106,106,0.4); color: #ffb4b4; }
.notice--success{ background: rgba(74,222,128,0.1); border-color: rgba(74,222,128,0.35); color: #b9f5cd; }
.notice--banner{ background: rgba(6,182,212,0.1); border-color: rgba(6,182,212,0.35); }

.banner{
  background: linear-gradient(90deg, rgba(139,92,246,0.25), rgba(6,182,212,0.2));
  color: var(--text-primary);
  text-align: center;
  font-size: 0.85rem;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border-soft);
}

/* =========================================================
   Auth screens
   ========================================================= */
.auth-body{
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px 18px;
  position: relative;
  overflow: hidden;
}

.auth-glow{
  position: absolute;
  width: 60vw;
  height: 60vw;
  max-width: 480px;
  max-height: 480px;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.35;
  pointer-events: none;
  z-index: 0;
}
.auth-glow--violet{ background: var(--accent-primary); top: -10%; left: -20%; }
.auth-glow--cyan{ background: var(--accent-glow); bottom: -15%; right: -15%; }

.auth-card{
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 400px;
  padding: 32px 26px;
}

.auth-brand{ display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.auth-brand__mark{ font-size: 1.4rem; color: var(--accent-primary); text-shadow: 0 0 18px var(--accent-primary); }
.auth-brand__name{ font-size: 1.3rem; font-weight: 600; letter-spacing: -0.01em; }
.auth-tagline{ color: var(--text-secondary); font-size: 0.9rem; margin: 0 0 22px; }
.auth-form{ display: flex; flex-direction: column; gap: 14px; }
.auth-footnote{ color: var(--text-muted); font-size: 0.78rem; text-align: center; margin: 20px 0 0; }

/* =========================================================
   Fields & buttons
   ========================================================= */
.field{ display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; flex: 1; }
.field--sm{ min-width: 130px; }
.field__label{ font-size: 0.78rem; color: var(--text-secondary); font-weight: 500; }
.field-row{ display: flex; gap: 12px; }
.field-row--wrap{ flex-wrap: wrap; }

input[type="text"], input[type="email"], input[type="password"], input[type="url"], input[type="number"], textarea, select{
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-soft);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color .15s ease, background .15s ease;
  width: 100%;
}
input:focus, textarea:focus, select:focus{
  border-color: var(--accent-primary);
  background: rgba(139,92,246,0.06);
}
input[type="color"]{
  width: 100%; height: 44px; padding: 4px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft); background: rgba(255,255,255,0.04);
}
textarea{ resize: vertical; }

.btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform .1s ease, filter .15s ease, background .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active{ transform: scale(0.97); }
.btn--block{ width: 100%; }
.btn--grow{ flex: 1; }
.btn--small{ padding: 9px 14px; font-size: 0.85rem; }
.btn--primary{
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-glow));
  color: #08090d;
  box-shadow: 0 6px 24px rgba(139,92,246,0.35);
}
.btn--primary:hover{ filter: brightness(1.08); }
.btn--secondary{
  background: rgba(139,92,246,0.14);
  border-color: rgba(139,92,246,0.35);
  color: var(--text-primary);
}
.btn--ghost{
  background: rgba(255,255,255,0.05);
  border-color: var(--border-soft);
  color: var(--text-primary);
}
.btn--danger{
  background: rgba(243,106,106,0.12);
  border-color: rgba(243,106,106,0.35);
  color: #ffb4b4;
}
.upload-btn{ cursor: pointer; margin-top: 4px; }

/* =========================================================
   Studio header / nav
   ========================================================= */
.studio-header{
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: rgba(8,9,13,0.75);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-softer);
}
.studio-header__brand{ display: flex; align-items: center; gap: 8px; }
.brand-mark{ color: var(--accent-primary); text-shadow: 0 0 14px var(--accent-primary); }
.brand-name{ font-weight: 600; font-size: 1.05rem; }
.studio-header__nav{ display: flex; gap: 8px; }
.icon-btn{
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border-soft);
  text-decoration: none;
  font-size: 1rem;
}

/* =========================================================
   Canvas stage
   ========================================================= */
.studio-main{
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - 62px);
}

.canvas-stage{
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
  position: relative;
  min-height: 45vh;
}
.canvas-stage__inner{
  position: relative;
  max-width: 100%;
  max-height: 52vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
#previewCanvas{
  max-width: 100%;
  max-height: 52vh;
  width: auto;
  height: auto;
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.55);
  touch-action: pinch-zoom;
}
.canvas-empty{
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 20px;
  pointer-events: none;
}
.canvas-stage__zoom{
  position: absolute;
  bottom: 10px;
  right: 16px;
}
.chip{
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border-soft);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.78rem;
}

/* =========================================================
   Bottom drawer
   ========================================================= */
.drawer{
  border-radius: 24px 24px 0 0;
  padding: 10px 16px 16px;
  position: relative;
}
.drawer__handle{
  width: 40px; height: 4px;
  background: var(--border-soft);
  border-radius: 999px;
  margin: 4px auto 12px;
}
.drawer__tabs{
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  background: rgba(255,255,255,0.04);
  border-radius: var(--radius-sm);
  padding: 4px;
}
.admin-tabs{ margin: 0 0 20px; }
.tab-btn{
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 10px 8px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.tab-btn.is-active{
  background: linear-gradient(135deg, rgba(139,92,246,0.9), rgba(6,182,212,0.85));
  color: #08090d;
}
.drawer__panel.is-hidden, .admin-panel.is-hidden{ display: none; }

.template-carousel{
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 4px 2px 14px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}
.template-thumb{
  scroll-snap-align: start;
  flex: 0 0 auto;
  width: 78px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.template-thumb img{ width: 46px; height: 46px; object-fit: contain; }
.template-thumb span{ font-size: 0.68rem; color: var(--text-secondary); text-align: center; line-height: 1.2; }
.template-thumb.is-active{ border-color: var(--accent-primary); background: rgba(139,92,246,0.12); }
.template-thumb.is-active span{ color: var(--text-primary); }

.control-row{ margin-bottom: 16px; }
.control-row__label{ display: block; font-size: 0.82rem; color: var(--text-secondary); margin-bottom: 8px; }
.control-row--switch{ display: flex; align-items: center; justify-content: space-between; }

.segmented{ display: flex; gap: 6px; flex-wrap: wrap; }
.segmented__item{
  border: 1px solid var(--border-soft);
  background: rgba(255,255,255,0.03);
  color: var(--text-secondary);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
}
.segmented__item.is-active{
  background: rgba(139,92,246,0.18);
  border-color: var(--accent-primary);
  color: var(--text-primary);
}

.swatch-row{ display: flex; gap: 10px; flex-wrap: wrap; }
.swatch{
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border-soft);
  background: var(--sw);
  cursor: pointer;
}
.swatch.is-active{ border-color: #fff; }

input[type="range"]{
  width: 100%;
  accent-color: var(--accent-primary);
}

.switch{ position: relative; display: inline-block; width: 44px; height: 26px; }
.switch input{ opacity: 0; width: 0; height: 0; position: absolute; }
.switch__track{
  position: absolute; inset: 0;
  background: rgba(255,255,255,0.12);
  border-radius: 999px;
  transition: background .15s ease;
}
.switch__track::before{
  content: "";
  position: absolute;
  width: 20px; height: 20px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .15s ease;
}
.switch input:checked + .switch__track{ background: linear-gradient(135deg, var(--accent-primary), var(--accent-glow)); }
.switch input:checked + .switch__track::before{ transform: translateX(18px); }
.switch-inline{ display: flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--text-secondary); }

/* =========================================================
   Sticky action bar
   ========================================================= */
.action-bar{
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgba(8,9,13,0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-softer);
}

/* =========================================================
   Toast
   ========================================================= */
.toast{
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(20,21,31,0.92);
  border: 1px solid var(--border-soft);
  color: var(--text-primary);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.82rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 50;
}
.toast.is-visible{ opacity: 1; transform: translateX(-50%) translateY(0); }

/* =========================================================
   Admin
   ========================================================= */
.admin-main{ max-width: 720px; margin: 0 auto; padding: 20px 16px 60px; }
.card{ padding: 20px; margin-bottom: 18px; }
.card h2{ margin: 0 0 16px; font-size: 1.05rem; }

.list{ display: flex; flex-direction: column; gap: 10px; }
.list-item{
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px; border: 1px solid var(--border-soft); border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.03);
}
.list-item__main{ display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.list-item__controls{ display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.list-item__controls select, .list-item__controls input[type="text"]{ width: auto; min-width: 120px; }
.list-item__delete{ display: flex; justify-content: flex-end; margin-top: -6px; }

.tag{
  font-size: 0.68rem;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(139,92,246,0.15);
  color: var(--text-secondary);
  text-transform: capitalize;
}
.tag--muted{ background: rgba(255,255,255,0.06); }

.empty-hint{ color: var(--text-muted); font-size: 0.85rem; }

.template-editor{ border: 1px solid var(--border-soft); border-radius: var(--radius-sm); background: rgba(255,255,255,0.03); padding: 10px 12px; }
.template-editor summary{
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  list-style: none;
  font-size: 0.9rem;
}
.template-editor summary::-webkit-details-marker{ display: none; }
.template-editor__thumb{ width: 34px; height: 34px; object-fit: contain; border-radius: 6px; background: rgba(255,255,255,0.05); }
.template-editor__form{ margin-top: 14px; }

/* =========================================================
   Desktop scale-up
   ========================================================= */
@media (min-width: 860px){
  .studio-main{
    display: grid;
    grid-template-columns: 1fr 380px;
    align-items: stretch;
  }
  .canvas-stage{ min-height: calc(100dvh - 62px); }
  .canvas-stage__inner{ max-height: 78vh; }
  #previewCanvas{ max-height: 78vh; }
  .drawer{
    border-radius: 0;
    border-left: 1px solid var(--border-soft);
    display: flex;
    flex-direction: column;
    height: calc(100dvh - 62px);
    overflow-y: auto;
  }
  .drawer__handle{ display: none; }
  .action-bar{
    grid-column: 2;
    position: sticky;
    bottom: 0;
  }
}
