:root {
  --font-main: 'Plus Jakarta Sans', 'Vazirmatn', -apple-system, BlinkMacSystemFont, sans-serif;
  
  /* Light Theme */
  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-card: #ffffff;
  --border-subtle: #e2e8f0;
  --border-hover: #cbd5e1;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: rgba(99, 102, 241, 0.1);
  --primary-glow: rgba(99, 102, 241, 0.25);
  
  --emerald: #10b981;
  --emerald-light: rgba(16, 185, 129, 0.1);
  
  --amber: #f59e0b;
  --amber-light: rgba(245, 158, 11, 0.1);

  --rose: #ef4444;
  --rose-light: rgba(239, 68, 68, 0.1);

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.08), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 25px -3px rgba(15, 23, 42, 0.1), 0 4px 10px -2px rgba(15, 23, 42, 0.04);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);

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

body.dark-theme {
  --bg-app: #080c14;
  --bg-surface: #0f172a;
  --bg-subtle: #1e293b;
  --bg-card: #131c31;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.16);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --primary: #818cf8;
  --primary-hover: #a5b4fc;
  --primary-light: rgba(129, 140, 248, 0.15);
  --primary-glow: rgba(129, 140, 248, 0.3);
  
  --emerald: #34d399;
  --emerald-light: rgba(52, 211, 153, 0.15);
  
  --amber: #fbbf24;
  --amber-light: rgba(251, 191, 36, 0.15);

  --rose: #f87171;
  --rose-light: rgba(248, 113, 113, 0.15);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 25px rgba(129, 140, 248, 0.2);
}

/* ----------------- Reset & Base ----------------- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* Decorative background glows */
.bg-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(100px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.4;
}

.glow-1 {
  width: 450px;
  height: 450px;
  top: -100px;
  right: -80px;
  background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
}

.glow-2 {
  width: 400px;
  height: 400px;
  bottom: -50px;
  left: -80px;
  background: radial-gradient(circle, var(--emerald) 0%, transparent 70%);
}

/* ----------------- Header ----------------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-subtle);
  transition: all 0.2s ease;
}

body:not(.dark-theme) .app-header {
  background: rgba(255, 255, 255, 0.85);
}

.header-container {
  max-width: 1360px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  user-select: none;
}

.brand-logo-wrap {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.brand-logo-wrap.sm {
  width: 32px;
  height: 32px;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-main);
}

.brand-title .highlight {
  color: var(--primary);
  margin-left: 1px;
}

.brand-tagline {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.ai-status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-light);
  border: 1px solid var(--border-subtle);
  color: var(--primary);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

.pulse-dot {
  width: 7px;
  height: 7px;
  background-color: var(--emerald);
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Studio Nav Pills */
.studio-nav-pills {
  display: flex;
  align-items: center;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  padding: 4px;
  border-radius: var(--radius-full);
  gap: 4px;
}

.studio-pill {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.studio-pill:hover {
  color: var(--text-main);
}

.studio-pill.active {
  background: var(--bg-surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.action-btn {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.action-btn:hover {
  background: var(--border-hover);
  color: var(--text-main);
}

.flashcards-header-btn {
  border-color: rgba(245, 158, 11, 0.4);
  color: var(--amber);
}

.flashcards-header-btn:hover {
  background: var(--amber-light);
  border-color: var(--amber);
}

.count-badge {
  background: var(--amber);
  color: #000;
  font-size: 10.5px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  margin-right: 2px;
}

.flashcard-tool-btn:hover {
  background: var(--amber-light) !important;
  color: var(--amber) !important;
  border-color: var(--amber) !important;
}

.icon-round-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.icon-round-btn:hover {
  background: var(--border-hover);
  color: var(--text-main);
  transform: translateY(-1px);
}

/* ----------------- Workspace Layout ----------------- */
.workspace-main {
  max-width: 1360px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 24px 40px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: relative;
  z-index: 10;
}

/* ----------------- Translation Studio Card (Main Dual Cards) ----------------- */
.translation-studio-card {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: visible;
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
}

.translation-studio-card:focus-within {
  border-color: var(--primary);
  box-shadow: var(--shadow-glow), var(--shadow-md);
}

.studio-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 18px 20px;
  min-height: 290px;
  position: relative;
}

.source-panel {
  border-right: 1px solid var(--border-subtle);
}

/* Swap Action Button */
.studio-center-swap {
  position: absolute;
  left: 50%;
  top: 18px;
  transform: translateX(-50%);
  z-index: 15;
}

.swap-action-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-md);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.2s, color 0.2s;
}

.swap-action-btn:hover {
  transform: rotate(180deg) scale(1.08);
  color: var(--primary);
  border-color: var(--primary);
}

/* Panel Header & Language Selector */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 12px;
  gap: 8px;
}

.lang-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
}

.lang-pill {
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.lang-pill:hover {
  color: var(--text-main);
  background: var(--bg-subtle);
}

.lang-pill.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
}

.lang-more-btn {
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.lang-more-btn:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
  border-color: var(--border-hover);
}

/* Input Area */
.input-editor-area {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
}

#sourceText {
  width: 100%;
  height: 100%;
  min-height: 150px;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-main);
  font-family: inherit;
  font-size: 20px;
  line-height: 1.6;
  resize: none;
  padding: 4px 32px 4px 0;
}

.clear-action-btn {
  position: absolute;
  top: 4px;
  right: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: var(--bg-subtle);
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.clear-action-btn:hover {
  background: var(--rose-light);
  color: var(--rose);
}

/* Target Output Display Area */
.output-display-area {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
}

.target-text {
  width: 100%;
  min-height: 150px;
  font-size: 20px;
  line-height: 1.6;
  color: var(--text-main);
  word-break: break-word;
  white-space: pre-wrap;
  padding: 4px 0;
}

.target-text.empty {
  color: var(--text-dim);
}

.phonetic-container {
  font-size: 13.5px;
  color: var(--text-muted);
  direction: ltr;
  text-align: left;
  padding: 4px 0;
  min-height: 22px;
  font-style: italic;
}

/* Loading Wave */
.loading-wave {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 20px 0;
}

.wave-bar {
  width: 4px;
  height: 22px;
  background: var(--primary);
  border-radius: 2px;
  animation: wave 1.2s infinite ease-in-out;
}

.wave-bar.bar-1 { animation-delay: -0.4s; }
.wave-bar.bar-2 { animation-delay: -0.2s; }
.wave-bar.bar-3 { animation-delay: 0s; }

@keyframes wave {
  0%, 40%, 100% { transform: scaleY(0.4); }
  20% { transform: scaleY(1.0); }
}

.wave-text {
  font-size: 13px;
  color: var(--primary);
  font-weight: 500;
  margin-left: 6px;
}

/* Alternative Nuances Pills */
.alternatives-box {
  padding: 10px 12px;
  background: var(--bg-subtle);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-md);
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.alternatives-header {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.alternatives-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.dict-chip {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 13px;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s ease;
}

.dict-chip:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}

/* Panel Footer */
.panel-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
  margin-top: auto;
}

.footer-tools {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tool-circle-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tool-circle-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
  transform: translateY(-1px);
}

.footer-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tone-select-container {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tone-label {
  font-size: 12px;
  color: var(--text-dim);
}

.modern-select {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-family: inherit;
  font-size: 12.5px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
}

.modern-select:focus {
  border-color: var(--primary);
}

.character-counter {
  font-size: 11.5px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.btn-primary-action {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border: none;
  padding: 7px 18px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
  transition: all 0.2s ease;
}

.btn-primary-action:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

/* ----------------- Linguistic Analysis Studio (Bottom Dual Cards) ----------------- */
.linguistic-studio-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

.analysis-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  animation: fadeInSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}

@keyframes fadeInSlideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.analysis-card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-badge {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.grammar-badge { background: var(--primary-light); color: var(--primary); }
.morph-badge { background: var(--emerald-light); color: var(--emerald); }

.card-title-group h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
}

.card-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-close-btn:hover {
  background: var(--border-subtle);
  color: var(--text-main);
}

.analysis-card-body {
  padding: 18px;
  max-height: 650px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Stat Pills Row */
.stat-pills-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat-pill {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-pill-label {
  font-size: 11px;
  color: var(--text-muted);
}

.stat-pill-value {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--primary);
}

.insight-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.insight-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.formula-chip {
  background: var(--primary-light);
  border: 1px dashed var(--primary);
  border-radius: var(--radius-md);
  padding: 9px 14px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--primary);
  direction: ltr;
  text-align: left;
}

.breakdown-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.breakdown-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-size: 13px;
}

.breakdown-comp {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 600;
}

.breakdown-content {
  font-weight: 700;
  color: var(--text-main);
  direction: ltr;
}

.insight-list {
  padding-right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-main);
}

.pos-chips-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.vocab-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 7px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
}

.vocab-word {
  font-weight: 700;
  color: var(--text-main);
  direction: ltr;
}

.vocab-pos {
  background: var(--primary-light);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.vocab-meaning {
  color: var(--text-muted);
}

/* ----------------- Morphology & Word Forms Elements ----------------- */
.morph-nav-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 6px;
}

.morph-nav-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

.morph-nav-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.morph-chip {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  color: var(--text-main);
  cursor: pointer;
  direction: ltr;
  transition: all 0.15s ease;
}

.morph-chip:hover {
  border-color: var(--emerald);
  color: var(--emerald);
}

.morph-chip.active {
  background: var(--emerald);
  color: #fff;
  border-color: var(--emerald);
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.morph-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 10px;
}

.morph-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px dashed var(--border-subtle);
  padding-bottom: 10px;
}

.morph-word-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.morph-word-num {
  background: var(--emerald);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.morph-word-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-main);
  direction: ltr;
}

.morph-base-badge {
  background: var(--primary-light);
  color: var(--primary);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  direction: rtl;
}

.morph-role-badge {
  background: var(--amber-light);
  color: var(--amber);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  direction: rtl;
}

.morph-root-meaning {
  font-size: 13.5px;
  color: var(--emerald);
  font-weight: 700;
}

.morph-sub-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.morph-sub-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.conj-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.conj-cell {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.conj-label {
  font-size: 10.5px;
  color: var(--text-dim);
}

.conj-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  direction: ltr;
}

.family-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.family-row {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
}

.family-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
}

.family-badge.noun { background: var(--primary-light); color: var(--primary); }
.family-badge.verb { background: var(--emerald-light); color: var(--emerald); }
.family-badge.adj { background: var(--amber-light); color: var(--amber); }
.family-badge.adv { background: rgba(168, 85, 247, 0.15); color: #a855f7; }

.family-content {
  font-weight: 600;
  color: var(--text-main);
  direction: ltr;
}

.nominalization-note {
  background: var(--amber-light);
  border: 1px dashed var(--amber);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-main);
}

.syn-ant-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.tag-label {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 700;
  min-width: 60px;
}

.syn-tag {
  background: var(--emerald-light);
  color: var(--emerald);
  border-radius: var(--radius-full);
  padding: 3px 9px;
  font-size: 12px;
  direction: ltr;
  font-weight: 600;
}

.ant-tag {
  background: var(--rose-light);
  color: var(--rose);
  border-radius: var(--radius-full);
  padding: 3px 9px;
  font-size: 12px;
  direction: ltr;
  font-weight: 600;
}

/* ----------------- Modals ----------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.2s ease;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 580px;
  width: 92%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalScaleUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalScaleUp {
  from { opacity: 0; transform: scale(0.96) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-header h3 {
  font-size: 16.5px;
  font-weight: 700;
  color: var(--text-main);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.api-key-field {
  display: flex;
  align-items: center;
  gap: 8px;
}

.api-key-field input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  color: var(--text-main);
  font-family: inherit;
  font-size: 14px;
  outline: none;
}

.api-key-field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

.field-hint {
  font-size: 12px;
  color: var(--text-dim);
}

.guide-box {
  background: var(--primary-light);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}

.guide-box h4 {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
}

.guide-box ol {
  padding-right: 20px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-main);
}

.guide-box a {
  color: var(--primary);
  text-decoration: underline;
}

.test-result-box {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.5;
}

.test-result-box.success {
  background: var(--emerald-light);
  color: var(--emerald);
  border: 1px solid var(--emerald);
}

.test-result-box.error {
  background: var(--rose-light);
  color: var(--rose);
  border: 1px solid var(--rose);
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.btn-primary {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border: none;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.btn-secondary {
  background: transparent;
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13.5px;
  cursor: pointer;
}

.btn-secondary:hover {
  background: var(--bg-subtle);
}

.btn-danger-text {
  background: transparent;
  border: none;
  color: var(--rose);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.btn-danger-text:hover {
  background: var(--rose-light);
}

/* ----------------- Language Modal ----------------- */
.lang-modal-card {
  max-width: 640px;
}

.modal-search {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-search input {
  width: 100%;
  padding: 9px 14px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  color: var(--text-main);
  outline: none;
  font-family: inherit;
  font-size: 14px;
}

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

.lang-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 6px;
  padding: 16px 20px;
  overflow-y: auto;
  max-height: 52vh;
}

.lang-item-btn {
  background: transparent;
  border: 1px solid transparent;
  padding: 8px 12px;
  text-align: left;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  color: var(--text-main);
  transition: all 0.1s;
}

.lang-item-btn:hover {
  background: var(--bg-subtle);
  color: var(--primary);
  border-color: var(--border-subtle);
}

.lang-item-btn.selected {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
  font-weight: 700;
}

/* ----------------- History Modal ----------------- */
.history-list {
  padding: 16px 20px;
  overflow-y: auto;
  max-height: 60vh;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-item {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  background: var(--bg-subtle);
  display: flex;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  transition: all 0.15s;
}

.history-item:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}

.history-langs {
  font-size: 11px;
  color: var(--text-muted);
}

.history-source {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-main);
}

.history-target {
  font-size: 14px;
  color: var(--primary);
}

/* ----------------- Flashcards Studio & Modal Styles ----------------- */
.flashcards-studio-card {
  width: 98vw;
  max-width: 1560px;
  height: 96vh;
  max-height: 96vh;
  display: flex;
  flex-direction: column;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.flashcards-studio-card.is-fullscreen {
  width: 100vw !important;
  max-width: 100vw !important;
  height: 100vh !important;
  max-height: 100vh !important;
  border-radius: 0 !important;
  border: none !important;
}

.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fc-fullscreen-btn {
  color: var(--text-muted);
  transition: all 0.15s ease;
}

.fc-fullscreen-btn:hover {
  color: var(--primary);
  background: var(--bg-card);
}

.fc-modal-nav {
  display: flex;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 3px;
  gap: 4px;
}

.fc-tab-btn {
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 5px 14px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.fc-tab-btn.active {
  background: var(--bg-surface);
  color: var(--emerald);
  box-shadow: var(--shadow-sm);
}

.fc-view-container {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
  height: 100%;
  max-height: none;
  overflow-y: auto;
}

#fcReviewView {
  max-width: 840px;
  width: 100%;
  margin: 0 auto;
}

#fcManageView {
  width: 100%;
}

.fc-review-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.fc-review-toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.fc-progress-badge {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  padding: 4px 12px;
  border-radius: var(--radius-full);
}

.fc-filter-pill-wrap {
  display: inline-flex;
  align-items: center;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 0 10px;
  gap: 6px;
  position: relative;
  transition: all 0.2s ease;
}

.fc-filter-pill-wrap:hover,
.fc-filter-pill-wrap:focus-within {
  border-color: var(--primary);
  background: var(--bg-card);
}

.fc-calendar-icon {
  color: var(--primary);
  flex-shrink: 0;
}

.fc-date-select {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 4px;
  direction: rtl;
}

.fc-date-select.sm {
  font-size: 11px;
  padding: 4px 2px;
}

.fc-date-select option {
  background: #1e293b;
  color: #f1f5f9;
}

.fc-quick-filters-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 4px 0;
}

.fc-quick-filter-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.fc-quick-filter-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.fc-quick-filter-chips.sm .fc-filter-chip {
  padding: 3px 9px;
  font-size: 11px;
}

.fc-filter-chip {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.18s ease;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  outline: none;
}

.fc-filter-chip:hover {
  background: var(--bg-card);
  color: var(--text-main);
  border-color: var(--primary);
}

.fc-filter-chip.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
}

.fc-tool-pill {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.fc-tool-pill:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

/* 3D Flip Card Viewport & Cards */
.flip-card-viewport {
  perspective: 1200px;
  width: 100%;
  min-height: 250px;
  cursor: pointer;
}

.flip-card-inner {
  width: 100%;
  min-height: 250px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  border-radius: var(--radius-lg);
}

.flip-card-inner.is-flipped {
  transform: rotateY(180deg);
}

.flip-card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-md);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.flip-card-face:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-glow), var(--shadow-md);
}

.flip-card-back {
  transform: rotateY(180deg);
  background: linear-gradient(155deg, var(--bg-card) 60%, var(--bg-subtle));
}

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

.face-tags-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.face-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

.face-tag.front-tag { background: var(--primary-light); color: var(--primary); }
.face-tag.back-tag { background: var(--emerald-light); color: var(--emerald); }
.face-tag.date-tag {
  background: var(--bg-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  font-weight: 600;
}

.face-main-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: auto 0;
  padding: 10px 0;
  width: 100%;
}

.fc-phrase-text {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-main);
  text-align: center;
  line-height: 1.5;
  direction: ltr;
}

.fc-meaning-text {
  font-size: 22px;
  font-weight: 700;
  color: var(--emerald);
  text-align: center;
  line-height: 1.5;
}

.fc-note-display-box {
  width: 100%;
  background: var(--amber-light);
  border: 1px dashed var(--amber);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-top: 14px;
  text-align: right;
  font-size: 13px;
  line-height: 1.6;
}

.fc-note-display-box .note-label {
  font-weight: 700;
  color: var(--amber);
  margin-left: 6px;
}

.face-bottom-row {
  display: flex;
  justify-content: center;
}

.flip-hint {
  font-size: 12px;
  color: var(--text-dim);
}

/* Card Bottom Navigation Controls */
.fc-card-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 4px;
}

.fc-nav-btn {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.fc-nav-btn:hover {
  background: var(--border-hover);
  color: var(--primary);
}

.fc-flip-btn {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  padding: 10px 24px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
  transition: all 0.2s ease;
}

.fc-flip-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

/* Tab 2: Manage All Cards List */
.fc-db-status-banner {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12.5px;
}

.db-badge-info {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
}

.db-badge-info svg {
  color: var(--primary);
}

.db-badge-info code {
  color: var(--emerald);
  background: var(--emerald-light);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11.5px;
  direction: ltr;
}

.db-banner-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-db-action {
  background: var(--emerald-light);
  color: var(--emerald);
  border: 1px solid var(--emerald);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-db-action:hover {
  background: var(--emerald);
  color: #fff;
}

.btn-db-export {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  transition: all 0.15s;
}

.btn-db-export:hover {
  background: var(--primary);
  color: #fff;
}

.fc-manage-header-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.fc-search-wrap {
  flex: 1;
  min-width: 200px;
}

.fc-search-wrap input {
  width: 100%;
  padding: 9px 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}

.fc-search-wrap input:focus {
  border-color: var(--primary);
}

.fc-filter-active-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(16, 185, 129, 0.08);
  border: 1px dashed var(--emerald);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 12.5px;
  color: var(--emerald);
}

.fc-filter-status-text {
  font-weight: 600;
}

.fc-reset-filter-btn {
  background: transparent;
  border: none;
  color: var(--rose);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.fc-reset-filter-btn:hover {
  background: rgba(244, 63, 94, 0.12);
}

.fc-item-date-badge {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 2px 9px;
  border-radius: var(--radius-full);
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.fc-item-date-badge:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

.fc-cards-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 14px;
  margin-top: 8px;
  align-items: start;
}

.fc-item-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  min-height: 135px;
  transition: all 0.2s ease;
}

.fc-item-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  transform: translateY(-2px);
}

.fc-item-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.fc-item-front {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  direction: ltr;
}

.fc-item-back {
  font-size: 15px;
  font-weight: 600;
  color: var(--emerald);
}

.fc-item-note-row {
  background: var(--amber-light);
  border: 1px dashed var(--amber);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-main);
}

.fc-item-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px dashed var(--border-subtle);
  padding-top: 8px;
  font-size: 11.5px;
  color: var(--text-dim);
}

.fc-item-btns {
  display: flex;
  align-items: center;
  gap: 6px;
}

.fc-item-edit-btn:hover {
  color: var(--primary) !important;
}

.fc-item-edit-form {
  grid-column: 1 / -1;
  background: var(--bg-card);
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.18);
  animation: fadeIn 0.2s ease;
}

.fc-edit-fields-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.fc-edit-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.fc-edit-field label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
}

.fc-edit-field input,
.fc-edit-field textarea {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text-main);
  font-family: inherit;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s;
}

.fc-edit-field input:focus,
.fc-edit-field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

.fc-edit-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.btn-save-sm {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 7px 16px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
}

.btn-save-sm:hover {
  opacity: 0.92;
}

.btn-cancel-sm {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
}

.btn-cancel-sm:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

/* Inline Note Box under translation */
.inline-note-box {
  padding: 0 16px 12px;
  animation: fadeIn 0.2s ease;
}

.inline-note-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-subtle);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  transition: all 0.2s ease;
}

.inline-note-wrapper:focus-within {
  border-color: var(--amber);
  background: var(--amber-light);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.15);
}

.inline-note-icon {
  color: var(--amber);
  flex-shrink: 0;
}

.inline-note-wrapper input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-family: inherit;
  font-size: 13px;
  direction: rtl;
}

.inline-note-wrapper input::placeholder {
  color: var(--text-dim);
  font-size: 12.5px;
}

.inline-note-clear-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.inline-note-clear-btn:hover {
  color: var(--text-main);
}

.icon-round-btn.sm {
  width: 28px;
  height: 28px;
  font-size: 12px;
}

/* ----------------- Toast ----------------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  padding: 10px 22px;
  border-radius: var(--radius-full);
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
  z-index: 200;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ----------------- Responsive ----------------- */
@media (max-width: 1024px) {
  .linguistic-studio-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 840px) {
  .translation-studio-card {
    flex-direction: column;
  }
  .source-panel {
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
  }
  .studio-center-swap {
    position: static;
    transform: none;
    display: flex;
    justify-content: center;
    padding: 8px 0;
  }
  .app-header .header-container {
    padding: 10px 16px;
    flex-wrap: wrap;
  }
  .studio-nav-pills {
    order: 3;
    width: 100%;
    justify-content: center;
  }
  .workspace-main {
    padding: 12px 14px 30px;
  }
}

@media (max-width: 640px) {
  .fc-cards-list-grid {
    grid-template-columns: 1fr;
  }
  .flashcards-studio-card {
    width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
  }
}

/* ----------------- Notebook Studio & Rich Text Editor ----------------- */
.notebook-header-btn {
  background: rgba(99, 102, 241, 0.1);
  color: #818cf8;
  border-color: rgba(99, 102, 241, 0.3);
}

.notebook-header-btn:hover {
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
  border-color: #818cf8;
}

.notebook-tool-btn:hover {
  color: #818cf8;
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.3);
}

.notebook-studio-card {
  width: 98vw;
  max-width: 1560px;
  height: 96vh;
  max-height: 96vh;
  display: flex;
  flex-direction: column;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.notebook-studio-card.is-fullscreen {
  width: 100vw !important;
  max-width: 100vw !important;
  height: 100vh !important;
  max-height: 100vh !important;
  border-radius: 0 !important;
  border: none !important;
}

.nb-subtitle {
  font-size: 11px;
  color: var(--text-dim);
  display: block;
  margin-top: 2px;
}

.nb-subtitle code {
  background: var(--bg-subtle);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 10.5px;
}

.nb-action-pill-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  padding: 6px 14px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.nb-action-pill-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.nb-action-pill-btn.secondary {
  background: var(--bg-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.nb-action-pill-btn.secondary:hover {
  background: var(--bg-card);
  color: var(--text-main);
  border-color: var(--primary);
}

.nb-studio-body {
  display: flex;
  flex: 1;
  height: calc(100% - 65px);
  overflow: hidden;
}

/* Sidebar Notes List */
.nb-sidebar {
  width: 320px;
  min-width: 270px;
  max-width: 360px;
  border-left: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.nb-sidebar-header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.nb-search-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.nb-search-icon {
  position: absolute;
  right: 10px;
  color: var(--text-dim);
  pointer-events: none;
}

.nb-search-wrap input {
  width: 100%;
  padding: 8px 32px 8px 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: inherit;
  font-size: 12.5px;
  outline: none;
  transition: border-color 0.15s;
}

.nb-search-wrap input:focus {
  border-color: var(--primary);
}

.nb-add-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.nb-add-btn:hover {
  background: var(--primary);
  color: #fff;
  transform: scale(1.05);
}

.nb-sidebar-meta-row {
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-dim);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-subtle);
}

.nb-sort-select {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  direction: rtl;
}

.nb-sort-select option {
  background: #1e293b;
  color: #f1f5f9;
}

/* Clean Compact List Items in Sidebar */
.nb-notes-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.nb-item {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: all 0.15s ease;
  position: relative;
}

.nb-item:hover {
  background: var(--bg-subtle);
  border-color: var(--primary);
  transform: translateX(-2px);
}

.nb-item.active {
  background: rgba(99, 102, 241, 0.12);
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

.nb-item.is-pinned {
  border-right: 3px solid var(--amber);
}

.nb-item-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nb-item-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.nb-pin-badge {
  font-size: 11px;
  flex-shrink: 0;
}

.nb-item-title-text {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.nb-item-date {
  font-size: 10px;
  color: var(--text-dim);
}

.nb-item-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  opacity: 0.6;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

.nb-item:hover .nb-item-actions {
  opacity: 1;
}

.nb-action-icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.nb-action-icon-btn:hover {
  background: var(--bg-subtle);
  color: var(--primary);
}

.nb-action-icon-btn.nb-del-btn:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.12);
}

/* Editor Pane */
.nb-editor-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  overflow: hidden;
}

.nb-editor-topbar {
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  gap: 12px;
  flex-wrap: wrap;
}

.nb-save-status-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nb-save-btn {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  padding: 6px 16px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.35);
  transition: all 0.2s ease;
}

.nb-save-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.45);
  filter: brightness(1.05);
}

.nb-save-btn:active {
  transform: translateY(0);
}

.nb-save-btn.has-unsaved {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  box-shadow: 0 2px 10px rgba(245, 158, 11, 0.45);
}

.nb-save-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--emerald);
  font-weight: 600;
}

.nb-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 8px var(--emerald);
  transition: all 0.2s;
}

.nb-status-dot.unsaved {
  background: var(--amber);
  box-shadow: 0 0 8px var(--amber);
}

.nb-editor-stats {
  font-size: 11.5px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}

.nb-sep {
  opacity: 0.4;
}

.nb-editor-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nb-tool-pill-action {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: var(--radius-full);
  padding: 4px 12px;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.15s;
}

.nb-tool-pill-action:hover {
  background: var(--primary);
  color: #fff;
}

.nb-title-container {
  padding: 16px 24px 8px;
  border-bottom: 1px dashed var(--border-subtle);
  min-height: 52px;
  display: flex;
  align-items: center;
}

.nb-title-display {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.4;
  margin: 0;
  padding: 2px 0;
  word-break: break-word;
  width: 100%;
}

.nb-title-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 22px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.4;
}

.nb-title-input::placeholder {
  color: var(--text-dim);
  opacity: 0.6;
}

/* Rich Text Formatting Toolbar */
.nb-formatting-toolbar {
  padding: 8px 16px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.nb-toolbar-group {
  display: flex;
  align-items: center;
  gap: 3px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 2px 4px;
}

.nb-tool-btn {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  transition: all 0.15s ease;
}

.nb-tool-btn.text-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.nb-tool-btn:hover {
  background: var(--bg-subtle);
  color: var(--primary);
}

.nb-tool-btn.active {
  background: var(--primary-light);
  color: var(--primary);
}

/* Content Editable Area */
.nb-editor-scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
  cursor: text;
}

.nb-editor-content {
  min-height: 100%;
  outline: none;
  font-size: 15.5px;
  line-height: 1.85;
  color: var(--text-main);
  direction: rtl;
  word-break: break-word;
}

.nb-editor-content:empty::before {
  content: attr(placeholder);
  color: var(--text-dim);
  pointer-events: none;
  display: block;
}

.nb-editor-content h1 {
  font-size: 24px;
  font-weight: 800;
  margin: 18px 0 10px;
  color: var(--text-main);
  line-height: 1.35;
}

.nb-editor-content h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 16px 0 8px;
  color: var(--text-main);
  line-height: 1.4;
}

.nb-editor-content h3 {
  font-size: 17px;
  font-weight: 700;
  margin: 14px 0 6px;
  color: var(--text-main);
  line-height: 1.4;
}

.nb-editor-content p {
  margin: 6px 0 10px;
}

.nb-editor-content blockquote {
  border-right: 4px solid var(--primary);
  background: rgba(99, 102, 241, 0.08);
  padding: 10px 16px;
  border-radius: 4px 0 0 4px;
  margin: 12px 0;
  font-style: italic;
  color: var(--text-main);
}

.nb-editor-content code {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  color: #f43f5e;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 13.5px;
}

.nb-editor-content pre {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin: 12px 0;
  overflow-x: auto;
  font-family: 'Consolas', monospace;
  direction: ltr;
  text-align: left;
}

.nb-editor-content ul,
.nb-editor-content ol {
  padding-right: 24px;
  margin: 10px 0;
}

.nb-editor-content mark {
  background: #fde047;
  color: #1e293b;
  padding: 1px 4px;
  border-radius: 3px;
}

.nb-editor-content hr {
  border: none;
  border-top: 1px dashed var(--border-subtle);
  margin: 20px 0;
}

.nb-task-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
}

.nb-task-item input[type="checkbox"] {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* Footer Bar */
.nb-editor-footer {
  padding: 8px 24px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nb-meta-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

@media (max-width: 820px) {
  .nb-studio-body {
    flex-direction: column;
  }
  .nb-sidebar {
    width: 100%;
    max-width: none;
    height: 180px;
    border-left: none;
    border-bottom: 1px solid var(--border-subtle);
  }
}
