body {
  font-family: system-ui, sans-serif;
  background: #0f172a;
  color: #e5e7eb;
  margin: 0;
}

header {
  padding: 1rem 1.5rem;
  background: #020617;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

h1 {
  font-size: 1.4rem;
  margin: 0;
  margin-bottom: 2rem;
}

.nav-bar {
  display: flex;
  gap: 0.5rem;
}

.nav-btn {
  border: none;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  background: #1f2937;
  color: #e5e7eb;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s, transform 0.1s;
}

.nav-btn:hover {
  background: #374151;
  transform: translateY(-1px);
}

.nav-btn-active {
  background: #4f46e5;
}

main {
  background: linear-gradient(180deg, #f8f9fa 0%, #e9ecef 100%);
  animation: fadeIn 0.5s ease-out;
}

.panel {
  transition: opacity 0.15s ease-out, transform 0.15s ease-out;
}

.panel-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Vocab table */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  font-size: 0.9rem;
}

thead {
  background: #020617;
}

th, td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #1f2937;
  text-align: left
}

tr:nth-child(even) {
  background: #020617;
}

tr:nth-child(odd) {
  background: #020617;
}

tr:hover {
  background: #111827;
}

#cardsGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.card-item {
  background: #020617;
  border-radius: 0.75rem;
  padding: 0.75rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

.card-item img {
  width: 100%;
  border-radius: 0.5rem;
  margin-bottom: 0.5rem;
}

.pill {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: #1f2937;
  font-size: 0.75rem;
  color: #a5b4fc;
}

input, button {
  font-family: inherit;
}

input {
  background: #020617;
  border: 1px solid #374151;
  border-radius: 0.375rem;
  padding: 0.4rem 0.6rem;
  color: #e5e7eb;
}

input:focus {
  outline: none;
  border-color: #4f46e5;
  box-shadow: 0 0 0 1px #4f46e5;
}

.small-btn {
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  margin: 0 0.1rem;
  border-radius: 0.25rem;
  border: 1px solid #374151;
  background: #111827;
  color: #e5e7eb;
  cursor: pointer;
}

.small-btn:hover {
  background: #1f2937;
}

.sorting-area {
  display: flex; flex-direction: column; align-items: center; padding: 20px;
}

.verb-card {
  width: 220px; height: 100px; margin: 20px 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: 3px solid #333; border-radius: 15px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: bold; color: white;
  cursor: grab; user-select: none; box-shadow: 0 8px 20px rgba(0,0,0,0.3);
  transition: all 0.3s ease;
}

.verb-card:active { cursor: grabbing; transform: scale(1.05); }

.categories-container {
  display: flex; flex-wrap: wrap; gap: 15px; justify-content: center; margin: 30px 0;
}

.category-box {
  width: 200px; height: 80px; padding: 10px;
  border: 3px dashed #665; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-weight: bold; font-size: 16px; color: #333;
  cursor: pointer; background: #f8f9fa; transition: all 0.3s;
}

.category-box:hover {
  background: #e9ecef; border-style: solid; transform: translateY(-2px);
}

.category-box.correct {
  border-color: #28a745; background: #d4edda;
  animation: pulse-green 0.6s ease-out;
}

.category-box.wrong {
  border-color: #dc3545; background: #f8d7da;
  animation: shake 0.5s ease-out;
}

.feedback {
  min-height: 40px; font-size: 18px; font-weight: bold; margin: 20px 0;
  text-align: center; padding: 10px; border-radius: 8px;
}

@keyframes pulse-green {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.next-btn {
  display: block;
  margin: 20px auto !important;   /* Centers horizontally */
  padding: 12px 30px;
  font-size: 16px;
  font-weight: bold;
  background: #007bff;
  color: white;
  border: none;
  border-radius: 25px;
  cursor: pointer;
  transition: all 0.3s;
}

.next-btn:hover {
  background: #0056b3;
  transform: translateY(-2px);
}

/* Multiple Choice: Exact Sorting Quiz Style Match (Dark Theme Optimized) */
.quiz-option-btn {
  width: 200px; height: 80px; padding: 10px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); /* .verb-card gradient */
  border: 3px dashed #a5b4fc; /* Theme dashed like #665 but lighter */
  border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: bold; font-size: 16px; color: #e5e7eb; /* Theme text */
  cursor: grab; user-select: none;
  box-shadow: 0 8px 20px rgba(0,0,0,0.5); /* Enhanced for dark bg */
  transition: all 0.3s ease; /* Matches sorting */
}

.quiz-option-btn:hover {
  background: #1f2937; /* Theme hover like .category-box but dark */
  border-style: solid; border-color: #4f46e5;
  transform: translateY(-2px);
}

.quiz-option-btn.correct {
  border-color: #10b981; background: #020617; /* Green success, theme bg */
  color: #34d399; animation: pulse-green 0.6s ease-out;
}

.quiz-option-btn.wrong {
  border-color: #ef4444; background: #020617; /* Red error, theme bg */
  color: #f87171; animation: shake 0.5s ease-out;
}

#quizFeedback {
  min-height: 40px; font-size: 18px; font-weight: bold; margin: 20px 0;
  text-align: center; padding: 15px; border-radius: 8px;
  background: rgba(31, 41, 55, 0.8); /* Dark theme prominent box */
  border: 1px solid #374151; box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  color: #f3f4f6;
}

#quizOptions {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  justify-content: center;
  margin: 30px 0;
  padding: 20px;
}

/* Container safety */
#quizOptions > * {
  flex-shrink: 0;
}

/* Latin word: Centered, prominent */
.quiz-latin {
    text-align: center;
    font-size: 2.8rem;  /* Slightly larger */
    font-weight: bold;
    margin: 1rem auto 1.5rem;
    color: #fef3c7;  /* Cream text for orange bg */
    display: flex;
    align-items: center;
    justify-content: center;

    /* Orange gradient container */
    background: linear-gradient(135deg, #f97316 0%, #ea580c 50%, #c2410c 100%);
    border: 3px solid #dc2626;  /* Red accent border */
    border-radius: 16px;
    padding: 1.5rem 2rem;
    box-shadow: 0 12px 30px rgba(249, 115, 22, 0.4),  /* Orange glow */
                inset 0 2px 4px rgba(255,255,255,0.2); /* Inner shine */
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    max-width: 300px;
}

.sortable {
  cursor: pointer;
  user-select: none;
}
.sort-arrow {
  font-size: 0.8em;
  transition: transform 0.2s;
}
.sort-asc .sort-arrow { transform: rotate(-180deg); } /* ↑ */
.sort-desc .sort-arrow { } /* ▽ default */
.sort-asc, .sort-desc { font-weight: bold; }


.filter-sidebar {
  float: right;
  width: 150px;
  margin-left: 20px;
  padding: 1rem;
  background: #020617;
  border-radius: 8px;
  border: 1px solid #1f2937;
}
.filter-sidebar h3 { margin-top: 0; font-size: 1rem; }
.filter-sidebar label { display: block; cursor: pointer; margin: 0.5rem 0; }
.filter-sidebar input[type="checkbox"] { margin-right: 0.5rem; }
.vocab-container { overflow: hidden; } /* Clear float */

.trans-btn {
  display: block;
  width: 100%;
  margin: 0.5rem 0;
  padding: 0.75rem;
  background: #1f2937;
  color: #e5e7eb;
  border: 1px solid #374151;
  border-radius: 0.5rem;
  cursor: pointer;
}
.trans-btn:hover { background: #374151; }

/* NOUN ONLY: Large boxes, exact 2 rows (4+3) */
#nounsQuizArea #nounCategories {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 15px !important;
  justify-content: center !important;
  max-width: 1100px !important;  /* Wider container */
}

#nounsQuizArea .category-box {
  flex: 0 0 220px !important;    /* Larger: fits 4/row */
  min-height: 85px !important;   /* Taller boxes */
  max-width: 240px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-sizing: border-box !important;
  font-size: 1.1em !important;   /* Readable text */
}

.vocab-controls {
  display: flex;
  justify-content: space-between;  /* Form links, Rest rechts */
  align-items: flex-end;
  position: relative;
}

.filter-sidebar {
  display: flex;
  margin-left: auto !important;  /* Schiebt Box maximal rechts */
  margin-right: 0 !important;
  gap: 8px;  /* Enger Abstand */
  background: #1e1b4b !important;  /* Dunkleres Indigo-Blau */
  color: white;  /* Kontrast-Text */
  padding: 14px 24px !important;  /* Extra breit */
  border-radius: 10px;
  min-width: 360px;  /* "Adjectives" + Gap passt locker */
  box-shadow: 0 4px 12px rgba(30,27,75,0.3);  /* Subtiler Glow */
  flex-shrink: 0;
}

.filter-sidebar label {
  margin: 0;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.filter-sidebar input[type="radio"]:checked + span {
  text-decoration: underline;
}

/* ==================== AUTH MODAL ==================== */
#authModal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 9999;
  backdrop-filter: blur(5px);
}

#authModal > div {
  background: white;
  margin: 100px auto;
  width: 90%;
  max-width: 400px;
  padding: 40px;
  border-radius: 15px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from { transform: translateY(-50px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

#authTitle {
  text-align: center;
  margin-bottom: 20px;
  color: #333;
  font-size: 24px;
}

#username, #password {
  width: 100%;
  padding: 15px;
  margin: 10px 0;
  box-sizing: border-box;
  border: 2px solid #ddd;
  border-radius: 8px;
  font-size: 16px;
  transition: border-color 0.3s;
}

#username:focus, #password:focus {
  outline: none;
  border-color: #007bff;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

#authSubmit, #toggleAuth {
  width: 100%;
  padding: 15px;
  margin: 10px 0;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s;
}

#authSubmit {
  background: #007bff;
  color: white;
}

#authSubmit:hover {
  background: #0056b3;
  transform: translateY(-1px);
}

#toggleAuth {
  background: #6c757d;
  color: white;
}

#toggleAuth:hover {
  background: #545b62;
  transform: translateY(-1px);
}

/* User Status & Buttons */
#userStatus {
  position: fixed;
  top: 15px;
  right: 15px;
  z-index: 10000;
  padding: 12px 20px;
  background: #f8f9fa;
  border-radius: 25px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border: 2px solid #e9ecef;
  transition: all 0.3s;
}

#userStatus.logged-in {
  background: #d4edda !important;  /* Light green */
  color: #155724 !important;       /* Dark green text */
  border: 2px solid #28a745;
}

#userStatus.guest {
  background: #f8d7da !important;  /* Light red */
  color: #721c24 !important;       /* Dark red text */
  border: 2px solid #dc3545;
}

#userStatus:hover {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

#loginBtn {
  position: fixed;
  top: 15px;
  left: 15px;
  z-index: 10000;
  padding: 12px 20px;
  background: linear-gradient(135deg, #28a745, #20c997);
  color: white;
  border: none;
  border-radius: 25px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
  transition: all 0.3s;
}

#loginBtn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(40, 167, 69, 0.5);
}

/* Responsive */
@media (max-width: 768px) {
  #authModal > div {
    margin: 50px 20px;
    padding: 30px 20px;
  }

  #userStatus, #loginBtn {
    top: 10px;
    padding: 10px 15px;
    font-size: 14px;
  }
}

.nav-section {
  background: white;
  border-radius: 20px;
  padding: 30px;
  margin-bottom: 40px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.nav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

/* Fade Animation */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Responsive */
@media (max-width: 768px) {
  #topBar h1 { font-size: 20px; }
  .nav-grid { grid-template-columns: 1fr; }
}

.result-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 16px;
    margin: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    padding: 16px 0;
}

.import-btn {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    width: 100%;
    margin-top: 12px;
    transition: all 0.2s;
}

.import-btn:hover {
    background: #2563eb;
    transform: translateY(-1px);
}

.loading, .error, .no-results {
    text-align: center;
    padding: 40px;
    font-size: 1.1em;
}

.loading { color: #64748b; }
.error { color: #dc2626; }
.no-results { color: #64748b; }