/* ═══════════════════════════════════════════════════════════════
   WordStats — style.css
   ═══════════════════════════════════════════════════════════════ */

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

:root {
  --bg:          #0d0f14;
  --bg-card:     rgba(19, 22, 30, 0.70);
  --bg-card2:    rgba(26, 30, 42, 0.88);
  --border:      rgba(255,255,255,0.07);
  --border-glow: rgba(110,86,255,0.35);

  --text:        #f0f2f8;
  --text-sub:    #8b90a8;
  --text-dim:    #555b75;

  --accent:      #6e56ff;
  --accent2:     #a855f7;
  --accent3:     #06b6d4;
  --accent-glow: rgba(110,86,255,0.25);

  --success:     #22c55e;
  --warn:        #f59e0b;
  --danger:      #ef4444;

  --radius:      16px;
  --radius-sm:   10px;
  --radius-xs:   6px;

  --font-body:  'Inter', system-ui, sans-serif;
  --font-head:  'Space Grotesk', system-ui, sans-serif;

  --shadow-card: 0 4px 32px rgba(0,0,0,0.45);
  --shadow-glow: 0 0 40px rgba(110,86,255,0.18);
}

html { background: var(--bg); scroll-behavior: smooth; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); }


body {
  background: transparent;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
}

/* ── Background gradient layer ─────────────────────────────────── */
.bg-layer {
  position: fixed;
  inset: -30%;
  z-index: 0;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 90% 70%  at 15%   5%,  rgba(110, 86,255,0.28) 0%, transparent 55%),
    radial-gradient(ellipse 85% 65%  at 88%  95%,  rgba(168, 85,247,0.24) 0%, transparent 55%),
    radial-gradient(ellipse 140% 100% at 50%  50%, rgba(110, 86,255,0.06) 0%, transparent 65%),
    radial-gradient(ellipse  60% 45%  at 55%  52%, rgba(  6,182,212,0.10) 0%, transparent 50%),
    radial-gradient(ellipse  50% 40%  at 25%  75%, rgba(110, 86,255,0.10) 0%, transparent 50%);
  mask-image: radial-gradient(ellipse 75% 75% at 50% 50%, black 45%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 75% 75% at 50% 50%, black 45%, transparent 100%);
  will-change: transform;
  pointer-events: none;
}

/* Prevent any child from blowing out horizontal bounds */
input, select, textarea, button { max-width: 100%; }

a { color: inherit; text-decoration: none; }
img { display: block; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select { font-family: inherit; }

/* Remove click-flash outline; keep keyboard focus ring */
*:focus          { outline: none; }
*:focus-visible  { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ── Utility ──────────────────────────────────────────────────── */
.hidden { display: none !important; }
.view   { position: relative; z-index: 1; min-height: 100vh; }

.gradient-text {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Navbar ───────────────────────────────────────────────────── */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  padding: 0 24px;
  margin: 6px;
  height: 64px;
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.462);
  backdrop-filter: blur(40px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.175);
  box-shadow:
    0 2px 0  rgba(110,86,255,0.10),
    0 4px 20px rgba(0,0,0,0.28),
    0 16px 48px rgba(0,0,0,0.18);
  border-radius:  24px;
}

.nav-inner {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-head);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.nav-logo-img { width: 32px; height: 32px; }

.nav-actions { display: flex; align-items: center; gap: 10px; }

.btn-ghost {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-sub);
  font-size: 0.875rem;
  font-weight: 500;
  transition: color 0.2s, background 0.2s;
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); background: var(--bg-card2); }

.btn-challenge {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: opacity 0.2s, transform 0.15s;
  box-shadow: 0 2px 16px rgba(110,86,255,0.4);
}
.btn-challenge:hover { opacity: 0.9; transform: translateY(-1px); }

.btn-icon { width: 16px; height: 16px; filter: brightness(0) invert(1); }
.btn-ghost .btn-icon { opacity: 0.5; transition: opacity 0.2s; }
.btn-ghost:hover .btn-icon { opacity: 1; }

/* ── Hero ─────────────────────────────────────────────────────── */
.hero {
  position: relative;
  min-height: 100svh;
  min-height: 100vh; /* fallback */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 100px 24px 80px;
  overflow: hidden;
}

.hero-bg-orbs { position: absolute; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.35;
}
.orb-1 {
  width: 600px; height: 600px;
  background: radial-gradient(circle, var(--accent), transparent 70%);
  top: -200px; left: -150px;
  animation: orbFloat1 10s ease-in-out infinite;
}
.orb-2 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, var(--accent2), transparent 70%);
  bottom: -150px; right: -100px;
  animation: orbFloat2 13s ease-in-out infinite;
}
.orb-3 {
  width: 350px; height: 350px;
  background: radial-gradient(circle, var(--accent3), transparent 70%);
  top: 40%; left: 50%;
  transform: translate(-50%,-50%);
  opacity: 0.18;
  animation: orbFloat3 8s ease-in-out infinite;
}

@keyframes orbFloat1 {
  0%,100% { transform: translate(0,0); }
  50%      { transform: translate(30px,20px); }
}
@keyframes orbFloat2 {
  0%,100% { transform: translate(0,0); }
  50%      { transform: translate(-20px,30px); }
}
@keyframes orbFloat3 {
  0%,100% { transform: translate(-50%,-50%) scale(1); }
  50%      { transform: translate(-50%,-50%) scale(1.15); }
}

.hero-content {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 700px;
  width: 100%;
}

.hero-eyebrow {
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 20px;
}

.hero-title {
  font-family: var(--font-head);
  font-size: clamp(2rem, 5vw, 3.4rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 20px;
}

.hero-sub {
  color: var(--text-sub);
  font-size: 1.05rem;
  max-width: 500px;
  margin: 0 auto 40px;
}

/* ── Search ───────────────────────────────────────────────────── */
.search-form { width: 100%; }

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1.5px solid rgba(255,255,255,0.10);
  border-radius: 100px;
  padding: 6px 6px 6px 20px;
  transition: border-color 0.25s, box-shadow 0.25s;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
}
.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: var(--shadow-card), 0 0 0 4px var(--accent-glow);
}

/* Search icon toggle button */
.search-icon-btn {
  position: relative;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
}

.si-search,
.si-clear {
  position: absolute;
  width: 20px;
  height: 20px;
  filter: brightness(0) invert(1);
  transition: opacity 0.2s ease, transform 0.25s ease;
  pointer-events: none;
}

/* default: show magnifier, hide X */
.si-search { opacity: 0.5; transform: scale(1)   rotate(0deg);   }
.si-clear  { opacity: 0;   transform: scale(0.4) rotate(-45deg); }

/* has-text: hide magnifier, show X */
.search-box.has-text .si-search { opacity: 0;   transform: scale(0.4) rotate(45deg);  }
.search-box.has-text .si-clear  { opacity: 0.65; transform: scale(1)   rotate(0deg);   }
.search-box.has-text .search-icon-btn:hover .si-clear { opacity: 1; }

.search-input {
  flex: 1;
  min-width: 0; /* critical: prevents flex child from overflowing */
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 1rem;
  padding: 10px 14px;
}
.search-input::placeholder { color: var(--text-dim); }

.search-btn {
  padding: 11px 28px;
  border-radius: 100px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  flex-shrink: 0;
  transition: opacity 0.2s, transform 0.15s;
  box-shadow: 0 2px 12px rgba(110,86,255,0.45);
}
.search-btn:hover { opacity: 0.88; transform: scale(0.98); }

/* mini variant */
.search-form.mini .search-box { padding: 4px 4px 4px 16px; }
.search-form.mini .search-input { font-size: 0.9rem; padding: 8px 12px; }
.search-form.mini .search-btn  { padding: 8px 20px; font-size: 0.85rem; }

/* ── Trending chips ───────────────────────────────────────────── */
.trending {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 28px;
}
.trending-label {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-weight: 500;
  letter-spacing: 0.06em;
}
.trend-chip {
  padding: 5px 14px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-sub);
  font-size: 0.825rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.trend-chip:hover { border-color: var(--accent); color: var(--text); background: var(--bg-card2); }

/* ── Categories strip ─────────────────────────────────────────── */
.categories-strip {
  padding: 60px 24px 100px;
  width: 100%;
  background: rgba(38, 41, 52, 0.529);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border-radius: 28px;
  border: 1px solid rgba(255,255,255,0.10);
  box-shadow:
    0 -8px 32px rgba(0,0,0,0.55),
    inset 0 1px 0 rgba(255,255,255,0.06);
}

.strip-header {
  text-align: center;
  margin-bottom: 48px;
  max-width: 1120px;
  margin-left: auto;
  margin-right: auto;
}
.strip-title {
  font-family: var(--font-head);
  font-size: clamp(1.4rem, 3vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  margin-bottom: 10px;
}
.strip-sub { color: var(--text-sub); font-size: 0.95rem; }

.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  max-width: 1120px;
  margin: 0 auto;
}

.cat-card {
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  padding: 28px 20px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.25s, transform 0.2s, box-shadow 0.25s;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(16px) saturate(1.3);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
}
.cat-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(110,86,255,0.06) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
}
.cat-card:hover {
  border-color: var(--border-glow);
  transform: translateY(-4px);
  box-shadow: var(--shadow-glow);
}
.cat-card:hover::before { opacity: 1; }
.cat-card-emoji { font-size: 2.4rem; margin-bottom: 12px; line-height: 1; }
.cat-card-name {
  font-family: var(--font-head);
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 6px;
}
.cat-card-count { font-size: 0.8rem; color: var(--text-dim); }

/* ── Result View ──────────────────────────────────────────────── */
.result-layout {
  max-width: 820px;
  margin: 0 auto;
  padding: 88px 24px 80px;
}

.result-topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 40px;
  flex-wrap: wrap;
}
.result-topbar .search-form {
  flex: 1;
  min-width: 0;
  width: auto;
}
.result-topbar .search-form.mini .search-box { width: 100%; }

.btn-back {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color 0.2s, background 0.2s;
}
.btn-back:hover { border-color: var(--accent); background: var(--bg-card2); }
.btn-back img { width: 18px; height: 18px; filter: brightness(0) invert(1); }

.result-hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 32px;
  align-items: center;
  margin-bottom: 32px;
}

.result-language-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 100px;
  background: rgba(110,86,255,0.12);
  border: 1px solid rgba(110,86,255,0.3);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--accent);
  margin-bottom: 12px;
}
.badge-icon { width: 13px; height: 13px; filter: brightness(0) invert(1); opacity: 0.8; }

.result-word {
  font-family: var(--font-head);
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 10px;
}

.result-variants {
  font-size: 0.85rem;
  color: var(--text-dim);
  font-style: italic;
}

/* ── Ring ─────────────────────────────────────────────────────── */
.ring-wrap {
  position: relative;
  width: 200px;
  height: 200px;
  flex-shrink: 0;
}
.ring-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg  { fill: none; stroke: var(--bg-card2); stroke-width: 14; }
.ring-fill {
  fill: none;
  stroke: url(#ringGrad);
  stroke-width: 14;
  stroke-linecap: round;
  stroke-dasharray: 515;
  stroke-dashoffset: 515;
  transition: stroke-dashoffset 1.4s cubic-bezier(.25,.8,.25,1);
}

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.ring-pct  { font-family: var(--font-head); font-size: 1.8rem; font-weight: 700; }
.ring-label { font-size: 0.7rem; color: var(--text-dim); text-align: center; margin-top: 2px; }

.mini-ring-wrap { position: relative; width: 120px; height: 120px; flex-shrink: 0; }
.mini-ring .ring-bg  { stroke-width: 10; }
.mini-ring .ring-fill { stroke-width: 10; stroke-dasharray: 301; stroke-dashoffset: 301; }
.mini-ring-wrap .ring-pct { font-size: 1.2rem; }

.result-meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
}
.meta-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 22px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-width: 90px;
  transition: border-color 0.2s;
}
.meta-chip:hover { border-color: var(--border-glow); }
.meta-value { font-family: var(--font-head); font-size: 1.2rem; font-weight: 700; }
.meta-key   { font-size: 0.75rem; color: var(--text-dim); margin-top: 2px; }

/* ── Unknown word banner ──────────────────────────────────────── */
.unknown-word-banner {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 20px 22px;
  border-radius: var(--radius);
  background: rgba(245,158,11,0.08);
  border: 1px solid rgba(245,158,11,0.28);
  box-shadow: 0 4px 24px rgba(0,0,0,0.3);
  margin-bottom: 24px;
  flex-wrap: wrap;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.uw-icon { font-size: 1.8rem; line-height: 1; flex-shrink: 0; margin-top: 2px; }
.uw-body { flex: 1; min-width: 200px; }
.uw-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.uw-title strong { color: var(--warn); }
.uw-sub { font-size: 0.82rem; color: var(--text-sub); }
.uw-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.uw-btn { white-space: nowrap; }

/* ── Cards ────────────────────────────────────────────────────── */
.result-section { margin-bottom: 20px; }
.card {
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: var(--radius);
  padding: 24px 28px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(22px) saturate(1.4);
  -webkit-backdrop-filter: blur(22px) saturate(1.4);
}
.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(110,86,255,0.25), transparent);
  pointer-events: none;
}
.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}
.card-header h3 {
  font-family: var(--font-head);
  font-size: 1rem;
  font-weight: 600;
}
.card-icon { width: 20px; height: 20px; opacity: 0.75; filter: brightness(0) invert(1); }

/* ── Category display ─────────────────────────────────────────── */
.detected-category {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.cat-label { font-size: 0.85rem; color: var(--text-dim); }
.cat-badge {
  padding: 4px 14px;
  background: rgba(110,86,255,0.15);
  border: 1px solid rgba(110,86,255,0.3);
  border-radius: 100px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
}
.cat-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.correct-toggle {
  background: none;
  border: none;
  padding: 2px 10px;
  border-radius: 100px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  background: rgba(110,86,255,0.12);
  border: 1px solid rgba(110,86,255,0.28);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  line-height: 1.6;
}
.correct-toggle:hover {
  background: rgba(110,86,255,0.22);
  color: #fff;
}

.cat-correction {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  overflow: hidden;
  max-height: 200px;
  transition: max-height 0.3s ease, opacity 0.25s ease, margin-top 0.25s ease;
  opacity: 1;
  margin-top: 0;
}
.cat-correction.collapsed {
  max-height: 0;
  opacity: 0;
  margin-top: -4px;
  pointer-events: none;
}

.cat-select {
  flex: 1;
  min-width: 180px;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text);
  padding: 8px 12px;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.2s;
}
.cat-select:focus { border-color: var(--accent); }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn-primary {
  padding: 10px 22px;
  border-radius: var(--radius-xs);
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  font-weight: 600;
  font-size: 0.875rem;
  transition: opacity 0.2s, transform 0.15s;
  box-shadow: 0 2px 10px rgba(110,86,255,0.4);
}
.btn-primary:hover { opacity: 0.88; transform: translateY(-1px); }
.btn-small { padding: 7px 16px; font-size: 0.8rem; }

/* ── Related chips ────────────────────────────────────────────── */
.related-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.related-chip {
  padding: 5px 14px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: var(--bg-card2);
  color: var(--text-sub);
  font-size: 0.825rem;
  cursor: pointer;
  transition: all 0.2s;
}
.related-chip:hover { border-color: var(--accent); color: var(--text); }
.related-empty { font-size: 0.85rem; color: var(--text-dim); font-style: italic; }

.add-related-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.mini-input {
  flex: 1;
  min-width: 160px;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text);
  padding: 8px 12px;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.2s;
}
.mini-input:focus { border-color: var(--accent); }

/* ── Cat stat ─────────────────────────────────────────────────── */
.cat-stat-inner { display: flex; align-items: center; gap: 24px; }
.cat-stat-label { font-size: 0.9rem; color: var(--text-sub); }

/* ── Category View ────────────────────────────────────────────── */
.cat-view-layout {
  max-width: 820px;
  margin: 0 auto;
  padding: 88px 24px 80px;
}
.cat-view-header { text-align: center; margin: 24px 0 48px; }
.cat-view-icon { font-size: 3.5rem; margin-bottom: 12px; }
.cat-view-name {
  font-family: var(--font-head);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin-bottom: 8px;
}
.cat-view-count { font-size: 0.9rem; color: var(--text-dim); }

.cat-words-list { display: flex; flex-direction: column; gap: 12px; }
.cat-word-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
}
.cat-word-row:hover { border-color: var(--border-glow); transform: translateX(4px); }
.cat-word-rank {
  font-size: 0.8rem;
  color: var(--text-dim);
  width: 28px;
  text-align: center;
  flex-shrink: 0;
}
.cat-word-text {
  font-family: var(--font-head);
  font-size: 1rem;
  font-weight: 600;
  flex: 1;
}
.cat-word-bar-wrap {
  flex: 2;
  height: 6px;
  background: var(--bg-card2);
  border-radius: 100px;
  overflow: hidden;
}
.cat-word-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 100px;
  transition: width 0.8s ease;
}
.cat-word-pct {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-sub);
  width: 48px;
  text-align: right;
  flex-shrink: 0;
}

/* ── Challenge View ───────────────────────────────────────────── */
.challenge-layout {
  max-width: 700px;
  margin: 0 auto;
  padding: 88px 24px 80px;
}
.challenge-hero {
  text-align: center;
  padding: 40px 0 32px;
}
.challenge-hero-icon { width: 56px; height: 56px; margin: 0 auto 18px; filter: brightness(0) invert(1) drop-shadow(0 0 18px var(--accent)); }
.challenge-title {
  font-family: var(--font-head);
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin-bottom: 12px;
}
.challenge-sub { color: var(--text-sub); font-size: 0.95rem; max-width: 480px; margin: 0 auto; }

.challenge-search-wrap { margin-bottom: 36px; }

.challenge-result { margin-bottom: 40px; }
.challenge-score-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  display: flex;
  gap: 32px;
  align-items: center;
  box-shadow: var(--shadow-card);
}
.score-ring-wrap { position: relative; width: 160px; height: 160px; flex-shrink: 0; }
.score-ring-fill { stroke: url(#scoreGrad); }
.score-ring-wrap .ring-pct { font-size: 1.6rem; }

.challenge-word-info { flex: 1; }
.challenge-word-info h3 {
  font-family: var(--font-head);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.challenge-word-info p { font-size: 0.875rem; color: var(--text-sub); margin-bottom: 16px; }

.rarity-bar-wrap {
  height: 8px;
  background: var(--bg-card2);
  border-radius: 100px;
  overflow: hidden;
  margin-bottom: 6px;
}
.rarity-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--success), var(--warn), var(--danger));
  border-radius: 100px;
  transition: width 1s ease;
}
.rarity-bar-legend {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-dim);
}

.leaderboard-section { margin-top: 32px; }
.leaderboard-title {
  font-family: var(--font-head);
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.leaderboard-list { display: flex; flex-direction: column; gap: 10px; }
.lb-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.lb-rank { font-size: 0.8rem; color: var(--text-dim); width: 24px; text-align: center; }
.lb-word { font-weight: 600; flex: 1; }
.lb-pct  { font-size: 0.85rem; color: var(--text-dim); }
.lb-badge-uncommon {
  padding: 2px 10px;
  border-radius: 100px;
  background: rgba(239,68,68,0.15);
  border: 1px solid rgba(239,68,68,0.3);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--danger);
}

/* ── Toast ────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--bg-card2);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: var(--radius-sm);
  padding: 12px 22px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-card);
  z-index: 200;
  transition: transform 0.35s cubic-bezier(.34,1.56,.64,1), opacity 0.25s;
  opacity: 0;
  backdrop-filter: blur(20px) saturate(1.3);
  -webkit-backdrop-filter: blur(20px) saturate(1.3);
}
.toast.show  { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast-icon  { width: 18px; height: 18px; filter: brightness(0) invert(1); }

/* ── Loader ───────────────────────────────────────────────────── */
.loader-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13,15,20,0.6);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
}
.loader-spinner {
  width: 44px; height: 44px;
  border: 3px solid var(--bg-card2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* SVG gradient defs — injected inline so CSS can reference it */
.svg-defs { position: absolute; width: 0; height: 0; }

/* ── Language badge ──────────────────────────────────────────── */
.lang-badge {
  padding: 4px 14px;
  background: rgba(6,182,212,0.12);
  border: 1px solid rgba(6,182,212,0.3);
  border-radius: 100px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent3);
}

/* ── Rarity badge ─────────────────────────────────────────────── */
.rarity-common   { color: var(--success); }
.rarity-uncommon { color: var(--warn);    }
.rarity-rare     { color: var(--danger);  }

/* ── Scrollbar ────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-card2); border-radius: 100px; }

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════ */

/* ── Tablet / large phone (≤ 700px) ─────────────────────────── */
@media (max-width: 700px) {
  /* Result hero: stack ring below word */
  .result-hero {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .result-word-block { order: 1; }
  .result-stat-block { order: 2; }
  .result-language-badge { margin: 0 auto 12px; }

  .ring-wrap { width: 160px; height: 160px; margin: 0 auto; }
  .ring-pct  { font-size: 1.4rem; }
  .result-meta { justify-content: center; }

  /* Challenge: stack vertically */
  .challenge-score-card { flex-direction: column; text-align: center; padding: 20px 16px; }
  .score-ring-wrap { margin: 0 auto; }
  .challenge-word-info { width: 100%; }

  /* Category word list: hide bar, keep rank/text/pct */
  .cat-word-bar-wrap { display: none; }

  /* Navbar: hide "Categories" label text */
  .nav-actions .btn-ghost span { display: none; }
  .btn-ghost { padding: 8px 10px; gap: 0; }
}

/* ── Small phone (≤ 480px) ───────────────────────────────────── */
@media (max-width: 480px) {
  /* Prevent any horizontal overflow */
  body { overflow-x: hidden; }

  /* Navbar: tighter, hide challenge text too */
  .navbar { padding: 0 14px; }
  .btn-challenge span { display: none; }
  .btn-challenge { padding: 8px 10px; gap: 0; }
  .btn-icon { width: 18px; height: 18px; }

  /* Hero */
  .hero { padding: 84px 16px 60px; min-height: auto; }
  .hero-title { font-size: 1.75rem; }
  .hero-sub   { font-size: 0.9rem; margin-bottom: 28px; }
  .hero-eyebrow { font-size: 0.72rem; }

  /* Search bar */
  .search-box { padding: 5px 5px 5px 14px; }
  .search-input { font-size: 0.9rem; padding: 8px 10px; }
  .search-btn {
    padding: 9px 18px;
    font-size: 0.82rem;
    white-space: nowrap;
  }
  .search-icon-btn, .si-search, .si-clear { width: 17px; height: 17px; }

  /* Mini search bar in result topbar */
  .result-topbar {
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 24px;
  }
  .result-topbar .search-form { flex: 1; min-width: 0; }
  .result-topbar .search-form.mini .search-box { width: 100%; }

  /* Result layout */
  .result-layout { padding: 80px 16px 60px; }
  .result-word { font-size: 1.8rem; }
  .result-hero { gap: 20px; margin-bottom: 20px; }
  .ring-wrap { width: 140px; height: 140px; }
  .ring-pct  { font-size: 1.25rem; }

  /* Meta chips: 3-up then wrap */
  .result-meta { gap: 8px; }
  .meta-chip { padding: 10px 14px; min-width: 0; flex: 1 1 calc(33% - 6px); }
  .meta-value { font-size: 1rem; }
  .meta-key   { font-size: 0.7rem; }

  /* Cards */
  .card { padding: 18px 16px; }
  .card-header { margin-bottom: 14px; }

  /* Category & language correction: stack select + button */
  .cat-correction { flex-direction: column; align-items: stretch; }
  .cat-select { min-width: 0; width: 100%; }
  .cat-correction .btn-primary { width: 100%; text-align: center; }

  /* Related: stack input + button */
  .add-related-row { flex-direction: column; align-items: stretch; }
  .mini-input { min-width: 0; width: 100%; }
  .add-related-row .btn-primary { width: 100%; text-align: center; }

  /* Cat stat ring */
  .cat-stat-inner { flex-direction: column; text-align: center; gap: 12px; }
  .mini-ring-wrap { margin: 0 auto; }

  /* Categories grid: 2 columns */
  .categories-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .cat-card { padding: 20px 12px 16px; }
  .cat-card-emoji { font-size: 2rem; }
  .categories-strip { padding: 40px 16px 60px; border-radius: 20px; }

  /* Category view */
  .cat-view-layout { padding: 80px 16px 60px; }
  .cat-view-name { font-size: 1.6rem; }
  .cat-word-row { padding: 12px 14px; gap: 10px; }
  .cat-word-text { font-size: 0.9rem; }

  /* Challenge view */
  .challenge-layout { padding: 80px 16px 60px; }
  .challenge-title { font-size: 1.75rem; }
  .challenge-score-card { padding: 18px 14px; gap: 20px; }
  .score-ring-wrap { width: 130px; height: 130px; }
  .challenge-word-info h3 { font-size: 1.25rem; }
  .lb-row { padding: 12px 14px; gap: 10px; }
  .lb-badge-uncommon { display: none; } /* too tight — info already implied */

  /* Toast: full-width with margin so it never clips edges */
  .toast {
    left: 16px;
    right: 16px;
    transform: translateY(80px);
    width: auto;
    max-width: none;
  }
  .toast.show { transform: translateY(0); }
}

/* ── Very small phone (≤ 360px) ─────────────────────────────── */
@media (max-width: 360px) {
  .hero-title { font-size: 1.5rem; }
  .search-btn { padding: 9px 14px; font-size: 0.78rem; }
  .meta-chip { flex: 1 1 calc(50% - 4px); }
  .categories-grid { grid-template-columns: repeat(2, 1fr); }
  .result-word { font-size: 1.5rem; }
}

/* ═══════════════════════════════════ FOOTER ════════════════════════════════════════ */

.site-footer {
  margin-top: 3.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(13, 15, 20, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.footer-inner {
  max-width: 920px;
  margin: 0 auto;
  padding: 3.5rem 1.5rem 2.5rem;
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 3.5rem;
  align-items: start;
}

/* Brand column */
.footer-brand {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.footer-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.footer-logo img {
  width: 22px;
  height: 22px;
  filter: brightness(0) invert(1);
}

.footer-tagline {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.65;
}

.footer-built-note {
  font-size: 0.78rem;
  color: var(--text-muted);
  opacity: 0.55;
  line-height: 1.6;
}

/* FAQ column */
.footer-section-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.1rem;
}

.faq-item {
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.faq-item:last-child {
  border-bottom: none;
}

.faq-question {
  padding: 0.8rem 0;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  user-select: none;
  transition: color 0.15s;
}

.faq-question:hover { color: var(--accent); }

.faq-question::-webkit-details-marker { display: none; }

.faq-question::after {
  content: '+';
  font-size: 1.25rem;
  font-weight: 300;
  color: var(--accent);
  flex-shrink: 0;
  line-height: 1;
  transition: transform 0.2s;
}

details[open] > .faq-question::after {
  transform: rotate(45deg);
}

.faq-answer {
  padding: 0 1rem 1rem 0;
  font-size: 0.83rem;
  color: var(--text-muted);
  line-height: 1.75;
  max-width: 62ch;
}

/* Copyright bar */
.footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding: 1.25rem 1.5rem 1.75rem;
}

.footer-bottom-inner {
  max-width: 920px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.footer-copy {
  font-size: 0.78rem;
  color: var(--text-muted);
  opacity: 0.7;
  font-weight: 500;
}

.footer-legal {
  font-size: 0.73rem;
  color: var(--text-muted);
  opacity: 0.45;
  line-height: 1.6;
}

@media (max-width: 700px) {
  .footer-inner {
    grid-template-columns: 1fr;
    gap: 2rem;
    padding: 2.5rem 1.25rem 2rem;
  }
}

@media (max-width: 480px) {
  .footer-bottom { padding: 1rem 1.25rem 1.5rem; }
}

/* ══════════════════════════════════════════════════════════════
   DESKTOP ENHANCEMENTS  (≥ 1024px)
   Only improves the desktop view — tablets and phones untouched.
   ══════════════════════════════════════════════════════════════ */
@media (min-width: 1024px) {
  /* Hero: larger title and search on wide screens */
  .hero-content  { max-width: 780px; }
  .hero-title    { font-size: clamp(2.8rem, 4.5vw, 5rem); }
  .hero-sub      { font-size: 1.12rem; max-width: 580px; }

  /* Result word: much bigger on desktop */
  .result-word   { font-size: clamp(3rem, 4.5vw, 5rem); }

  /* Result layout: a bit wider */
  .result-layout { max-width: 960px; }

  /* Ring: slightly bigger with bigger percentage label */
  .ring-wrap     { width: 220px; height: 220px; }
  .ring-pct      { font-size: 2rem; }

  /* Meta chips: comfortable min-width */
  .meta-chip     { min-width: 120px; }
}
