:root {
  --bg: #0B0E14;
  --surface: #131823;
  --surface-hover: #1A2131;
  --stage: #06080D;
  --border: #222B3D;
  --border-strong: #32405B;
  --text: #E2E8F0;
  --muted: #94A3B8;
  --cyan: #38BDF8;
  --violet: #A855F7;
  --coral: #F43F5E;
  --emerald: #34D399;
  --radius: 14px;
  --radius-sm: 9px;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); color: var(--text); font-family: var(--font-sans); line-height: 1.6; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; overflow-x: clip; max-width: 100%; }
body {
  margin: 0; min-height: 100vh; max-width: 100%; overflow-x: clip;
  background: radial-gradient(circle at 18% 0%, rgba(56, 189, 248, 0.06), transparent 42%), radial-gradient(circle at 82% 8%, rgba(168, 85, 247, 0.06), transparent 40%), var(--bg);
  color: var(--text); display: flex; flex-direction: column;
}
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.wrap { width: 100%; max-width: 1160px; margin: 0 auto; padding: 0 20px; }
main { flex: 1; padding-bottom: 48px; min-width: 0; }

.hero-grid > *, .card-grid > *, .controls-grid > *, .exp-grid > *, .guide-article > *, .footer-grid > * { min-width: 0; }

.site-header { position: sticky; top: 0; z-index: 40; background: rgba(11, 14, 20, 0.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.nav-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; flex-wrap: wrap; padding: 8px 0; }
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--text); font-weight: 700; font-size: 1.08rem; letter-spacing: -0.02em; }
.brand:hover { text-decoration: none; color: #fff; }
.brand-mark { width: 28px; height: 28px; flex-shrink: 0; }
.nav-links { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.nav-links a { color: var(--muted); font-size: 0.94rem; font-weight: 500; }
.nav-links a:hover, .nav-links a[aria-current="page"] { color: var(--text); text-decoration: none; }
.nav-actions, .toolbar-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.nav-mobile-only { display: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 7px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 0.88rem; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.1s ease;
}
.btn.nav-toggle { display: none; }
.btn:hover { background: var(--surface-hover); border-color: var(--border-strong); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: rgba(56, 189, 248, 0.14); border-color: rgba(56, 189, 248, 0.45); color: #BAE6FD; }
.btn-primary:hover { background: rgba(56, 189, 248, 0.22); border-color: var(--cyan); }
.btn-accent { background: linear-gradient(135deg, rgba(56, 189, 248, 0.22), rgba(168, 85, 247, 0.22)); border-color: rgba(168, 85, 247, 0.5); color: #F8FAFC; }
.btn.is-active, .btn.is-saved { background: rgba(52, 211, 153, 0.16); border-color: var(--emerald); color: #A7F3D0; }

.breadcrumbs { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 16px 0 8px; font-size: 0.85rem; color: var(--muted); }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--cyan); }
.lab-head { margin-bottom: 14px; }
.lab-head h1, .page-head h1 { margin: 0 0 6px; font-size: clamp(1.48rem, 3vw, 2.2rem); line-height: 1.18; letter-spacing: -0.025em; }
.lab-hook, .page-hook { margin: 0; color: var(--muted); font-size: 0.98rem; max-width: 72ch; }

.stage-shell { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35); max-width: 100%; }
.stage-wrap {
  position: relative; width: 100%; aspect-ratio: 16 / 10; background: var(--stage);
  overflow: hidden; touch-action: none; overscroll-behavior: contain; user-select: none; -webkit-user-select: none;
}
.stage-canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.stage-hud { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; flex-wrap: wrap; gap: 6px; pointer-events: none; z-index: 3; }
.hud-pill { background: rgba(11, 14, 20, 0.8); border: 1px solid rgba(50, 64, 91, 0.85); border-radius: 999px; padding: 4px 10px; font-size: 0.77rem; font-family: var(--font-mono); color: var(--text); }
.stage-status-badge {
  position: absolute; bottom: 12px; left: 12px; background: rgba(11, 14, 20, 0.85);
  border: 1px solid var(--border-strong); border-radius: 999px; padding: 4px 11px;
  font-size: 0.78rem; color: var(--cyan); pointer-events: none; z-index: 3; opacity: 0; transition: opacity 0.2s ease;
}
.stage-status-badge.is-visible { opacity: 1; }
.stage-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 12px 16px; background: var(--surface); border-top: 1px solid var(--border); }

.stage-shell.is-zen, .stage-shell:fullscreen { width: 100vw; height: 100dvh; max-width: none; border-radius: 0; border: 0; display: flex; flex-direction: column; background: var(--stage); }
.stage-shell.is-zen { position: fixed; inset: 0; z-index: 80; }
.stage-shell.is-zen .stage-wrap, .stage-shell:fullscreen .stage-wrap { flex: 1; aspect-ratio: auto; height: 100%; }

.preset-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--border); background: rgba(11, 14, 20, 0.45); }
.preset-label { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-right: 4px; }
.preset-chip {
  min-height: 36px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 0.84rem; font-weight: 600; cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.preset-chip:hover { border-color: var(--cyan); background: var(--surface-hover); }
.preset-chip.is-active { border-color: var(--cyan); background: rgba(56, 189, 248, 0.18); color: #E0F2FE; }

.controls-panel { padding: 16px; border-top: 1px solid var(--border); background: var(--surface); }
.controls-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px 18px; }
.control-item { display: flex; flex-direction: column; gap: 6px; }
.control-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 0.88rem; }
.control-top label { font-weight: 600; color: var(--text); }
.control-val { font-family: var(--font-mono); font-size: 0.84rem; color: var(--cyan); }
.control-item input[type="range"] { width: 100%; height: 34px; margin: 0; background: transparent; appearance: none; cursor: pointer; }
.control-item input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 999px; background: var(--border); }
.control-item input[type="range"]::-webkit-slider-thumb {
  appearance: none; width: 22px; height: 22px; margin-top: -8px; border-radius: 50%;
  background: var(--cyan); border: 2px solid var(--stage); box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.35);
}
.control-item input[type="range"]::-moz-range-track { height: 6px; border-radius: 999px; background: var(--border); }
.control-item input[type="range"]::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--cyan); border: 2px solid var(--stage); }
.control-item select { min-height: 40px; padding: 6px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--stage); color: var(--text); width: 100%; }
.control-toggle {
  display: flex; align-items: center; justify-content: space-between; min-height: 42px;
  padding: 6px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--stage); cursor: pointer; font-size: 0.88rem; font-weight: 600;
}
.control-toggle input { width: 19px; height: 19px; accent-color: var(--cyan); flex-shrink: 0; }

.find-next-section { margin-top: 26px; }
.hop-strip { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; }
.section-title { margin: 0 0 14px; font-size: 1.3rem; letter-spacing: -0.015em; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.lab-card {
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; color: var(--text); text-decoration: none;
  transition: border-color 0.16s ease, transform 0.16s ease;
}
.lab-card:hover { border-color: var(--cyan); transform: translateY(-2px); text-decoration: none; }
.card-thumb { width: 100%; aspect-ratio: 16 / 10; background: var(--stage); border-bottom: 1px solid var(--border); overflow: hidden; }
.card-thumb svg { display: block; width: 100%; height: 100%; }
.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-tag {
  display: inline-block; align-self: flex-start; font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--cyan); background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.25); border-radius: 999px; padding: 2px 9px;
}
.card-title { margin: 2px 0 0; font-size: 1.04rem; font-weight: 700; color: var(--text); }
.card-desc { margin: 0; font-size: 0.88rem; color: var(--muted); }

.ad-safe-band { margin-top: 32px; padding-top: 28px; border-top: 1px solid var(--border); }
.guide-article { display: grid; gap: 22px; }
.guide-block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px 24px; max-width: 100%; }
.guide-block h2 { margin: 0 0 12px; font-size: 1.28rem; letter-spacing: -0.015em; }
.guide-block h3 { margin: 16px 0 8px; font-size: 1.04rem; color: #BAE6FD; }
.guide-block p { margin: 0 0 12px; color: var(--text); overflow-wrap: break-word; }
.guide-block p:last-child { margin-bottom: 0; }
.guide-svg-box { margin: 16px 0; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--stage); overflow: hidden; }
.guide-svg-box svg { display: block; width: 100%; height: auto; }
.exp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(225px, 1fr)); gap: 14px; margin-top: 12px; }
.exp-card { background: var(--stage); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; display: flex; flex-direction: column; justify-content: space-between; gap: 10px; }
.exp-card h3 { margin: 0 0 6px; font-size: 0.98rem; color: var(--cyan); }
.exp-card p { margin: 0; font-size: 0.88rem; color: var(--muted); }
.formula-box { background: var(--stage); border: 1px solid var(--border); border-left: 3px solid var(--violet); border-radius: var(--radius-sm); padding: 12px 16px; margin: 14px 0; font-family: var(--font-mono); font-size: 0.92rem; color: #E9D5FF; overflow-x: auto; max-width: 100%; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-top: 10px; max-width: 100%; }
.param-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; text-align: left; }
.param-table th, .param-table td { padding: 11px 14px; border-bottom: 1px solid var(--border); }
.param-table th { background: var(--stage); color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; }
.param-table tr:last-child td { border-bottom: 0; }
.faq-list { display: grid; gap: 10px; }
.faq-item { background: var(--stage); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; }
.faq-item h3 { margin: 0 0 6px; font-size: 1rem; color: var(--text); }
.faq-item p { margin: 0; font-size: 0.92rem; color: var(--muted); }
.guide-bridge { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; background: rgba(168, 85, 247, 0.08); border: 1px solid rgba(168, 85, 247, 0.35); border-radius: var(--radius); padding: 16px 20px; }

.hero-grid { display: grid; grid-template-columns: 1.05fr 1fr; gap: 24px; align-items: center; margin: 22px 0 28px; }
.hero-copy h1 { margin: 0 0 12px; font-size: clamp(1.82rem, 3.6vw, 2.7rem); line-height: 1.12; letter-spacing: -0.03em; }
.hero-copy p { margin: 0 0 18px; color: var(--muted); font-size: 1.02rem; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 10px; }
.search-bar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin: 18px 0; padding: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.search-input { flex: 1; min-width: 180px; min-height: 40px; padding: 8px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--stage); color: var(--text); }
.saved-strip { margin: 0 0 24px; padding: 16px; background: rgba(52, 211, 153, 0.06); border: 1px solid rgba(52, 211, 153, 0.3); border-radius: var(--radius); }
.saved-strip[hidden], .drawer-backdrop[hidden], .saved-drawer[hidden] { display: none; }
.drawer-backdrop { position: fixed; inset: 0; background: rgba(6, 8, 13, 0.72); z-index: 60; }
.saved-drawer { position: fixed; top: 0; right: 0; width: min(390px, 92vw); height: 100dvh; background: var(--surface); border-left: 1px solid var(--border); z-index: 70; display: flex; flex-direction: column; padding: 18px; gap: 14px; overflow-y: auto; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); padding-bottom: 12px; }
.saved-list { display: grid; gap: 10px; }
.saved-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; background: var(--stage); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.saved-row > div { min-width: 0; flex: 1; overflow-wrap: anywhere; }

.toast {
  position: fixed; bottom: 20px; right: 20px; z-index: 90; padding: 10px 16px;
  border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--cyan);
  color: var(--text); font-size: 0.9rem; font-weight: 600; box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  opacity: 0; transform: translateY(10px); pointer-events: none; transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.is-visible { opacity: 1; transform: translateY(0); }

.site-footer { border-top: 1px solid var(--border); background: var(--surface); padding: 32px 0 24px; margin-top: 40px; }
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 22px; margin-bottom: 22px; }
.footer-col h3 { margin: 0 0 10px; font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.footer-col ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; font-size: 0.9rem; }
.footer-col a { color: var(--text); }
.footer-bottom { border-top: 1px solid var(--border); padding-top: 16px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 0.84rem; color: var(--muted); }

@media (max-width: 860px) { .hero-grid { grid-template-columns: 1fr; } }
@media (max-width: 768px) {
  .wrap { padding: 0 14px; }
  .nav-inner { min-height: 54px; padding: 6px 0; }
  .btn.nav-toggle { display: inline-flex; }
  .nav-desktop-random { display: none; }
  .nav-links { display: none; order: 4; width: 100%; flex-direction: column; align-items: stretch; gap: 4px; padding: 8px 0 4px; border-top: 1px solid var(--border); }
  .nav-links.is-open { display: flex; }
  .nav-links a, .nav-mobile-only { display: flex; align-items: center; min-height: 42px; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--stage); border: 1px solid var(--border); color: var(--text); font-weight: 600; text-align: left; }
}
@media (max-width: 640px) {
  .stage-wrap { aspect-ratio: 4 / 3; min-height: 240px; }
  .hud-pill { font-size: 0.7rem; padding: 3px 8px; }
  .stage-toolbar { padding: 10px 12px; gap: 8px; }
  .stage-toolbar .toolbar-group { width: 100%; }
  .stage-toolbar .btn { flex: 1 1 auto; min-height: 40px; padding: 7px 10px; font-size: 0.82rem; }
  .preset-bar { padding: 10px 12px; }
  .controls-panel { padding: 14px 12px; }
  .controls-grid { grid-template-columns: 1fr; }
  .guide-block { padding: 16px 14px; }
  .hop-strip .btn { flex: 1 1 auto; }
}
