:root {
  --bg-primary: #f8fafc;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --bg-card-back: #f1f5f9;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-sub: #475569;
  --border-color: #e2e8f0;
  --border-card: #cbd5e1;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  --accent: #06b6d4;
  --accent-light: #ecfeff;
  --success: #10b981;
  --success-light: #ecfdf5;
  --success-hover: #059669;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --danger-hover: #dc2626;
  --card-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
  --card-shadow-hover: 0 25px 30px -5px rgba(79, 70, 229, 0.15), 0 12px 15px -6px rgba(79, 70, 229, 0.1);
  --radius-lg: 1.25rem;
  --radius-md: 0.75rem;
  --radius-sm: 0.5rem;
}

[data-theme="dark"] {
  --bg-primary: #090d16;
  --bg-surface: #111827;
  --bg-card: #151e32;
  --bg-card-back: #1a253d;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-sub: #cbd5e1;
  --border-color: #1e293b;
  --border-card: #334155;
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --primary-light: #1e1b4b;
  --accent: #22d3ee;
  --accent-light: #083344;
  --success: #34d399;
  --success-light: #064e3b;
  --success-hover: #10b981;
  --danger: #f87171;
  --danger-light: #450a0a;
  --danger-hover: #ef4444;
  --card-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
  --card-shadow-hover: 0 25px 35px -5px rgba(99, 102, 241, 0.25), 0 12px 20px -6px rgba(99, 102, 241, 0.15);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.3s ease, color 0.3s ease;
  user-select: none;
  -webkit-user-select: none;
}

/* App Header */
.app-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 0.85rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(8px);
}

.header-container {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-badge {
  background: linear-gradient(135deg, #4f46e5, #06b6d4);
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
}

.title-wrap h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.title-wrap p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

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

/* Profile Switcher Button */
.btn-profile {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.4rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

#cloudStatusIcon {
  font-size: 0.9rem;
  transition: opacity 0.3s;
}

#cloudStatusIcon.syncing {
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.6; }
  100% { transform: scale(1); opacity: 1; }
}

/* Profile Gateway Screen */
.profile-gateway-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

.profile-card-modal {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  max-width: 580px;
  width: 100%;
  padding: 2.25rem 2rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
  text-align: center;
}

.gateway-logo {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.gateway-header h2 {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 0.4rem;
  letter-spacing: -0.02em;
}

.gateway-header p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 2rem;
  line-height: 1.5;
}

.profile-options-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.profile-option-card {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1.25rem 1.5rem;
  background: var(--bg-primary);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: left;
  transition: all 0.25s ease;
}

.profile-option-card:hover {
  border-color: var(--primary);
  transform: translateY(-3px);
  box-shadow: 0 10px 20px -5px rgba(79, 70, 229, 0.2);
}

.profile-avatar-large {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.85rem;
  flex-shrink: 0;
}

.win-avatar {
  background: linear-gradient(135deg, #eef2ff, #e0e7ff);
  border: 1px solid #c7d2fe;
}

[data-theme="dark"] .win-avatar {
  background: linear-gradient(135deg, #1e1b4b, #312e81);
  border-color: #4338ca;
}

.guest-avatar {
  background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
  border: 1px solid #cbd5e1;
}

[data-theme="dark"] .guest-avatar {
  background: linear-gradient(135deg, #1e293b, #334155);
  border-color: #475569;
}

.profile-info {
  flex: 1;
}

.profile-title-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.25rem;
}

.profile-title-row h3 {
  font-size: 1.15rem;
  font-weight: 700;
}

.lock-tag {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
}

[data-theme="dark"] .lock-tag {
  background: #450a0a;
  color: #f87171;
  border-color: #7f1d1d;
}

.free-tag {
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
}

[data-theme="dark"] .free-tag {
  background: #064e3b;
  color: #34d399;
  border-color: #065f46;
}

.profile-info p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.btn-select-profile {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.btn-select-profile:hover {
  background: var(--primary-hover);
}

.btn-select-profile.btn-guest {
  background: var(--border-card);
  color: var(--text-main);
}

.btn-select-profile.btn-guest:hover {
  background: var(--primary);
  color: white;
}

/* Inline PIN Form inside Win Card */
.win-pin-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 0.5rem 0.25rem;
  animation: fadeIn 0.2s ease;
}

.pin-form-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
}

.pin-input-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.pin-input-row input {
  font-size: 1.5rem;
  letter-spacing: 0.4rem;
  text-align: center;
  padding: 0.55rem 0.85rem;
  width: 150px;
  background: var(--bg-surface);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.pin-input-row input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.pin-error {
  color: var(--danger);
  font-size: 0.85rem;
  font-weight: 600;
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* Main Container */
.main-content {
  flex: 1;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

/* Filter and Options Bar */
.toolbar-section {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: var(--bg-surface);
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.select-custom {
  background: var(--bg-primary);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}

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

.btn-icon {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

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

.btn-pill {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.45rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-pill:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* Mastery Review Filter Tabs */
.mastery-tabs-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  background: var(--bg-surface);
  padding: 0.4rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.mastery-tab {
  background: transparent;
  border: none;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

.mastery-tab:hover {
  color: var(--text-main);
  background: var(--bg-primary);
}

.mastery-tab.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.3);
}

.mastery-tab.tab-forgot.active {
  background: var(--danger);
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.3);
}

.mastery-tab.tab-remembered.active {
  background: var(--success);
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
}

.tab-count {
  background: rgba(0, 0, 0, 0.08);
  padding: 0.1rem 0.45rem;
  border-radius: 9999px;
  font-size: 0.75rem;
}

[data-theme="dark"] .tab-count {
  background: rgba(255, 255, 255, 0.15);
}

.mastery-tab.active .tab-count {
  background: rgba(255, 255, 255, 0.25);
  color: white;
}

/* Progress bar */
.progress-card {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.progress-track {
  width: 100%;
  height: 6px;
  background: var(--border-color);
  border-radius: 9999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 9999px;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Empty State */
.empty-state {
  background: var(--bg-surface);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-lg);
  padding: 3.5rem 1.5rem;
  text-align: center;
  margin: 1rem 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 0.75rem;
}

.empty-state h3 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.empty-state p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* 3D Flashcard Stage */
.card-scene {
  perspective: 1200px;
  width: 100%;
  max-width: 650px;
  min-height: 380px;
  margin: 0.25rem auto;
  position: relative;
  cursor: pointer;
}

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

.flashcard.flipped {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius-lg);
  padding: 2rem 2rem 1.6rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--card-shadow);
  border: 2px solid var(--border-card);
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

.card-scene:hover .card-face {
  box-shadow: var(--card-shadow-hover);
  border-color: var(--primary);
}

.card-front {
  background: var(--bg-card);
}

.card-back {
  background: var(--bg-card-back);
  transform: rotateY(180deg);
}

/* Card internals */
.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.unit-tag {
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pos-tag {
  background: var(--accent-light);
  color: #0891b2;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-sm);
  font-style: italic;
}

[data-theme="dark"] .pos-tag {
  color: #38bdf8;
}

/* Status Badge on Card */
.status-badge {
  font-size: 0.76rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.2s;
}

.status-badge.status-remembered {
  background: var(--success-light);
  color: var(--success);
  border: 1px solid var(--success);
}

.status-badge.status-forgot {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid var(--danger);
}

.status-badge.status-none {
  display: none;
}

.card-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 1.5rem 0;
  gap: 1rem;
}

.word-text {
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.definition-text {
  font-size: 1.35rem;
  font-weight: 500;
  line-height: 1.6;
  color: var(--text-sub);
  max-width: 92%;
}

.definition-th {
  font-size: 1.05rem;
  font-weight: 600;
  color: #0d9488;
  background: rgba(13, 148, 136, 0.08);
  border: 1px solid rgba(13, 148, 136, 0.22);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.85rem;
  margin-top: 0.5rem;
  line-height: 1.5;
  max-width: 92%;
  display: inline-block;
}

[data-theme="dark"] .definition-th {
  color: #2dd4bf;
  background: rgba(45, 212, 191, 0.12);
  border-color: rgba(45, 212, 191, 0.25);
}

.card-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  border-top: 1px dashed var(--border-color);
  padding-top: 1rem;
}

.flip-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.audio-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.audio-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: scale(1.08);
}

.audio-btn:active {
  transform: scale(0.95);
}

/* Review Action Controls (จำได้ / จำไม่ได้ / พลิก) */
.review-action-container {
  display: grid;
  grid-template-columns: 1fr 1.25fr 1fr;
  gap: 0.75rem;
  max-width: 650px;
  width: 100%;
  margin: 0.25rem auto 0;
}

.btn-review {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  position: relative;
}

.btn-forgot {
  background: var(--danger-light);
  color: var(--danger);
  border: 1.5px solid var(--danger);
}

.btn-forgot:hover {
  background: var(--danger);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(239, 68, 68, 0.3);
}

.btn-remembered {
  background: var(--success-light);
  color: var(--success);
  border: 1.5px solid var(--success);
}

.btn-remembered:hover {
  background: var(--success);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.3);
}

.shortcut-tag {
  background: rgba(0, 0, 0, 0.08);
  font-size: 0.75rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}

.btn-forgot:hover .shortcut-tag,
.btn-remembered:hover .shortcut-tag {
  background: rgba(255, 255, 255, 0.25);
  color: white;
}

.shortcut-tag-light {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  font-size: 0.75rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}

.btn-flip-main {
  background: var(--primary);
  color: white;
  border: none;
  font-size: 1rem;
  font-weight: 700;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-flip-main:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.5);
}

.btn-flip-main:active {
  transform: translateY(0);
}

/* Control Navigation Bar */
.control-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 650px;
  width: 100%;
  margin: 0 auto;
}

.btn-nav {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  transition: all 0.2s ease;
}

.btn-nav:hover:not(:disabled) {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-2px);
}

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

/* Keyboard hint footer */
.shortcut-tips {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.kbd {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-family: inherit;
  font-weight: 600;
  box-shadow: 0 1px 1px rgba(0,0,0,0.1);
  margin: 0 0.15rem;
}

/* Modal styles for Word List */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  padding: 1rem;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg-surface);
  width: 100%;
  max-width: 720px;
  max-height: 85vh;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 0.3s ease;
}

.modal-backdrop.open .modal-content {
  transform: scale(1);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-search {
  padding: 0.75rem 1.5rem 0.5rem;
}

.search-input {
  width: 100%;
  padding: 0.65rem 1rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  outline: none;
  font-size: 0.95rem;
}

.modal-filter-bar {
  padding: 0.4rem 1.5rem 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  gap: 0.5rem;
}

.modal-tabs {
  display: flex;
  gap: 0.4rem;
}

.modal-tab {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.modal-tab.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.btn-text-danger {
  background: transparent;
  border: none;
  color: var(--danger);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-sm);
}

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

.modal-body {
  padding: 1rem 1.5rem;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.word-list-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.word-list-item:hover {
  border-color: var(--primary);
  transform: translateX(4px);
}

.word-list-item.item-forgot {
  border-left: 4px solid var(--danger);
}

.word-list-item.item-remembered {
  border-left: 4px solid var(--success);
}

.item-left {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-width: 78%;
}

.item-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.item-word {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-main);
}

.item-def {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.item-def-th {
  font-size: 0.84rem;
  font-weight: 500;
  color: #0d9488;
  line-height: 1.4;
  margin-top: 0.15rem;
}

[data-theme="dark"] .item-def-th {
  color: #2dd4bf;
}

.item-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Mobile Responsive */
@media (max-width: 640px) {
  .header-container {
    flex-wrap: wrap;
  }
  .card-scene, .flashcard {
    min-height: 330px;
  }
  .card-face {
    padding: 1.6rem 1.15rem 1.15rem;
  }
  .word-text {
    font-size: 1.65rem;
  }
  .definition-text {
    font-size: 1.1rem;
  }
  .toolbar-section {
    flex-direction: column;
    align-items: stretch;
  }
  .filter-group {
    justify-content: space-between;
  }
  .review-action-container {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }
  .btn-flip-main {
    grid-column: span 2;
    order: -1;
  }
  .btn-review {
    padding: 0.75rem 0.5rem;
    font-size: 0.88rem;
  }
  .control-bar {
    gap: 0.5rem;
  }
  .btn-nav {
    padding: 0.65rem 1rem;
    font-size: 0.88rem;
  }
  .shortcut-tips {
    display: none;
  }
}
