/* ========================================
   Base styles — Global reset, variables, animations.
   Edit here for global color scheme, fonts, scrollbar styles.
   ======================================== */
:root {
  color-scheme: dark;
  --app-font-ui: "Segoe UI Variable Text", "HarmonyOS Sans SC", "MiSans", "OPPO Sans", "Source Han Sans SC", "Noto Sans SC", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --app-font-display: "Segoe UI Variable Display", "HarmonyOS Sans SC", "MiSans", "OPPO Sans", "Source Han Sans SC", "Noto Sans SC", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --app-font-mono: "SFMono-Regular", "Cascadia Code", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  --rb-bg: #0b0b10;
  --rb-bg-deep: #07070a;
  --rb-bg-soft: #121018;
  --rb-panel: rgba(20, 19, 26, 0.94);
  --rb-panel-soft: rgba(28, 25, 35, 0.74);
  --rb-panel-solid: #17151e;
  --rb-line: rgba(255, 255, 255, 0.11);
  --rb-line-strong: rgba(139, 92, 246, 0.4);
  --rb-text: #f4f4f5;
  --rb-muted: #ada6bc;
  --rb-dim: #837a92;
  --rb-primary: #7c3aed;
  --rb-primary-2: #8b5cf6;
  --rb-primary-3: #a78bfa;
  --rb-cyan: #8b5cf6;
  --rb-green: #34d399;
  --rb-pink: #8b5cf6;
  --rb-yellow: #facc15;
  --rb-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  --rb-shadow-soft: 0 16px 48px rgba(0, 0, 0, 0.34);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--app-font-ui);
  font-optical-sizing: auto;
  font-synthesis: none;
  font-feature-settings: "kern" 1, "liga" 1;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: linear-gradient(180deg, #0b0b10 0%, #050506 100%);
  color: var(--rb-text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

button,
input,
textarea,
select,
option {
  font-family: inherit;
}

h1,
h2,
h3,
h4,
h5,
h6,
.nav-brand,
.canvas-brand,
.purchase-brand {
  font-family: var(--app-font-display);
  letter-spacing: 0;
}

code,
kbd,
pre,
samp {
  font-family: var(--app-font-mono);
}

/* ReactBits FloatingLines background */
.bg-glow {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 0;
  overflow: hidden;
  background: #050506;
  opacity: 1;
  pointer-events: none;
}
.bg-glow .floating-lines-canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100% !important;
  height: 100% !important;
  display: block;
  opacity: 1;
}
.bg-glow.floating-lines-fallback {
  background:
    radial-gradient(ellipse at 50% 28%, rgba(125,17,219,0.26), transparent 28%),
    radial-gradient(ellipse at 50% 50%, rgba(28,195,167,0.16), transparent 36%),
    radial-gradient(ellipse at 50% 72%, rgba(91,0,255,0.22), transparent 30%),
    linear-gradient(180deg, #101016, #050506);
}

/* Particles */
.particles { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.particle { position: absolute; border-radius: 50%; opacity: 0.1; animation: float linear infinite; background: rgba(139,92,246,0.36) !important; }

/* Scrollbar */
.chat-container::-webkit-scrollbar { width: 6px; }
.chat-container::-webkit-scrollbar-track { background: transparent; }
.chat-container::-webkit-scrollbar-thumb {
  background: rgba(180,151,207,0.16);
  border-radius: 3px;
  transition: background-color 0.45s ease;
}
.chat-container::-webkit-scrollbar-thumb:hover { background: rgba(139,92,246,0.42); }
.chat-container.is-scrollbar-hidden::-webkit-scrollbar-thumb { background: transparent; }
.chat-container.is-scrollbar-hidden::-webkit-scrollbar-thumb:hover { background: transparent; }
.chat-container {
  scrollbar-color: rgba(180,151,207,0.16) transparent;
  transition: scrollbar-color 0.45s ease;
}
.chat-container.is-scrollbar-hidden {
  scrollbar-color: transparent transparent;
}

/* Animations */
@keyframes fadeInUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeInDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

@property --rb-border-angle {
  syntax: "<angle>";
  initial-value: 0deg;
  inherits: false;
}

@keyframes rbBorderSpin {
  to { --rb-border-angle: 360deg; }
}

@keyframes rbShineSweep {
  0% { transform: translateX(-140%) skewX(-16deg); opacity: 0; }
  18% { opacity: 0.42; }
  42% { opacity: 0; }
  100% { transform: translateX(160%) skewX(-16deg); opacity: 0; }
}

@keyframes rbSoftPulse {
  0%, 100% { opacity: 0.52; }
  50% { opacity: 0.78; }
}

/* Toast */
.toast-container {
  position: fixed;
  inset: 0;
  z-index: 1300;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  pointer-events: none;
}

.toast {
  --toast-accent: var(--rb-primary-3);
  width: max-content;
  min-width: 210px;
  max-width: min(420px, calc(100vw - 32px));
  min-height: 48px;
  padding: 13px 18px;
  border-radius: 8px;
  background: var(--rb-panel-solid);
  color: var(--rb-text);
  box-shadow: var(--rb-shadow-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  opacity: 0;
  transform: translateY(10px) scale(0.98);
  transition: opacity 180ms ease-out, transform 220ms cubic-bezier(0.16, 1, 0.3, 1);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.toast::before {
  content: "";
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 3px;
  background: var(--toast-accent);
}

.toast.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.toast.success { --toast-accent: #71c29a; }
.toast.error { --toast-accent: #ff7464; }

@media (max-width: 520px) {
  .toast-container { padding: 16px; }
  .toast { min-width: 0; }
}

.points-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(3, 7, 18, 0.68);
  backdrop-filter: blur(12px);
}

.points-dialog {
  position: relative;
  width: min(420px, 100%);
  border: 1px solid var(--rb-line);
  border-radius: 8px;
  background: var(--rb-panel-solid);
  box-shadow: var(--rb-shadow);
  padding: 24px;
}

.points-dialog h2 {
  margin: 0 0 8px;
  color: #fff;
  font-size: 22px;
}

.points-dialog p {
  margin: 0;
  color: var(--rb-muted);
  line-height: 1.6;
}

.points-dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: 1px solid var(--rb-line);
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
  color: #fff;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.points-dialog-required {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 8px;
  background: rgba(250, 204, 21, 0.1);
  border: 1px solid rgba(250, 204, 21, 0.2);
  color: rgba(255,255,255,0.82);
}

.points-dialog-required strong { color: #facc15; }

.points-dialog-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 20px;
}

.points-dialog-actions a,
.points-dialog-actions button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.12);
  text-decoration: none;
  cursor: pointer;
  font: inherit;
}

.points-dialog-primary {
  background: var(--rb-green);
  border-color: var(--rb-green);
  color: #fff;
  font-weight: 700;
}

.points-dialog-secondary {
  background: rgba(255,255,255,0.07);
  color: #fff;
}

.points-dialog-actions button {
  background: transparent;
  color: rgba(255,255,255,0.66);
}

.file-limit-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(3, 7, 18, 0.68);
  backdrop-filter: blur(12px);
}

.file-limit-dialog {
  position: relative;
  width: min(460px, 100%);
  border: 1px solid var(--rb-line);
  border-radius: 8px;
  background: var(--rb-panel-solid);
  box-shadow: var(--rb-shadow);
  padding: 24px;
}

.file-limit-dialog h2 {
  margin: 0 0 8px;
  padding-right: 32px;
  color: #fff;
  font-size: 22px;
}

.file-limit-dialog p {
  margin: 0;
  color: var(--rb-muted);
  line-height: 1.6;
}

.file-limit-dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: 1px solid var(--rb-line);
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
  color: #fff;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.file-limit-dialog-list {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
}

.file-limit-dialog-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 116, 100, 0.08);
  border: 1px solid rgba(255, 116, 100, 0.22);
}

.file-limit-dialog-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

.file-limit-dialog-reason {
  color: var(--rb-muted);
  font-size: 12.5px;
  line-height: 1.5;
}

.file-limit-dialog-actions {
  display: grid;
  grid-template-columns: 1fr;
  margin-top: 20px;
}

.file-limit-dialog-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid var(--rb-green);
  background: var(--rb-green);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

/* Responsive */
@media (max-width: 768px) {
  .navbar { padding: 10px 20px; }
  .settings-row { flex-wrap: wrap; }
}

/* UI polish layer: restrained depth, focus states, and consistent surfaces. */
:root {
  --rb-radius-sm: 10px;
  --rb-radius-md: 14px;
  --rb-radius-lg: 18px;
  --rb-focus-ring: 0 0 0 3px rgba(139,92,246,0.2);
  --rb-surface-glass: linear-gradient(145deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03));
  --rb-surface-border: rgba(255,255,255,0.11);
  --rb-surface-shadow: 0 18px 46px rgba(0,0,0,0.26);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: none;
  box-shadow: var(--rb-focus-ring);
}

::selection { background: rgba(167,139,250,0.3); color: #fff; }

button,
a,
input,
textarea,
select {
  transition: border-color 0.22s ease, background 0.22s ease, color 0.22s ease, box-shadow 0.22s ease, transform 0.22s ease;
}

/* Shared product icon language: 24px rounded outline icons, always currentColor. */
.ui-icon {
  width: 1.12em;
  height: 1.12em;
  display: inline-block;
  flex: 0 0 auto;
  vertical-align: -0.18em;
  overflow: visible;
}

button > .ui-icon,
a > .ui-icon,
[data-ui-icon-ready]:not([data-icon-only="true"]) > .ui-icon {
  margin-right: 0.5em;
}

[data-icon-only="true"] > .ui-icon,
.canvas-toolbar-btn > .ui-icon,
.canvas-hover-btn > .ui-icon,
.canvas-selection-action > .ui-icon,
.canvas-status-btn > .ui-icon,
.canvas-shortcuts-head button > .ui-icon,
.canvas-media-preview-close > .ui-icon {
  margin-right: 0;
}

@media (prefers-reduced-motion: reduce) {
  html:focus-within,
  *, *::before, *::after {
    scroll-behavior: auto !important;
  }

  .particle {
    animation: none !important;
  }

  .toast {
    transform: none !important;
    transition: opacity 80ms linear !important;
  }
}
