/* =====================================================
   FlashLearn — Design System & Styles
   A premium, dark-mode, mobile-first flashcard PWA
   ===================================================== */

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

:root {
  /* Core palette */
  --bg-deep: #0a0a14;
  --bg-base: #0f0f1a;
  --bg-card: #161625;
  --bg-card-elevated: #1c1c30;
  --bg-surface: rgba(255, 255, 255, 0.04);
  --bg-surface-hover: rgba(255, 255, 255, 0.07);
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-active: rgba(99, 102, 241, 0.3);

  /* Text */
  --text-primary: #f0f0f5;
  --text-secondary: #9d9db5;
  --text-tertiary: #6b6b82;
  --text-accent: #a78bfa;

  /* Accent gradient */
  --accent-1: #6366f1;
  --accent-2: #8b5cf6;
  --accent-3: #a78bfa;
  --gradient-primary: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  --gradient-warm: linear-gradient(135deg, #f59e0b, #ef4444);
  --gradient-cool: linear-gradient(135deg, #06b6d4, #3b82f6);
  --gradient-green: linear-gradient(135deg, #10b981, #34d399);

  /* Rating colors */
  --color-hard: #ef4444;
  --color-good: #f59e0b;
  --color-easy: #10b981;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.15);

  /* Animation */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast: 150ms;
  --duration-normal: 250ms;
  --duration-slow: 400ms;

  /* Safe areas */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
}

/* ───── Screen System ───── */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateX(30px);
  transition: opacity var(--duration-slow) var(--ease-out),
              transform var(--duration-slow) var(--ease-out),
              visibility 0s var(--duration-slow);
}

.screen.active {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
  transition: opacity var(--duration-slow) var(--ease-out),
              transform var(--duration-slow) var(--ease-out),
              visibility 0s;
}

.screen.exiting {
  opacity: 0;
  transform: translateX(-30px);
}

/* ───── Header user profile & avatar ───── */
.header-user-info {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-width: 0;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-active);
  background: var(--bg-surface);
  flex-shrink: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.btn-icon-text {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration-fast);
}

.btn-icon-text:hover {
  background: var(--bg-surface-hover);
  border-color: var(--accent-1);
  color: var(--text-accent);
}

.btn-icon-text svg {
  width: 14px;
  height: 14px;
}

/* ═══════════════════════════════════════════════
   SCREEN: LOGIN
   ═══════════════════════════════════════════════ */

.login-hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
  text-align: center;
  gap: var(--space-lg);
}

/* Logo orb with pulsing glow */
.logo-orb {
  position: relative;
  width: 96px;
  height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.orb-glow {
  position: absolute;
  inset: -20px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.25), transparent 70%);
  border-radius: 50%;
  animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { transform: scale(1); opacity: 0.6; }
  50% { transform: scale(1.15); opacity: 1; }
}

.logo-icon {
  width: 56px;
  height: 56px;
  color: var(--accent-3);
  position: relative;
  z-index: 1;
}

.hero-title {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.hero-title .accent {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
  line-height: 1.5;
  font-weight: 400;
}

.auth-box {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin-top: var(--space-md);
}

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  width: 100%;
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: white;
  color: #1f2937;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-fast);
  box-shadow: var(--shadow-sm);
}

.btn-google:hover {
  background: #f9fafb;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.google-icon {
  width: 20px;
  height: 20px;
}

/* ═══════════════════════════════════════════════
   SCREEN: LIBRARY
   ═══════════════════════════════════════════════ */

.library-container {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg);
  padding-bottom: calc(var(--safe-bottom) + var(--space-2xl));
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

.library-upload-section {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
}

.upload-zone {
  width: 100%;
  padding: var(--space-xl);
  border: 2px dashed var(--border-subtle);
  border-radius: var(--radius-xl);
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-out);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
}

.upload-zone.compact {
  padding: var(--space-md);
  border-radius: var(--radius-md);
}

.upload-zone:hover {
  border-color: var(--accent-1);
  background: rgba(99, 102, 241, 0.04);
}

.upload-label {
  font-size: 0.88rem;
  color: var(--text-primary);
  text-align: center;
}

.library-section {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
}

.section-title {
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
  border-left: 3px solid var(--accent-1);
  padding-left: var(--space-sm);
}

/* Documents Grid */
.docs-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.doc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  transition: all var(--duration-fast);
}

.doc-item:hover {
  border-color: var(--border-active);
  background: var(--bg-card-elevated);
}

.doc-item-info {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.doc-item-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.doc-item-meta {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-top: 3px;
}

.doc-item-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-left: var(--space-md);
}

.btn-danger-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: rgba(239, 68, 68, 0.1);
  color: var(--color-hard);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--duration-fast);
}

.btn-danger-icon:hover {
  background: var(--color-hard);
  color: white;
}

.btn-danger-icon svg {
  width: 16px;
  height: 16px;
}

/* Prompts Grid */
.prompts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-sm);
}

@media (min-width: 500px) {
  .prompts-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.prompt-item-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: var(--space-md);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  height: 120px;
}

.prompt-item-card:hover {
  border-color: var(--border-active);
}

.prompt-item-title {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.prompt-item-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-sm);
}

.prompt-item-date {
  font-size: 0.7rem;
  color: var(--text-tertiary);
}

.prompt-item-btn {
  background: none;
  border: none;
  color: var(--text-accent);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.prompt-item-btn:hover {
  text-decoration: underline;
}

/* ═══════════════════════════════════════════════
   SCREEN: PROMPT BUILDER
   ═══════════════════════════════════════════════ */

.pb-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: var(--space-lg);
  max-width: 550px;
  margin: 0 auto;
  width: 100%;
}

.wizard-progress {
  display: flex;
  justify-content: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-xl);
}

.wizard-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  transition: all var(--duration-fast);
}

.wizard-dot.active {
  background: var(--accent-3);
  transform: scale(1.2);
  box-shadow: 0 0 8px var(--accent-1);
}

.wizard-dot.completed {
  background: var(--accent-1);
}

.wizard-content {
  flex: 1;
  position: relative;
}

.wizard-step {
  display: none;
  flex-direction: column;
  animation: fadeIn var(--duration-normal) var(--ease-out);
}

.wizard-step.active {
  display: flex;
}

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

.step-question {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: var(--space-xs);
  letter-spacing: -0.01em;
}

.step-description {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-lg);
  line-height: 1.4;
}

/* Inputs and Forms */
.pb-input {
  width: 100%;
  padding: var(--space-md);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.92rem;
  outline: none;
  transition: border-color var(--duration-fast);
}

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

.pb-presets {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-top: var(--space-md);
}

.pb-chip {
  padding: 6px 12px;
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration-fast);
  border: 1px solid transparent;
}

.pb-chip:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.pb-chip.active {
  background: rgba(99, 102, 241, 0.15);
  border-color: var(--accent-1);
  color: var(--text-accent);
}

.pb-select-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.btn-select {
  width: 100%;
  padding: var(--space-md);
  text-align: left;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-fast);
}

.btn-select:hover {
  background: var(--bg-card-elevated);
}

.btn-select.active {
  border-color: var(--accent-1);
  background: rgba(99, 102, 241, 0.1);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.1);
}

.pb-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  margin-bottom: var(--space-xs);
}

/* Prompt output screen */
.generated-prompt-box {
  width: 100%;
  height: 200px;
  margin-bottom: var(--space-md);
}

.generated-prompt-box textarea {
  width: 100%;
  height: 100%;
  background: #08080f;
  color: #a5b4fc;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  line-height: 1.5;
  resize: none;
  outline: none;
}

.pb-result-actions {
  display: flex;
  gap: var(--space-sm);
}

.btn-primary {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px;
  border-radius: var(--radius-md);
  border: none;
  background: var(--gradient-primary);
  color: white;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-secondary {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

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

.wizard-nav {
  display: flex;
  justify-content: space-between;
  margin-top: var(--space-xl);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border-subtle);
}

/* Pre-made carousel at bottom */
.pb-premade-section {
  background: #08080f;
  border-top: 1px solid var(--border-subtle);
  padding: var(--space-lg);
  margin-top: auto;
}

.premade-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  margin-bottom: var(--space-md);
}

.premade-carousel {
  display: flex;
  gap: var(--space-md);
  overflow-x: auto;
  padding-bottom: var(--space-sm);
  -webkit-overflow-scrolling: touch;
}

.premade-card {
  flex: 0 0 200px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  cursor: pointer;
  transition: all var(--duration-fast);
}

.premade-card:hover {
  border-color: var(--accent-1);
}

.premade-card h5 {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.premade-card p {
  font-size: 0.7rem;
  color: var(--text-tertiary);
  line-height: 1.4;
}

/* ═══════════════════════════════════════════════
   SCREEN: TOPICS BROWSER
   ═══════════════════════════════════════════════ */

.app-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  padding-top: calc(var(--safe-top) + var(--space-md));
  background: rgba(15, 15, 26, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 10;
}

.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: none;
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--duration-fast);
  flex-shrink: 0;
}

.btn-icon:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.btn-icon.small {
  width: 32px;
  height: 32px;
}

.btn-icon svg {
  width: 20px;
  height: 20px;
}

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

.header-title {
  font-size: 1.05rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.header-stats {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* Search bar */
.search-bar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  background: var(--bg-base);
  border-bottom: 1px solid var(--border-subtle);
  transition: all var(--duration-normal) var(--ease-out);
}

.search-bar.hidden {
  display: none;
}

.search-icon {
  width: 18px;
  height: 18px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.search-bar input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
}

.search-bar input::placeholder {
  color: var(--text-tertiary);
}

/* Progress overview */
.progress-overview {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  padding: var(--space-lg);
  margin: var(--space-md) var(--space-lg) 0;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
}

.progress-ring-wrap {
  position: relative;
  width: 64px;
  height: 64px;
  flex-shrink: 0;
}

.progress-ring {
  width: 64px;
  height: 64px;
}

.progress-percent {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-accent);
}

.progress-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.progress-main {
  font-size: 0.95rem;
  font-weight: 600;
}

.progress-sub {
  font-size: 0.78rem;
  color: var(--text-tertiary);
}

/* View mode toggle */
.view-mode-bar {
  display: flex;
  gap: var(--space-xs);
  padding: var(--space-md) var(--space-lg) var(--space-sm);
}

.view-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration-fast);
}

.view-btn.active {
  background: rgba(99, 102, 241, 0.12);
  border-color: var(--accent-1);
  color: var(--accent-3);
}

.view-btn svg {
  width: 15px;
  height: 15px;
}

/* Topics list */
.topics-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-sm) var(--space-lg) calc(var(--safe-bottom) + var(--space-xl));
  -webkit-overflow-scrolling: touch;
}

.topic-group {
  margin-bottom: var(--space-lg);
  animation: slideUp var(--duration-slow) var(--ease-out) both;
}

.topic-group:nth-child(2) { animation-delay: 50ms; }
.topic-group:nth-child(3) { animation-delay: 100ms; }
.topic-group:nth-child(4) { animation-delay: 150ms; }
.topic-group:nth-child(5) { animation-delay: 200ms; }
.topic-group:nth-child(6) { animation-delay: 250ms; }

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

.topic-section-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  padding: var(--space-md) 0 var(--space-sm);
}

.topic-card {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all var(--duration-fast);
  margin-bottom: var(--space-sm);
  -webkit-user-select: none;
  user-select: none;
}

.topic-card:hover {
  background: var(--bg-card-elevated);
  border-color: var(--border-active);
  transform: translateX(4px);
}

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

.topic-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  flex-shrink: 0;
  color: white;
}

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

.topic-name {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.topic-meta {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.topic-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 600;
  flex-shrink: 0;
}

.topic-badge.new {
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-3);
}

.topic-badge.progress {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.topic-badge.done {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.topic-arrow {
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.topic-arrow svg {
  width: 16px;
  height: 16px;
}

/* "All Cards" list view */
.all-card-item {
  padding: var(--space-md);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  margin-bottom: var(--space-sm);
  cursor: pointer;
  transition: all var(--duration-fast);
}

.all-card-item:hover {
  border-color: var(--border-active);
  background: var(--bg-card-elevated);
}

.all-card-item .card-type-tag {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  margin-bottom: var(--space-xs);
}

.all-card-item .card-preview {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ═══════════════════════════════════════════════
   SCREEN: FLASHCARD VIEWER
   ═══════════════════════════════════════════════ */

.card-header {
  background: rgba(10, 10, 20, 0.9);
}

.header-card-controls {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

#btn-read-aloud.active {
  color: var(--accent-3);
  background: rgba(99, 102, 241, 0.15);
  border-color: var(--accent-1);
}

.card-progress-bar {
  height: 3px;
  background: var(--bg-surface);
  position: relative;
}

.card-progress-fill {
  height: 100%;
  background: var(--gradient-primary);
  transition: width var(--duration-normal) var(--ease-out);
  border-radius: 0 2px 2px 0;
  width: 0%;
}

.cards-viewport {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md) var(--space-lg);
  overflow: hidden;
  perspective: 1000px;
}

.card-container {
  width: 100%;
  max-width: 500px;
  min-height: 300px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.5s var(--ease-out);
  cursor: pointer;
}

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

.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
}

.card-front {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-lg);
}

.card-back {
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-active);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  transform: rotateY(180deg);
}

.card-type-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  margin-bottom: var(--space-md);
  align-self: flex-start;
}

.card-type-label.concept {
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-3);
}

.card-type-label.command {
  background: rgba(6, 182, 212, 0.15);
  color: #22d3ee;
}

.card-type-label.diagram {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.card-type-label.scenario {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

.card-type-label.interview {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.card-type-label.qa {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
}

.card-type-label.mistake {
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
}

.card-type-label.advanced {
  background: rgba(251, 191, 36, 0.12);
  color: #fde68a;
}

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: var(--space-md);
  letter-spacing: -0.01em;
}

.card-body {
  font-size: 0.88rem;
  line-height: 1.7;
  color: var(--text-secondary);
  flex: 1;
}

.card-body p {
  margin-bottom: var(--space-md);
}

.card-body p:last-child {
  margin-bottom: 0;
}

.card-body strong {
  color: var(--text-primary);
  font-weight: 600;
}

.card-body code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  background: rgba(255,255,255,0.06);
  padding: 2px 6px;
  border-radius: 4px;
  color: #c084fc;
}

.card-body pre {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  overflow-x: auto;
  margin: var(--space-md) 0;
  font-size: 0.78rem;
  line-height: 1.6;
}

.card-body pre code {
  background: none;
  padding: 0;
  color: #a5b4fc;
  font-size: inherit;
}

.card-body ul, .card-body ol {
  padding-left: var(--space-lg);
  margin-bottom: var(--space-md);
}

.card-body li {
  margin-bottom: var(--space-xs);
  line-height: 1.6;
}

.card-body table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-md) 0;
  font-size: 0.8rem;
}

.card-body th, .card-body td {
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border-subtle);
  text-align: left;
}

.card-body th {
  background: rgba(99, 102, 241, 0.08);
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.card-body blockquote {
  border-left: 3px solid var(--accent-1);
  padding: var(--space-md);
  margin: var(--space-md) 0;
  background: rgba(99, 102, 241, 0.05);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: italic;
  color: var(--text-secondary);
}

.card-flip-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--text-tertiary);
  margin-top: var(--space-lg);
  opacity: 0.6;
}

.card-flip-hint svg {
  width: 14px;
  height: 14px;
}

/* Swipe animation states */
.card-container.swipe-left {
  animation: swipeLeft 0.35s var(--ease-out) forwards;
}
.card-container.swipe-right {
  animation: swipeRight 0.35s var(--ease-out) forwards;
}

@keyframes swipeLeft {
  to { transform: translateX(-120%) rotate(-8deg); opacity: 0; }
}
@keyframes swipeRight {
  to { transform: translateX(120%) rotate(8deg); opacity: 0; }
}

/* Card navigation */
.card-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
  padding: var(--space-md) var(--space-lg);
}

.btn-card-nav {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--duration-fast);
}

.btn-card-nav:hover {
  border-color: var(--accent-1);
  color: var(--text-primary);
  box-shadow: var(--shadow-glow);
}

.btn-card-nav:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.btn-card-nav svg {
  width: 22px;
  height: 22px;
}

.btn-flip {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-xl);
  border-radius: var(--radius-full);
  border: none;
  background: var(--gradient-primary);
  color: white;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-fast);
  box-shadow: var(--shadow-md);
}

.btn-flip:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.btn-flip:active {
  transform: scale(0.97);
}

.btn-flip svg {
  width: 18px;
  height: 18px;
}

/* Card rating actions */
.card-actions {
  display: flex;
  gap: var(--space-sm);
  padding: 0 var(--space-lg) var(--space-md);
  padding-bottom: calc(var(--safe-bottom) + var(--space-md));
}

.btn-action {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-fast);
}

.btn-action svg {
  width: 16px;
  height: 16px;
}

.btn-action.hard {
  color: var(--color-hard);
}
.btn-action.hard:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
}

.btn-action.good {
  color: var(--color-good);
}
.btn-action.good:hover {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.3);
}

.btn-action.easy {
  color: var(--color-easy);
}
.btn-action.easy:hover {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
}

/* ═══════════════════════════════════════════════
   MODALS
   ═══════════════════════════════════════════════ */

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  opacity: 0;
  visibility: hidden;
  transition: all var(--duration-normal);
}

.modal.visible {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  transform: translateY(20px);
  transition: transform var(--duration-normal) var(--ease-out);
}

.modal.visible .modal-content {
  transform: translateY(0);
}

.modal-content h4 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: var(--space-sm);
}

.modal-content p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: var(--space-lg);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
}

.btn-danger {
  padding: 10px 20px;
  border-radius: var(--radius-md);
  border: none;
  background: var(--color-hard);
  color: white;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-danger:hover {
  background: #dc2626;
}

.hidden {
  display: none !important;
}

/* ═══════════════════════════════════════════════
   UTILITIES & RESPONSIVENESS
   ═══════════════════════════════════════════════ */

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
  text-align: center;
  color: var(--text-tertiary);
  gap: var(--space-md);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 0.9rem;
}

/* Toast notification */
.toast {
  position: fixed;
  bottom: calc(var(--safe-bottom) + 100px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-subtle);
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: all var(--duration-normal) var(--ease-out);
  z-index: 100;
  pointer-events: none;
}

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

/* Media queries for tablet+ */
@media (min-width: 768px) {
  .upload-zone {
    max-width: 600px;
    padding: var(--space-2xl);
  }

  .topics-list {
    display: grid;
    grid-template-columns: 1fr;
    max-width: 600px;
    margin: 0 auto;
  }

  .cards-viewport {
    padding: var(--space-xl);
  }

  .card-container {
    max-width: 550px;
    min-height: 360px;
  }

  .docs-grid {
    max-width: 600px;
    margin: 0 auto;
  }
}

/* Landscape phone */
@media (max-height: 500px) and (orientation: landscape) {
  .card-face {
    padding: var(--space-md);
  }

  .card-nav {
    padding: var(--space-xs) var(--space-lg);
  }

  .card-actions {
    padding: 0 var(--space-lg) var(--space-xs);
  }
}

/* ═══════════════════════════════════════
   LANGUAGE BADGE (card header)
═══════════════════════════════════════ */
.lang-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: linear-gradient(135deg, rgba(99,102,241,0.25), rgba(167,139,250,0.25));
  border: 1px solid rgba(99,102,241,0.4);
  color: #a5b4fc;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  user-select: none;
  flex-shrink: 0;
}

.lang-badge:hover {
  background: linear-gradient(135deg, rgba(99,102,241,0.4), rgba(167,139,250,0.4));
  transform: scale(1.05);
}

.lang-badge.translated {
  background: linear-gradient(135deg, rgba(16,185,129,0.25), rgba(52,211,153,0.25));
  border-color: rgba(16,185,129,0.4);
  color: #6ee7b7;
}

/* ═══════════════════════════════════════
   LANGUAGE PICKER MODAL
═══════════════════════════════════════ */
.lang-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: flex-end;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.lang-modal.visible {
  display: flex;
  opacity: 1;
  pointer-events: all;
}

.lang-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.lang-modal-sheet {
  position: relative;
  width: 100%;
  max-height: 85vh;
  background: var(--bg-card, #1a1a2e);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.lang-modal.visible .lang-modal-sheet {
  transform: translateY(0);
}

.lang-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

.lang-modal-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary, #fff);
  margin: 0;
}

.lang-modal-sub {
  font-size: 0.78rem;
  color: var(--text-tertiary, rgba(255,255,255,0.4));
  padding: 10px 20px 6px;
  margin: 0;
  flex-shrink: 0;
}

.lang-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 12px 16px 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

@media (min-width: 480px) {
  .lang-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.lang-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255,255,255,0.04);
  border: 1.5px solid rgba(255,255,255,0.07);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  text-align: left;
}

.lang-option:hover {
  background: rgba(99,102,241,0.15);
  border-color: rgba(99,102,241,0.3);
  transform: scale(1.02);
}

.lang-option.active {
  background: linear-gradient(135deg, rgba(99,102,241,0.25), rgba(167,139,250,0.2));
  border-color: rgba(99,102,241,0.6);
}

.lang-option .lang-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary, #fff);
  line-height: 1.2;
}

.lang-option .lang-native {
  font-size: 0.75rem;
  color: var(--text-secondary, rgba(255,255,255,0.6));
  font-family: inherit;
}

.lang-option .lang-check {
  display: none;
  margin-left: auto;
  color: #a5b4fc;
}

.lang-option.active .lang-check {
  display: inline-block;
}

/* ═══════════════════════════════════════
   TRANSLATION SHIMMER (loading state)
═══════════════════════════════════════ */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

.translating-shimmer {
  opacity: 0.55;
  pointer-events: none;
  position: relative;
}

.translating-shimmer::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(99,102,241,0.12) 40%,
    rgba(167,139,250,0.18) 60%,
    transparent 100%
  );
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite linear;
  pointer-events: none;
}

.translating-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: #a5b4fc;
  padding: 4px 10px;
  background: rgba(99,102,241,0.12);
  border-radius: 20px;
  margin-bottom: 10px;
  animation: pulse 1.2s ease-in-out infinite;
}

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