/* ==========================================================================
   ChatWidget Studio — studio chrome styles
   (Widget preview styles are generated at runtime — see app.js:generateCSS)
   --------------------------------------------------------------------------
   Sections:
     1. Tokens & reset
     2. Top bar
     3. Workspace layout
     4. Sidebar (tabs, controls)
     5. Preview canvas & device frames
     6. Export modal & code view
     7. Toast, focus, scrollbars, responsive
   ========================================================================== */

/* 1. Tokens & reset
   ========================================================================== */
:root {
  --bg: #e2e2e2;
  --app: #efefef;
  --card: #ffffff;
  --border: #ececec;
  --border-hover: #e0e0e0;
  --text: #1b1b1b;
  --secondary: #767676;
  --muted: #a4a4a4;
  --placeholder: #b4b4b4;
  --dark: #1d1d1d;
  --dark-hover: #000000;
  --white: #ffffff;
  --track: #e5e5e5;
  --green: #34a853;
  --radius-app: 20px;
  --radius-card: 12px;
  --radius-side: 12px;
  --radius-btn: 10px;
  --radius-pill: 999px;
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-7: 32px;
  --s-8: 40px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-hover: 0 6px 20px rgba(0, 0, 0, 0.08);
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --dur: 180ms;
  --font-ui: "Inter", system-ui, sans-serif;
}

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

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--text);
  background: var(--app);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

button {
  font: inherit;
  cursor: pointer;
  color: inherit;
  background: none;
  border: 0;
}
input,
select,
textarea {
  font: inherit;
}

/* 2. Top bar
   ========================================================================== */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0px;
  min-width: 230px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--dark);
  color: var(--bg);
}
.brand-mark svg {
  width: 19px;
  height: 19px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.brand-text strong {
  font-family: var(--font-ui);
  font-size: 15px;
  color: var(--text);
  letter-spacing: -0.01em;
}
.brand-text span {
  font-family: var(--font-ui);
  font-size: 10.5px;
  color: var(--secondary);
}

.topbar-center {
  display: flex;
  gap: 4px;
  margin-inline: auto;
  padding: 4px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.device-btn,
.zoom-btn {
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--secondary);
}
.device-btn:hover,
.zoom-btn:hover {
  color: var(--text);
}
.device-btn.is-active,
.zoom-btn.is-active {
  background: var(--border);
  color: var(--text);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar-divider {
  width: 1px;
  height: 22px;
  background: var(--border);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 13px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition:
    background 0.15s,
    border-color 0.15s,
    transform 0.1s;
}
.btn:active {
  transform: translateY(1px);
}
.btn-ghost {
  color: var(--text);
}
.btn-ghost:hover {
  background: var(--track);
}
.btn-ghost[aria-pressed="true"] {
  background: var(--border);
  color: var(--text);
}
.btn-outline {
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover {
  border-color: var(--secondary);
}
.btn-primary {
  background: var(--dark);
  color: var(--bg);
  font-weight: 600;
}
.btn-primary:hover {
  background: var(--dark-hover);
}

/* 3. Workspace layout
   ========================================================================== */
.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: auto 1fr;
  min-height: 0;
}

/* 4. Sidebar
   ========================================================================== */
.sidebar {
  display: flex;
  flex-direction: row;
  min-height: 0;
  background: var(--card);
  border-right: 1px solid var(--border);
}

.sidebar-nav {
  width: 190px;
  background: var(--app);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  gap: 20px;
  overflow-y: auto;
}

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

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-group-title {
  font-family: var(--font-ui);
  font-size: 10.5px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0 10px;
  margin-bottom: 8px;
  margin-top: 4px;
}
.nav-group:first-child .nav-group-title {
  margin-top: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  border-radius: 8px;
  font-family: var(--font-ui);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  opacity: 0.7;
  text-align: left;
  transition: all 0.15s;
}
.nav-item:hover {
  background: var(--border);
  opacity: 1;
}
.nav-item.is-active {
  background: var(--card);
  opacity: 1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.sidebar-body {
  width: 330px;
  flex: none;
  overflow-y: auto;
  padding: 24px 20px 40px;
}
.sidebar-body::-webkit-scrollbar {
  width: 6px;
}
.sidebar-body::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar-body::-webkit-scrollbar-thumb {
  background: var(--border-hover);
  border-radius: var(--radius-pill);
}
.sidebar-body::-webkit-scrollbar-thumb:hover {
  background: var(--secondary);
}

.panel-title {
  margin: 4px 0 2px;
  font-family: var(--font-ui);
  font-size: 15px;
  color: var(--text);
  margin-bottom: 5px;
}
.panel-sub {
  margin: 0 0 14px;
  font-size: 12px;
  color: var(--secondary);
}

/* Controls */
.control {
  margin: 10px 0;
}
.control-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}
.control-label output {
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--secondary);
}

.control input[type="text"],
.control select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--app);
  color: var(--text);
  outline: none;
}
.control input[type="text"]:focus,
.control select:focus {
  border-color: var(--dark);
}

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

.color-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.color-row input[type="color"] {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: none;
  cursor: pointer;
}
.color-row code {
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--secondary);
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 13px;
  width: 100%;
}
.switch {
  position: relative;
  width: 36px;
  height: 20px;
  background: var(--border);
  border-radius: 999px;
  transition: background 0.15s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--card);
  transition: left 0.15s;
}
.switch.is-on {
  background: var(--dark);
}
.switch.is-on::after {
  left: 18px;
}

.seg-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.seg-btn {
  flex: 1;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  color: var(--secondary);
  text-transform: capitalize;
}
.seg-btn:hover {
  color: var(--text);
}
.seg-btn.is-active {
  border-color: var(--dark);
  color: var(--dark);
  background: var(--dark-soft);
}

.file-btn {
  display: block;
  width: 100%;
  padding: 9px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--secondary);
  text-align: center;
  font-size: 12.5px;
}
.file-btn:hover {
  border-color: var(--dark);
  color: var(--dark);
}

/* Template grid */
.tpl-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.tpl-card {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--app);
  text-align: left;
  transition:
    border-color 0.15s,
    transform 0.12s;
}
.tpl-card:hover {
  border-color: var(--secondary);
  transform: translateY(-1px);
}
.tpl-card.is-active {
  border-color: var(--dark);
}
.tpl-swatch {
  display: flex;
  height: 26px;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 8px;
}
.tpl-swatch span {
  flex: 1;
}
.tpl-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.tpl-tag {
  display: block;
  font-family: var(--font-ui);
  font-size: 10px;
  color: var(--secondary);
  margin-top: 2px;
}
.tpl-badge {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--dark);
  color: var(--bg);
  padding: 3px 6px;
  border-radius: 4px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}

/* 5. Preview canvas
   ========================================================================== */
.canvas {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.canvas-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
}
.canvas-hint {
  font-family: var(--font-ui);
  font-size: 15px;
  color: var(--secondary);
  font-weight: 500;
  padding: 10px 8px;
}
.canvas-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text);
  cursor: pointer;
}
.canvas-toggle input {
  accent-color: var(--dark);
}

.device-frame {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 12px 24px 28px;
  min-height: 0;
  padding-top: 0;
}

.device-screen {
  position: relative;
  width: 100%;
  height: 100%;
  transform: scale(1); /* Scopes position: fixed to this container */

  background: #eef0f4;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-hover);
  transition:
    max-width 0.35s ease,
    max-height 0.35s ease;
}
.device-frame[data-device="tablet"] .device-screen {
  max-width: 768px;
  max-height: 940px;
}
.device-frame[data-device="mobile"] .device-screen {
  max-width: 390px;
  max-height: 780px;
  border-radius: 26px;
}

/* Fake host page inside the screen (SaaS Dashboard) */
.host-page {
  position: absolute;
  inset: 0;
  display: flex;
  background: #f8fafc;
}

.host-sidebar {
  width: 22%;
  min-width: 140px;
  background: #ffffff;
  border-right: 1px solid #e2e8f0;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.host-sidebar-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #3b82f6;
  margin-bottom: 16px;
}
.host-sidebar-item {
  height: 12px;
  border-radius: 4px;
  background: #e2e8f0;
  width: 100%;
}
.host-sidebar-item:nth-child(2) {
  background: #cbd5e1;
  width: 80%;
}
.host-sidebar-item:nth-child(3) {
  width: 70%;
}
.host-sidebar-item:nth-child(4) {
  width: 85%;
}
.host-sidebar-item:nth-child(5) {
  width: 60%;
}

.host-main {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.host-navbar {
  height: 56px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}
.host-nav-left {
  width: 120px;
  height: 12px;
  border-radius: 4px;
  background: #cbd5e1;
}
.host-nav-right {
  display: flex;
  gap: 12px;
}
.host-nav-avatar {
  width: 28px;
  height: 28px;
  border-radius: 14px;
  background: #94a3b8;
}

.host-content {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.host-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.host-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.host-card-title {
  width: 40px;
  height: 10px;
  background: #cbd5e1;
  border-radius: 3px;
}
.host-card-value {
  width: 70%;
  height: 24px;
  background: #e2e8f0;
  border-radius: 4px;
}

.host-charts {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}
.host-chart {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 16px;
  height: 140px;
  display: flex;
  flex-direction: column;
}
.host-chart-header {
  width: 80px;
  height: 10px;
  background: #cbd5e1;
  border-radius: 3px;
  margin-bottom: 16px;
}
.host-chart-body {
  flex: 1;
  background: #f1f5f9;
  border-radius: 6px;
  border: 1px dashed #cbd5e1;
}

.host-table {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.host-table-row {
  height: 24px;
  background: #f8fafc;
  border-radius: 4px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 12px;
}
.host-table-row:first-child {
  background: #f1f5f9;
}
.host-table-cell {
  height: 8px;
  border-radius: 2px;
  background: #e2e8f0;
  flex: 1;
}
.host-table-row:first-child .host-table-cell {
  background: #cbd5e1;
}

#widget-mount {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
#widget-mount > * {
  pointer-events: auto;
}

/* 6. Export modal & code view
   ========================================================================== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
}
.modal[hidden] {
  display: none;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 8, 14, 0.7);
  backdrop-filter: blur(3px);
}

.modal-card {
  position: relative;
  width: min(880px, 92vw);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

.modal-head {
  padding: 18px 20px 12px;
}
.modal-head h2 {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 18px;
  color: var(--text);
}
.modal-head p {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--secondary);
}
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  color: var(--secondary);
  font-size: 15px;
  padding: 6px;
}
.modal-close:hover {
  color: var(--text);
}

.code-tabs {
  display: flex;
  gap: 2px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
}
.code-tab {
  padding: 8px 13px;
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.code-tab:hover {
  color: var(--text);
}
.code-tab.is-active {
  color: var(--dark);
  border-bottom-color: var(--dark);
}

.code-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
}
.code-view {
  margin: 0;
  height: 100%;
  max-height: 58vh;
  overflow: auto;
  padding: 18px 20px 24px;
  font-family: var(--font-ui);
  font-size: 12px;
  line-height: 1.65;
  color: var(--text);
  white-space: pre;
  background: var(--bg);
}
.code-copy {
  position: absolute;
  top: 12px;
  right: 18px;
}

/* 7. Toast, focus, scrollbars, responsive
   ========================================================================== */
.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translate(-50%, 12px);
  padding: 10px 18px;
  border-radius: 10px;
  background: #22c55e;
  color: #ffffff;
  font-weight: 600;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.2s,
    transform 0.2s;
  z-index: 60;
}
.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

:focus-visible {
  outline: 2px solid var(--dark);
  outline-offset: 2px;
}

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001s !important;
    transition-duration: 0.001s !important;
  }
}

@media (max-width: 960px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: 45% 55%;
  }
  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .sidebar-nav {
    display: none; /* simple mobile fallback, ideally would be a dropdown or scrollable row */
  }
  .sidebar-body {
    width: 100%;
  }
  .topbar {
    flex-wrap: wrap;
  }
  .topbar-center {
    order: 3;
    margin-inline: 0;
  }
}

/* 8. Preloader (Studio UI)
   ========================================================================== */
.preloader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 2px;
  justify-content: center;
  align-items: center;
  animation: cw-hide-preloader 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) 1.5s forwards;
  pointer-events: none;
}

.preloader-logo {
  width: 55px;
  height: 55px;
  animation: cw-pop-in 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes cw-pop-in {
  0% {
    transform: scale(0.8);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes cw-hide-preloader {
  0% {
    opacity: 1;
    visibility: visible;
  }
  100% {
    opacity: 0;
    visibility: hidden;
  }
}

.loader {
  --main-size: 4em;
  --text-color: var(--text);
  --shine-color: rgba(255, 255, 255, 0.2);
  --shadow-color: var(--muted);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  user-select: none;
  position: relative;
  font-size: var(--main-size);
  font-weight: 900;
  text-transform: uppercase;
  color: var(--text-color);
  width: 7.3em;
  height: 1em;
  filter: drop-shadow(0 0 0.05em var(--shine-color));
}

.loader .text {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  position: absolute;
}

.loader .text:nth-child(1) {
  clip-path: polygon(0% 0%, 11.11% 0%, 11.11% 100%, 0% 100%);
  font-size: calc(var(--main-size) / 20);
  margin-left: -2.1em;
  opacity: 0.6;
}
.loader .text:nth-child(2) {
  clip-path: polygon(11.11% 0%, 22.22% 0%, 22.22% 100%, 11.11% 100%);
  font-size: calc(var(--main-size) / 16);
  margin-left: -0.98em;
  opacity: 0.7;
}
.loader .text:nth-child(3) {
  clip-path: polygon(22.22% 0%, 33.33% 0%, 33.33% 100%, 22.22% 100%);
  font-size: calc(var(--main-size) / 13);
  margin-left: -0.33em;
  opacity: 0.8;
}
.loader .text:nth-child(4) {
  clip-path: polygon(33.33% 0%, 44.44% 0%, 44.44% 100%, 33.33% 100%);
  font-size: calc(var(--main-size) / 11);
  margin-left: -0.05em;
  opacity: 0.9;
}
.loader .text:nth-child(5) {
  clip-path: polygon(44.44% 0%, 55.55% 0%, 55.55% 100%, 44.44% 100%);
  font-size: calc(var(--main-size) / 10);
  margin-left: 0em;
  opacity: 1;
}
.loader .text:nth-child(6) {
  clip-path: polygon(55.55% 0%, 66.66% 0%, 66.66% 100%, 55.55% 100%);
  font-size: calc(var(--main-size) / 11);
  margin-left: 0.05em;
  opacity: 0.9;
}
.loader .text:nth-child(7) {
  clip-path: polygon(66.66% 0%, 77.77% 0%, 77.77% 100%, 66.66% 100%);
  font-size: calc(var(--main-size) / 13);
  margin-left: 0.33em;
  opacity: 0.8;
}
.loader .text:nth-child(8) {
  clip-path: polygon(77.77% 0%, 88.88% 0%, 88.88% 100%, 77.77% 100%);
  font-size: calc(var(--main-size) / 16);
  margin-left: 0.98em;
  opacity: 0.7;
}
.loader .text:nth-child(9) {
  clip-path: polygon(88.88% 0%, 100% 0%, 100% 100%, 88.88% 100%);
  font-size: calc(var(--main-size) / 20);
  margin-left: 2.1em;
  opacity: 0.6;
}

.loader .text span {
  animation:
    loader-scrolling 2s cubic-bezier(0.1, 0.6, 0.9, 0.4) infinite,
    loader-shadow 2s cubic-bezier(0.1, 0.6, 0.9, 0.4) infinite;
}

.loader .text:nth-child(1) span {
  background: linear-gradient(
    to right,
    var(--text-color) 4%,
    var(--shadow-color) 7%
  );
  background-size: 200% auto;
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
}
.loader .text:nth-child(2) span {
  background: linear-gradient(
    to right,
    var(--text-color) 9%,
    var(--shadow-color) 13%
  );
  background-size: 200% auto;
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
}
.loader .text:nth-child(3) span {
  background: linear-gradient(
    to right,
    var(--text-color) 15%,
    var(--shadow-color) 18%
  );
  background-size: 200% auto;
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
}
.loader .text:nth-child(4) span {
  background: linear-gradient(
    to right,
    var(--text-color) 20%,
    var(--shadow-color) 23%
  );
  background-size: 200% auto;
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
}
.loader .text:nth-child(6) span {
  background: linear-gradient(
    to right,
    var(--shadow-color) 29%,
    var(--text-color) 32%
  );
  background-size: 200% auto;
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
}
.loader .text:nth-child(7) span {
  background: linear-gradient(
    to right,
    var(--shadow-color) 34%,
    var(--text-color) 37%
  );
  background-size: 200% auto;
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
}
.loader .text:nth-child(8) span {
  background: linear-gradient(
    to right,
    var(--shadow-color) 39%,
    var(--text-color) 42%
  );
  background-size: 200% auto;
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
}
.loader .text:nth-child(9) span {
  background: linear-gradient(
    to right,
    var(--shadow-color) 45%,
    var(--text-color) 48%
  );
  background-size: 200% auto;
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
}

.loader .line {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  height: 0.05em;
  width: calc(var(--main-size) / 2);
  margin-top: 0.9em;
  border-radius: 0.05em;
}

.loader .line::before {
  content: "";
  position: absolute;
  height: 100%;
  width: 100%;
  background-color: var(--text-color);
  opacity: 0.3;
}

.loader .line::after {
  content: "";
  position: absolute;
  height: 100%;
  width: 100%;
  background-color: var(--text-color);
  border-radius: 0.05em;
  transform: translateX(-90%);
  animation: loader-wobble 2s cubic-bezier(0.5, 0.8, 0.5, 0.2) infinite;
}

@keyframes loader-wobble {
  0% {
    transform: translateX(-90%);
  }
  50% {
    transform: translateX(90%);
  }
  100% {
    transform: translateX(-90%);
  }
}

@keyframes loader-scrolling {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

@keyframes loader-shadow {
  0% {
    background-position: -98% 0;
  }
  100% {
    background-position: 102% 0;
  }
}

/* 10. Welcome Overlay
   ========================================================================== */
.welcome-overlay {
  position: absolute;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  transition:
    opacity 0.3s ease,
    visibility 0.3s ease;
}

.welcome-content {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  max-width: 480px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.05);
  animation: modal-up 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.welcome-icon {
  font-size: 48px;
  margin-bottom: 20px;
}

.welcome-content h2 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0;
}

.welcome-content p {
  font-size: 14px;
  color: var(--secondary);
  line-height: 1.5;
  margin-bottom: 32px;
  margin-top: 5px;
}

.welcome-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
}

.welcome-actions .btn {
  padding: 10px 20px;
  font-size: 14.5px;
}

.welcome-content--wide {
  max-width: 800px;
  width: 90%;
}

.welcome-templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
  gap: 12px;
  max-height: 55vh;
  overflow-y: auto;
  margin-top: 20px;
  padding: 4px 8px 4px 4px;
  text-align: left;
}

.welcome-content--hero {
  max-width: 800px;
  width: 90%;
  padding: 60px 40px;
  text-align: left;
  border-radius: 24px;
}

.welcome-hero-layout {
  display: flex;
  align-items: center;
  gap: 64px;
}

.welcome-hero-text {
  flex: 1;
}

.welcome-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--surface);
  color: var(--secondary);
  font-size: 13px;
  font-weight: 600;
  border-radius: 999px;
  margin-bottom: 24px;
  border: 1px solid var(--border);
}

.welcome-hero-title {
  font-size: 32px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.12;
  letter-spacing: -0.02em;
  margin-bottom: 24px;
}

.welcome-hero-features {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 40px;
  list-style: none;
  padding: 0;
}

.welcome-hero-features li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #71717a;
  font-weight: 500;
}

.welcome-hero-features li i {
  color: var(--primary);
  font-size: 16px;
}

.welcome-hero-text .welcome-actions {
  justify-content: flex-start;
  margin-top: 0;
}

.welcome-trust {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 15px;
  font-size: 12px;
  font-weight: 500;
  color: #a1a1aa;
  display: none;
}

.welcome-trust .dot {
  color: #e4e4e7;
  font-size: 11px;
}

.welcome-hero-illus {
  position: relative;
  width: 300px;
  height: 300px;

  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.mini-widget {
  width: 100%;
  height: 100%;

  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: float-widget 6s ease-in-out infinite;
}

.mini-widget img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}
@keyframes float-widget {
  0% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
  100% {
    transform: translateY(0);
  }
}

/* Feedback Modal Styles */
.feedback-emoji-btn:hover {
  background: #e5e7eb !important;
}
.feedback-emoji-btn.is-active {
  background: #ffffff !important;
  border-color: #006aff !important;
  box-shadow: 0 2px 8px rgba(0, 106, 255, 0.15);
}
#feedback-message:focus {
  outline: none;
  border-color: #006aff;
  background: #ffffff;
}
