/* ─── Variables ─── */
:root {
  --bg: #323437;
  --bg-alt: #2c2e31;
  --bg-dark: #1e1e20;
  --main: #e2b714;
  --main-dim: rgba(226,183,20,0.12);
  --text: #d1d0c5;
  --sub: #85888c;
  --sub-alt: #2c2e31;
  --error: #ca4754;
  --error-extra: #7e2a33;
  --text-dim: #6b6c72;
  --success: #7ec850;
  --info: #6bb3e0;
  --border: #3a3b3f;
}

/* ─── Reset ─── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* ─── Nav ─── */

.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  background: rgba(30,30,32,0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 40px;
  z-index: 100;
  border-bottom: 1px solid rgba(58,59,63,0.5);
}

.nav-logo {
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: 0.3px;
}

.nav-logo span { color: var(--main); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 32px;
}

.nav-links a {
  color: var(--sub);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.2s;
}

.nav-links a:hover { color: var(--text); }

.nav-cta {
  background: var(--main) !important;
  color: var(--bg-dark) !important;
  padding: 6px 16px;
  border-radius: 6px;
  font-weight: 600 !important;
  transition: opacity 0.2s !important;
}

.nav-cta:hover { opacity: 0.9; color: var(--bg-dark) !important; }

.nav-user { font-size: 14px; color: var(--sub); }

.nav-logout {
  display: inline;
}

.nav-logout button {
  background: none;
  border: none;
  color: var(--sub);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s;
}

.nav-logout button:hover { color: var(--text); }

/* ─── Top Nav (app pages) ─── */

.topnav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 42px;
  background: var(--bg-alt);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
  border-bottom: 1px solid var(--border);
}

.topnav-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.topnav-logo .logo-text {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.2px;
}

.topnav-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topnav-link {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  color: var(--sub);
  text-decoration: none;
  cursor: pointer;
  transition: color 0.15s;
}

.topnav-link:hover { color: var(--text); }

.user-menu {
  position: relative;
}

.topnav-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #424448;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: Menlo, Monaco, Consolas, monospace;
  font-size: 10px;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s;
  padding: 0;
}

.topnav-avatar:hover { border-color: var(--text); }

.user-menu-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 200px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 0;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.user-menu.open .user-menu-dropdown { display: block; }

.user-menu-header {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-menu-name {
  font-family: Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}

.user-menu-email {
  font-family: Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  color: var(--text-muted);
}

.user-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.user-menu-item {
  display: block;
  width: 100%;
  padding: 8px 14px;
  background: none;
  border: none;
  font-family: Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  text-align: left;
  transition: color 0.15s, background 0.15s;
}

.user-menu-item:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

/* ─── Buttons ─── */

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  background: var(--main);
  color: var(--bg-dark);
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.2s, transform 0.2s;
}

.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  background: transparent;
  color: var(--sub);
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.2s, border-color 0.2s;
}

.btn-secondary:hover { color: var(--text); border-color: var(--sub); }

/* ─── Hero ─── */

.hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 40px 60px;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -200px;
  left: 50%;
  transform: translateX(-50%);
  width: 800px;
  height: 800px;
  background: radial-gradient(ellipse, rgba(226,183,20,0.06) 0%, transparent 70%);
  pointer-events: none;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--main-dim);
  border: 1px solid rgba(226,183,20,0.2);
  border-radius: 20px;
  font-family: Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  color: var(--main);
  margin-bottom: 28px;
}

.hero h1 {
  font-size: clamp(36px, 5vw, 56px);
  font-weight: 700;
  line-height: 1.15;
  max-width: 720px;
  margin-bottom: 20px;
  letter-spacing: -0.5px;
}

.hero h1 .accent { color: var(--main); }

.hero-sub {
  font-size: 18px;
  color: var(--sub);
  max-width: 520px;
  line-height: 1.6;
  margin-bottom: 36px;
}

.hero-actions {
  display: flex;
  gap: 14px;
  align-items: center;
}

.hero-note {
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-dim);
}

/* ─── Section base ─── */

section {
  padding: 100px 40px;
}

.section-inner {
  max-width: 1000px;
  margin: 0 auto;
}

.section-label {
  font-family: Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  color: var(--main);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 12px;
}

.section-title {
  font-size: clamp(24px, 3vw, 36px);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 16px;
  letter-spacing: -0.3px;
}

.section-desc {
  font-size: 16px;
  color: var(--sub);
  max-width: 560px;
  line-height: 1.6;
}

/* ─── Problem section ─── */

.problem { background: var(--bg); }

.problem-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  margin-top: 48px;
  align-items: center;
}

.problem-text h3 { font-size: 20px; font-weight: 600; margin-bottom: 16px; line-height: 1.3; }
.problem-text p { color: var(--sub); font-size: 15px; line-height: 1.7; margin-bottom: 20px; }

.problem-stats { display: flex; gap: 24px; }
.problem-stat { text-align: center; }
.problem-stat .num { font-family: Menlo, Monaco, Consolas, monospace; font-size: 28px; font-weight: 700; color: var(--main); }
.problem-stat .label { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

.problem-visual {
  position: relative;
  background: var(--bg-dark);
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 32px;
  overflow: hidden;
}

.problem-visual::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--error), var(--main) 50%, var(--success));
}

.grind-line { display: flex; align-items: center; gap: 10px; padding: 8px 0; font-family: Menlo, Monaco, Consolas, monospace; font-size: 13px; }
.grind-line .idx { color: var(--text-dim); min-width: 24px; }
.grind-line .name { color: var(--sub); flex: 1; }
.grind-line .tag { font-size: 11px; padding: 2px 8px; border-radius: 4px; background: rgba(202,71,84,0.12); color: var(--error); }
.grind-line .tag.forgotten { background: rgba(107,108,114,0.15); color: var(--text-dim); text-decoration: line-through; }
.grind-line .check { color: var(--success); }
.grind-line .cross { color: var(--error); }
.grind-divider { border: none; border-top: 1px dashed var(--border); margin: 12px 0; }
.grind-label { font-family: Menlo, Monaco, Consolas, monospace; font-size: 11px; color: var(--text-dim); text-align: center; padding: 4px 0; }

/* ─── How it works ─── */

.how { background: var(--bg-dark); }

.how-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; margin-top: 48px; }

.how-step {
  background: var(--bg);
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 28px;
  position: relative;
  transition: border-color 0.3s;
}

.how-step:hover { border-color: var(--main); }

.how-step-num { font-family: Menlo, Monaco, Consolas, monospace; font-size: 32px; font-weight: 700; color: var(--main); opacity: 0.3; position: absolute; top: 16px; right: 20px; }
.how-step-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--main-dim); display: flex; align-items: center; justify-content: center; font-size: 18px; margin-bottom: 16px; }
.how-step h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.how-step p { font-size: 14px; color: var(--sub); line-height: 1.6; }

/* ─── Demo viz ─── */

.demo { background: var(--bg); }

.demo-container {
  margin-top: 48px;
  background: var(--bg-dark);
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 32px;
  overflow: hidden;
}

.demo-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.demo-title { font-family: Menlo, Monaco, Consolas, monospace; font-size: 13px; color: var(--sub); }
.demo-badge { font-family: Menlo, Monaco, Consolas, monospace; font-size: 11px; color: var(--main); padding: 3px 10px; background: var(--main-dim); border-radius: 4px; }

/* ─── Viz styles ─── */

.viz-scenes { display: flex; gap: 32px; justify-content: center; align-items: flex-start; flex-wrap: wrap; }
.viz-scene { flex: 0 1 auto; }

.viz-array-wrap { position: relative; display: flex; flex-direction: column; align-items: center; }
.viz-target { position: absolute; top: 4px; right: 0; font-family: Menlo, Monaco, Consolas, monospace; font-size: 12px; color: var(--sub); background: var(--bg); padding: 2px 8px; border-radius: 4px; border: 1px solid var(--border); }
.viz-pointers { position: relative; width: 100%; height: 24px; margin-bottom: 2px; }
.viz-pointer { position: absolute; bottom: 0; display: flex; flex-direction: column; align-items: center; font-family: Menlo, Monaco, Consolas, monospace; font-size: 11px; font-weight: 500; transition: left 0.4s cubic-bezier(.4,0,.2,1), height 0.4s cubic-bezier(.4,0,.2,1); }
.viz-pointer .ptr-label { white-space: nowrap; }
.viz-pointer .ptr-arrow { line-height: 1; font-size: 10px; }
.viz-pointer.ptr-info { color: var(--info); }
.viz-pointer.ptr-main { color: var(--main); }
.viz-pointer.ptr-error { color: var(--error); }
.viz-pointer.ptr-success { color: var(--success); }

.viz-cells { display: flex; gap: 2px; }
.viz-cell {
  width: 42px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: Menlo, Monaco, Consolas, monospace;
  font-size: 13px; font-weight: 500;
  color: var(--text);
  transition: all 0.4s cubic-bezier(.4,0,.2,1);
}
.viz-cell.dimmed { opacity: 0.25; }
.viz-cell.accent-cell { border-color: var(--main); background: var(--main-dim); }
.viz-cell.found-cell { border-color: var(--success); background: rgba(126,200,80,0.15); color: var(--success); }

.viz-indices { display: flex; gap: 2px; margin-top: 3px; }
.viz-idx { width: 42px; text-align: center; font-family: Menlo, Monaco, Consolas, monospace; font-size: 10px; color: var(--text-dim); }

.viz-vars { display: flex; gap: 16px; justify-content: center; margin-top: 8px; font-family: Menlo, Monaco, Consolas, monospace; font-size: 12px; }
.viz-var-key { color: var(--text-dim); }
.viz-var { color: var(--sub); }

/* tree */
.viz-tree-svg { overflow: visible; }
.viz-tree-svg line { stroke: var(--border); stroke-width: 1.5; transition: stroke 0.4s, stroke-width 0.4s; }
.viz-tree-svg line.path { stroke: var(--main); stroke-width: 2.5; }
.viz-tree-svg circle { fill: var(--bg-alt); stroke: var(--border); stroke-width: 1.5; transition: fill 0.4s, stroke 0.4s; }
.viz-tree-svg circle.current { fill: var(--main-dim); stroke: var(--main); stroke-width: 2.5; }
.viz-tree-svg circle.checked { fill: var(--main-dim); stroke: var(--main); opacity: 0.5; }
.viz-tree-svg circle.found { fill: rgba(126,200,80,0.15); stroke: var(--success); stroke-width: 2.5; }
.viz-tree-svg text { fill: var(--text); font-family: Menlo, Monaco, Consolas, monospace; font-size: 12px; text-anchor: middle; dominant-baseline: central; pointer-events: none; }

.viz-comment { text-align: center; font-family: Menlo, Monaco, Consolas, monospace; font-size: 13px; color: var(--sub); min-height: 20px; margin: 16px 0 12px; transition: opacity 0.3s; }

.viz-controls { display: flex; align-items: center; justify-content: center; gap: 12px; }
.viz-controls button { background: var(--bg-alt); border: 1px solid var(--border); color: var(--sub); font-family: Menlo, Monaco, Consolas, monospace; font-size: 12px; padding: 5px 14px; border-radius: 4px; cursor: pointer; transition: color 0.2s, border-color 0.2s; }
.viz-controls button:hover { color: var(--text); border-color: var(--sub); }
.viz-controls button:disabled { opacity: 0.3; cursor: default; }
.viz-controls .step-counter { font-family: Menlo, Monaco, Consolas, monospace; font-size: 12px; color: var(--text-dim); min-width: 40px; text-align: center; }

/* ─── Features ─── */

.features { background: var(--bg-dark); }

.features-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 48px; }

.feature-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  transition: border-color 0.3s, transform 0.2s;
}

.feature-card:hover { border-color: var(--main); transform: translateY(-2px); }

.feature-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px; margin-bottom: 14px; }
.feature-icon.gold { background: var(--main-dim); }
.feature-icon.blue { background: rgba(107,179,224,0.12); }
.feature-icon.green { background: rgba(126,200,80,0.12); }
.feature-icon.red { background: rgba(202,71,84,0.12); }

.feature-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.feature-card p { font-size: 13px; color: var(--sub); line-height: 1.6; }

/* ─── Pricing ─── */

.pricing { background: var(--bg); }
.pricing .section-inner { text-align: center; }
.pricing .section-desc { margin: 0 auto 12px; }

.pricing-toggle { display: inline-flex; align-items: center; gap: 12px; margin-bottom: 48px; font-size: 14px; color: var(--sub); }
.pricing-toggle .toggle-track { width: 44px; height: 24px; background: var(--border); border-radius: 12px; position: relative; cursor: pointer; transition: background 0.3s; }
.pricing-toggle .toggle-track.active { background: var(--main); }
.pricing-toggle .toggle-thumb { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; background: var(--bg-dark); border-radius: 50%; transition: left 0.3s; }
.pricing-toggle .toggle-track.active .toggle-thumb { left: 23px; }
.pricing-toggle .save-badge { font-family: Menlo, Monaco, Consolas, monospace; font-size: 11px; color: var(--success); background: rgba(126,200,80,0.12); padding: 2px 8px; border-radius: 4px; }

.pricing-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; max-width: 680px; margin: 0 auto; }

.pricing-card { background: var(--bg-dark); border: 1px solid var(--border); border-radius: 12px; padding: 32px; text-align: left; position: relative; transition: border-color 0.3s; }
.pricing-card.featured { border-color: var(--main); }
.pricing-card.featured::before { content: 'MOST POPULAR'; position: absolute; top: -10px; left: 24px; font-family: Menlo, Monaco, Consolas, monospace; font-size: 10px; font-weight: 500; color: var(--bg-dark); background: var(--main); padding: 2px 10px; border-radius: 4px; letter-spacing: 1px; }

.pricing-card .plan-name { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.pricing-card .plan-desc { font-size: 13px; color: var(--text-dim); margin-bottom: 20px; }
.pricing-card .plan-price { display: flex; align-items: baseline; gap: 4px; margin-bottom: 24px; }
.pricing-card .plan-price .amount { font-size: 36px; font-weight: 700; }
.pricing-card .plan-price .period { font-size: 14px; color: var(--sub); }
.pricing-card .plan-price .amount.free { color: var(--sub); }

.plan-features { list-style: none; margin-bottom: 24px; }
.plan-features li { font-size: 13px; color: var(--sub); padding: 6px 0; display: flex; align-items: center; gap: 8px; }
.plan-features li::before { content: '\2713'; color: var(--success); font-weight: 600; font-size: 12px; }
.plan-features li.disabled { color: var(--text-dim); }
.plan-features li.disabled::before { content: '\2014'; color: var(--text-dim); }

.plan-btn { display: block; width: 100%; padding: 10px; text-align: center; font-family: 'Inter', sans-serif; font-size: 14px; font-weight: 600; border-radius: 8px; cursor: pointer; text-decoration: none; transition: opacity 0.2s; border: none; }
.plan-btn.primary { background: var(--main); color: var(--bg-dark); }
.plan-btn.secondary { background: transparent; border: 1px solid var(--border); color: var(--sub); }
.plan-btn:hover { opacity: 0.85; }

/* ─── Final CTA ─── */

.final-cta { background: var(--bg-dark); text-align: center; padding: 100px 40px; }
.final-cta h2 { font-size: clamp(24px, 3vw, 36px); font-weight: 700; margin-bottom: 16px; letter-spacing: -0.3px; }
.final-cta h2 .accent { color: var(--main); }
.final-cta p { font-size: 16px; color: var(--sub); margin-bottom: 32px; max-width: 480px; margin-left: auto; margin-right: auto; }

/* ─── Footer ─── */

.footer {
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 32px 40px;
}

.footer-inner { max-width: 1000px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; }
.footer-brand { font-size: 14px; font-weight: 600; color: var(--sub); }
.footer-brand span { color: var(--main); }
.footer-links { display: flex; gap: 24px; }
.footer-links a { font-size: 13px; color: var(--text-dim); text-decoration: none; transition: color 0.2s; }
.footer-links a:hover { color: var(--sub); }
.footer-copy { font-size: 12px; color: var(--text-dim); }

/* ─── Auth pages ─── */

.auth-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.auth-body::before {
  content: '';
  position: absolute;
  top: -300px;
  left: 50%;
  transform: translateX(-50%);
  width: 900px;
  height: 900px;
  background: radial-gradient(ellipse, rgba(226,183,20,0.04) 0%, transparent 70%);
  pointer-events: none;
}

.auth-card { width: 100%; max-width: 400px; padding: 0 24px; position: relative; z-index: 1; }

.auth-logo { text-align: center; margin-bottom: 36px; }
.auth-logo a { font-family: 'Inter', sans-serif; font-size: 20px; font-weight: 700; color: var(--text); text-decoration: none; letter-spacing: 0.3px; }
.auth-logo a span { color: var(--main); }
.auth-logo p { font-size: 13px; color: var(--text-dim); margin-top: 6px; }

.auth-panel { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 32px; }
.auth-title { font-size: 20px; font-weight: 600; margin-bottom: 24px; text-align: center; }

.social-buttons { display: flex; flex-direction: column; gap: 10px; margin-bottom: 24px; }
.social-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 10px; background: var(--bg-dark); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-family: 'Inter', sans-serif; font-size: 14px; font-weight: 500; cursor: pointer; text-decoration: none; transition: border-color 0.2s, background 0.2s; }
.social-btn:hover { border-color: var(--sub); background: var(--bg-alt); }
.social-btn svg { width: 18px; height: 18px; flex-shrink: 0; }

.auth-divider { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.auth-divider span { font-size: 12px; color: var(--text-dim); font-family: Menlo, Monaco, Consolas, monospace; text-transform: lowercase; }

.auth-error { display: none; background: rgba(202,71,84,0.1); border: 1px solid rgba(202,71,84,0.25); border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; font-size: 13px; color: var(--error); }
.auth-error.visible { display: block; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--sub); margin-bottom: 6px; }
.form-group input { width: 100%; padding: 10px 14px; background: var(--bg-dark); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-family: 'Inter', sans-serif; font-size: 14px; outline: none; transition: border-color 0.2s; }
.form-group input::placeholder { color: var(--text-dim); }
.form-group input:focus { border-color: var(--main); }

.form-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.form-row label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--sub); cursor: pointer; }
.form-row label input[type="checkbox"] { width: 14px; height: 14px; accent-color: var(--main); cursor: pointer; }
.form-link { font-size: 13px; color: var(--main); text-decoration: none; transition: opacity 0.2s; }
.form-link:hover { opacity: 0.8; }

.auth-submit { width: 100%; padding: 11px; background: var(--main); color: var(--bg-dark); font-family: 'Inter', sans-serif; font-size: 14px; font-weight: 600; border: none; border-radius: 8px; cursor: pointer; transition: opacity 0.2s, transform 0.2s; }
.auth-submit:hover { opacity: 0.9; transform: translateY(-1px); }

.auth-footer { text-align: center; margin-top: 20px; font-size: 13px; color: var(--text-dim); }
.auth-footer a { color: var(--main); text-decoration: none; font-weight: 500; transition: opacity 0.2s; }
.auth-footer a:hover { opacity: 0.8; }

.auth-terms { text-align: center; margin-top: 16px; font-size: 11px; color: var(--text-dim); line-height: 1.5; }
.auth-terms a { color: var(--sub); text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 2px; }
.auth-terms a:hover { color: var(--text); }

.auth-back { text-align: center; margin-top: 24px; }
.auth-back a { font-size: 13px; color: var(--text-dim); text-decoration: none; transition: color 0.2s; }
.auth-back a:hover { color: var(--sub); }

.password-wrap { position: relative; }
.password-wrap input { padding-right: 42px; }
.password-toggle { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 14px; padding: 4px; transition: color 0.2s; }
.password-toggle:hover { color: var(--sub); }

.password-strength { display: flex; gap: 4px; margin-top: 8px; }
.password-strength .bar { flex: 1; height: 3px; border-radius: 2px; background: var(--border); transition: background 0.3s; }
.password-strength .bar.weak { background: var(--error); }
.password-strength .bar.medium { background: var(--main); }
.password-strength .bar.strong { background: var(--success); }
.password-hint { font-size: 11px; color: var(--text-dim); margin-top: 4px; }

/* ─── Floating Metrics Pill ─── */

.metrics-pill {
  position: fixed;
  top: 52px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 4px 18px;
  font-family: Menlo, Monaco, Consolas, monospace;
  font-size: 12.5px;
  color: var(--sub);
  height: 28px;
  z-index: 95;
}

.metrics-pill .stat {
  display: flex;
  align-items: center;
  gap: 4px;
}

.metrics-pill .stat .label {
  color: var(--text-dim);
}

.metrics-pill .stat .value {
  color: var(--sub);
}

.metrics-pill .stat .value.accent {
  color: var(--main);
}

.metrics-pill .dot-sep {
  color: var(--text-dim);
  font-size: 10px;
}

/* ─── App layout (sidebar + content) ─── */

.app-layout {
  display: flex;
  min-height: calc(100vh - 42px);
  padding-top: 42px;
}

.sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--bg-alt);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 42px;
  height: calc(100vh - 42px);
  overflow-y: auto;
  padding: 8px 0;
}

.sidebar-group { margin-bottom: 8px; }

.sidebar-group-title {
  padding: 16px 16px 6px 16px;
  font-family: 'Inter', sans-serif;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.sidebar-group:first-child .sidebar-group-title {
  padding-top: 8px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 12px 5px 16px;
  border-left: 2px solid transparent;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.1s;
}

.sidebar-item:hover {
  background: rgba(255,255,255,0.02);
}

.sidebar-item.active {
  border-left-color: var(--main);
  background: var(--main-dim);
}

.sidebar-item.active .item-name {
  color: var(--main);
}

.sidebar-item .item-name {
  font-family: Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  color: var(--sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.sidebar-item .item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: 8px;
}

.memory-bar {
  display: inline-block;
  width: 50px;
  height: 3px;
  background: var(--bg);
  border-radius: 1.5px;
  overflow: hidden;
  vertical-align: middle;
}

.memory-bar .fill {
  display: block;
  height: 100%;
  background: #555659;
  border-radius: 1.5px;
}

.item-pct {
  font-family: Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  color: var(--text-dim);
  width: 28px;
  text-align: right;
}

.item-badge {
  font-family: Menlo, Monaco, Consolas, monospace;
  font-size: 10px;
  color: var(--text-dim);
  padding: 1px 5px;
  border: 1px solid var(--text-dim);
  border-radius: 3px;
}

/* ─── Internal pages ─── */

.page-content {
  flex: 1;
  min-width: 0;
  min-height: calc(100vh - 100px);
  padding-bottom: 48px;
}

/* When no sidebar (public pages), add top padding for fixed nav */
.app-layout:not(:has(.sidebar)) .page-content {
  padding-top: 24px;
}

.page-content .container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 40px;
}

.page-content h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 24px;
  letter-spacing: -0.3px;
}

/* ─── Pattern page: override generic section padding ─── */

section.pattern-section {
  padding: 0;
}

/* ─── Pattern page: Theory zone ─── */

.theory-zone {
  max-width: 720px;
  padding: 24px 32px 0 32px;
}

.theory-zone .page-title {
  font-family: 'Inter', sans-serif;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  letter-spacing: 0;
}

.page-meta {
  font-family: Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  color: var(--sub);
  margin-bottom: 12px;
}

.page-divider {
  height: 1px;
  background: var(--border);
  margin-bottom: 8px;
}

.memory-status {
  font-family: Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 24px;
}

.memory-status .mem-value {
  color: rgba(226,183,20,0.6);
}

/* ─── Pattern page: Post-practice zone ─── */

.post-practice {
  max-width: 720px;
  padding: 0 32px 48px 32px;
}

/* ─── Pattern page: Sections ─── */

.theory-zone .section,
.post-practice .section {
  margin-bottom: 28px;
}

.theory-zone .section:last-child {
  margin-bottom: 16px;
}

.section-header {
  display: flex;
  align-items: baseline;
  gap: 0;
  margin-bottom: 12px;
}

.section-header .comment-slash {
  font-family: Menlo, Monaco, Consolas, monospace;
  font-size: 14px;
  color: var(--main);
  opacity: 0.6;
  margin-right: 7px;
  user-select: none;
}

.section-header h2 {
  font-family: Menlo, Monaco, Consolas, monospace;
  font-size: 14px;
  font-weight: 400;
  color: var(--sub);
  text-transform: lowercase;
}

/* ─── Pattern page: Callout ─── */

.theory-zone .callout,
.post-practice .callout {
  border-left: 2px solid rgba(226,183,20,0.3);
  background: var(--bg-alt);
  padding: 12px 16px;
  border-radius: 4px;
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
}

/* ─── Pattern page: Body text ─── */

.theory-zone .body-text,
.post-practice .body-text {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
}

/* ─── Pattern page: Code block ─── */

.theory-zone .code-block,
.post-practice .code-block {
  background: var(--bg-dark);
  font-family: Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  padding: 14px 16px;
  border-radius: 4px;
  line-height: 1.65;
  overflow-x: auto;
}

/* ─── Pattern page: Complexity ─── */

.complexity-block {
  background: var(--bg-dark);
  padding: 10px 16px;
  border-radius: 4px;
  font-family: Menlo, Monaco, Consolas, monospace;
  font-size: 14px;
  display: flex;
  gap: 24px;
}

.complexity-block .c-label {
  color: var(--sub);
}

.complexity-block .c-value {
  color: var(--text);
  margin-left: 6px;
}

.complexity-block .c-note {
  color: var(--sub);
  font-size: 12px;
  margin-left: 4px;
}

/* ─── Pattern page: Toggle (solution) ─── */

.toggle-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}

.toggle-btn {
  font-family: Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  color: var(--sub);
  cursor: pointer;
  user-select: none;
  background: none;
  border: none;
  padding: 0;
}

.toggle-btn:hover {
  color: var(--text);
}

/* ─── Pattern page: Steps ─── */

.theory-zone .steps-list,
.post-practice .steps-list {
  list-style: none;
  counter-reset: steps;
}

.theory-zone .steps-list li,
.post-practice .steps-list li {
  counter-increment: steps;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  padding: 3px 0;
  padding-left: 20px;
  position: relative;
}

.theory-zone .steps-list li::before,
.post-practice .steps-list li::before {
  content: counter(steps) ".";
  position: absolute;
  left: 0;
  color: var(--sub);
  font-family: Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
}

/* ─── Pattern page: Inline code ─── */

.theory-zone .inline-code,
.theory-zone code.inline-code,
.post-practice .inline-code,
.post-practice code.inline-code,
.practice-left .inline-code {
  background: var(--bg-alt);
  font-family: Menlo, Monaco, Consolas, monospace;
  font-size: 13.5px;
  padding: 1px 5px;
  border-radius: 2px;
  color: var(--main);
}

.callout .inline-code {
  color: var(--text);
}

/* ─── Pattern page: Quiz ─── */

.quiz-question {
  margin-bottom: 16px;
}

.quiz-question .q-text {
  font-size: 13.5px;
  color: var(--text);
  margin-bottom: 6px;
}

.quiz-question .q-number {
  font-family: Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  color: var(--sub);
  margin-right: 4px;
}

.quiz-options {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  padding-left: 20px;
}

.quiz-option {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  color: var(--sub);
  cursor: pointer;
  padding: 2px 0;
}

.radio {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1.5px solid var(--sub);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.radio.selected {
  border-color: var(--main);
}

.radio.selected::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--main);
}

.quiz-option.selected {
  color: var(--text);
}

/* ─── Pattern page: Practice zone (responsive layout) ─── */

.practice-zone {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
}

.practice-left {
  padding: 20px 32px;
  max-width: 720px;
  border-bottom: 1px solid var(--border);
}

.practice-right {
  display: flex;
  flex-direction: column;
  background: #2b2b2b;
}

@media (min-width: 1680px) {
  .practice-zone {
    flex-direction: row;
  }
  .practice-left {
    width: 720px;
    flex-shrink: 0;
    border-bottom: none;
  }
  .practice-right {
    flex: 1;
    max-width: calc(720px * 1.618);
    border-left: 1px solid var(--border);
  }
}

.problem-title {
  font-family: Menlo, Monaco, Consolas, monospace;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 10px;
}

.problem-desc {
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--text);
  margin-bottom: 16px;
}

.problem-desc p {
  margin-bottom: 8px;
}

.problem-desc p:last-child {
  margin-bottom: 0;
}

.example-section {
  margin-top: 20px;
}

.example-section > strong {
  display: block;
  margin-bottom: 4px;
}

.example-content {
  border-left: 2px solid var(--border);
  padding-left: 14px;
  margin-left: 2px;
  color: var(--sub);
}

.example-block {
  background: var(--bg-dark);
  font-family: Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  padding: 10px 14px;
  border-radius: 4px;
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 16px;
}

.example-block .ex-label { color: var(--sub); }
.example-block .ex-comment { color: var(--sub); font-size: 12px; }

.hint-toggle {
  font-family: Menlo, Monaco, Consolas, monospace;
  font-size: 12.5px;
  color: var(--sub);
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
}

.hint-toggle:hover { color: var(--text); }

/* Practice right — editor */

.editor-toolbar {
  height: 32px;
  background: #3c3f41;
  border-bottom: 1px solid #323232;
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 12px;
  flex-shrink: 0;
}

.lang-tabs {
  display: flex;
  gap: 2px;
}

.lang-tab {
  font-family: Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  color: var(--sub);
  background: transparent;
  border: none;
  padding: 4px 10px;
  cursor: pointer;
  border-radius: 3px;
  transition: color 0.15s, background 0.15s;
}

.lang-tab:hover {
  color: var(--text);
  background: rgba(255,255,255,0.05);
}

.lang-tab.active {
  color: var(--text);
  background: rgba(255,255,255,0.1);
}

.editor-toolbar .spacer { flex: 1; }

.run-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--main);
  color: var(--bg-dark);
  font-family: Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  font-weight: 500;
  padding: 3px 12px;
  border-radius: 3px;
  border: none;
  cursor: pointer;
  line-height: 1;
}

.run-btn:hover { filter: brightness(1.1); }
.run-btn .play-icon { font-size: 9px; }

.code-area {
  height: 420px;
  overflow: hidden;
  position: relative;
}

@media (min-width: 1680px) {
  .code-area {
    height: auto;
    flex: 1;
    min-height: 420px;
  }
}

.code-area .cm-editor {
  height: 100%;
  user-select: text;
  -webkit-user-select: text;
}

.code-area .cm-content,
.code-area .cm-line {
  user-select: text;
  -webkit-user-select: text;
}

.code-area .cm-content ::selection,
.code-area .cm-line ::selection,
.code-area .cm-content::selection,
.code-area .cm-line::selection {
  background-color: #214283 !important;
}

.code-area .cm-editor.cm-focused {
  outline: none;
}

/* ─── Editor bottom bar ─── */

.editor-bottombar {
  height: 32px;
  background: #3c3f41;
  border-top: 1px solid #323232;
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 12px;
  flex-shrink: 0;
}

.testcases-toggle {
  font-family: Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  color: var(--sub);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: color 0.15s;
}

.testcases-toggle:hover { color: var(--text); }

.testcases-toggle .toggle-chevron {
  font-size: 8px;
  display: inline-block;
  transition: transform 0.15s;
}

.test-bar {
  display: flex;
  align-items: center;
  font-family: Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  color: var(--sub);
  gap: 6px;
  margin-left: auto;
}

.test-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--sub);
  flex-shrink: 0;
}

.test-dot.running { background: var(--main); animation: pulse 1s infinite; }
.test-dot.passed { background: var(--success); }
.test-dot.failed { background: var(--error); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.test-status { display: flex; gap: 8px; align-items: center; }
.test-passed { color: var(--success); }
.test-failed { color: var(--error); }
.test-total { color: var(--text-dim); }

/* ─── Collapsible test cases ─── */

.testcases-panel {
  display: none;
  background: #2b2b2b;
  border-top: 1px solid #323232;
  padding: 12px 14px;
  max-height: 420px;
  overflow-y: auto;
}

.testcases-panel.open { display: block; }

.testcases-panel .example-block {
  background: #313335;
  margin-bottom: 8px;
  border-left: 3px solid transparent;
  transition: border-color 0.2s;
}

.testcases-panel .example-block:last-child {
  margin-bottom: 0;
}

.testcases-panel .example-block.tc-passed {
  border-left-color: var(--success);
}

.testcases-panel .example-block.tc-failed {
  border-left-color: var(--error);
}

.ex-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.ex-details {
  display: flex;
  flex-direction: column;
}

.tc-badge {
  font-family: Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tc-badge-passed {
  color: var(--success);
  background: rgba(126,200,80,0.1);
}

.tc-badge-failed {
  color: var(--error);
  background: rgba(202,71,84,0.1);
}

.ex-actual {
  color: var(--error) !important;
}

.tc-output {
  font-family: Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  margin-top: 8px;
  padding: 6px 8px;
  border-radius: 3px;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.5;
}

.tc-output-stdout {
  background: rgba(255,255,255,0.04);
  color: var(--sub);
}

.tc-output-stderr {
  background: rgba(202,71,84,0.08);
  color: var(--error);
}

/* ─── Quiz interaction states ─── */

.quiz-option.correct .radio {
  border-color: var(--success);
}

.quiz-option.correct .radio::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}

.quiz-option.correct {
  color: var(--success);
}

.quiz-option.incorrect .radio {
  border-color: var(--error);
}

.quiz-option.incorrect .radio::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--error);
}

.quiz-option.incorrect {
  color: var(--error);
}

/* ─── Markdown inside sections ─── */

.callout p, .body-text p {
  margin-bottom: 8px;
}

.callout p:last-child, .body-text p:last-child {
  margin-bottom: 0;
}

.callout ul, .callout ol, .body-text ul, .body-text ol {
  margin: 8px 0 8px 4px;
  list-style: none;
  padding-left: 0;
}

.callout ol, .body-text ol {
  margin-left: 20px;
  list-style: decimal;
}

.callout li, .body-text li {
  margin-bottom: 4px;
}

/* Callout list items: monospace, smaller, muted */
.callout ul li {
  font-family: Menlo, Monaco, Consolas, monospace;
  font-size: 14px;
  color: var(--sub);
  padding: 1px 0;
}

.callout ul li::before {
  content: "\b7  ";
  color: var(--main);
}

/* Body text list items: regular font, gold marker */
.body-text ul li {
  padding: 1px 0;
}

.body-text ul li::before {
  content: "\b7  ";
  color: var(--main);
}

.callout strong, .body-text strong {
  font-weight: 600;
  color: var(--text);
}

.steps-list li p {
  margin: 0;
  display: inline;
}

/* ─── Code block with pre ─── */

pre.code-block {
  white-space: pre;
  overflow-x: auto;
}

pre.code-block code {
  font-family: Menlo, Monaco, Consolas, monospace;
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
}

/* ─── Prism syntax highlighting (matching mockup palette) ─── */

.code-block .token.keyword,
.code-block .token.builtin { color: var(--error); }

.code-block .token.function { color: var(--main); }

.code-block .token.comment { color: var(--sub); }

.code-block .token.number { color: var(--info); }

.code-block .token.string { color: var(--success); }

.code-block .token.class-name,
.code-block .token.type { color: var(--main); }

.code-block .token.operator,
.code-block .token.punctuation { color: var(--text); }

.code-block .token.boolean { color: var(--info); }

/* ─── Content protection ─── */

.pattern-content {
  user-select: none;
  -webkit-user-select: none;
}

.practice-right {
  user-select: text;
  -webkit-user-select: text;
}

@media print {
  .pattern-content { display: none !important; }
  body::after { content: 'Printing is not allowed'; display: block; text-align: center; padding: 100px; font-size: 24px; }
}

/* ─── Loading ─── */

.loading {
  color: var(--text-dim);
  padding: 2rem;
  text-align: center;
  font-family: Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
}
