:root {
  --bg-0: #0a0e16;
  --bg-1: #0f1420;
  --bg-2: #141a2a;
  --frost-100: #eef2fb;
  --frost-300: #b9c4e0;
  --frost-500: #7c88ab;
  --violet: #9d6fe8;
  --violet-bright: #b78af2;
  --violet-dim: #5b4a86;
  --ice-cyan: #7fd6d2;
  --border: rgba(180, 195, 230, 0.12);
  --glass: rgba(20, 26, 42, 0.55);
  --font-display: "Unbounded", "Manrope", sans-serif;
  --font-body: "Manrope", sans-serif;
  --font-mono: "JetBrains Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-0);
  color: var(--frost-100);
  font-family: var(--font-body);
  overflow-x: hidden;
}

body {
  background:
    radial-gradient(ellipse 900px 500px at 15% -10%, rgba(157,111,232,0.16), transparent 60%),
    radial-gradient(ellipse 700px 500px at 100% 10%, rgba(127,214,210,0.08), transparent 55%),
    linear-gradient(180deg, var(--bg-0), var(--bg-1) 40%, var(--bg-0));
  min-height: 100vh;
}

#snow {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0.035;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

/* ---------- TOPBAR ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px clamp(20px, 5vw, 64px);
  backdrop-filter: blur(14px);
  background: rgba(10, 14, 22, 0.55);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  letter-spacing: 0.04em;
  font-weight: 600;
  font-size: 1.05rem;
}

.brand-mark {
  color: var(--violet-bright);
  font-size: 1.3rem;
  filter: drop-shadow(0 0 8px rgba(157,111,232,0.6));
}

.topnav { display: flex; gap: clamp(18px, 3vw, 34px); }

.nav-link {
  color: var(--frost-500);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  position: relative;
  padding-bottom: 4px;
  transition: color 0.25s ease;
}

.nav-link::after {
  content: "";
  position: absolute;
  left: 0; right: 100%;
  bottom: 0;
  height: 1px;
  background: var(--violet-bright);
  transition: right 0.3s ease;
}

.nav-link:hover, .nav-link.active { color: var(--frost-100); }
.nav-link:hover::after, .nav-link.active::after { right: 0; }

/* ---------- SCREENS ---------- */

main { position: relative; z-index: 4; }

.screen {
  display: none;
  min-height: calc(100vh - 78px);
  padding: clamp(32px, 6vw, 72px) clamp(20px, 5vw, 64px) 80px;
  animation: fadein 0.5s ease;
}

.screen.active { display: block; }

@keyframes fadein {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- HOME ---------- */

.home-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: clamp(30px, 5vw, 70px);
  align-items: center;
  max-width: 1280px;
  margin: 4vh auto 0;
}

.eyebrow {
  font-family: var(--font-mono);
  color: var(--ice-cyan);
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  margin: 0 0 18px;
  opacity: 0.85;
}

.home-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.6rem, 6vw, 4.4rem);
  line-height: 1.04;
  margin: 0 0 24px;
  letter-spacing: -0.01em;
}

.ice-underline {
  color: var(--violet-bright);
  position: relative;
}

.ice-underline::after {
  content: "";
  position: absolute;
  left: 2px; right: 2px; bottom: 2px;
  height: 0.32em;
  background: linear-gradient(90deg, var(--violet-dim), var(--ice-cyan));
  opacity: 0.35;
  z-index: -1;
  border-radius: 4px;
}

.home-sub {
  color: var(--frost-300);
  font-size: 1.05rem;
  line-height: 1.65;
  max-width: 46ch;
  margin: 0 0 32px;
}

.home-actions { display: flex; gap: 16px; margin-bottom: 46px; flex-wrap: wrap; }

.btn {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.95rem;
  padding: 14px 26px;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--violet), #7454c7);
  color: #fff;
  box-shadow: 0 10px 30px -10px rgba(157,111,232,0.55);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 16px 34px -10px rgba(157,111,232,0.7); }

.btn-ghost {
  background: transparent;
  color: var(--frost-100);
  border-color: var(--border);
}
.btn-ghost:hover { border-color: var(--violet-bright); color: var(--violet-bright); transform: translateY(-2px); }

.home-stats { display: flex; gap: clamp(20px, 4vw, 46px); flex-wrap: wrap; }

.stat { display: flex; flex-direction: column; gap: 4px; }
.stat-num { font-family: var(--font-display); font-size: 1.5rem; font-weight: 600; color: var(--violet-bright); }
.stat-label { font-size: 0.78rem; color: var(--frost-500); letter-spacing: 0.02em; }

.home-visual { position: relative; display: flex; justify-content: center; }

.glass-card {
  width: 100%;
  max-width: 400px;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 18px;
  backdrop-filter: blur(16px);
  box-shadow: 0 30px 60px -30px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.04);
  overflow: hidden;
}

.floating { animation: float 6s ease-in-out infinite; }
@keyframes float {
  0%, 100% { transform: translateY(0) rotate(-0.4deg); }
  50% { transform: translateY(-14px) rotate(0.4deg); }
}

.glass-card-head {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
}

.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--violet-dim); }
.dot:nth-child(1) { background: #e8768a; }
.dot:nth-child(2) { background: #e8c976; }
.dot:nth-child(3) { background: #7fd68f; }

.glass-title {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--frost-500);
  margin-left: 6px;
}

.glass-code {
  margin: 0;
  padding: 20px 18px 24px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.7;
  color: var(--frost-300);
  white-space: pre-wrap;
}

.tok-comment { color: var(--frost-500); font-style: italic; }

.icicle {
  position: absolute;
  width: 3px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--ice-cyan), transparent);
  opacity: 0.5;
}
.icicle-1 { height: 60px; top: -20px; left: 20%; }
.icicle-2 { height: 90px; top: -30px; left: 55%; }
.icicle-3 { height: 40px; top: -10px; right: 10%; }

/* ---------- LIBRARY / SELECT + PREVIEW ---------- */

.library-head { max-width: 780px; margin: 0 auto 40px; text-align: left; }
.library-head h2 {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 3.4vw, 2.5rem);
  margin: 0 0 10px;
}
.library-head p { color: var(--frost-300); margin: 0; line-height: 1.6; }

.library-body {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 28px;
  max-width: 1280px;
  margin: 0 auto;
  align-items: start;
}

.shelf {
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: sticky;
  top: 100px;
}

.shelf-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
  color: var(--frost-100);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.shelf-item:hover { transform: translateX(4px); border-color: rgba(157,111,232,0.4); }

.shelf-item.selected {
  border-color: var(--violet-bright);
  background: linear-gradient(135deg, rgba(157,111,232,0.14), rgba(127,214,210,0.05));
}

.shelf-item-title { font-weight: 700; font-size: 0.98rem; }
.shelf-item-meta { font-family: var(--font-mono); font-size: 0.72rem; color: var(--frost-500); }

.shelf-item-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.tag {
  font-size: 0.68rem;
  font-family: var(--font-mono);
  padding: 3px 8px;
  border-radius: 20px;
  background: rgba(127,214,210,0.1);
  color: var(--ice-cyan);
  border: 1px solid rgba(127,214,210,0.2);
}

.reader {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--glass);
  backdrop-filter: blur(16px);
  overflow: hidden;
  min-height: 460px;
}

.reader-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.reader-title-wrap h3 {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: 1.2rem;
}
.reader-title-wrap p { margin: 0; color: var(--frost-500); font-size: 0.85rem; }

.copy-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid rgba(157,111,232,0.35);
  background: rgba(157,111,232,0.1);
  color: var(--violet-bright);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease, border-color 0.2s ease;
  white-space: nowrap;
}
.copy-btn:hover { background: rgba(157,111,232,0.2); border-color: var(--violet-bright); }
.copy-btn:active { transform: scale(0.96); }
.copy-btn.copied { background: rgba(127,214,210,0.18); border-color: var(--ice-cyan); color: var(--ice-cyan); }

.reader-body { max-height: 560px; overflow: auto; }

.reader-body pre {
  margin: 0;
  padding: 22px 26px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.65;
  color: var(--frost-300);
  white-space: pre;
}

.reader-body::-webkit-scrollbar, .shelf::-webkit-scrollbar { width: 8px; }
.reader-body::-webkit-scrollbar-thumb { background: var(--violet-dim); border-radius: 8px; }

.line-num { color: var(--frost-500); opacity: 0.5; user-select: none; display: inline-block; width: 34px; }

/* ---------- TUTORIAL ---------- */

.tutorial-steps {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  max-width: 780px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.tutorial-steps li {
  display: flex;
  gap: 20px;
  padding: 22px 24px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255,255,255,0.02);
}

.step-num {
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--violet-bright);
  flex-shrink: 0;
}

.tutorial-steps h3 { margin: 0 0 6px; font-family: var(--font-display); font-size: 1.05rem; }
.tutorial-steps p { margin: 0; color: var(--frost-300); line-height: 1.6; font-size: 0.94rem; }
.tutorial-steps code {
  font-family: var(--font-mono);
  background: rgba(127,214,210,0.1);
  color: var(--ice-cyan);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 0.85em;
}

.disclaimer {
  max-width: 780px;
  margin: 34px auto 0;
  padding: 18px 22px;
  border-radius: 14px;
  border: 1px solid rgba(232,118,138,0.3);
  background: rgba(232,118,138,0.06);
  color: var(--frost-300);
  font-size: 0.88rem;
  line-height: 1.6;
}

/* ---------- FOOTER ---------- */

.site-footer {
  position: relative;
  z-index: 4;
  text-align: center;
  padding: 26px;
  color: var(--frost-500);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
}

/* ---------- RESPONSIVE ---------- */

@media (max-width: 880px) {
  .home-grid { grid-template-columns: 1fr; }
  .library-body { grid-template-columns: 1fr; }
  .shelf { position: static; flex-direction: row; overflow-x: auto; }
  .shelf-item { min-width: 220px; }
  .topnav { gap: 16px; }
}
