:root {
  --bg: #080c0f;
  --surface: #0e1318;
  --surface2: #141b22;
  --border: rgba(255,255,255,0.07);
  --border-hover: rgba(255,255,255,0.15);
  --text: #eef2f5;
  --text-muted: #7a8a96;
  --text-dim: #304050;
  --accent:  #2e8fc4;
  --accent2: #3ec9a7;
  --accent3: #e07b5a;
  --accent4: #c45ea0;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Manrope', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
  opacity: 0.4;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(46,143,196,0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(46,143,196,0.015) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
  z-index: 0;
}

.orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
  z-index: 0;
}
.orb-1 {
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(46,143,196,0.1) 0%, transparent 70%);
  top: -150px; right: -150px;
}
.orb-2 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(62,201,167,0.07) 0%, transparent 70%);
  bottom: 100px; left: -100px;
}

/* ── HERO ── */
.hero {
  position: relative;
  z-index: 1;
  padding: 80px 40px 60px;
  max-width: 1480px;
  margin: 0 auto;
}

.hero-tag {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent2);
  border: 1px solid rgba(62,201,167,0.3);
  padding: 4px 14px;
  border-radius: 2px;
  margin-bottom: 32px;
}
.hero-title {
  font: inherit;
  font-size: inherit;
  letter-spacing: inherit;
  color: inherit;
  text-transform: inherit;
  margin: 0;
  font-weight: inherit;
  display: inline;
}
.lang-drop {
  position: relative;
  font-family: 'Space Mono', monospace;
  font-size: 13px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  padding: 0 18px 0 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='6' height='4'%3E%3Cpath d='M0 0l3 4 3-4' fill='none' stroke='%237a8a96' stroke-width='1'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0 center;
}
.lang-drop:hover .lang-current { color: var(--text); }
.lang-drop.open .lang-current { color: var(--text); }
.lang-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 6px;
  list-style: none;
  background: #0e1318;
  border: 1px solid rgba(62,201,167,0.25);
  border-radius: 2px;
  padding: 4px 0;
  min-width: 60px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 0.15s, transform 0.15s;
  z-index: 100;
}
.lang-drop.open .lang-menu {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.lang-menu li {
  padding: 8px 16px;
  font-size: 12px;
  color: var(--text-muted);
  transition: background 0.12s, color 0.12s;
}
.lang-menu li:hover { background: rgba(62,201,167,0.1); color: var(--text); }
.lang-menu li.active { color: var(--accent2); }

.cross {
  display: inline-block;
  font-size: 14px;
  color: var(--accent2);
}

h1 {
  font-family: 'Unbounded', sans-serif;
  font-size: clamp(32px, 6vw, 84px);
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: -0.03em;
  margin-bottom: 24px;
}

h1 .line1 { display: block; color: var(--text); }
h1 .line2 {
  display: block;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 50%, var(--accent3) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-desc {
  font-size: 16px;
  color: var(--text-muted);
  max-width: 500px;
  line-height: 1.7;
  font-weight: 300;
  margin-bottom: 48px;
}

.stats-row { display: flex; gap: 40px; flex-wrap: wrap; }

.stat { display: flex; flex-direction: column; gap: 2px; }

.stat-num {
  font-family: 'Unbounded', sans-serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

/* ── CONTROLS ── */
.controls {
  background: rgba(8,12,15,0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 16px 40px;
}

@media (max-width: 768px) {
  .filters.hidden {
    display: none;
  }
}

.controls-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.search-wrap {
  position: relative;
  flex: 0 1 auto;
  width: 300px;
  min-width: 180px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 14px;
}

#search {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: 'Manrope', sans-serif;
  font-size: 14px;
  padding: 9px 12px 9px 36px;
  outline: none;
  transition: border-color 0.2s;
}

#search:focus { border-color: var(--accent); }
#search::placeholder { color: var(--text-dim); }

.filters { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }

.pill {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.04em;
  padding: 5px 12px;
  border-radius: 2px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  user-select: none;
}

.pill:hover { border-color: var(--border-hover); color: var(--text); }
.pill.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(46,143,196,0.1);
}

.count-badge {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  margin-left: auto;
  align-self: center;
}

/* ── MAIN ── */
.main {
  position: relative;
  z-index: 1;
  max-width: 1480px;
  margin: 0 auto;
  padding: 40px 40px 80px;
}

.category-section { margin-bottom: 56px; }

.category-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.cat-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cat-title {
  font-family: 'Unbounded', sans-serif;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

.cat-line { flex: 1; height: 1px; background: var(--border); }

.cat-count {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  color: var(--text-dim);
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 2px;
}

/* ── CARD ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 24px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px; height: 0;
  background: var(--card-accent, var(--accent));
  transition: height 0.3s ease;
}

.card:hover::before,
.card.open::before { height: 100%; }

.card:hover { background: var(--surface2); border-color: var(--border-hover); }
.card.open { background: var(--surface2); border-color: rgba(46,143,196,0.25); }

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.term-name {
  font-family: 'Unbounded', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.term-latin {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  color: var(--accent);
  margin-bottom: 8px;
  opacity: 0.8;
}

.term-short {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  font-weight: 300;
}

.toggle-icon {
  width: 28px; height: 28px;
  border: 1px solid var(--border);
  border-radius: 2px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim);
  font-size: 18px;
  flex-shrink: 0;
  transition: all 0.2s;
  font-family: monospace;
  line-height: 1;
}

.card:hover .toggle-icon { border-color: var(--border-hover); color: var(--text-muted); }
.card.open .toggle-icon { border-color: var(--accent); color: var(--accent); }

/* ── DETAIL ── */
.card-detail {
  display: none;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  animation: fadeIn 0.2s ease;
}

.card.open .card-detail { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.detail-text {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.75;
  margin-bottom: 14px;
}

.memory-box {
  background: rgba(46,143,196,0.06);
  border: 1px solid rgba(46,143,196,0.15);
  border-left: 3px solid var(--card-accent, var(--accent));
  border-radius: 2px;
  padding: 12px 14px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
  font-style: italic;
}

.memory-label {
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--card-accent, var(--accent));
  margin-bottom: 6px;
  font-style: normal;
}

/* ── EMPTY ── */
.empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-dim);
  font-family: 'Space Mono', monospace;
  font-size: 13px;
}

/* ── FOOTER ── */
footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--border);
  padding: 32px 40px;
}

.footer-inner {
  max-width: 1400px;
  margin: 0 auto;
}

.footer-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent2);
  border: 1px solid rgba(62,201,167,0.3);
  padding: 4px 14px;
  border-radius: 2px;
  margin-bottom: 16px;
}

.footer-bar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.footer-bar-left .cross {
  font-size: 14px;
}

.lang-current-sm {
  color: var(--text-muted);
  font-size: 11px;
}

.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.05em;
}

.footer-link {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
}

.footer-link:hover {
  color: var(--accent2);
}

.footer-top-link {
  cursor: pointer;
  transition: color 0.2s;
  font-size: 16px;
  line-height: 1;
}

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

@media (max-width: 768px) {
  .hero { padding: 60px 20px 40px; }
  .controls { padding: 12px 20px; }
  .main { padding: 24px 20px 60px; }
  .controls-inner { flex-direction: column; align-items: stretch; }
  .search-wrap { width: 100%; max-width: 100%; min-width: 0; }
  .count-badge { margin-left: 0; }
  footer { padding: 20px; }
  .footer-bottom { flex-direction: column; gap: 6px; text-align: center; }
}



#top-btn {
  position: fixed;
  bottom: 32px;
  right: 32px;
  z-index: 200;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, background 0.2s;
}
#top-btn.visible {
  opacity: 1;
  pointer-events: auto;
}
#top-btn:hover {
  background: var(--surface2);
  color: var(--text);
}