/* =====================================================================
   Sidebar navigation
   ===================================================================== */
.nav-link, .nav-category-header {
  width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; margin-bottom: 4px; border-radius: 10px;
  background: none; border: none; text-align: left;
  color: var(--nav-text); font-size: 14px; font-weight: 500; line-height: 1.3;
  transition: color var(--ease), background var(--ease);
}
.nav-link:hover, .nav-category-header:hover { color: #fff; background: var(--nav-hover); }
.nav-link.active { color: #fff; font-weight: 600; background: var(--nav-active); }
.nav-link.active .nav-icon { color: #60a5fa; }
.nav-icon { font-size: 19px; width: 20px; display: inline-flex; justify-content: center; flex-shrink: 0; }
.nav-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-caret { font-size: 15px; transition: transform var(--ease); }
.nav-category.open > .nav-category-header { color: #fff; }
.nav-category.open .nav-caret { transform: rotate(180deg); }

.nav-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 18px; padding: 0 6px; border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 700; line-height: 18px;
  background: rgba(148, 163, 184, 0.22); color: #e2e8f0;
}
.nav-badge.is-new { background: var(--cta); color: var(--nav-bg); }

.nav-section-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: #64748b; margin: 18px 12px 8px;
}
.nav-category-list {
  display: none; flex-direction: column; gap: 2px;
  margin: 0 0 8px 21px; padding-left: 12px; border-left: 1px solid rgba(148, 163, 184, 0.18);
}
.nav-category.open .nav-category-list { display: flex; }
.nav-demo-link {
  padding: 7px 10px; border-radius: 8px; color: var(--nav-text); font-size: 13.5px; line-height: 1.35;
  transition: color var(--ease), background var(--ease);
}
.nav-demo-link:hover { color: #fff; background: var(--nav-hover); }
.nav-demo-link.active { color: #fff; font-weight: 600; background: var(--nav-active); }
.nav-empty { padding: 6px 10px; font-size: 12px; color: #64748b; font-style: italic; }

/* Sidebar search (dark) */
.search-box { position: relative; margin-bottom: 14px; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #64748b; font-size: 16px; pointer-events: auto; }
#search-input {
  width: 100%; background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff; padding: 10px 12px 10px 36px; border-radius: 10px; font-size: 13.5px; outline: none;
  transition: border-color var(--ease), box-shadow var(--ease), background var(--ease);
}
#search-input::placeholder { color: #64748b; }
#search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18); background: rgba(255, 255, 255, 0.06); }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 60; display: none;
  background: var(--nav-card); border: 1px solid var(--nav-border); border-radius: 12px; padding: 6px;
  max-height: 360px; overflow-y: auto; box-shadow: var(--shadow-dropdown-dark);
}
.search-results.open { display: block; }
.search-result {
  display: flex; flex-direction: column; gap: 1px; padding: 8px 10px; border-radius: 8px; font-size: 13.5px; color: #fff;
}
.search-result:hover, .search-result.focused { background: rgba(255, 255, 255, 0.06); }
.search-result-cat { color: var(--nav-text); font-size: 12px; }
.search-empty { padding: 10px; color: var(--nav-text); font-size: 13px; }

/* Sidebar footer: "user card" slot, used for the appearance switcher */
.sb-user-card {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  background: none; border: 1px solid transparent; border-radius: 12px; text-align: left; color: #fff;
  transition: background var(--ease), border-color var(--ease);
}
.sb-user-card:hover, .sb-user-card.open { background: var(--nav-hover); border-color: rgba(255, 255, 255, 0.06); }
.sb-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-grad); color: #fff; font-size: 17px;
}
.sb-user-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.sb-user-name { font-size: 13px; font-weight: 600; color: #fff; }
.sb-user-role { font-size: 12px; color: var(--nav-text); }
.sb-user-caret { color: var(--nav-text); font-size: 15px; transition: transform var(--ease); }
.sb-user-card.open .sb-user-caret { transform: rotate(180deg); }

/* Dark dropdown (opens upwards from the sidebar footer) */
.theme-menu {
  position: absolute; bottom: calc(100% + 8px); left: 0; right: 0; z-index: 60; display: none;
  background: var(--nav-card); border: 1px solid var(--nav-border); border-radius: 12px; padding: 8px;
  box-shadow: var(--shadow-dropdown-dark); animation: pop-in 0.15s ease;
}
.theme-menu.open { display: block; }
.menu-head { padding: 6px 10px 10px; margin-bottom: 6px; border-bottom: 1px solid var(--nav-line); }
.menu-head strong { display: block; font-size: 14px; font-weight: 600; color: #fff; }
.menu-head span { font-size: 12px; color: var(--nav-text); }
.theme-menu { max-height: calc(100vh - 110px); overflow-y: auto; }
.menu-label {
  display: flex; align-items: center; gap: 6px; padding: 6px 10px 4px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: #64748b;
}
.menu-label .ti { font-size: 14px; }
.menu-label-sep { margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--nav-line); }
.lang-badge {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 22px; height: 22px; border-radius: 7px; font-size: 10px; font-weight: 800; letter-spacing: 0.02em;
  background: rgba(255, 255, 255, 0.08); color: #e2e8f0; border: 1px solid rgba(255, 255, 255, 0.14);
}
.theme-option[aria-pressed="true"] .lang-badge { background: var(--accent); border-color: var(--accent); color: #fff; }
.theme-option {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px;
  background: none; border: none; border-radius: 8px; color: #fff; font-size: 14px; text-align: left;
}
.theme-option:hover { background: rgba(255, 255, 255, 0.06); }
.theme-option .ti-check { margin-left: auto; color: #60a5fa; font-size: 17px; }
.theme-swatch { display: inline-flex; flex-shrink: 0; width: 22px; height: 22px; border-radius: 7px; overflow: hidden; border: 1px solid rgba(255, 255, 255, 0.14); }
.theme-swatch i { flex: 1; }

@keyframes pop-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

/* =====================================================================
   Buttons
   ===================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-size: 14.5px; font-weight: 600; line-height: 1.2; white-space: nowrap;
  transition: filter var(--ease), background var(--ease), border-color var(--ease), color var(--ease), transform var(--ease);
}
.btn .ti { font-size: 18px; }
.btn-cta { background: var(--cta); color: var(--cta-ink); }
.btn-cta:hover { filter: brightness(1.07); }
.btn-cta .ti-arrow-right { transition: transform var(--ease); }
.btn-cta:hover .ti-arrow-right { transform: translateX(3px); }
.btn-cta-grad { background: var(--cta-grad); color: #fff; }
.btn-cta-grad:hover { filter: brightness(1.07); }
.btn-confirm { background: var(--accent-grad); color: #fff; }
.btn-confirm:hover { filter: brightness(1.07); }
.btn-secondary { background: var(--surface); border-color: var(--border-input); color: var(--text-body); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-secondary.is-on { border-color: var(--cta); color: var(--cta-strong); background: var(--cta-soft); }
.btn-dark { background: rgba(255, 255, 255, 0.03); border-color: var(--nav-border); color: #fff; }
.btn-dark:hover { border-color: var(--accent); }
.btn-sm { padding: 9px 14px; font-size: 13.5px; }

.icon-btn {
  width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  background: transparent; border: none; border-radius: 8px; color: var(--text-secondary); font-size: 19px;
  transition: background var(--ease), color var(--ease);
}
.icon-btn:hover { background: var(--border); color: var(--text-primary); }
.icon-btn-dark { color: #fff; font-size: 22px; }
.icon-btn-dark:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }

/* Buttons generated by Lab.ui.button inside demo control panels */
.button-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 4px; }
.lab-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 9px; padding: 9px 14px; font-size: 13.5px; font-weight: 600;
  border: 1px solid var(--border-input); background: var(--surface); color: var(--text-body);
  transition: background var(--ease), border-color var(--ease), color var(--ease), filter var(--ease);
}
.lab-btn:hover { border-color: var(--accent); color: var(--accent); }
.lab-btn-primary { background: var(--cta-grad); border-color: transparent; color: #fff; }
.lab-btn-primary:hover { filter: brightness(1.07); color: #fff; border-color: transparent; }
.lab-btn-danger { color: #b91c1c; }
.lab-btn-danger:hover { background: var(--color-danger-soft); border-color: var(--color-danger); color: #b91c1c; }
.lab-btn:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }
.lab-btn:disabled:hover { border-color: var(--border-input); color: var(--text-body); background: var(--surface); }
.lab-btn-primary:disabled:hover { background: var(--cta-grad); color: #fff; border-color: transparent; }

/* =====================================================================
   Home: hero (dark brand zone)
   ===================================================================== */
.hero {
  position: relative; overflow: hidden; isolation: isolate;
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr); gap: 32px; align-items: center;
  background: linear-gradient(160deg, #10203d 0%, #060c19 100%);
  border: 1px solid var(--nav-border); border-radius: var(--radius-xl);
  padding: 56px 56px 52px; color: #fff;
}
.hero-stars { position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.hero-stars span { position: absolute; width: 1px; height: 1px; background: #fff; border-radius: 50%; }
.hero-rings { position: absolute; right: -210px; bottom: -310px; z-index: -1; pointer-events: none; }
.hero-rings span { position: absolute; left: 50%; top: 50%; border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 50%; transform: translate(-50%, -50%); }
.hero-rings span:nth-child(1) { width: 420px; height: 420px; }
.hero-rings span:nth-child(2) { width: 620px; height: 620px; }

.hero-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; margin-bottom: 22px;
  border: 1px solid var(--nav-border); background: rgba(255, 255, 255, 0.03); border-radius: var(--radius-pill);
  font-size: 12px; color: #cbd5e1;
}
.hero-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.18); }
.hero h1 { font-size: 52px; line-height: 1.1; font-weight: 800; color: #fff; margin-bottom: 18px; letter-spacing: -0.02em; }
.hero h1 .accent { color: var(--cta); }
.hero-sub { font-size: 17px; line-height: 1.6; color: #b1afaf; max-width: 480px; margin-bottom: 30px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 40px; }
.hero-stats { display: flex; flex-wrap: wrap; gap: 36px; }
.hero-stat strong { display: block; font-size: 26px; font-weight: 800; color: #fff; line-height: 1.1; }
.hero-stat span { font-size: 13px; color: var(--nav-text); }

.hero-art { position: relative; display: flex; align-items: center; justify-content: center; min-height: 320px; }
.hero-art::before {
  content: ''; position: absolute; width: 380px; height: 380px; border-radius: 50%;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.16), transparent 70%);
}
.hero-art::after {
  content: ''; position: absolute; bottom: 8px; width: 200px; height: 22px; border-radius: 50%;
  background: rgba(0, 0, 0, 0.45); filter: blur(10px);
}
.hero-art .sparky-mascot { position: relative; z-index: 1; width: 300px; max-width: 100%; animation: float 5s ease-in-out infinite; }

@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

/* =====================================================================
   Mascot
   ===================================================================== */
.sparky-mascot { display: block; overflow: visible; cursor: pointer; user-select: none; }
.sparky-mascot .sm-eye { transform-box: fill-box; transform-origin: center; transition: transform 0.08s ease; }
.sparky-mascot.blink .sm-eye { transform: scaleY(0.08); }
.sparky-mascot .sm-bolt { transform-box: fill-box; transform-origin: 50% 100%; animation: bolt-glow 3.2s ease-in-out infinite; }
.sparky-mascot.shake .sm-body { animation: shake 0.5s ease; transform-box: fill-box; transform-origin: 50% 100%; }
@keyframes bolt-glow {
  0%, 100% { filter: drop-shadow(0 0 0 rgba(245, 160, 30, 0)); }
  50% { filter: drop-shadow(0 0 14px rgba(245, 160, 30, 0.55)); }
}
@keyframes shake {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(-6deg); }
  40% { transform: rotate(5deg); }
  60% { transform: rotate(-3deg); }
  80% { transform: rotate(2deg); }
}

/* =====================================================================
   Sections, page headers
   ===================================================================== */
.section { margin-top: 56px; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.kicker { display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); margin-bottom: 6px; }
.kicker.orange { color: var(--cta-strong); }
.section-title { font-size: 32px; font-weight: 800; margin: 0; }
.link-arrow { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; color: var(--accent); }
.link-arrow:hover { color: var(--accent-strong); }

.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 28px; flex-wrap: wrap; }
.page-header-main { display: flex; align-items: flex-start; gap: 16px; min-width: 0; }
.page-header h1 { font-size: 30px; font-weight: 800; margin-bottom: 4px; }
.page-header p { font-size: 15px; margin: 0; max-width: 720px; }
.page-header-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.breadcrumb { display: flex; align-items: center; gap: 6px; margin-bottom: 14px; font-size: 13px; color: var(--text-tertiary); }
.breadcrumb a { color: var(--text-secondary); font-weight: 500; transition: color var(--ease); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .ti { font-size: 14px; }

/* Tinted icon squares */
.icon-square {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center; font-size: 22px;
  background: var(--accent-soft); color: var(--accent);
}
.icon-square.lg { width: 52px; height: 52px; border-radius: 14px; font-size: 26px; }
.tone-blue { --tone: #3b82f6; --tone-soft: rgba(59, 130, 246, 0.12); --tone-grad: linear-gradient(135deg, #2f5fd6, #1c3a94); }
.tone-orange { --tone: #ff9d41; --tone-soft: rgba(255, 157, 65, 0.16); --tone-grad: linear-gradient(135deg, #ff9d41, #c96a1c); }
.tone-green { --tone: #6fb83f; --tone-soft: rgba(111, 184, 63, 0.16); --tone-grad: linear-gradient(135deg, #6fb83f, #2f7a2a); }
.tone-purple { --tone: #b267d4; --tone-soft: rgba(178, 103, 212, 0.16); --tone-grad: linear-gradient(135deg, #b267d4, #6d3291); }
.tone-mustard { --tone: #afa72e; --tone-soft: rgba(175, 167, 46, 0.18); --tone-grad: linear-gradient(135deg, #c4bb3a, #7d7612); }
[class*="tone-"] .icon-square, .icon-square[class*="tone-"] { background: var(--tone-soft); color: var(--tone); }

/* =====================================================================
   Stat cards
   ===================================================================== */
.stat-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; margin-bottom: 28px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 20px 22px; box-shadow: var(--shadow-card); }
.stat-card-label { font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.stat-card-value { font-size: 26px; font-weight: 800; color: var(--text-primary); line-height: 1.1; }
.stat-card-value.blue { color: var(--accent); }
.stat-card-value.green { color: var(--color-positive); }
.stat-card-value.orange { color: var(--cta-strong); }

/* =====================================================================
   Toolbar: segmented tabs + search
   ===================================================================== */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 24px; flex-wrap: wrap; }
.segmented { display: inline-flex; gap: 2px; padding: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; flex-wrap: wrap; }
.segmented button {
  border: none; background: none; padding: 7px 14px; border-radius: 8px;
  font-size: 13.5px; font-weight: 600; color: var(--text-secondary); transition: color var(--ease), background var(--ease);
}
.segmented button:hover { color: var(--text-primary); }
.segmented button.active { background: var(--nav-bg); color: #fff; }
.input-search { position: relative; width: 260px; }
.input-search .ti { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-tertiary); font-size: 17px; }
.input-search input { width: 100%; padding-left: 38px; }

.text-input {
  background: var(--surface); border: 1px solid var(--border-input); border-radius: var(--radius-sm);
  padding: 11px 14px; font-size: 14px; color: var(--text-primary); outline: none;
  transition: border-color var(--ease), box-shadow var(--ease);
}
.text-input::placeholder { color: var(--text-tertiary); }
.text-input:focus { border-color: var(--accent); box-shadow: var(--focus-ring); }

/* =====================================================================
   Demo cards
   ===================================================================== */
.card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }

.demo-card {
  position: relative; display: flex; flex-direction: column; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: transform var(--ease), box-shadow var(--ease), border-color var(--ease);
}
.demo-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.demo-card-preview {
  height: 160px; background: var(--sim-bg); position: relative; display: flex; align-items: center;
  justify-content: center; overflow: hidden;
}
.demo-card-preview.preview-fallback { background: var(--tone-grad, linear-gradient(135deg, #2f5fd6, #1c3a94)); }
.demo-card-preview.preview-fallback .ti { font-size: 56px; color: #fff; opacity: 0.95; }
.demo-card-preview canvas { width: 100%; height: 100%; display: block; }
.card-pill {
  position: absolute; top: 12px; left: 12px; z-index: 2;
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.22); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  color: #fff; font-size: 11px; font-weight: 700; letter-spacing: 0.02em;
}
.card-pill .ti { font-size: 13px; }
.demo-card-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.demo-card-body h3 { font-size: 16px; font-weight: 700; margin: 0; }
.demo-card-desc {
  font-size: 13.5px; line-height: 1.5; margin: 0; color: var(--text-secondary);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.demo-card-meta { margin-top: auto; padding-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: var(--radius-pill); background: var(--surface-hover); color: var(--text-secondary); font-size: 11.5px; font-weight: 600; }

/* Favorite toggle: round glass button on the card banner */
.fav-toggle {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  width: 32px; height: 32px; border-radius: 50%; border: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.22); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  color: #fff; font-size: 17px; opacity: 0; transition: opacity var(--ease), background var(--ease), color var(--ease), transform var(--ease);
}
.demo-card:hover .fav-toggle, .demo-card:focus-within .fav-toggle, .fav-toggle.active { opacity: 1; }
.fav-toggle:hover { background: rgba(255, 255, 255, 0.35); transform: scale(1.06); }
.fav-toggle.active { background: var(--cta); color: var(--cta-ink); }
@media (hover: none) { .fav-toggle { opacity: 1; } }

/* Card illustrations (js/previews.js): navy banner, dot grid, glow in the category tone */
.demo-card-preview.pv {
  background:
    radial-gradient(circle at 50% 62%, color-mix(in srgb, var(--tone, #3b82f6) 26%, transparent), transparent 62%),
    radial-gradient(rgba(148, 163, 184, 0.14) 1px, transparent 1.2px) 0 0 / 16px 16px,
    linear-gradient(160deg, #10203d 0%, #0b1329 100%);
}
.pv-svg { width: 100%; height: 100%; display: block; overflow: visible; }
.demo-card-preview.pv canvas { width: 100%; height: 100%; display: block; }
.pv-anim { transform-box: view-box; animation-play-state: paused; animation-duration: 1.6s; animation-timing-function: ease-in-out; animation-iteration-count: infinite; }
.demo-card:hover .pv-anim, .demo-card:focus-visible .pv-anim { animation-play-state: running; }
.pv-spring { transform-origin: 67px 104px; animation-name: pv-spring; }
.pv-mass { animation-name: pv-mass; }
.pv-bob-v { transform-origin: 110px 44px; animation-name: pv-bob-v; }
.pv-swing { transform-origin: 160px 48px; animation-name: pv-swing; animation-duration: 2.2s; }
.pv-bounce { animation-name: pv-bounce; animation-duration: 1.1s; animation-timing-function: cubic-bezier(.5, 0, .5, 1); }
.pv-glow { transform-box: fill-box; transform-origin: center; animation-name: pv-glow; }
.pv-pulse { animation-name: pv-pulse; }
.pv-drift { animation-name: pv-drift; animation-timing-function: steps(1); animation-duration: 1.2s; }
.pv-flow { animation-name: pv-flow; animation-timing-function: linear; animation-duration: 1s; }
.pv-slide { animation-name: pv-slide; }
.pv-needle-swing { transform-box: view-box; animation-name: pv-needle; }
.pv-draw { animation-name: pv-draw; animation-duration: 2.4s; animation-timing-function: linear; }
@keyframes pv-spring { 50% { transform: scaleX(0.72); } }
@keyframes pv-mass { 50% { transform: translateX(-33px); } }
@keyframes pv-bob-v { 50% { transform: scaleY(0.84); } }
@keyframes pv-swing { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-24deg); } }
@keyframes pv-bounce { 50% { transform: translateY(66px) scaleY(0.9); } }
@keyframes pv-glow { 50% { transform: scale(1.3); opacity: 0.7; } }
@keyframes pv-pulse { 50% { transform: translate(10px, -4px); } }
@keyframes pv-drift { 50% { transform: translate(10px, 10px); } }
@keyframes pv-flow { to { stroke-dashoffset: -32; } }
@keyframes pv-slide { 50% { transform: translateX(34px); } }
@keyframes pv-needle { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(38deg); } }
@keyframes pv-draw { to { stroke-dashoffset: -100; } }

/* "Explore more" card (dashed) */
.new-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center;
  min-height: 280px; padding: 24px; border-radius: var(--radius-lg);
  background: #eef2fb; border: 2px dashed #c7d3ec; transition: border-color var(--ease), background var(--ease);
}
.new-card:hover { border-color: var(--accent); }
.new-card-title { font-size: 16px; font-weight: 700; color: var(--accent); }
.new-card p { font-size: 13px; margin: 0; max-width: 220px; }

/* =====================================================================
   Category cards
   ===================================================================== */
.category-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.category-card {
  display: flex; flex-direction: column; gap: 14px; padding: 24px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card); transition: transform var(--ease), box-shadow var(--ease);
}
.category-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.category-card h3 { font-size: 17px; font-weight: 700; margin: 0 0 4px; }
.category-card p { font-size: 14px; line-height: 1.55; color: #5b6472; margin: 0; }
.category-card-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--text-tertiary); }
.category-card-foot .ti { color: var(--accent); font-size: 17px; transition: transform var(--ease); }
.category-card:hover .category-card-foot .ti { transform: translateX(3px); }

/* =====================================================================
   CTA banner
   ===================================================================== */
.cta-banner {
  position: relative; overflow: hidden; margin-top: 56px;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  background: linear-gradient(135deg, #2151d1, #0b1329); border-radius: var(--radius-xl);
  padding: 48px 56px; color: #fff;
}
.cta-banner h2 { color: #fff; font-size: 28px; font-weight: 800; margin-bottom: 8px; letter-spacing: -0.01em; }
.cta-banner p { color: #c7d2fe; font-size: 15px; margin: 0; max-width: 520px; }
.cta-banner > * { position: relative; z-index: 1; }
.cta-bolt { position: absolute !important; right: 180px; top: 50%; transform: translateY(-50%) rotate(12deg); font-size: 160px; opacity: 0.06; z-index: 0 !important; pointer-events: none; }

/* =====================================================================
   Empty states / 404
   ===================================================================== */
.empty-state {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px;
  padding: 60px 24px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
}
.empty-state .icon-square { margin-bottom: 8px; }
.empty-title { font-size: 17px; font-weight: 700; color: var(--text-primary); margin: 0; }
.empty-sub { font-size: 14px; color: var(--text-tertiary); margin: 0 0 14px; }

.not-found { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 56px 20px; }
.not-found .sparky-mascot { width: 110px; transform: rotate(-8deg); margin-bottom: 8px; }
.not-found-code { font-size: 64px; font-weight: 900; color: var(--cta); line-height: 1; margin-bottom: 10px; }
.not-found h1 { font-size: 24px; font-weight: 800; }
.not-found p { max-width: 380px; margin-bottom: 24px; }
.not-found-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* =====================================================================
   Demo page
   ===================================================================== */
.demo-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.demo-title-row h1 { margin: 0 0 6px; font-size: 30px; font-weight: 800; }
.demo-description-lg { max-width: 760px; margin: 0; font-size: 15px; }
.demo-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }

/* Controls panel */
.panel-section-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-tertiary);
  margin: 20px 0 12px;
}
.panel-section-title:first-child { margin-top: 0; }
.control-group { margin-bottom: 16px; }
.control-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; gap: 8px; }
.control-label { font-size: 13px; font-weight: 600; color: var(--text-body); }
.control-value { font-family: var(--font-mono); font-size: 12.5px; color: var(--accent); font-weight: 600; white-space: nowrap; }
.control-hint { font-size: 12px; color: var(--text-tertiary); margin: -8px 0 14px; }
.control-number-input {
  width: 64px; background: var(--surface-alt); border: 1px solid var(--border-input); color: var(--text-primary);
  font-family: var(--font-mono); font-size: 12.5px; padding: 4px 7px; border-radius: 7px;
  text-align: right; -moz-appearance: textfield; outline: none; transition: border-color var(--ease), box-shadow var(--ease);
}
.control-number-input::-webkit-inner-spin-button, .control-number-input::-webkit-outer-spin-button {
  -webkit-appearance: none; appearance: none; margin: 0;
}
.control-number-input:focus { border-color: var(--accent); box-shadow: var(--focus-ring); }
.control-unit { font-family: var(--font-mono); font-size: 12px; color: var(--text-tertiary); white-space: nowrap; }

/* Collapsible control-panel sections (native <details>/<summary>) */
.panel-collapsible { border-top: 1px solid var(--border); margin-top: 16px; padding-top: 2px; }
.panel-collapsible-summary {
  cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between;
  margin: 12px 0 10px; user-select: none;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-tertiary);
}
.panel-collapsible-summary::-webkit-details-marker { display: none; }
.panel-collapsible-summary::after {
  content: ''; width: 8px; height: 8px; margin-right: 4px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px); transition: transform var(--ease);
}
.panel-collapsible[open] > .panel-collapsible-summary::after { transform: rotate(-135deg) translateY(-2px); }
.panel-collapsible-summary:hover { color: var(--accent); }
.panel-collapsible-body :last-child { margin-bottom: 0; }

/* Range sliders */
input[type=range].slider {
  -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 999px;
  background: var(--surface-sunken); outline: none; display: block; margin: 4px 0;
}
input[type=range].slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); cursor: pointer; border: 3px solid var(--surface);
  box-shadow: 0 0 0 1px var(--accent), 0 2px 6px rgba(11, 19, 41, 0.2); transition: transform var(--ease);
}
input[type=range].slider::-webkit-slider-thumb:hover { transform: scale(1.12); }
input[type=range].slider::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%; background: var(--accent); cursor: pointer;
  border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--accent);
}
input[type=range].slider::-moz-range-progress { background: var(--accent); height: 6px; border-radius: 999px; }
input[type=range].slider:focus-visible { box-shadow: var(--focus-ring); }

/* Selects */
.select-input {
  -webkit-appearance: none; appearance: none; width: 100%;
  background: var(--surface-alt) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239aa3b2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6l6 -6'/%3E%3C/svg%3E") no-repeat right 10px center;
  border: 1px solid var(--border-input); color: var(--text-primary);
  padding: 9px 34px 9px 12px; border-radius: var(--radius-sm); font-size: 13.5px; margin-top: 6px; outline: none; cursor: pointer;
  transition: border-color var(--ease), box-shadow var(--ease);
}
.select-input:hover { border-color: var(--border-strong); }
.select-input:focus { border-color: var(--accent); box-shadow: var(--focus-ring); }

/* Checkboxes */
.checkbox-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.checkbox-row input[type=checkbox] {
  -webkit-appearance: none; appearance: none; flex-shrink: 0; margin: 0; cursor: pointer;
  width: 18px; height: 18px; border-radius: 6px; border: 1.5px solid var(--border-strong); background: var(--surface);
  display: inline-grid; place-content: center; transition: background var(--ease), border-color var(--ease);
}
.checkbox-row input[type=checkbox]::after {
  content: ''; width: 5px; height: 9px; border-right: 2px solid #fff; border-bottom: 2px solid #fff;
  transform: rotate(45deg) translate(-1px, -1px) scale(0); transition: transform 0.12s ease;
}
.checkbox-row input[type=checkbox]:checked { background: var(--accent); border-color: var(--accent); }
.checkbox-row input[type=checkbox]:checked::after { transform: rotate(45deg) translate(-1px, -1px) scale(1); }
.checkbox-row input[type=checkbox]:hover { border-color: var(--accent); }
.checkbox-label { font-size: 13.5px; color: var(--text-body); cursor: pointer; }

.formula-box {
  font-family: var(--font-mono); font-size: 15px; text-align: center; background: var(--surface-alt);
  border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin: 10px 0; color: var(--accent-strong);
  letter-spacing: 0.02em; font-weight: 600;
}

/* Stats */
.stat-row { display: flex; flex-direction: column; gap: 4px; }
.stat-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-tertiary); }
.stat-value { font-family: var(--font-mono); font-size: 18px; font-weight: 700; color: var(--text-primary); }

/* Charts */
.chart-wrapper { width: 100%; height: 170px; background: var(--sim-bg); border-radius: 12px; grid-column: 1 / -1; }
.chart-wrapper canvas { width: 100%; height: 100%; display: block; }
.chart-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-tertiary);
  margin: 6px 0 6px; grid-column: 1 / -1;
}
.demo-sim .chart-title { color: #94a3b8; }

.demo-error {
  display: flex; align-items: center; justify-content: center; width: 100%; height: 100%;
  color: #fca5a5; font-size: 14px; padding: 20px; text-align: center;
}

/* Explanation */
.demo-explanation h2 { font-size: 19px; font-weight: 800; display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.demo-explanation h2 .icon-square { width: 36px; height: 36px; border-radius: 10px; font-size: 19px; }
.how-it-works-body { max-width: 820px; }
.how-it-works-body p { font-size: 14.5px; line-height: 1.65; color: var(--text-body); }
.how-it-works-body ul { padding-left: 20px; font-size: 14.5px; line-height: 1.65; color: var(--text-body); }
.how-it-works-body li { margin-bottom: 4px; }
.how-it-works-body li::marker { color: var(--cta); }
.how-it-works-body strong { color: var(--text-primary); }
.how-it-works-body code { font-family: var(--font-mono); font-size: 13px; background: var(--surface-hover); padding: 1px 6px; border-radius: 6px; }

/* Sorting visualization */
.sort-canvas-wrap { width: 100%; height: 100%; display: flex; flex-direction: column; padding: 16px; }
.sort-canvas-wrap canvas { flex: 1; min-height: 0; width: 100%; height: auto; }
.sort-legend { display: flex; gap: 16px; font-size: 11px; color: #94a3b8; padding-top: 10px; flex-wrap: wrap; }
.sort-legend span { display: flex; align-items: center; gap: 5px; }
.sort-legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }

/* Resistor Networks: circuit builder tree cards */
.circuit-group-card {
  border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 12px;
  background: var(--surface-alt); padding: 10px 12px; margin-bottom: 10px;
}
.circuit-group-card.parallel { border-left-color: var(--color-purple); }
.circuit-group-card .circuit-group-card { background: var(--surface); }
.circuit-group-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); }
.circuit-group-card.parallel .circuit-group-label { color: var(--color-purple); }
.circuit-resistor-card {
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
  padding: 10px 12px; margin: 0 0 8px;
}
.circuit-row-split { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.circuit-value-row { display: flex; gap: 6px; margin: 8px 0; }
.circuit-value-row .control-number-input { flex: 0 0 64px; }
.circuit-value-row select { flex: 1; margin: 0; }
.circuit-footer-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
.circuit-footer-row .checkbox-row { margin: 0; }

/* Game of Life */
.gol-rule-toggles { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.gol-rule-btn {
  width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--border-input);
  background: var(--surface-alt); color: var(--text-secondary); font-family: var(--font-mono); font-size: 12px;
  display: flex; align-items: center; justify-content: center; padding: 0; transition: border-color var(--ease), background var(--ease);
}
.gol-rule-btn:hover { border-color: var(--accent); }
.gol-rule-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.gol-rule-btn.active.survival { background: var(--color-positive); border-color: var(--color-positive); }
.code-box {
  font-family: var(--font-mono); font-size: 12px; line-height: 1.6; white-space: pre; overflow-x: auto;
  background: var(--sim-bg); border: 1px solid var(--nav-border); border-radius: 12px;
  padding: 12px 14px; color: #cbd5e1; margin: 10px 0 4px;
}

/* Generic full-size sim canvas wrap */
.sim-fill { width: 100%; height: 100%; position: relative; }
.sim-fill canvas { width: 100%; height: 100%; display: block; }
.sim-hint {
  position: absolute; bottom: 12px; left: 12px; font-size: 12px; color: #cbd5e1;
  background: rgba(11, 19, 41, 0.72); border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 5px 10px; border-radius: 8px; pointer-events: none; backdrop-filter: blur(4px);
}
.sim-progress-wrap { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 12px; background: rgba(11, 19, 41, 0.6); }
.sim-progress-bar { width: 220px; height: 6px; background: rgba(255, 255, 255, 0.12); border-radius: 999px; overflow: hidden; }
.sim-progress-fill { height: 100%; background: var(--cta-grad); width: 0%; transition: width 0.1s linear; }
.sim-progress-label { font-size: 13px; color: #cbd5e1; font-family: var(--font-mono); }

/* =====================================================================
   About page
   ===================================================================== */
.about-lead { font-size: 16px; line-height: 1.65; color: var(--text-body); max-width: 720px; margin: 0 0 28px; }
.about-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.about-step-top { display: flex; align-items: center; justify-content: space-between; }
.about-step-num { font-size: 28px; font-weight: 800; color: var(--tone); opacity: 0.3; font-family: var(--font-mono); }
.about-area-head { display: flex; align-items: center; gap: 14px; }
.about-area-head h3 { margin: 0; }
.about-area-head h3 a { transition: color var(--ease); }
.about-area-head h3 a:hover { color: var(--accent); }
.about-area-count { font-size: 13px; color: var(--text-tertiary); }
.tag-link { transition: background var(--ease), color var(--ease); }
.tag-link:hover { background: var(--accent-soft); color: var(--accent); }
.powered-pill { color: #cbd5e1; transition: border-color var(--ease); }
.powered-pill:hover { border-color: var(--cta); }
.powered-pill .ti { color: var(--cta); font-size: 14px; }
.powered-pill strong { color: #fff; font-weight: 700; margin-left: -4px; }

/* Powered by Sparky card */
.powered-card {
  display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-card);
}
.powered-brand {
  position: relative; overflow: hidden; isolation: isolate; min-height: 320px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 32px;
  background: linear-gradient(160deg, #10203d 0%, #060c19 100%);
}
.powered-brand .hero-rings { right: auto; bottom: auto; left: 50%; top: 50%; }
.powered-art { position: relative; }
.powered-art::before { content: ''; position: absolute; inset: -40px; border-radius: 50%; background: radial-gradient(circle, rgba(59, 130, 246, 0.2), transparent 70%); z-index: -1; }
.powered-art .sparky-mascot { width: 160px; }
.powered-mark { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.powered-mark span { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; color: var(--nav-text); }
.powered-mark strong { font-size: 30px; font-weight: 800; color: #fff; letter-spacing: -0.01em; }
.powered-body { padding: 40px 44px; display: flex; flex-direction: column; justify-content: center; }
.powered-body .section-title { margin-bottom: 14px; }
.powered-body .about-lead { margin-bottom: 14px; }
.powered-body .hero-actions { margin: 10px 0 0; }

/* =====================================================================
   Responsive
   ===================================================================== */
@media (max-width: 1250px) {
  .hero { padding: 44px 40px; }
  .hero h1 { font-size: 44px; }
}
@media (max-width: 1050px) {
  .card-grid, .category-grid, .about-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .powered-card { grid-template-columns: 1fr; }
  .powered-brand { min-height: 260px; }
  .powered-body { padding: 28px 24px; }
  .demo-controls-panel { padding: 0; border: none; background: none; box-shadow: none; }
  .controls-toggle {
    display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
    padding: 13px 16px; color: var(--text-primary); font-size: 14px; font-weight: 600; margin-bottom: 10px;
  }
  .controls-toggle .ti-chevron-down { margin-left: auto; transition: transform var(--ease); color: var(--text-tertiary); }
  .demo-controls-panel.expanded .controls-toggle .ti-chevron-down { transform: rotate(180deg); }
  .demo-controls-body { display: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 18px; }
  .demo-controls-panel.expanded .demo-controls-body { display: block; }
}
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; text-align: center; padding: 40px 24px; }
  .hero-sub { margin-left: auto; margin-right: auto; }
  .hero-actions, .hero-stats { justify-content: center; }
  .hero-art { order: -1; min-height: 200px; }
  .hero-art .sparky-mascot { width: 190px; }
  .hero-art::before { width: 260px; height: 260px; }
  .stat-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cta-banner { padding: 36px 32px; }
}
@media (max-width: 700px) {
  .card-grid, .category-grid, .about-grid { grid-template-columns: 1fr; }
  .stat-cards { gap: 12px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .input-search { width: 100%; }
  .cta-banner { flex-direction: column; align-items: flex-start; }
  .section-title { font-size: 26px; }
  .page-header h1, .demo-title-row h1 { font-size: 26px; }
}
@media (max-width: 560px) {
  .hero h1 { font-size: 38px; }
  .hero-stats { gap: 24px; }
}
.fav-toggle.active .ti, .btn-secondary.is-on .ti { -webkit-text-stroke: 1.2px currentColor; }
