/* ===================================================================
   GrammarType — Minimalist Monkeytype-Inspired Stylesheet
   Themes: Serika Dark (Default), Carbon, Nord, Taro, Botanical, Matrix, Paper Light
   =================================================================== */

:root {
  --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", "Roboto Mono", Menlo, Monaco, Consolas, monospace;

  /* Default Monkeytype Theme: Serika Dark */
  --bg-primary: #323437;
  --bg-secondary: #2c2e31;
  --bg-card: #25272a;
  --bg-hover: #3c3f43;
  --border-subtle: #3a3c40;

  --accent: #e2b714;
  --accent-hover: #f0c522;
  --accent-light: rgba(226, 183, 20, 0.12);

  --text-main: #d1d0c5;
  --text-untyped: #646669;
  --text-muted: #848689;
  --text-dim: #505255;

  --color-correct: #d1d0c5;
  --color-incorrect: #ca4754;
  --color-extra: #7e2a33;

  --warning-bg: rgba(226, 183, 20, 0.08);
  --warning-border: rgba(226, 183, 20, 0.25);
  --warning-text: #e2b714;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  --caret-color: #e2b714;
}

/* Monkeytype Carbon */
[data-theme="carbon"] {
  --bg-primary: #313131;
  --bg-secondary: #2b2b2b;
  --bg-card: #242424;
  --bg-hover: #3a3a3a;
  --border-subtle: #3d3d3d;
  --accent: #f66e0d;
  --accent-hover: #ff7f24;
  --accent-light: rgba(246, 110, 13, 0.15);
  --text-main: #f5e6c8;
  --text-untyped: #616161;
  --text-muted: #8a8a8a;
  --text-dim: #4d4d4d;
  --color-correct: #f5e6c8;
  --color-incorrect: #e45c5c;
  --caret-color: #f66e0d;
}

/* Monkeytype Nord */
[data-theme="nord"] {
  --bg-primary: #242933;
  --bg-secondary: #1e222b;
  --bg-card: #191c24;
  --bg-hover: #2e3440;
  --border-subtle: #313744;
  --accent: #88c0d0;
  --accent-hover: #81a1c1;
  --accent-light: rgba(136, 192, 208, 0.15);
  --text-main: #eceff4;
  --text-untyped: #4c566a;
  --text-muted: #7b88a1;
  --text-dim: #3b4252;
  --color-correct: #eceff4;
  --color-incorrect: #bf616a;
  --caret-color: #88c0d0;
}

/* Monkeytype Taro */
[data-theme="taro"] {
  --bg-primary: #131519;
  --bg-secondary: #1b1d24;
  --bg-card: #21242d;
  --bg-hover: #2a2e39;
  --border-subtle: #292d37;
  --accent: #b388ff;
  --accent-hover: #c49eff;
  --accent-light: rgba(179, 136, 255, 0.15);
  --text-main: #e6e6e6;
  --text-untyped: #626673;
  --text-muted: #8f95a5;
  --text-dim: #444751;
  --color-correct: #e6e6e6;
  --color-incorrect: #ff5370;
  --caret-color: #b388ff;
}

/* Monkeytype Botanical */
[data-theme="botanical"] {
  --bg-primary: #1e2621;
  --bg-secondary: #171d19;
  --bg-card: #131915;
  --bg-hover: #26312a;
  --border-subtle: #2b3830;
  --accent: #8bb39c;
  --accent-hover: #9fc1ad;
  --accent-light: rgba(139, 179, 156, 0.15);
  --text-main: #eaf0ec;
  --text-untyped: #49574d;
  --text-muted: #728477;
  --text-dim: #37423a;
  --color-correct: #eaf0ec;
  --color-incorrect: #d47d7d;
  --caret-color: #8bb39c;
}

/* Monkeytype Matrix */
[data-theme="matrix"] {
  --bg-primary: #0d110d;
  --bg-secondary: #141a14;
  --bg-card: #192119;
  --bg-hover: #202b20;
  --border-subtle: #1f2b1f;
  --accent: #00ff41;
  --accent-hover: #20ff57;
  --accent-light: rgba(0, 255, 65, 0.15);
  --text-main: #d5fcdb;
  --text-untyped: #2e5735;
  --text-muted: #548b5e;
  --text-dim: #1d3b23;
  --color-correct: #d5fcdb;
  --color-incorrect: #ff3333;
  --caret-color: #00ff41;
}

/* Paper Light */
[data-theme="paper-light"] {
  --bg-primary: #f5f5f0;
  --bg-secondary: #eae8df;
  --bg-card: #dfdccf;
  --bg-hover: #d5d1c0;
  --border-subtle: #ccc7b3;
  --accent: #2e5aac;
  --accent-hover: #24498c;
  --accent-light: rgba(46, 90, 172, 0.12);
  --text-main: #222222;
  --text-untyped: #9e9e98;
  --text-muted: #6e6e68;
  --text-dim: #b8b8b0;
  --color-correct: #222222;
  --color-incorrect: #c53030;
  --caret-color: #2e5aac;
}

/* Full Black (OLED Pitch Black) */
[data-theme="full-black"], [data-theme="oled-black"] {
  --bg-primary: #000000;
  --bg-secondary: #0a0a0a;
  --bg-card: #141414;
  --bg-hover: #1f1f1f;
  --border-subtle: #242424;
  --accent: #e2b714;
  --accent-hover: #ffd026;
  --accent-light: rgba(226, 183, 20, 0.15);
  --text-main: #f5f5f5;
  --text-untyped: #555555;
  --text-muted: #888888;
  --text-dim: #444444;
  --color-correct: #f5f5f5;
  --color-incorrect: #ff4757;
  --color-extra: #8b0000;
  --caret-color: #e2b714;
}

/* Monochrome Black (Pure Black & Crisp White) */
[data-theme="monochrome-black"] {
  --bg-primary: #000000;
  --bg-secondary: #0b0b0b;
  --bg-card: #141414;
  --bg-hover: #202020;
  --border-subtle: #262626;
  --accent: #ffffff;
  --accent-hover: #e0e0e0;
  --accent-light: rgba(255, 255, 255, 0.15);
  --text-main: #ffffff;
  --text-untyped: #484848;
  --text-muted: #888888;
  --text-dim: #3a3a3a;
  --color-correct: #ffffff;
  --color-incorrect: #ff3344;
  --color-extra: #771122;
  --caret-color: #ffffff;
}

/* Dracula */
[data-theme="dracula"] {
  --bg-primary: #282a36;
  --bg-secondary: #21222c;
  --bg-card: #191a21;
  --bg-hover: #343746;
  --border-subtle: #44475a;
  --accent: #bd93f9;
  --accent-hover: #caa9fa;
  --accent-light: rgba(189, 147, 249, 0.15);
  --text-main: #f8f8f2;
  --text-untyped: #6272a4;
  --text-muted: #9499ab;
  --text-dim: #44475a;
  --color-correct: #f8f8f2;
  --color-incorrect: #ff5555;
  --caret-color: #bd93f9;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  transition: background-color 0.2s ease, color 0.2s ease;
  overflow-x: hidden;
}

/* Minimalist Monkeytype Header */
.app-header {
  padding: 1.5rem 2rem 0.5rem;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

.header-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  cursor: pointer;
}

.brand-icon {
  font-size: 1.6rem;
  line-height: 1;
}

.brand-title {
  font-family: var(--font-sans);
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-muted);
}

.brand-title .accent-text {
  color: var(--accent);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Minimalist Buttons & Selects */
.icon-btn, .pill-btn, .select-pill {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  text-decoration: none;
  outline: none;
}

.icon-btn:hover, .pill-btn:hover, .select-pill:hover {
  color: var(--text-main);
}

.pill-btn.active, .select-pill.active {
  color: var(--accent);
}

.select-pill {
  background: var(--bg-secondary);
  color: var(--text-muted);
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
}

.select-pill:focus {
  color: var(--text-main);
}

/* Main Container */
.main-content {
  flex: 1;
  max-width: 1050px;
  width: 100%;
  margin: 0 auto;
  padding: 0.5rem 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 1.2rem;
}

/* Minimalist Monkeytype Config Bar - Ultra Compact */
.config-bar {
  background: var(--bg-secondary) !important;
  border: 1px solid var(--border-subtle) !important;
  border-radius: 999px !important;
  padding: 0.15rem 0.8rem !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 0.45rem !important;
  flex-wrap: nowrap !important;
  white-space: nowrap !important;
  overflow-x: auto !important;
  max-width: fit-content !important;
  margin: 0 auto 0.4rem auto !important;
  font-size: 0.68rem !important;
  opacity: 0.85;
  transition: all 0.2s ease;
  scrollbar-width: none;
}

.config-bar::-webkit-scrollbar {
  display: none;
}

.config-bar:hover {
  opacity: 1;
  border-color: rgba(226, 183, 20, 0.3) !important;
}

.config-group {
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.2rem !important;
  flex-shrink: 0 !important;
}

.config-group > span:first-child {
  display: none !important; /* Hide redundant labels (category, form, level, font) */
}

.config-bar .select-pill {
  font-size: 0.68rem !important;
  padding: 0.1rem 0.35rem !important;
  height: 22px !important;
  line-height: 1 !important;
  border-radius: 4px !important;
  border: 1px solid transparent !important;
  background: transparent !important;
  color: var(--text-muted) !important;
  cursor: pointer !important;
  max-width: 140px !important;
  text-overflow: ellipsis !important;
  overflow: hidden !important;
  white-space: nowrap !important;
}

.config-bar .select-pill:focus,
.config-bar .select-pill:hover {
  color: var(--text-main) !important;
  background: rgba(255, 255, 255, 0.04) !important;
}

.config-divider {
  width: 1px !important;
  height: 10px !important;
  background: var(--border-subtle) !important;
  margin: 0 0.1rem !important;
  flex-shrink: 0 !important;
}

.config-item {
  color: var(--text-dim) !important;
  cursor: pointer !important;
  padding: 0.08rem 0.25rem !important;
  border-radius: 3px !important;
  font-size: 0.68rem !important;
  font-family: var(--font-mono) !important;
  transition: all 0.15s ease !important;
  user-select: none !important;
}

.config-item:hover {
  color: var(--text-main) !important;
}

.config-item.active {
  color: var(--accent) !important;
  font-weight: 700 !important;
}

#lesson-counter {
  font-size: 0.68rem !important;
  color: var(--text-dim) !important;
  font-family: var(--font-mono) !important;
  margin: 0 0.1rem !important;
}

/* Minimalist Grammar Cue Pill Header - Sleek & Compact */
.grammar-cue-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.45rem;
  max-width: 860px;
  width: 100%;
  margin: 0.25rem auto 0.75rem auto;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.25rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  transition: all 0.2s ease;
}

.grammar-cue-meta {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
}

.badge-tag {
  font-size: 0.78rem;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.02em;
  background: var(--accent-light);
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  border: 1px solid rgba(226, 183, 20, 0.3);
}

.badge-level {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.06em;
  background: var(--bg-card);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
}

.lesson-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.grammar-rule-text {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1.45;
  max-width: 780px;
}

.grammar-bengali-text {
  font-size: 0.82rem;
  color: var(--accent);
  font-weight: 500;
  line-height: 1.4;
  background: rgba(255, 255, 255, 0.04);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-sm);
  display: none;
}

.grammar-pro-tip {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--warning-bg);
  border-left: 3px solid var(--accent);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  text-align: left;
  width: 100%;
}

.cue-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.2rem;
}

.mistake-alert {
  background: rgba(197, 48, 48, 0.12);
  border-left: 3px solid var(--color-incorrect);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-main);
  width: 100%;
  text-align: left;
}

.error-strike {
  text-decoration: line-through;
  color: var(--color-incorrect);
  font-weight: 600;
}

/* Parts of Speech Tags */
.pos-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
  margin-top: 0.4rem;
}

.pos-pill {
  font-size: 0.72rem;
  background: var(--bg-secondary);
  color: var(--text-muted);
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
}

.pos-pill strong {
  color: var(--text-main);
}

/* Live Minimalist Counter */
.live-stats-bar {
  display: flex;
  align-items: baseline;
  gap: 1.5rem;
  font-family: var(--font-mono);
  font-size: 1.35rem;
  color: var(--accent);
  margin-bottom: -0.5rem;
  padding-left: 0.25rem;
  user-select: none;
}

.live-stat-item {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
}

.live-stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* ===================================================================
   MONKEYTYPE TYPING ARENA & ROCK-SOLID CARET
   =================================================================== */

.typing-arena {
  position: relative;
  width: 100%;
  min-height: 140px;
  cursor: default;
  outline: none;
}

/* Words Stream Container */
.words-container {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 0.65em;
  font-family: var(--font-mono);
  font-size: 1.65rem;
  line-height: 2.2;
  user-select: none;
  max-height: 200px;
  overflow-y: hidden;
  scroll-behavior: smooth;
  padding: 0.2rem 0;
}

/* Words are inline-flex without position:relative to preserve absolute global coordinates */
.word {
  display: inline-flex;
}

.char {
  color: var(--text-untyped);
  transition: color 0.05s ease;
}

.char.correct {
  color: var(--text-main);
}

.char.incorrect {
  color: var(--color-incorrect);
  border-bottom: 2px solid var(--color-incorrect);
}

.char.extra {
  color: var(--color-extra);
  opacity: 0.8;
}

/* The Smooth Glide Caret */
.caret {
  position: absolute;
  top: 0;
  left: 0;
  width: 2.5px;
  background-color: var(--caret-color);
  border-radius: 2px;
  pointer-events: none;
  transition: transform 0.08s cubic-bezier(0.2, 0.9, 0.3, 1), height 0.06s ease;
  animation: caretFlash 1.1s infinite;
  z-index: 10;
  display: none;
}

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

/* Hidden Keystroke Capture Input */
.hidden-input {
  position: absolute;
  opacity: 0;
  top: -9999px;
  left: -9999px;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

/* Unfocused Overlay */
.focus-notice {
  position: absolute;
  inset: 0;
  background: rgba(50, 52, 55, 0.85);
  backdrop-filter: blur(2px);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 20;
}

/* Bottom Minimalist Controls */
.restart-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
}

.restart-circle-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--radius-full);
  transition: color 0.15s ease, transform 0.25s ease;
  outline: none;
}

.restart-circle-btn:hover {
  color: var(--text-main);
  transform: rotate(90deg);
}

.shortcut-hints {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.key-pill {
  background: var(--bg-secondary);
  color: var(--text-muted);
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

/* Virtual Keyboard */
.virtual-keyboard {
  max-width: 680px;
  width: 100%;
  margin: 1rem auto 0;
  display: none;
  flex-direction: column;
  gap: 0.3rem;
  user-select: none;
}

.keyboard-row {
  display: flex;
  justify-content: center;
  gap: 0.3rem;
}

.key {
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.5rem 0;
  width: 36px;
  text-align: center;
  cursor: pointer;
  transition: all 0.1s ease;
}

.key.key-wide { width: 54px; }
.key.key-space { width: 220px; }

.key:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

.key.active-target {
  background: var(--accent);
  color: #000000;
  font-weight: 700;
  box-shadow: 0 0 8px var(--accent);
}

/* Minimalist Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal-overlay.show {
  display: flex;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  max-width: 550px;
  width: 100%;
  box-shadow: 0 12px 30px rgba(0,0,0,0.5);
  max-height: 85vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.modal-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
}

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

/* Results Screen */
.results-hero {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.results-primary {
  display: flex;
  align-items: baseline;
  gap: 1rem;
}

.results-big-wpm {
  font-family: var(--font-mono);
  font-size: 3.5rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
}

.results-big-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.results-sub-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.sub-stat {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  color: var(--text-main);
}

.sub-stat small {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.takeaway-box {
  background: var(--bg-card);
  padding: 1rem;
  border-radius: var(--radius-md);
  border-left: 3px solid var(--accent);
  margin-bottom: 1.5rem;
}

.takeaway-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.takeaway-text {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Minimalist Form Controls */
.modal-input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font-sans);
  padding: 0.65rem 0.85rem;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
  outline: none;
}

.modal-input:focus {
  border-color: var(--accent);
}

.btn-primary {
  background: var(--accent);
  color: #000000;
  font-weight: 700;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.btn-primary:hover {
  opacity: 0.9;
}

/* Directory Modal */
.directory-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 0.3rem;
}

.directory-item {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.directory-item:hover {
  background: var(--bg-hover);
}

.directory-item.active {
  border-left: 3px solid var(--accent);
}

.dir-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
}

.dir-preview {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 420px;
}

/* Footer */
.app-footer {
  margin-top: auto;
  padding: 1.5rem 2rem;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.footer-container {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.theme-pill-selector {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-secondary);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
}

/* Grammar Form Picker Modal & Grid */
.form-category-tabs {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  margin-bottom: 0.85rem;
}

.tab-pill {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.76rem;
  padding: 0.35rem 0.65rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.tab-pill:hover {
  color: var(--text-main);
  border-color: var(--text-muted);
}

.tab-pill.active {
  background: var(--accent);
  color: #000000;
  border-color: var(--accent);
  font-weight: 600;
}

.form-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.6rem;
  max-height: 420px;
  overflow-y: auto;
  padding-right: 0.3rem;
}

.form-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-card:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.form-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 6px rgba(226, 183, 20, 0.25);
  background: var(--bg-secondary);
}

.form-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-card-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.form-card-count {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  color: var(--accent);
  background: rgba(226, 183, 20, 0.12);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.form-card-desc {
  font-size: 0.74rem;
  color: var(--text-muted);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Responsive */
@media (max-width: 768px) {
  .app-header { padding: 1rem; }
  .main-content { padding: 1rem 1rem 2rem; }
  .words-container { font-size: 1.25rem; line-height: 1.9; }
  .config-bar { gap: 0.4rem; font-size: 0.68rem; flex-wrap: nowrap; overflow-x: auto; }
  .key { width: 28px; font-size: 0.72rem; padding: 0.4rem 0; }
  .key.key-wide { width: 44px; }
  .key.key-space { width: 140px; }
}
