/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

/* ===== HEADER: override nav for planck-scale inline tabs ===== */
.knav { gap: 16px; padding: 0 16px; }

/* ===== TABS (inside nav) ===== */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
}
.tab {
  cursor: pointer;
  padding: 6px 16px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  transition: var(--t);
}
.tab:hover { color: var(--text); background: var(--surface2); }
.tab.active { background: var(--surface3); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,0.4); }

/* ===== SEARCH ===== */
.search-wrap { position: relative; display: flex; align-items: center; }
.search-icon {
  position: absolute;
  left: 10px;
  font-size: 16px;
  color: var(--muted);
  pointer-events: none;
}
.search-input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  padding: 7px 12px 7px 32px;
  width: 200px;
  outline: none;
  transition: var(--t);
}
.search-input::placeholder { color: var(--muted); }
.search-input:focus { border-color: var(--border-glow); box-shadow: 0 0 0 2px rgba(78,158,255,0.12); }

/* ===== TAB PANELS ===== */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ===== EXPLORE ===== */
.explore-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 24px 0;
  flex-wrap: wrap;
}
.cat-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.cat-pill {
  cursor: pointer;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: var(--t);
  white-space: nowrap;
  user-select: none;
}
.cat-pill:hover { opacity: 0.85; }
.cat-pill.all {
  background: var(--surface2);
  border-color: var(--border);
  color: var(--text-dim);
}
.cat-pill.all.active {
  background: var(--surface3);
  border-color: var(--border-glow);
  color: var(--text);
}
.count-label { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* ===== CARD GRID ===== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  padding: 14px 24px 32px;
}
.concept-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  transition: var(--t);
  position: relative;
  overflow: hidden;
}
.concept-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--card-accent, var(--blue));
  opacity: 0.8;
}
.concept-card:hover {
  border-color: var(--border-glow);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.card-cat { font-size: 10px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--card-accent, var(--blue)); margin-bottom: 8px; }
.card-id { font-family: var(--font-mono); font-size: 10px; color: var(--muted); float: right; margin-top: 1px; }
.card-topic { font-size: 15px; font-weight: 700; line-height: 1.3; margin-bottom: 8px; letter-spacing: -0.01em; }
.card-one-liner { font-size: 12px; color: var(--text-dim); line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.card-status { font-size: 10px; padding: 2px 8px; border-radius: 999px; background: rgba(255,255,255,0.05); color: var(--muted); border: 1px solid var(--border); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-arrow { font-size: 14px; color: var(--muted); transition: var(--t); }
.concept-card:hover .card-arrow { color: var(--text); transform: translateX(2px); }
.no-results { grid-column: 1/-1; text-align: center; padding: 64px 24px; color: var(--muted); }
.no-results-icon { font-size: 48px; margin-bottom: 12px; }
.no-results-text { font-size: 15px; }

/* ===== FLASHCARDS ===== */
.fc-shell { max-width: 680px; margin: 0 auto; padding: 32px 24px 48px; display: flex; flex-direction: column; align-items: stretch; gap: 20px; }
.fc-header { display: flex; align-items: center; justify-content: space-between; }
.fc-meta { display: flex; align-items: center; gap: 10px; }
.fc-status { font-size: 13px; color: var(--muted); }
.fc-cat-badge { font-size: 10px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; background: rgba(78,158,255,0.12); color: var(--blue); border: 1px solid rgba(78,158,255,0.25); }
.fc-controls { display: flex; gap: 8px; }
.btn-sm { cursor: pointer; padding: 6px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-dim); font-family: var(--font); font-size: 12px; font-weight: 500; transition: var(--t); }
.btn-sm:hover { border-color: var(--border-glow); color: var(--text); }
.fc-progress-bar-wrap { height: 3px; background: var(--surface2); border-radius: 999px; overflow: hidden; }
.fc-progress-bar { height: 100%; background: linear-gradient(90deg, var(--blue), var(--cyan)); border-radius: 999px; transition: width 0.4s cubic-bezier(0.4,0,0.2,1); }
.fc-stage { perspective: 1200px; height: 340px; }
.flashcard { width: 100%; height: 100%; cursor: pointer; outline: none; }
.fc-inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform 0.55s cubic-bezier(0.4,0,0.2,1); }
.flashcard.flipped .fc-inner { transform: rotateY(180deg); }
.fc-front, .fc-back { position: absolute; inset: 0; backface-visibility: hidden; border-radius: var(--radius-lg); border: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 36px; text-align: center; }
.fc-front { background: linear-gradient(135deg, var(--surface) 0%, var(--surface2) 100%); box-shadow: 0 8px 40px rgba(0,0,0,0.5); }
.fc-back { background: linear-gradient(135deg, var(--surface2) 0%, var(--surface3) 100%); transform: rotateY(180deg); text-align: left; align-items: flex-start; justify-content: flex-start; box-shadow: 0 8px 40px rgba(0,0,0,0.5); gap: 14px; }
.fc-front-hint { position: absolute; top: 16px; font-size: 11px; color: var(--muted); letter-spacing: 0.05em; }
.fc-topic { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; }
.fc-id-badge { position: absolute; bottom: 16px; font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.fc-one-liner { font-size: 15px; font-weight: 600; line-height: 1.5; }
.fc-why { font-size: 13px; color: var(--text-dim); line-height: 1.6; }
.fc-eq { font-family: var(--font-mono); font-size: 12px; background: rgba(0,0,0,0.3); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 12px; color: var(--cyan); width: 100%; white-space: pre-wrap; word-break: break-all; }
.fc-eq:empty { display: none; }
.fc-status-badge { font-size: 10px; padding: 3px 10px; border-radius: 999px; background: rgba(255,255,255,0.05); color: var(--muted); border: 1px solid var(--border); align-self: flex-start; }
.fc-nav { display: flex; gap: 12px; justify-content: center; }
.btn-nav { cursor: pointer; padding: 10px 24px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-dim); font-family: var(--font); font-size: 13px; font-weight: 500; transition: var(--t); min-width: 100px; }
.btn-nav:hover { border-color: var(--border-glow); color: var(--text); }
.btn-nav-green { border-color: rgba(52,211,153,0.4); color: var(--green); background: rgba(52,211,153,0.06); }
.btn-nav-green:hover { border-color: var(--green); background: rgba(52,211,153,0.12); }
.fc-keyboard-hint { text-align: center; font-size: 11px; color: var(--muted); }

/* ===== SCALE MAP ===== */
.scale-shell { max-width: 860px; margin: 0 auto; padding: 32px 24px 64px; }
.scale-header { margin-bottom: 40px; }
.scale-title { font-size: 26px; font-weight: 800; letter-spacing: -0.03em; margin-bottom: 10px; }
.scale-desc { color: var(--text-dim); line-height: 1.7; max-width: 600px; }
.scale-desc strong { color: var(--gold); }
.scale-track { position: relative; display: flex; gap: 0; }
.scale-axis { width: 2px; background: linear-gradient(180deg, var(--border) 0%, var(--blue) 40%, var(--purple) 70%, var(--gold) 90%, #ff4444 100%); position: absolute; left: 130px; top: 0; bottom: 0; border-radius: 1px; }
.scale-items { display: flex; flex-direction: column; gap: 0; width: 100%; }
.scale-item { display: flex; align-items: flex-start; gap: 0; position: relative; min-height: 56px; }
.scale-item + .scale-item { border-top: 1px solid var(--border); }
.scale-label { width: 130px; flex-shrink: 0; text-align: right; padding-right: 24px; padding-top: 12px; font-family: var(--font-mono); font-size: 11px; color: var(--muted); line-height: 1.3; }
.scale-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; margin-top: 16px; position: relative; z-index: 2; box-shadow: 0 0 0 3px var(--bg); }
.scale-content { padding: 12px 0 12px 20px; flex: 1; }
.scale-item-name { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.scale-item-detail { font-size: 12px; color: var(--text-dim); line-height: 1.5; }
.scale-zone-label { position: absolute; right: 0; top: 14px; font-size: 10px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; padding: 2px 8px; border-radius: 4px; opacity: 0.7; }
.scale-item.zone-planck .scale-dot { background: var(--gold); box-shadow: 0 0 12px var(--gold), 0 0 0 3px var(--bg); animation: pulse-gold 2s ease-in-out infinite; }
@keyframes pulse-gold { 0%,100% { box-shadow: 0 0 12px var(--gold), 0 0 0 3px var(--bg); } 50% { box-shadow: 0 0 24px var(--gold), 0 0 0 4px var(--bg); } }
.scale-item.zone-planck .scale-item-name { color: var(--gold); }
.scale-item.zone-desert { background: repeating-linear-gradient(-45deg, transparent, transparent 8px, rgba(255,255,255,0.01) 8px, rgba(255,255,255,0.01) 16px); }
.scale-item.zone-desert .scale-item-name { color: var(--muted); font-style: italic; }

/* ===== CONCEPT MODAL ===== */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(6,9,15,0.85); backdrop-filter: blur(8px); cursor: pointer; }
.modal-card { position: relative; background: var(--surface2); border: 1px solid var(--border-glow); border-radius: var(--radius-lg); padding: 32px; max-width: 560px; width: 100%; max-height: 80vh; overflow-y: auto; box-shadow: 0 24px 80px rgba(0,0,0,0.7); animation: modal-in 0.2s cubic-bezier(0.4,0,0.2,1); }
@keyframes modal-in { from { opacity:0; transform: scale(0.95) translateY(8px); } to { opacity:1; transform: scale(1) translateY(0); } }
.modal-close { position: absolute; top: 16px; right: 16px; background: none; border: 1px solid var(--border); border-radius: 6px; color: var(--muted); cursor: pointer; font-size: 14px; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; transition: var(--t); }
.modal-close:hover { border-color: var(--border-glow); color: var(--text); }
.mc-cat { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 8px; }
.mc-id { font-family: var(--font-mono); font-size: 11px; color: var(--muted); float: right; }
.mc-topic { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; margin-bottom: 16px; clear: both; }
.mc-one-liner { font-size: 14px; color: var(--text-dim); line-height: 1.65; margin-bottom: 16px; }
.mc-section { margin-bottom: 14px; }
.mc-label { font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-bottom: 5px; }
.mc-value { font-size: 13px; color: var(--text); line-height: 1.6; }
.mc-eq { font-family: var(--font-mono); font-size: 12px; background: rgba(0,0,0,0.35); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; color: var(--cyan); white-space: pre-wrap; word-break: break-all; margin-top: 5px; }
.mc-status { display: inline-block; font-size: 11px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-dim); background: rgba(255,255,255,0.04); }
.mc-refs { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }

/* ===== MOBILE ===== */
@media (max-width: 768px) {
  .knav { flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 8px; }
  .tabs { order: 3; width: 100%; justify-content: center; }
  .knav-right { gap: 6px; }
  .search-input { width: 140px; }
  .card-grid { grid-template-columns: 1fr; padding: 12px 16px 32px; }
  .explore-bar { padding: 12px 16px 0; }
}
