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

:root {
  --bg: #0e0e0e;
  --bg2: #161616;
  --bg3: #1f1f1f;
  --border: #2e2e2e;
  --text: #e8e8e0;
  --muted: #888;
  --red: #e8473f;
  --gold: #c8a84b;
  --blue: #4a90d9;
  --accent: var(--red);
}

body.jp { --accent: var(--blue); }

html { scroll-behavior: smooth; }

a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 16px;
  line-height: 1.7;
  min-height: 100vh;
}

body.jp { font-family: 'Zen Kaku Gothic New', 'IBM Plex Mono', monospace; font-size: 16px; }
body.jp p, body.jp .step p { font-size: 15px; }
body.jp .yt-card-desc { font-size: 14px; }
body.jp .info-box { font-size: 15px; line-height: 1.9; }

/* ── NAV ── */
nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(14,14,14,0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: stretch;
}
nav .nav-links {
  display: flex;
  overflow-x: auto;
  flex: 1;
}
nav a {
  display: inline-flex;
  align-items: center;
  padding: 16px 22px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  letter-spacing: 0.08em;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.2s, border-color 0.2s;
  text-transform: uppercase;
  text-decoration: none;
}
body.jp nav a { font-family: 'Zen Kaku Gothic New', sans-serif; letter-spacing: 0.06em; }
nav a:hover { color: var(--text); text-decoration: none; }
nav a.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Flags / lang switcher */
.nav-lang {
  display: flex;
  align-items: center;
  padding: 0 0.75rem;
  flex-shrink: 0;
}
.nav-flag {
  padding: 14px 10px;
  font-size: 1.2rem;
  text-decoration: none;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}
.nav-flag--current { opacity: 0.4; cursor: default; }
.nav-flag:hover { text-decoration: none; opacity: 0.8; }
.nav-flag--current:hover { opacity: 0.4; }

/* Hamburger — hidden on desktop */
.nav-hamburger { display: none; }
.nav-active-label { display: none; }

/* ── PAGE CONTENT ── */
.section {
  padding: 3rem 1.5rem;
  max-width: 960px;
  margin: 0 auto;
}

.section-title {
  font-family: 'Zen Kaku Gothic New', sans-serif;
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  gap: 12px;
}
.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── STEPS ── */
.step {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}
.step:last-child { border-bottom: none; }

.step-num {
  width: 36px;
  height: 36px;
  border: 1px solid var(--accent);
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--accent);
  font-size: 13px;
  font-family: 'IBM Plex Mono', monospace;
  flex-shrink: 0;
}

.step h3 {
  font-family: 'Zen Kaku Gothic New', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.step p { color: var(--muted); font-size: 15px; line-height: 1.7; }
.step a { color: var(--gold); text-decoration: none; }
.step a:hover { text-decoration: underline; }

.details-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  color: var(--gold);
  font-size: 13px;
  cursor: pointer;
  letter-spacing: 0.05em;
  user-select: none;
  background: none;
  border: none;
  padding: 0;
  font-family: 'IBM Plex Mono', monospace;
}
.details-toggle:hover { text-decoration: underline; }
.details-toggle .arrow { transition: transform 0.2s; display: inline-block; }
.details-toggle.open .arrow { transform: rotate(90deg); }

.step-details {
  display: none;
  margin-top: 1rem;
  border-left: 2px solid var(--border);
  padding-left: 1rem;
}
.step-details.open { display: block; }

.step-detail-item { margin-bottom: 1rem; }
.step-detail-item p { color: var(--muted); font-size: 14px; margin-bottom: 6px; }
.step-detail-item img {
  width: 100%;
  max-width: 480px;
  border: 1px solid var(--border);
  border-radius: 4px;
  display: block;
}

/* ── INFO BOX ── */
.info-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.8;
}
.info-box strong { color: var(--text); }

/* ── KANA TABLE ── */
.kana-tabs { display: flex; gap: 8px; margin-bottom: 1.5rem; }
.kana-tab {
  padding: 8px 20px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: none;
  color: var(--muted);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
}
.kana-tab.active { border-color: var(--red); color: var(--red); }

.kana-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 6px;
}

.kana-cell {
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 10px 6px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.kana-cell:hover { border-color: var(--red); background: var(--bg3); }
.kana-cell .jp { font-family: 'Zen Kaku Gothic New', sans-serif; font-size: 22px; }
.kana-cell .rom { font-size: 12px; color: var(--muted); margin-top: 4px; letter-spacing: 0.05em; }
.kana-cell .kana-audio { font-size: 11px; margin-top: 5px; opacity: 0.25; transition: opacity 0.15s; }
.kana-cell:hover .kana-audio { opacity: 0.7; }

/* ── TRAINER ── */
.trainer-modes { display: flex; gap: 8px; margin-bottom: 2rem; flex-wrap: wrap; }
.mode-btn {
  padding: 8px 20px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: none;
  color: var(--muted);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
}
.mode-btn.active { border-color: var(--red); color: var(--red); }

.score-bar {
  display: flex;
  gap: 2rem;
  margin-bottom: 2rem;
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.score-bar strong { color: var(--text); font-size: 18px; display: block; }

.trainer-card {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3rem 2rem;
  text-align: center;
  background: var(--bg2);
  max-width: 420px;
  margin: 0 auto;
}

.trainer-char {
  font-family: 'Zen Kaku Gothic New', sans-serif;
  font-size: 96px;
  line-height: 1;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.trainer-hint {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 1.5rem;
  min-height: 20px;
  letter-spacing: 0.05em;
}
.trainer-hint.ok { color: #4caf50; }
.trainer-hint.err { color: var(--red); }

.answers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 1rem;
}

.ans-btn {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--bg3);
  color: var(--text);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.15s;
}
.ans-btn:hover { border-color: var(--muted); }
.ans-btn.correct { border-color: #4caf50; color: #4caf50; background: rgba(76,175,80,0.08); }
.ans-btn.wrong { border-color: var(--red); color: var(--red); background: rgba(232,71,63,0.08); }

.replay-btn {
  padding: 6px 20px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: none;
  color: var(--muted);
  font-size: 1.6rem;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 0.75rem;
  display: block;
  width: 100%;
}
.replay-btn:hover { color: var(--text); border-color: var(--muted); }

.next-btn {
  padding: 10px 28px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: none;
  color: var(--muted);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  letter-spacing: 0.08em;
  cursor: pointer;
  text-transform: uppercase;
  transition: all 0.2s;
  display: none;
}
.next-btn:hover { color: var(--text); border-color: var(--text); }

/* ── CYRILLIC TABLE ── */
.cyr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 6px;
  margin-bottom: 2rem;
}
.cyr-cell {
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 10px 6px;
  text-align: center;
  cursor: default;
  transition: border-color 0.2s, background 0.2s;
  background: var(--bg2);
}
.cyr-cell:hover { border-color: var(--blue); background: var(--bg3); }
.cyr-cell .letter { font-family: 'IBM Plex Mono', monospace; font-size: 22px; color: var(--text); }
.cyr-cell .rom { font-size: 12px; color: var(--muted); margin-top: 4px; letter-spacing: 0.05em; font-family: 'IBM Plex Mono', monospace; }
.cyr-cell .ipa { font-size: 12px; color: var(--blue); margin-top: 2px; font-family: 'IBM Plex Mono', monospace; }
.cyr-cell .audio-btn {
  background: none; border: none; cursor: pointer; color: var(--muted);
  font-size: 12px; padding: 0; margin-top: 3px; display: block; width: 100%;
  transition: color 0.15s;
}
.cyr-cell .audio-btn:hover { color: var(--blue); }

.cyr-section-label {
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 1.5rem 0 0.75rem;
  font-family: 'IBM Plex Mono', monospace;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

/* ── RESOURCES ── */
.res-category { margin-bottom: 2.5rem; }
.res-category-title {
  font-family: 'Zen Kaku Gothic New', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.res-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1px;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.res-card {
  padding: 1.5rem;
  background: var(--bg2);
  transition: background 0.2s;
}
.res-card:hover { background: var(--bg3); }
.res-card h3 {
  font-family: 'Zen Kaku Gothic New', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.res-card h3 span { color: var(--accent); }
.res-card p { color: var(--muted); font-size: 14px; line-height: 1.6; }

/* ── JLPT LEVELS ── */
.jlpt-intro {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1.5rem;
  margin-bottom: 2.5rem;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.8;
}
.jlpt-intro strong { color: var(--text); }

.jlpt-levels { display: flex; flex-direction: column; gap: 1px; border: 1px solid var(--border); border-radius: 4px; overflow: hidden; margin-bottom: 2.5rem; }

.jlpt-level {
  background: var(--bg2);
  border-left: 4px solid transparent;
  padding: 1.5rem;
  cursor: pointer;
  transition: background 0.2s;
}
.jlpt-level:hover { background: var(--bg3); }
.jlpt-level.open { background: var(--bg3); }

.jlpt-level-header { display: flex; align-items: center; gap: 1rem; }
.jlpt-badge {
  font-family: 'Zen Kaku Gothic New', sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  width: 52px;
  height: 52px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: -0.02em;
}

.jlpt-level-meta { flex: 1; }
.jlpt-level-name { font-family: 'Zen Kaku Gothic New', sans-serif; font-size: 1rem; font-weight: 700; margin-bottom: 4px; }
.jlpt-level-tagline { font-size: 14px; color: var(--muted); }
.jlpt-level-stats { display: flex; gap: 1.5rem; font-size: 12px; color: var(--muted); letter-spacing: 0.05em; text-align: right; flex-shrink: 0; }
.jlpt-level-stats strong { display: block; font-size: 16px; color: var(--text); letter-spacing: 0; }

.jlpt-arrow { color: var(--muted); font-size: 14px; transition: transform 0.2s; margin-left: 8px; }
.jlpt-level.open .jlpt-arrow { transform: rotate(90deg); }

.jlpt-body { display: none; margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }
.jlpt-level.open .jlpt-body { display: block; }
.jlpt-body p { color: var(--muted); font-size: 15px; line-height: 1.8; margin-bottom: 0.75rem; }
.jlpt-body p:last-child { margin-bottom: 0; }
.jlpt-body strong { color: var(--text); }

.jlpt-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 1rem; }
.jlpt-tag { padding: 4px 10px; border: 1px solid var(--border); border-radius: 2px; font-size: 12px; color: var(--muted); letter-spacing: 0.04em; }

.jlpt-score-block {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.8;
}
.jlpt-score-block strong { color: var(--text); }

.jlpt-bar-section { margin-bottom: 2.5rem; }
.jlpt-bar-title { font-size: 13px; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 1rem; }

.jlpt-faq { margin-bottom: 2.5rem; }
.jlpt-faq-item { border-bottom: 1px solid var(--border); padding: 1rem 0; }
.jlpt-faq-item:first-child { border-top: 1px solid var(--border); }
.jlpt-faq-q { font-size: 15px; color: var(--text); cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 1rem; user-select: none; }
.jlpt-faq-q .jlpt-arrow { margin-left: auto; }
.jlpt-faq-a { display: none; font-size: 14px; color: var(--muted); line-height: 1.8; padding-top: 0.75rem; }
.jlpt-faq-item.open .jlpt-faq-a { display: block; }
.jlpt-faq-item.open .jlpt-arrow { transform: rotate(90deg); }

/* ── TRKI LEVELS ── */
.trki-levels { display: flex; flex-direction: column; gap: 1px; border: 1px solid var(--border); border-radius: 4px; overflow: hidden; margin-bottom: 2.5rem; }
.trki-level {
  background: var(--bg2);
  border-left: 4px solid transparent;
  padding: 1.5rem;
  cursor: pointer;
  transition: background 0.2s;
}
.trki-level:hover { background: var(--bg3); }
.trki-level.open { background: var(--bg3); }
.trki-level-header { display: flex; align-items: center; gap: 1rem; }
.trki-badge {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 1.1rem;
  font-weight: 700;
  width: 52px;
  height: 52px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.trki-level-meta { flex: 1; }
.trki-level-name { font-family: 'Zen Kaku Gothic New', sans-serif; font-size: 1rem; font-weight: 700; margin-bottom: 4px; }
.trki-level-tagline { font-size: 14px; color: var(--muted); }
.trki-level-stats { display: flex; gap: 1.5rem; font-size: 12px; color: var(--muted); text-align: right; flex-shrink: 0; font-family: 'IBM Plex Mono', monospace; }
.trki-level-stats strong { display: block; font-size: 16px; color: var(--text); }
.trki-arrow { color: var(--muted); font-size: 14px; transition: transform 0.2s; margin-left: 8px; }
.trki-level.open .trki-arrow { transform: rotate(90deg); }
.trki-body { display: none; margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }
.trki-level.open .trki-body { display: block; }
.trki-body p { color: var(--muted); font-size: 15px; line-height: 1.8; margin-bottom: 0.75rem; }
.trki-body p strong { color: var(--text); }
.trki-score-block { background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 1rem; font-size: 14px; color: var(--muted); margin: 1rem 0; line-height: 1.8; }
.trki-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 0.75rem; }
.trki-tag { border: 1px solid var(--border); border-radius: 2px; padding: 3px 10px; font-size: 12px; color: var(--muted); font-family: 'IBM Plex Mono', monospace; }

/* ── JLPT CEFR CHART ── */
.jlpt-cefr-chart { border: 1px solid var(--border); border-radius: 4px; overflow: hidden; }
.jcc-head { display: grid; grid-template-columns: 60px 90px 110px 90px 70px; background: var(--bg3); border-bottom: 1px solid var(--border); padding: 8px 1rem; }
.jcc-col-label { font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.jcc-row { display: grid; grid-template-columns: 60px 90px 110px 90px 70px; align-items: center; padding: 14px 1rem; border-bottom: 1px solid var(--border); border-left: 3px solid var(--lvl-color); background: var(--bg2); transition: background 0.2s; }
.jcc-row:last-of-type { border-bottom: none; }
.jcc-row:hover { background: var(--bg3); }
.jcc-badge { font-family: 'Zen Kaku Gothic New', sans-serif; font-size: 1rem; font-weight: 700; width: 40px; height: 40px; border-radius: 3px; display: flex; align-items: center; justify-content: center; }
.jcc-score { font-size: 13px; color: var(--muted); }
.jcc-cefr { display: flex; flex-direction: column; gap: 3px; }
.jcc-cefr-tag { display: inline-block; padding: 2px 8px; border-radius: 2px; font-family: 'Zen Kaku Gothic New', sans-serif; font-weight: 700; font-size: 13px; width: fit-content; }
.jcc-cefr-note { font-size: 12px; color: var(--muted); letter-spacing: 0.03em; }
.jcc-vocab, .jcc-kanji { font-size: 14px; color: var(--text); font-family: 'IBM Plex Mono', monospace; }
.jcc-footnote { padding: 10px 1rem; font-size: 12px; color: var(--muted); background: var(--bg3); border-top: 1px solid var(--border); line-height: 1.6; }

/* ── YOUTUBE SECTION ── */
.yt-controls { display: flex; gap: 8px; margin-bottom: 1.5rem; flex-wrap: wrap; align-items: center; }
.yt-search {
  flex: 0 0 100%;
  min-width: 0;
  padding: 9px 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--text);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
.yt-search:focus { border-color: var(--accent); }
.yt-search::placeholder { color: var(--muted); }

.yt-filter-btn {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: none;
  color: var(--muted);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  letter-spacing: 0.05em;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}
.yt-filter-btn:hover { color: var(--text); border-color: var(--muted); }
.yt-filter-btn.active { border-color: var(--accent); color: var(--accent); }

body.jp .yt-filter-btn { font-family: 'Zen Kaku Gothic New', sans-serif; font-size: 13px; }

.yt-cat-block { margin-bottom: 2.5rem; }
.yt-cat-title {
  font-family: 'Zen Kaku Gothic New', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.yt-cat-count { font-size: 12px; background: var(--bg3); border: 1px solid var(--border); border-radius: 2px; padding: 1px 6px; color: var(--muted); font-weight: 400; }

.yt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1px;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.yt-card { padding: 1.25rem 1.5rem; background: var(--bg2); transition: background 0.2s; display: flex; flex-direction: column; gap: 6px; }
.yt-card:hover { background: var(--bg3); }

.yt-card-name {
  font-family: 'Zen Kaku Gothic New', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--gold);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.yt-card-name:hover { text-decoration: underline; }
.yt-card-name svg { flex-shrink: 0; opacity: 0.6; }
.yt-card-desc { font-size: 14px; color: var(--muted); line-height: 1.6; }

.yt-platform-badge { display: inline-block; font-size: 12px; padding: 1px 6px; border-radius: 2px; border: 1px solid var(--border); color: var(--muted); width: fit-content; letter-spacing: 0.04em; }
.yt-platform-badge.twitch { border-color: #9147ff44; color: #9147ff; }

.yt-empty { padding: 3rem; text-align: center; color: var(--muted); font-size: 15px; display: none; }
.yt-stats { font-size: 13px; color: var(--muted); margin-bottom: 1.5rem; letter-spacing: 0.05em; }
.yt-stats span { color: var(--text); }

/* ── FORUM ── */
.remark42 { margin-top: 2rem; }

/* ── FOOTER ── */
.site-stats a { color: var(--gold); text-decoration: none; }
.site-stats a:hover { text-decoration: underline; }
.site-stats {
  text-align: center;
  padding: 6px 1rem;
  font-size: 0.78rem;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.04em;
  min-height: 1.5rem;
}

footer {
  border-top: 1px solid var(--border);
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.05em;
}
footer a { color: var(--gold); text-decoration: none; }

/* ── DISCORD BUTTON ── */
.btn-discord {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 28px;
  background: #5865F2;
  color: white;
  border-radius: 4px;
  text-decoration: none;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.05em;
  transition: background 0.2s, transform 0.1s;
}
.btn-discord:hover { background: #4752C4; transform: translateY(-1px); text-decoration: none; color: white; }

/* ── GRAMMAR ── */
.grammar-levels { display:flex; flex-direction:column; gap:1px; border:1px solid var(--border); border-radius:4px; overflow:hidden; }
.grammar-level-card { display:flex; align-items:center; gap:1.2rem; padding:1.2rem 1.5rem; background:var(--bg2); border-left:3px solid transparent; text-decoration:none; transition:background 0.15s; }
.grammar-level-card:hover { background:var(--bg3); text-decoration:none; }
.grammar-badge { font-family:'IBM Plex Mono',monospace; font-size:1.1rem; font-weight:600; padding:6px 14px; border-radius:4px; min-width:52px; text-align:center; }
.grammar-level-info { flex:1; }
.grammar-level-name { font-family:'Zen Kaku Gothic New',sans-serif; font-weight:700; font-size:1rem; color:var(--text); }
.grammar-level-count { font-size:12px; color:var(--muted); margin-top:3px; }

.grammar-table { width:100%; border-collapse:collapse; font-size:13px; }
.grammar-table thead tr { background:var(--bg2); border-bottom:2px solid var(--border); }
.grammar-table th { padding:10px 12px; text-align:left; font-family:'IBM Plex Mono',monospace; font-size:11px; color:var(--muted); letter-spacing:0.05em; font-weight:600; }
.grammar-row { border-bottom:1px solid var(--border); cursor:pointer; transition:background 0.1s; }
.grammar-row:hover { background:var(--bg3); }
.grammar-num { color:var(--muted); font-family:'IBM Plex Mono',monospace; font-size:11px; padding:10px 12px; }
.grammar-jp { font-family:'Zen Kaku Gothic New',sans-serif; font-size:15px; padding:10px 12px; color:var(--text); }
.grammar-jp ruby rt { font-family:'Zen Kaku Gothic New',sans-serif; color:var(--gold); font-size:9px; opacity:0; transition:opacity 0.15s; }
.grammar-row:hover .grammar-jp ruby rt { opacity:1; }
body.show-furigana .grammar-jp ruby rt { opacity:1; }
/* Ромадзи: скрыты по умолчанию, показываются кнопкой */
.grammar-romaji { font-family:'IBM Plex Mono',monospace; font-size:12px; color:var(--gold); padding:10px 12px; display:none; }
.grammar-romaji-th { display:none; }
body.show-romaji .grammar-romaji { display:table-cell; }
body.show-romaji .grammar-romaji-th { display:table-cell; }
.grammar-meaning { color:var(--muted); font-size:14px; padding:10px 12px; }
/* Стрелка-подсказка: строка кликабельна */
.grammar-arrow { padding:10px 12px 10px 4px; color:var(--border); font-size:11px; font-family:'IBM Plex Mono',monospace; text-align:right; white-space:nowrap; transition:color 0.15s; }
.grammar-row:hover .grammar-arrow { color:var(--gold); }

/* === Grammar progress tracking === */
.grammar-row.grammar-known { opacity:0.42; }
.grammar-row.grammar-known:hover { opacity:0.7; }
.grammar-known-btn {
  display:inline-flex; align-items:center; gap:3px;
  font-family:'IBM Plex Mono',monospace; font-size:10px;
  padding:3px 8px; border-radius:3px;
  background:transparent; border:1px solid var(--border);
  color:var(--muted); cursor:pointer; transition:all 0.15s; white-space:nowrap;
}
.grammar-known-btn:hover { border-color:#4caf50; color:#4caf50; }
.grammar-known-btn.active { border-color:#4caf50; color:#4caf50; background:rgba(76,175,80,0.12); }
.grammar-known-cell { padding:6px 8px; text-align:right; white-space:nowrap; }
.grammar-progress-wrap { margin-bottom:1rem; }
.grammar-progress-meta { display:flex; align-items:center; justify-content:space-between; margin-bottom:5px; }
.grammar-progress-label { font-family:'IBM Plex Mono',monospace; font-size:11px; color:var(--muted); }
.grammar-progress-count { font-family:'IBM Plex Mono',monospace; font-size:12px; color:#4caf50; font-weight:600; }
.grammar-progress-bar-track { height:4px; background:var(--border); border-radius:2px; overflow:hidden; }
.grammar-progress-bar { height:100%; background:#4caf50; border-radius:2px; transition:width 0.3s; width:0; }
.grammar-filter-row { display:flex; gap:6px; align-items:center; margin-bottom:1rem; flex-wrap:wrap; }
.grammar-filter-btn {
  font-family:'IBM Plex Mono',monospace; font-size:10px; letter-spacing:0.04em;
  padding:4px 12px; border-radius:3px;
  background:var(--bg2); border:1px solid var(--border);
  color:var(--muted); cursor:pointer; transition:all 0.15s;
}
.grammar-filter-btn:hover { border-color:var(--text); color:var(--text); }
.grammar-filter-btn.active { border-color:var(--gold); color:var(--gold); }
.grammar-filter-label { font-family:'IBM Plex Mono',monospace; font-size:11px; color:var(--muted); margin-right:2px; }
.grammar-level-progress { font-size:11px; font-family:'IBM Plex Mono',monospace; color:#4caf50; margin-top:2px; display:none; }
.gram-known-page-btn { margin-left:12px; border-color:rgba(76,175,80,0.4); color:rgba(76,175,80,0.6); }
.gram-known-page-btn:hover { border-color:#4caf50 !important; color:#4caf50 !important; }
.gram-known-page-btn.active { border-color:#4caf50 !important; color:#4caf50 !important; background:rgba(76,175,80,0.12) !important; }

.gram-breadcrumb { font-size:12px; color:var(--muted); margin-bottom:1.5rem; display:flex; gap:6px; align-items:center; flex-wrap:wrap; }
.gram-breadcrumb a { color:var(--gold); text-decoration:none; }
.gram-breadcrumb a:hover { text-decoration:underline; }
.gram-header { display:flex; align-items:flex-start; gap:1.2rem; padding:1.5rem; background:var(--bg2); border:1px solid var(--border); border-left:3px solid transparent; border-radius:4px; margin-bottom:1.5rem; }
.gram-badge { font-family:'IBM Plex Mono',monospace; font-weight:600; font-size:1rem; padding:4px 10px; border-radius:4px; flex-shrink:0; }
.gram-title { font-family:'Zen Kaku Gothic New',sans-serif; font-size:2rem; font-weight:700; color:var(--text); margin-bottom:4px; }
.gram-romaji-title { font-family:'IBM Plex Mono',monospace; font-size:14px; color:var(--gold); }
.gram-block { background:var(--bg2); border:1px solid var(--border); border-radius:4px; padding:1.2rem 1.5rem; margin-bottom:1rem; }
.gram-block-title { font-family:'IBM Plex Mono',monospace; font-size:10px; color:var(--muted); letter-spacing:0.1em; text-transform:uppercase; margin-bottom:0.8rem; font-weight:600; }
.gram-meaning-ru { font-size:1.25rem; color:var(--text); margin-bottom:4px; }
.gram-meaning-en { font-size:13px; color:var(--muted); font-style:italic; }
.gram-formation { width:100%; border-collapse:collapse; font-size:13px; }
.gram-formation td { padding:6px 10px; border:1px solid var(--border); color:var(--muted); }
.gram-formation td:first-child { color:var(--text); font-family:'IBM Plex Mono',monospace; font-size:11px; }
.gram-example { padding:0.9rem 0; border-bottom:1px solid var(--border); }
.gram-example:last-child { border-bottom:none; }
.gram-ex-jp { font-family:'Zen Kaku Gothic New',sans-serif; font-size:18px; color:var(--text); margin-bottom:6px; }
.gram-ex-romaji { font-family:'IBM Plex Mono',monospace; font-size:12px; color:var(--muted); margin-bottom:6px; }
.gram-ex-ru { font-size:15px; color:var(--gold); }
.gram-block-notes { border-left:3px solid var(--gold); background:rgba(200,168,75,0.05); }
.gram-note-line { font-size:13px; color:var(--muted); line-height:1.7; margin-bottom:6px; }
.gram-note-line:last-child { margin-bottom:0; }
.related-grid { display:flex; flex-direction:column; gap:6px; }
.related-item { display:flex; align-items:center; gap:10px; padding:8px 10px; background:var(--bg3); border-radius:4px; text-decoration:none; transition:background 0.15s; }
.related-item:hover { background:var(--border); text-decoration:none; }
.related-badge { font-family:'IBM Plex Mono',monospace; font-size:10px; font-weight:600; border:1px solid; border-radius:3px; padding:2px 6px; flex-shrink:0; }
.related-jp { font-family:'Zen Kaku Gothic New',sans-serif; font-size:14px; color:var(--text); flex-shrink:0; }
.related-meaning { font-size:12px; color:var(--muted); }

.gram-toggle-btns { display:flex; gap:8px; justify-content:flex-end; margin-bottom:1rem; }
.gram-toggle-btn { font-family:'IBM Plex Mono',monospace; font-size:11px; padding:5px 14px; background:transparent; border:1px solid var(--border); border-radius:2px; color:var(--muted); cursor:pointer; letter-spacing:0.05em; transition:border-color 0.15s, color 0.15s; }
.gram-toggle-btn:hover { color:var(--text); border-color:var(--muted); }
.gram-toggle-btn.active { color:var(--red); border-color:var(--red); }

/* Ромадзи — скрыт по умолчанию */
.gram-romaji-title { display:none; }
body.show-romaji .gram-romaji-title { display:block; }
.gram-ex-romaji { display:none; }
body.show-romaji .gram-ex-romaji { display:block; }

/* Фуригана — скрыта по умолчанию, видна при наведении или активной кнопке */
.gram-title ruby rt,
.gram-ex-jp ruby rt { font-family:'Zen Kaku Gothic New',sans-serif; color:var(--gold); opacity:0; transition:opacity 0.15s; }
.gram-title ruby rt { font-size:11px; }
.gram-ex-jp ruby rt { font-size:9px; }
.gram-header:hover .gram-title ruby rt,
.gram-example:hover .gram-ex-jp ruby rt { opacity:1; }
body.show-furigana .gram-title ruby rt,
body.show-furigana .gram-ex-jp ruby rt { opacity:1; }

/* Фуригана в словах-примерах кандзи */
.kanji-word-written ruby rt { font-family:'Zen Kaku Gothic New',sans-serif; color:var(--gold); font-size:9px; opacity:0; transition:opacity 0.15s; }
.kanji-word-item:hover .kanji-word-written ruby rt { opacity:1; }
body.show-furigana .kanji-word-written ruby rt { opacity:1; }
body.show-furigana .kanji-word-reading { display:none; }

/* ── KANJI ── */
.kanji-table { width:100%; border-collapse:collapse; font-size:13px; }
.kanji-table thead tr { background:var(--bg2); border-bottom:2px solid var(--border); }
.kanji-table th { padding:10px 12px; text-align:left; font-family:'IBM Plex Mono',monospace; font-size:11px; color:var(--muted); letter-spacing:0.05em; font-weight:600; }
.kanji-row { border-bottom:1px solid var(--border); cursor:pointer; transition:background 0.1s; }
.kanji-row:hover { background:var(--bg3); }
.kanji-num { color:var(--muted); font-family:'IBM Plex Mono',monospace; font-size:11px; padding:10px 12px; }
.kanji-char { font-family:'Zen Kaku Gothic New',sans-serif; font-size:24px; padding:8px 12px; color:var(--text); text-align:center; }
.kanji-on { font-family:'Zen Kaku Gothic New',sans-serif; font-size:13px; padding:10px 12px; color:var(--text); }
.kanji-kun { font-family:'Zen Kaku Gothic New',sans-serif; font-size:13px; padding:10px 12px; color:var(--gold); }
.kanji-meaning { color:var(--muted); font-size:14px; padding:10px 12px; }

.kanji-hero { display:flex; align-items:center; gap:2rem; padding:1.5rem; background:var(--bg2); border:1px solid var(--border); border-left:3px solid transparent; border-radius:4px; margin-bottom:1.5rem; }
.kanji-hero-char { font-family:'Zen Kaku Gothic New',sans-serif; font-size:7rem; line-height:1; flex-shrink:0; min-width:120px; text-align:center; }
.kanji-hero-info { flex:1; display:flex; flex-direction:column; gap:1rem; }
.kanji-readings { display:flex; flex-direction:column; gap:6px; }
.kanji-reading-group { display:flex; align-items:center; gap:10px; }
.kanji-reading-label { font-family:'IBM Plex Mono',monospace; font-size:11px; color:var(--muted); border:1px solid var(--border); border-radius:2px; padding:1px 6px; flex-shrink:0; }
.kanji-reading-values { font-family:'Zen Kaku Gothic New',sans-serif; font-size:15px; color:var(--text); display:flex; flex-wrap:wrap; gap:8px; }
.kanji-pills { display:flex; flex-wrap:wrap; gap:6px; margin-top:4px; }
.kanji-pill { font-family:'IBM Plex Mono',monospace; font-size:11px; color:var(--muted); border:1px solid var(--border); border-radius:2px; padding:2px 8px; }
.kanji-meaning-ru { font-size:1.25rem; color:var(--text); margin-bottom:4px; font-family:'Zen Kaku Gothic New',sans-serif; }

/* Prev/Next navigation on kanji detail page */
.kanji-page-nav { display:flex; align-items:stretch; gap:0; margin-top:2rem; border:1px solid var(--border); border-radius:4px; overflow:hidden; }
.kanji-page-nav-btn {
  display:flex; flex-direction:column; justify-content:center;
  flex:1; padding:14px 18px; text-decoration:none; color:var(--text);
  background:var(--bg2); transition:background 0.15s, color 0.15s;
  min-width:0;
}
.kanji-page-nav-btn:hover { background:var(--bg3); text-decoration:none; color:var(--text); }
.kanji-page-nav-prev { border-right:1px solid var(--border); }
.kanji-page-nav-next { border-left:1px solid var(--border); text-align:right; align-items:flex-end; }
.kanji-page-nav-empty { background:transparent; cursor:default; pointer-events:none; flex:0.4; }
.kanji-page-nav-char { font-family:'Zen Kaku Gothic New',sans-serif; font-size:1.3rem; color:var(--text); display:block; }
.kanji-page-nav-mean { font-size:11px; color:var(--muted); display:block; margin-top:2px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:200px; }
.kanji-page-nav-list {
  display:flex; align-items:center; justify-content:center;
  padding:14px 20px; color:var(--muted); text-decoration:none;
  font-family:'IBM Plex Mono',monospace; font-size:12px;
  white-space:nowrap; transition:color 0.15s, background 0.15s;
  background:var(--bg2);
}
.kanji-page-nav-list:hover { color:var(--text); background:var(--bg3); text-decoration:none; }

.kanji-word-item { display:flex; align-items:center; gap:12px; padding:8px 0; border-bottom:1px solid var(--border); }
.kanji-word-item:last-child { border-bottom:none; }
.kanji-word-written { font-family:'Zen Kaku Gothic New',sans-serif; font-size:17px; color:var(--text); min-width:80px; }
.kanji-word-reading { display:none; }
.kanji-word-meaning { font-size:14px; color:var(--muted); }

/* Секции уровней на общей странице кандзи */
.kanji-level-section { margin-bottom:2.5rem; }
.kanji-level-header { display:flex; align-items:center; gap:12px; padding:8px 0 10px 12px; border-left:3px solid var(--border); margin-bottom:12px; }
.kanji-level-badge { font-family:'IBM Plex Mono',monospace; font-size:1rem; font-weight:600; }
.kanji-level-title { font-family:'Zen Kaku Gothic New',sans-serif; font-size:1rem; color:var(--text); }
.kanji-level-count { font-family:'IBM Plex Mono',monospace; font-size:11px; color:var(--muted); margin-left:auto; }

/* Сетка кандзи (как таблица Менделеева) */
.kanji-grid { display:flex; flex-wrap:wrap; gap:4px; }
.kanji-cell { width:64px; height:64px; background:var(--bg2); border:1px solid var(--border); border-top:2px solid var(--cell-color, var(--border)); border-radius:3px; display:flex; flex-direction:column; align-items:center; justify-content:center; cursor:pointer; text-decoration:none; position:relative; transition:background 0.1s, border-color 0.1s; user-select:none; }
.kanji-cell:hover { background:var(--bg3); border-color:var(--cell-color, var(--muted)); }
.kanji-cell-char { font-family:'Zen Kaku Gothic New',sans-serif; font-size:28px; line-height:1; color:var(--text); }
.kanji-cell-num { font-family:'IBM Plex Mono',monospace; font-size:8px; color:var(--muted); position:absolute; top:3px; left:5px; line-height:1; }

/* Popup при наведении на строку кандзи */
.kanji-popup { position:fixed; z-index:1000; display:flex; flex-direction:row; align-items:stretch; background:var(--bg2); border:1px solid var(--border); border-radius:6px; box-shadow:0 8px 32px rgba(0,0,0,0.5); pointer-events:none; min-width:240px; max-width:300px; overflow:hidden; }
.kanji-popup-char { font-family:'Zen Kaku Gothic New',sans-serif; font-size:4.5rem; line-height:1; padding:1rem 1.2rem; border-right:1px solid var(--border); display:flex; align-items:center; justify-content:center; color:var(--text); background:var(--bg3); }
.kanji-popup-body { padding:0.8rem 1rem; display:flex; flex-direction:column; gap:5px; flex:1; justify-content:center; }
.kanji-popup-on  { font-family:'Zen Kaku Gothic New',sans-serif; font-size:13px; color:var(--text); }
.kanji-popup-kun { font-family:'Zen Kaku Gothic New',sans-serif; font-size:13px; color:var(--gold); }
.kanji-popup-ru  { font-size:12px; color:var(--muted); line-height:1.4; margin-top:4px; border-top:1px solid var(--border); padding-top:6px; }
.kanji-popup-info { font-family:'IBM Plex Mono',monospace; font-size:10px; color:var(--muted); }
.kanji-popup-link { font-family:'IBM Plex Mono',monospace; font-size:11px; color:var(--gold); text-decoration:none; margin-top:4px; letter-spacing:0.03em; }
.kanji-popup-link:hover { text-decoration:underline; }

@media (max-width:600px) {
  .kanji-hero { flex-direction:column; gap:1rem; }
  .kanji-hero-char { font-size:5rem; min-width:unset; }
  .kanji-popup { display:none !important; }
}

/* ── RESPONSIVE ── */
@media (max-width: 600px) {
  .section { padding: 2rem 1rem; }

  /* Mobile nav — single fixed-height row */
  nav {
    height: 48px;
    flex-wrap: nowrap;
    align-items: center;
    overflow: visible;
  }
  .nav-hamburger {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: none;
    border: none;
    color: var(--muted);
    font-size: 1.3rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: color 0.2s;
    padding: 0;
  }
  .nav-hamburger:hover, .nav-hamburger.open { color: var(--accent); }
  .nav-active-label {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
    padding: 0 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .nav-lang { flex-shrink: 0; padding: 0 0.25rem; }
  .nav-flag { padding: 10px 8px; font-size: 1.1rem; }

  /* Dropdown — absolute, full-width, overlays content */
  nav .nav-links {
    display: none;
    position: absolute;
    top: 48px;
    left: 0;
    right: 0;
    flex-direction: column;
    background: rgba(14,14,14,0.98);
    border-bottom: 1px solid var(--border);
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    z-index: 200;
    flex: none;
  }
  nav .nav-links.open { display: flex; }
  nav .nav-links a {
    padding: 14px 20px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    border-left: 3px solid transparent;
    white-space: normal;
  }
  nav .nav-links a:last-child { border-bottom: none; }
  nav .nav-links a.active {
    border-left-color: var(--accent);
    color: var(--accent);
    border-bottom-color: var(--border);
  }

  .jlpt-level-stats { display: none; }
  .trki-level-stats { display: none; }
  .jcc-head, .jcc-row { grid-template-columns: 50px 80px 95px 75px 55px; padding: 10px 0.75rem; }
}
