:root {
  --brand: #7C3AED;
  --brand-2: #06B6D4;
  --brand-grad: linear-gradient(135deg, #7C3AED 0%, #06B6D4 100%);
  --bg: #ffffff;
  --bg-soft: #f5f3ff;
  --surface: #ffffff;
  --border: #e8e4f5;
  --text: #1a1530;
  --text-soft: #5b5470;
  --shadow: 0 10px 30px rgba(124, 58, 237, 0.10);
  --shadow-strong: 0 22px 55px rgba(124, 58, 237, 0.22);
  --radius: 18px;
  --header-bg: rgba(255, 255, 255, 0.78);
}

/* Dark theme via system preference */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0b1a;
    --bg-soft: #161229;
    --surface: #191430;
    --border: #2c2750;
    --text: #f3f0ff;
    --text-soft: #b7b0d6;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    --shadow-strong: 0 22px 55px rgba(0, 0, 0, 0.6);
    --header-bg: rgba(14, 11, 26, 0.72);
  }
}

/* Manual override (toggle) — higher specificity than :root, always wins */
html[data-theme="dark"] {
  --bg: #0e0b1a; --bg-soft: #161229; --surface: #191430; --border: #2c2750;
  --text: #f3f0ff; --text-soft: #b7b0d6; --shadow: 0 10px 30px rgba(0,0,0,.45);
  --shadow-strong: 0 22px 55px rgba(0,0,0,.6); --header-bg: rgba(14,11,26,.72);
}
html[data-theme="light"] {
  --bg: #ffffff; --bg-soft: #f5f3ff; --surface: #ffffff; --border: #e8e4f5;
  --text: #1a1530; --text-soft: #5b5470; --shadow: 0 10px 30px rgba(124,58,237,.10);
  --shadow-strong: 0 22px 55px rgba(124,58,237,.22); --header-bg: rgba(255,255,255,.78);
}

* { box-sizing: border-box; }

html { background: var(--bg); scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: transparent;
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  position: relative;
  z-index: 0;
  overflow-x: hidden;
}

/* Ambient gradient orbs (pure CSS, GPU-friendly) */
body::before, body::after {
  content: ""; position: fixed; z-index: -1; pointer-events: none;
  width: 52vw; height: 52vw; border-radius: 50%;
  filter: blur(90px); opacity: 0.32;
}
body::before {
  background: radial-gradient(circle, #7C3AED, transparent 70%);
  top: -14vw; left: -12vw;
  animation: orbA 22s ease-in-out infinite;
}
body::after {
  background: radial-gradient(circle, #06B6D4, transparent 70%);
  bottom: -16vw; right: -12vw;
  animation: orbB 26s ease-in-out infinite;
}
@keyframes orbA { 0%,100% { transform: translate(0,0); } 50% { transform: translate(7vw, 6vw); } }
@keyframes orbB { 0%,100% { transform: translate(0,0); } 50% { transform: translate(-6vw, -7vw); } }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { width: 100%; max-width: 940px; margin: 0 auto; padding: 0 20px; }

/* Header / nav */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: var(--header-bg);
  backdrop-filter: blur(14px) saturate(160%);
  border-bottom: 1px solid var(--border);
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; height: 66px; gap: 12px; }
.logo { font-weight: 800; font-size: 18px; letter-spacing: -0.02em; display: flex; align-items: center; gap: 9px; white-space: nowrap; }
.logo .dot { width: 13px; height: 13px; border-radius: 50%; background: var(--brand-grad); box-shadow: 0 0 12px rgba(124,58,237,.5); }
.nav { display: flex; gap: 14px; flex-wrap: wrap; font-size: 14px; }
.nav a { color: var(--text-soft); transition: color .15s; }
.nav a.active, .nav a:hover { color: var(--brand); text-decoration: none; }

/* Theme toggle */
.theme-toggle {
  flex: none; width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-soft);
  cursor: pointer; display: grid; place-items: center;
  transition: transform .15s, color .15s, border-color .15s, box-shadow .15s;
}
.theme-toggle:hover { color: var(--brand); border-color: var(--brand); transform: translateY(-1px); box-shadow: var(--shadow); }
.theme-toggle:active { transform: scale(.94); }
.theme-toggle svg { width: 18px; height: 18px; }

/* Hero */
.hero { padding: 54px 0 30px; text-align: center; }
.hero h1 {
  font-size: clamp(32px, 6vw, 52px);
  line-height: 1.12; margin: 0 0 14px; letter-spacing: -0.025em; font-weight: 800;
}
.hero h1 .accent {
  background: var(--brand-grad); -webkit-background-clip: text; background-clip: text;
  color: transparent; display: inline-block; animation: floaty 4.5s ease-in-out infinite;
}
@keyframes floaty { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.hero p.lead { color: var(--text-soft); font-size: 17.5px; max-width: 640px; margin: 0 auto; }

/* Input */
.input-wrap { margin: 30px auto 8px; max-width: 720px; }
.input-box {
  width: 100%; font-size: 18px; padding: 18px 20px;
  border: 2px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  outline: none; transition: border-color .2s, box-shadow .2s;
  font-family: inherit; resize: vertical;
  box-shadow: var(--shadow);
}
.input-box:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(124,58,237,.16); }
.input-hint { text-align: center; color: var(--text-soft); font-size: 13px; margin-top: 9px; }

/* Style cards grid */
.styles-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px; margin: 34px 0 8px;
}
.style-card {
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 11px;
  position: relative; overflow: hidden;
  transition: transform .2s cubic-bezier(.16,1,.3,1), box-shadow .2s, border-color .2s;
  animation: rise .5s ease both;
}
.style-card::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: var(--brand-grad); opacity: 0; transition: opacity .3s; mix-blend-mode: overlay;
}
.style-card:hover {
  transform: translateY(-6px) scale(1.012);
  box-shadow: var(--shadow-strong);
  border-color: color-mix(in srgb, var(--brand) 45%, var(--border));
}
.style-card:hover::after { opacity: .07; }
.styles-grid .style-card:nth-child(1) { animation-delay: .04s; }
.styles-grid .style-card:nth-child(2) { animation-delay: .10s; }
.styles-grid .style-card:nth-child(3) { animation-delay: .16s; }
.styles-grid .style-card:nth-child(4) { animation-delay: .22s; }
.styles-grid .style-card:nth-child(5) { animation-delay: .28s; }
.styles-grid .style-card:nth-child(6) { animation-delay: .34s; }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

.style-card .card-head { display: flex; align-items: center; justify-content: space-between; }
.style-card .card-title { font-weight: 700; font-size: 15px; }
.style-card .card-desc { font-size: 12.5px; color: var(--text-soft); margin: 0; }
.preview {
  background: var(--bg-soft); border: 1px dashed var(--border);
  border-radius: 12px; padding: 15px; min-height: 60px;
  font-size: 26px; word-break: break-word; line-height: 1.45;
  font-variant-numeric: tabular-nums;
}
.preview.empty { color: var(--text-soft); font-size: 15px; font-variant-numeric: normal; }

.copy-btn {
  align-self: flex-start; cursor: pointer; border: none; position: relative; overflow: hidden;
  background: var(--brand-grad); color: #fff; font-weight: 600;
  font-size: 13px; padding: 9px 16px; border-radius: 10px;
  transition: filter .15s, transform .12s, box-shadow .15s;
}
.copy-btn::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,.4) 50%, transparent 70%);
  transform: translateX(-120%);
}
.copy-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(124,58,237,.35); }
.copy-btn:hover::before { animation: shimmer .7s ease; }
.copy-btn:active { transform: scale(.96); }
.copy-btn.copied { background: #16a34a; box-shadow: 0 8px 22px rgba(22,163,74,.35); }
@keyframes shimmer { to { transform: translateX(120%); } }

/* Sections */
section.block { padding: 42px 0; border-top: 1px solid var(--border); }
section.block h2 { font-size: 26px; margin: 0 0 16px; letter-spacing: -0.01em; font-weight: 800; }
section.block h2::after {
  content: ""; display: block; width: 50px; height: 3px; margin-top: 11px;
  background: var(--brand-grad); border-radius: 2px;
}
section.block p, section.block li { color: var(--text-soft); }
section.block ul { padding-left: 20px; }
section.block ul li { margin: 6px 0; }

.faq-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 16px 18px; margin-bottom: 14px; box-shadow: var(--shadow);
  transition: border-color .2s, transform .2s;
}
.faq-item:hover { border-color: color-mix(in srgb, var(--brand) 40%, var(--border)); transform: translateY(-2px); }
.faq-item h3 { margin: 0 0 6px; font-size: 16.5px; }
.faq-item p { margin: 0; }

/* Reverse converter (chart / converter page) */
.reverse-box { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.reverse-box textarea {
  width: 100%; min-height: 84px; font-size: 18px; padding: 14px;
  border: 2px solid var(--border); border-radius: 12px; background: var(--surface);
  color: var(--text); font-family: inherit; resize: vertical; transition: border-color .2s, box-shadow .2s;
}
.reverse-box textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(124,58,237,.16); }
.reverse-out { font-size: 20px; padding: 15px; background: var(--bg-soft); border: 1px dashed var(--border); border-radius: 12px; word-break: break-word; min-height: 56px; }
.reverse-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.reverse-row select, .reverse-box select {
  font-size: 15px; padding: 9px 12px; border-radius: 10px; border: 2px solid var(--border);
  background: var(--surface); color: var(--text); font-family: inherit; cursor: pointer;
}

/* Mapping table (chart page) */
.map-wrap { overflow-x: auto; }
.map-table { width: 100%; border-collapse: collapse; margin-top: 16px; font-size: 15px; }
.map-table th, .map-table td { border: 1px solid var(--border); padding: 10px 8px; text-align: center; }
.map-table th { background: var(--bg-soft); font-weight: 700; }
.map-table td.char { font-size: 20px; }
.map-table tbody tr { transition: background .15s; }
.map-table tbody tr:hover { background: var(--bg-soft); }

/* Footer */
.site-footer {
  border-top: 1px solid var(--border); padding: 36px 0 52px; margin-top: 28px;
  position: relative;
}
.site-footer::before {
  content: ""; position: absolute; top: -1px; left: 0; right: 0; height: 1px;
  background: var(--brand-grad); opacity: .5;
}
.footer-links { display: flex; flex-wrap: wrap; gap: 10px 18px; font-size: 14px; }
.footer-links a { color: var(--text-soft); }
.footer-links a:hover { color: var(--brand); }
.footer-note { color: var(--text-soft); font-size: 13px; margin-top: 16px; }

.tag { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--bg-soft); color: var(--text-soft); margin-left: 6px; }

@media (prefers-reduced-motion: reduce) {
  body::before, body::after, .hero h1 .accent, .style-card { animation: none !important; }
  .style-card { transition: none; }
}

@media (max-width: 600px) {
  .nav { display: none; }
  .styles-grid { grid-template-columns: 1fr; }
  .hero { padding: 34px 0 18px; }
}
