:root {
  --paper: #eef1f8;
  --ink: #1d1b2c;
  --muted: #5d5b70;
  --faint: #8a889c;
  --line: rgba(20, 20, 40, 0.1);
  --c-home: #6d5bff;
  --c-compute: #f08a00;
  --c-codex: #0ea59a;
  --c-api: #a24cf0;
  --c-video: #e8337f;
  --c-trading: #10a36b;
  --c-downloads: #1d8fe0;
  --c-gold: #e0a100;
  --c-business: #4f5bea;
  --c-opc: #f0532b;
  --g-panel: rgba(255, 255, 255, 0.58);
  --g-solid: rgba(255, 255, 255, 0.78);
  --g-dialog: rgba(250, 250, 253, 0.96);
  --g-edge: rgba(255, 255, 255, 0.84);
  --g-blur: blur(26px) saturate(185%);
  --g-lift: 0 1px 0 rgba(255, 255, 255, 0.72) inset, 0 12px 40px rgba(40, 50, 90, 0.12), 0 2px 6px rgba(40, 50, 90, 0.05);
  --g-spring: cubic-bezier(0.2, 0.9, 0.25, 1.12);
  --g-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --radius: 26px;
}

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

html {
  color-scheme: light;
  scroll-behavior: smooth;
  overflow-x: clip;
  max-width: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  letter-spacing: -0.01em;
  overflow-x: clip;
  max-width: 100%;
  -webkit-font-smoothing: antialiased;
}

/* Ambient 4-quadrant wallpaper stage */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background-color: var(--paper);
  background-image:
    radial-gradient(46vmax 42vmax at 10% 8%, rgba(109, 91, 255, 0.24), transparent 62%),
    radial-gradient(44vmax 40vmax at 92% 10%, rgba(191, 90, 242, 0.34), transparent 60%),
    radial-gradient(48vmax 42vmax at 12% 88%, rgba(255, 143, 163, 0.32), transparent 64%),
    radial-gradient(46vmax 40vmax at 90% 88%, rgba(255, 214, 10, 0.28), transparent 62%);
  transition: opacity 0.3s ease;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: radial-gradient(rgba(40, 50, 90, 0.06) 1px, transparent 1px);
  background-size: 18px 18px;
  opacity: 0.45;
}

body[data-wp="particles"]::after {
  background-image: radial-gradient(rgba(109, 91, 255, 0.24) 1.4px, transparent 1.4px);
  background-size: 20px 20px;
  opacity: 0.9;
}

body[data-wp="scene"]::before {
  background-image:
    linear-gradient(180deg, rgba(208, 224, 255, 0.85) 0%, rgba(247, 214, 232, 0.72) 45%, rgba(255, 236, 198, 0.75) 100%),
    radial-gradient(ellipse 90% 45% at 75% 18%, rgba(255, 214, 10, 0.55), transparent 60%),
    linear-gradient(166deg, transparent 58%, rgba(255, 130, 169, 0.45) 59%, rgba(121, 97, 255, 0.38) 100%);
}

body[data-wp="clean"]::before {
  background-image: none;
  background-color: #f6f7fb;
}
body[data-wp="clean"]::after {
  opacity: 0.22;
}

body[data-wp="custom"]::before {
  background-image: var(--wp-custom-url);
  background-size: cover;
  background-position: center;
}
body[data-wp="custom"]::after {
  background: rgba(238, 241, 248, 0.32);
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, textarea, select {
  font-family: inherit;
}

.tnum {
  font-variant-numeric: tabular-nums;
}

.page-wrap {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 20px 64px;
}

.glass-card {
  background: var(--g-solid);
  backdrop-filter: var(--g-blur);
  -webkit-backdrop-filter: var(--g-blur);
  border: 1px solid var(--g-edge);
  border-radius: var(--radius);
  box-shadow: var(--g-lift);
}

.glass-panel {
  background: var(--g-panel);
  backdrop-filter: var(--g-blur);
  -webkit-backdrop-filter: var(--g-blur);
  border: 1px solid var(--g-edge);
  border-radius: 22px;
  box-shadow: var(--g-lift);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  border-radius: 999px;
  padding: 10px 18px;
  transition: transform 0.2s var(--g-spring), box-shadow 0.2s var(--g-ease), background 0.2s ease, opacity 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
}
.btn:active {
  transform: translateY(0) scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, #6d5bff, #8b5cf6);
  color: #fff;
  box-shadow: 0 6px 20px rgba(109, 91, 255, 0.3);
}

.btn-orange {
  background: linear-gradient(135deg, #ff9914, #f06500);
  color: #fff;
  box-shadow: 0 10px 26px rgba(240, 101, 0, 0.34);
}

.btn-dark {
  background: #1d1b2c;
  color: #fff;
  box-shadow: 0 8px 20px rgba(29, 27, 44, 0.22);
}

.btn-blue {
  background: linear-gradient(135deg, #1d8fe0, #0066cc);
  color: #fff;
  box-shadow: 0 8px 20px rgba(29, 143, 224, 0.25);
}

.btn-green {
  background: linear-gradient(135deg, #10a36b, #0c7e52);
  color: #fff;
  box-shadow: 0 8px 20px rgba(16, 163, 107, 0.25);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.85);
  color: var(--ink);
  border: 1px solid rgba(20, 20, 40, 0.1);
}

.pill-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.5;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(20, 22, 42, 0.38);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop.is-open {
  display: flex;
}

.modal-box {
  position: relative;
  width: 100%;
  max-width: 470px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--g-dialog);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 28px;
  padding: 28px 26px 26px;
  box-shadow: 0 28px 70px rgba(15, 20, 45, 0.24);
  animation: modalPop 0.24s var(--g-spring);
}

.modal-box.modal-wide {
  max-width: 820px;
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(20, 20, 40, 0.06);
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover {
  background: rgba(20, 20, 40, 0.12);
  color: var(--ink);
}

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  margin: 14px 0 6px;
}

.input-box {
  width: 100%;
  height: 44px;
  border-radius: 13px;
  border: 1.5px solid rgba(20, 20, 40, 0.14);
  background: #fff;
  padding: 0 14px;
  font-size: 14.5px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.input-box:focus {
  border-color: var(--c-home);
  box-shadow: 0 0 0 3px rgba(109, 91, 255, 0.16);
}

textarea.input-box {
  height: auto;
  min-height: 100px;
  padding: 12px 14px;
  resize: vertical;
}

/* Global Toast */
.toast-wrap {
  position: fixed;
  top: 76px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast-item {
  background: rgba(29, 27, 44, 0.94);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  animation: modalPop 0.2s var(--g-spring);
}

.toast-item.is-err {
  background: #d92d20;
}
.toast-item.is-ok {
  background: #0f766e;
}

/* Wallpaper Picker Grid */
.wp-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.wp-card {
  border: 2px solid rgba(20, 20, 40, 0.08);
  border-radius: 16px;
  background: #fff;
  padding: 8px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.18s ease, transform 0.18s ease;
}
.wp-card:hover {
  transform: translateY(-2px);
}
.wp-card.is-active {
  border-color: var(--c-home);
  box-shadow: 0 0 0 3px rgba(109, 91, 255, 0.14);
}
.wp-thumb {
  height: 58px;
  border-radius: 10px;
  margin-bottom: 8px;
  border: 1px solid rgba(20, 20, 40, 0.06);
}
.wp-thumb.t-aura {
  background: radial-gradient(circle at 20% 20%, #c7d2fe, transparent 60%), radial-gradient(circle at 80% 30%, #fbcfe8, transparent 60%), radial-gradient(circle at 50% 90%, #fef08a, #eef1f8 70%);
}
.wp-thumb.t-particles {
  background-color: #eef1f8;
  background-image: radial-gradient(#818cf8 1.5px, transparent 1.5px);
  background-size: 10px 10px;
}
.wp-thumb.t-scene {
  background: linear-gradient(180deg, #dbeafe 0%, #fce7f3 60%, #fb7185 62%, #fed7aa 100%);
}
.wp-thumb.t-clean {
  background-color: #f8f9fc;
  background-image: radial-gradient(rgba(0,0,0,0.08) 1px, transparent 1px);
  background-size: 10px 10px;
}
.wp-thumb.t-custom {
  background: repeating-linear-gradient(135deg, #eceef5, #eceef5 8px, #e1e4ee 8px, #e1e4ee 16px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--muted);
}

/* Subpage compact footer */
.sub-footer {
  margin-top: 56px;
  padding-top: 22px;
  border-top: 1px solid rgba(20, 20, 40, 0.08);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  font-size: 13px;
  color: var(--muted);
}

.sub-footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  font-weight: 600;
  color: var(--ink);
}

/* Floating Mascot 小壹 */
.floating-bot {
  position: fixed;
  left: 22px;
  bottom: 22px;
  z-index: 320;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.bot-bubble {
  max-width: 260px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.95);
  border-radius: 18px;
  padding: 12px 14px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--ink);
  box-shadow: 0 12px 32px rgba(20, 24, 55, 0.16);
}

.bot-bubble-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}

.bot-rest-btn {
  border: none;
  background: none;
  color: var(--faint);
  font-size: 11.5px;
  cursor: pointer;
}
.bot-rest-btn:hover { color: var(--ink); }

.bot-trigger {
  position: relative;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.85);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(18px);
  box-shadow: 0 10px 28px rgba(25, 25, 50, 0.18);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s var(--g-spring);
}
.bot-trigger:hover { transform: scale(1.06); }
.bot-trigger img { width: 46px; height: 46px; }

.bot-draw-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, #c084fc, #a24cf0);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
}

@media (max-width: 860px) {
  body {
    padding-bottom: calc(88px + env(safe-area-inset-bottom));
  }
  .page-wrap {
    padding: 12px 14px 36px;
  }
  .wp-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .floating-bot {
    left: 14px;
    bottom: calc(84px + env(safe-area-inset-bottom));
  }
  .bot-bubble {
    max-width: 210px;
  }
  .bot-trigger {
    width: 48px;
    height: 48px;
  }
  .bot-trigger img {
    width: 38px;
    height: 38px;
  }
}
