/* =============================
   CSS Variables
   ============================= */
:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #e0e7ff;
  --success: #22c55e;
  --success-light: #dcfce7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-light: #94a3b8;
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* =============================
   Dark Theme
   ============================= */
[data-theme="dark"] {
  --primary-light: #1e1b4b;
  --success-light: #052e16;
  --danger-light: #2d0808;
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-light: #475569;
  --bg: #0f172a;
  --bg-card: #1e293b;
  --border: #334155;
  --shadow: 0 2px 12px rgba(0,0,0,0.35);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
}

/* Smooth theme transitions */
body, .header, .folder-header, .modal, .folder-card,
.card-item, .flip-card-front, .flip-card-back,
.stat-card, .quiz-header, .btn-icon, .btn-back,
.form-input, .add-card-btn, .btn-quiz-exit, .btn-full.secondary {
  transition: background-color 0.22s ease, color 0.22s ease,
              border-color 0.22s ease, box-shadow 0.22s ease;
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: var(--font);
  border: none;
  cursor: pointer;
  outline: none;
  transition: transform 0.1s, opacity 0.1s;
  user-select: none;
  touch-action: manipulation;
}

button:active {
  transform: scale(0.96);
  opacity: 0.85;
}

input, textarea {
  font-family: var(--font);
  font-size: 16px;
  outline: none;
  border: none;
}

/* =============================
   App Container
   ============================= */
#app {
  height: 100dvh;
  position: relative;
  overflow: hidden;
  touch-action: pan-x pan-y;
}

#main-view {
  position: relative;
  height: 100%;
  width: 100%;
  z-index: 1;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  will-change: transform;
}

.edge-back-layer {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: var(--bg);
  transform: translateX(-28%);
  pointer-events: none;
}

.edge-back-layer .screen {
  pointer-events: none;
}

/* =============================
   Screen (each view)
   ============================= */
.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: fadeIn 0.2s ease;
}

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

/* =============================
   Header
   ============================= */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  padding-top: max(16px, env(safe-area-inset-top));
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.header-left .header-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
}

.btn-icon.primary {
  background: var(--primary);
  color: white;
}

.btn-icon.danger {
  background: var(--danger-light);
  color: var(--danger);
}

.btn-back {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
}

/* =============================
   Scrollable content area
   ============================= */
.content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 20px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}

/* =============================
   Empty State
   ============================= */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  color: var(--text-secondary);
}

.empty-state .empty-icon {
  font-size: 56px;
  margin-bottom: 16px;
  opacity: 0.6;
}

.empty-state p {
  font-size: 15px;
  line-height: 1.6;
}

/* =============================
   Folder Cards (Home)
   ============================= */
.quiz-all-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 16px;
  background: var(--primary);
  color: white;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 20px;
  box-shadow: 0 4px 16px rgba(99,102,241,0.35);
}

.folders-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.folder-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s;
  text-align: left;
  width: 100%;
}

.folder-card:active {
  transform: scale(0.98);
}

.folder-icon-wrap {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  flex-shrink: 0;
}

.folder-info {
  flex: 1;
  min-width: 0;
}

.folder-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.folder-count {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.folder-arrow {
  font-size: 18px;
  color: var(--text-light);
  flex-shrink: 0;
}

/* =============================
   Card List (Folder View)
   ============================= */
.folder-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.folder-header-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.folder-header-info {
  flex: 1;
}

.folder-header-info .folder-name {
  font-size: 18px;
}

.quiz-folder-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  color: white;
  margin-bottom: 16px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.cards-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card-item {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  gap: 12px;
  cursor: pointer;
}

.card-item:active {
  transform: scale(0.99);
}

.card-item-words {
  flex: 1;
  min-width: 0;
}

.card-side1 {
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-side2 {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-item-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.btn-sm {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  background: var(--bg);
}

.btn-sm.danger {
  background: var(--danger-light);
  color: var(--danger);
}

.add-card-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  background: transparent;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 500;
  margin-top: 12px;
}

/* =============================
   Quiz Screen
   ============================= */
.quiz-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  padding-top: max(14px, env(safe-area-inset-top));
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.quiz-progress-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.quiz-counter {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.quiz-score {
  display: flex;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
}

.score-correct { color: var(--success); }
.score-wrong { color: var(--danger); }

.btn-quiz-exit {
  padding: 8px 14px;
  border-radius: 20px;
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
}

.quiz-progress-bar-wrap {
  height: 3px;
  background: var(--border);
  flex-shrink: 0;
}

.quiz-progress-bar {
  height: 100%;
  background: var(--primary);
  transition: width 0.3s ease;
}

.quiz-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  gap: 24px;
}

/* Card Flip */
.flip-card-container {
  width: 100%;
  max-width: 480px;
  perspective: 1200px;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
}

/* Swipe indicators */
.swipe-indicator {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 32px;
  font-weight: 800;
  padding: 10px 14px;
  border-radius: 12px;
  border: 3px solid;
  opacity: 0;
  pointer-events: none;
  z-index: 10;
  transition: opacity 0.06s;
}
.swipe-indicator-correct {
  right: 12px;
  color: var(--success);
  border-color: var(--success);
  background: var(--success-light);
}
.swipe-indicator-wrong {
  left: 12px;
  color: var(--danger);
  border-color: var(--danger);
  background: var(--danger-light);
}

.flip-card-inner {
  position: relative;
  width: 100%;
  min-height: 200px;
  transform-style: preserve-3d;
  transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: var(--radius);
}

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

.flip-card-front,
.flip-card-back {
  position: absolute;
  top: 0; left: 0; right: 0;
  min-height: 200px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 24px;
  background: var(--bg-card);
  text-align: center;
}

.flip-card-back {
  transform: rotateY(180deg);
}

.card-word {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  word-break: break-word;
}

.card-hint {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-light);
  display: flex;
  align-items: center;
  gap: 4px;
}

.card-description {
  margin-top: 14px;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  background: var(--bg);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  width: 100%;
  text-align: left;
  word-break: break-word;
}

.quiz-reveal-btn {
  width: 100%;
  max-width: 480px;
  padding: 16px;
  background: var(--primary);
  color: white;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(99,102,241,0.35);
}

/* Quiz Action Buttons */
.quiz-actions {
  display: flex;
  gap: 20px;
  width: 100%;
  max-width: 480px;
}

.btn-wrong,
.btn-correct {
  flex: 1;
  padding: 18px;
  border-radius: var(--radius);
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
}

.btn-wrong {
  background: var(--danger-light);
  color: var(--danger);
}

.btn-correct {
  background: var(--success-light);
  color: var(--success);
}

.btn-wrong:disabled,
.btn-correct:disabled {
  opacity: 0.35;
  pointer-events: none;
}

/* =============================
   Stats Screen
   ============================= */
.stats-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 32px 24px;
  padding-bottom: max(32px, env(safe-area-inset-bottom));
  align-items: center;
  justify-content: center;
  gap: 24px;
  animation: fadeIn 0.3s ease;
}

.stats-icon {
  font-size: 64px;
}

.stats-title {
  font-size: 26px;
  font-weight: 700;
  text-align: center;
}

.stats-cards {
  display: flex;
  gap: 16px;
  width: 100%;
  max-width: 400px;
}

.stat-card {
  flex: 1;
  padding: 20px 16px;
  border-radius: var(--radius);
  text-align: center;
}

.stat-card.correct {
  background: var(--success-light);
}

.stat-card.wrong {
  background: var(--danger-light);
}

.stat-num {
  font-size: 40px;
  font-weight: 700;
  line-height: 1;
}

.stat-card.correct .stat-num { color: var(--success); }
.stat-card.wrong .stat-num { color: var(--danger); }

.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 6px;
}

.stats-bar-wrap {
  width: 100%;
  max-width: 400px;
}

.stats-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.stats-bar-bg {
  height: 10px;
  background: var(--danger-light);
  border-radius: 99px;
  overflow: hidden;
}

.stats-bar-fill {
  height: 100%;
  background: var(--success);
  border-radius: 99px;
  transition: width 0.6s ease;
}

.stats-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 400px;
}

.btn-full {
  width: 100%;
  padding: 16px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
}

.btn-full.primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 16px rgba(99,102,241,0.3);
}

.btn-full.secondary {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: var(--shadow);
}

.btn-full.danger {
  background: var(--danger-light);
  color: var(--danger);
}

.btn-full:disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* =============================
   Modal
   ============================= */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 100;
  backdrop-filter: blur(2px);
  animation: fadeIn 0.2s ease;
}

.modal-wrap {
  position: fixed;
  inset: 0;
  z-index: 101;
  display: flex;
  align-items: flex-end;
  pointer-events: none;
}

.modal-wrap:not(.hidden) {
  pointer-events: auto;
}

.modal {
  width: 100%;
  max-height: 92dvh;
  background: var(--bg-card);
  border-radius: 24px 24px 0 0;
  padding: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 12px auto 0;
}

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

.modal-title {
  font-size: 18px;
  font-weight: 700;
}

.btn-modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

.modal-content {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Form Elements */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-input {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 12px 14px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  color: var(--text);
  transition: border-color 0.15s;
}

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

.form-textarea {
  resize: none;
  min-height: 80px;
  line-height: 1.5;
}

.char-count {
  font-size: 12px;
  color: var(--text-light);
  text-align: right;
}

/* Color Picker */
.color-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.color-swatch {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: transform 0.15s, border-color 0.15s;
}

.color-swatch:active { transform: scale(0.9); }
.color-swatch.selected { border-color: white; outline: 2px solid var(--primary); }

/* Icon Picker */
.icon-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.15s;
}

.icon-btn:active { transform: scale(0.9); }
.icon-btn.selected { border-color: var(--primary); background: var(--primary-light); }

/* Delete Confirm */
.delete-confirm {
  padding: 24px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.delete-confirm .icon {
  font-size: 48px;
}

.delete-confirm h3 {
  font-size: 18px;
  font-weight: 700;
}

.delete-confirm p {
  font-size: 14px;
  color: var(--text-secondary);
}

.delete-confirm-actions {
  display: flex;
  gap: 10px;
  width: 100%;
  margin-top: 8px;
}

.delete-confirm-actions button {
  flex: 1;
  padding: 14px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
}

.btn-cancel {
  background: var(--bg);
  color: var(--text);
}

.btn-delete {
  background: var(--danger);
  color: white;
}

/* =============================
   Quiz Setup Modal
   ============================= */
.mode-picker {
  display: flex;
  gap: 10px;
}
.mode-btn {
  flex: 1;
  padding: 14px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 2px solid var(--border);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}
.mode-btn.selected {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}
.count-stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
}
.stepper-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-card);
  box-shadow: var(--shadow);
  font-size: 22px;
  font-weight: 300;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
}
.stepper-val {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  min-width: 48px;
  text-align: center;
}
.stepper-hint {
  text-align: center;
  font-size: 12px;
  color: var(--text-light);
  margin-top: 4px;
}

/* =============================
   Multiple Choice Quiz
   ============================= */
.mc-body {
  padding: 20px;
  gap: 20px;
}
.mc-question {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  word-break: break-word;
  padding: 8px;
}
.mc-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  max-width: 480px;
}
.mc-option {
  padding: 18px 10px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  text-align: center;
  box-shadow: var(--shadow);
  word-break: break-word;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.mc-option:active:not(:disabled) { transform: scale(0.97); }
.mc-option.mc-correct {
  background: var(--success-light);
  border-color: var(--success);
  color: var(--success);
}
.mc-option.mc-wrong {
  background: var(--danger-light);
  border-color: var(--danger);
  color: var(--danger);
}
.mc-option:disabled { cursor: default; }
.mc-description {
  width: 100%;
  max-width: 480px;
  font-size: 14px;
  color: var(--text-secondary);
  background: var(--bg);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  line-height: 1.5;
}
.mc-next-btn {
  width: 100%;
  max-width: 480px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  margin-top: 4px;
  opacity: 1;
  transition: opacity 0.15s, transform 0.1s;
}
.mc-next-btn:disabled {
  opacity: 0.35;
  cursor: default;
  transform: none;
}

/* =============================
   CSV Import
   ============================= */
.csv-info {
  font-size: 14px;
  color: var(--text-secondary);
  background: var(--bg);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
}
.csv-preview {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.csv-preview-row {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.csv-preview-row:last-child { border-bottom: none; }
.csv-preview-row span:first-child {
  flex: 1;
  font-weight: 500;
  color: var(--text);
}
.csv-preview-row span:last-child {
  flex: 1;
  color: var(--text-secondary);
}
.csv-more {
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text-light);
  text-align: center;
  background: var(--bg);
}


/* TTS button on card */
.tts-btn {
  margin-top: 8px;
  padding: 6px 12px;
  background: var(--bg);
  border-radius: 20px;
  font-size: 14px;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

/* Lang row in folder modal */
.lang-row {
  display: flex;
  gap: 10px;
}


/* =============================
   Search
   ============================= */
.search-input {
  flex: 1;
  height: 36px;
  padding: 0 12px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-size: 16px;
  color: var(--text);
  transition: border-color 0.15s;
}
.search-input:focus { border-color: var(--primary); }

.search-count {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.search-folder-tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  white-space: nowrap;
}

mark.search-hl {
  background: #fde68a;
  color: #92400e;
  border-radius: 2px;
  padding: 0 1px;
}

[data-theme="dark"] mark.search-hl {
  background: #78350f;
  color: #fde68a;
}

/* =============================
   Settings Page
   ============================= */
.settings-section-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  padding: 20px 20px 6px;
}
.settings-list {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  padding: 0;
}
.settings-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 14px;
  background: none;
  text-align: left;
  gap: 14px;
  color: var(--text);
  font-size: 16px;
}
.settings-item:active {
  background: var(--border);
}
.settings-item-icon {
  font-size: 22px;
  width: 32px;
  text-align: center;
  flex-shrink: 0;
}
.settings-item-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.settings-item-label {
  flex: 1;
  font-weight: 500;
}
.settings-item-sub {
  font-size: 12px;
  color: var(--text-secondary);
}
.settings-item-arrow {
  font-size: 20px;
  color: var(--text-light);
  flex-shrink: 0;
}
.settings-badge {
  font-size: 13px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  flex-shrink: 0;
}
.settings-badge.on {
  background: var(--primary-light);
  color: var(--primary);
}
.settings-badge.off {
  background: var(--border);
  color: var(--text-secondary);
}
.settings-divider {
  height: 1px;
  background: var(--border);
  margin: 0 20px;
}

/* Hidden */
.hidden {
  display: none !important;
}

/* Utility */
.divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* Scroll */
::-webkit-scrollbar {
  display: none;
}

/* Safe area padding for content */
.content-safe {
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}


