/* ==========================================================================
   1. BASE STYLES & LAYOUT
   ========================================================================== */
   * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  }
  
  body {
    background-color: #f4f6f9;
    color: #333;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
  }
  
  .container-wrapper {
    width: 100%;
    max-width: 860px;
    display: flex;
    flex-direction: column;
    gap: 20px;
  }
  
  .app-window {
    width: 100%;
    background: #ffffff;
    border: 1px solid #ccc;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    overflow: hidden;
  }
  
  /* ==========================================================================
     2. NAVIGATION BAR
     ========================================================================== */
  .nav-bar {
    background: #2c3e50;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    padding: 10px 14px;
    gap: 10px;
  }
  
  .nav-group-left,
  .nav-group-right {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .nav-item {
    position: relative;
  }
  
  .nav-btn {
    background: none;
    border: none;
    color: #ecf0f1;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
    white-space: nowrap;
  }
  
  .nav-btn:hover,
  .nav-btn.active,
  .nav-item:hover .nav-btn {
    background: #34495e;
  }
  
  .grammar-select {
    max-width: 260px;
  }
  
  .lang-switch {
    display: flex;
    align-items: center;
  }
  
  .lang-select {
    background: #34495e;
    color: #fff;
    border: 1px solid #5d6d7e;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    outline: none;
  }
  
  .kanji-toggle-label {
    color: #ecf0f1;
    font-size: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: 500;
    background: #34495e;
    padding: 5px 10px;
    border-radius: 4px;
    border: 1px solid #5d6d7e;
    user-select: none;
    white-space: nowrap;
  }
  
  .kanji-toggle-label input[type="checkbox"] {
    cursor: pointer;
  }
  
  /* Dropdown Menu */
  .dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: #ffffff;
    min-width: 260px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
    border: 1px solid #ddd;
    border-radius: 0 0 4px 4px;
    z-index: 100;
  }
  
  .checkbox-dropdown {
    padding: 10px;
    min-width: 260px;
  }
  
  .nav-item:hover .dropdown-menu {
    display: block;
  }
  
  .dropdown-actions {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
  }
  
  .btn-action-small {
    background: #e2e8f0;
    border: none;
    padding: 4px 8px;
    font-size: 11px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    color: #334155;
  }
  
  .btn-action-small:hover {
    background: #cbd5e1;
  }
  
  .checkbox-scroll-area {
    max-height: 240px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  
  .checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    padding: 3px 5px;
    border-radius: 3px;
  }
  
  .checkbox-item:hover {
    background: #f1f5f9;
  }
  
  /* ==========================================================================
     3. MAIN DRILL AREA
     ========================================================================== */
  .main-content {
    padding: 30px 20px;
    text-align: center;
  }
  
  .prompt-text {
    display: block;
    font-size: 16px;
    color: #555;
    margin-bottom: 12px;
    font-weight: 500;
    word-break: break-word;
    overflow-wrap: anywhere;
    line-height: 1.4;
    min-height: 24px;
  }
  
  .target-word {
    font-size: 42px;
    font-weight: bold;
    color: #2c3e50;
    margin: 10px 0 5px 0;
    word-break: break-word;
  }
  
  .target-meaning {
    font-size: 15px;
    color: #7f8c8d;
    margin-bottom: 20px;
    word-break: break-word;
  }
  
  .input-group {
    margin: 20px 0;
    display: flex;
    justify-content: center;
    gap: 10px;
  }
  
  .answer-input {
    width: 65%;
    max-width: 360px;
    padding: 12px 15px;
    font-size: 18px;
    border: 2px solid #bdc3c7;
    border-radius: 4px;
    outline: none;
  }
  
  .answer-input:focus {
    border-color: #3498db;
  }
  
  .btn-submit {
    padding: 12px 24px;
    font-size: 16px;
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
  }
  
  .btn-submit:hover {
    background: #219653;
  }
  
  .feedback-area {
    min-height: 40px;
    margin-top: 15px;
    font-size: 16px;
    font-weight: 600;
    word-break: break-word;
    overflow-wrap: anywhere;
    hyphens: auto;
    line-height: 1.4;
  }
  
  .feedback-correct {
    color: #27ae60;
  }
  
  .feedback-incorrect {
    color: #c0392b;
  }
  
  /* Stats Bar */
  .stats-bar {
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: #6c757d;
  }
  
  /* ==========================================================================
     4. MINI DICTIONARY
     ========================================================================== */
  .dictionary-window {
    background: #ffffff;
    border: 1px solid #e0e6ed;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.06);
    padding: 20px;
  }
  
  .dictionary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
  }
  
  .dictionary-title-group {
    display: flex;
    align-items: center;
    gap: 10px;
  }
  
  .dictionary-title-group h3 {
    font-size: 16px;
    color: #2c3e50;
    font-weight: 600;
  }
  
  .dictionary-badge {
    background: #e2e8f0;
    color: #475569;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
  }
  
  .dictionary-controls {
    display: flex;
    align-items: center;
    gap: 10px;
  }
  
  .dict-search-input {
    padding: 6px 12px;
    font-size: 13px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    outline: none;
    width: 200px;
  }
  
  .dict-search-input:focus {
    border-color: #3498db;
  }
  
  .btn-toggle {
    background: #34495e;
    color: white;
    border: none;
    padding: 6px 14px;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
  }
  
  .btn-toggle:hover {
    background: #2c3e50;
  }
  
  .dictionary-content {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #f0f3f7;
    max-height: 480px;
    overflow-y: auto;
  }
  
  .dictionary-content.collapsed {
    display: none;
  }
  
  .lesson-section {
    margin-bottom: 22px;
  }
  
  .lesson-section-title {
    font-size: 14px;
    font-weight: 700;
    color: #1e293b;
    background: #f1f5f9;
    padding: 6px 12px;
    border-radius: 4px;
    margin-bottom: 12px;
    border-left: 4px solid #3b82f6;
  }
  
  .dict-word-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
  }
  
  .dict-word-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    word-break: break-word;
  }
  
  .dict-word-jp {
    font-size: 18px;
    font-weight: bold;
    color: #0f172a;
  }
  
  .dict-word-romaji {
    font-size: 12px;
    color: #64748b;
  }
  
  .dict-word-meaning {
    font-size: 13px;
    color: #334155;
    font-weight: 500;
  }
  
  .dict-word-tag {
    font-size: 10px;
    text-transform: uppercase;
    background: #e0f2fe;
    color: #0369a1;
    padding: 2px 6px;
    border-radius: 4px;
    width: fit-content;
    font-weight: 600;
    margin-top: 2px;
  }
  
  /* ==========================================================================
     5. MISTAKES LOG WINDOW
     ========================================================================== */
  .mistakes-window {
    background: #ffffff;
    border: 1px solid #e0e6ed;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.06);
    padding: 20px;
  }
  
  .mistakes-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #f0f3f7;
    padding-bottom: 12px;
    margin-bottom: 15px;
  }
  
  .mistakes-header h3 {
    font-size: 16px;
    color: #2c3e50;
    font-weight: 600;
  }
  
  .btn-clear {
    background: #ecf0f1;
    color: #7f8c8d;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
  }
  
  .btn-clear:hover {
    background: #e2e8f0;
    color: #c0392b;
  }
  
  .mistakes-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 350px;
    overflow-y: auto;
  }
  
  .empty-mistakes-msg {
    color: #95a5a6;
    font-size: 14px;
    text-align: center;
    padding: 15px 0;
    font-style: italic;
  }
  
  .mistake-card {
    background: #fff5f5;
    border-left: 4px solid #e74c3c;
    border-radius: 4px;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 14px;
    word-break: break-word;
    overflow-wrap: anywhere;
  }
  
  .mistake-prompt-title {
    font-weight: bold;
    color: #2c3e50;
  }
  
  .mistake-prompt-form {
    color: #7f8c8d;
    font-size: 13px;
  }
  
  .mistake-details {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin-top: 4px;
    font-size: 14px;
  }
  
  .user-ans {
    color: #c0392b;
    font-weight: 600;
    word-break: break-word;
    overflow-wrap: anywhere;
  }
  
  .correct-ans {
    color: #27ae60;
    font-weight: 600;
    word-break: break-word;
    overflow-wrap: anywhere;
  }
  
  /* ==========================================================================
     6. COMPACT MOBILE OPTIMIZATIONS
     ========================================================================== */
  @media (max-width: 640px) {
    body {
      padding: 8px 4px;
    }
  
    .container-wrapper {
      gap: 10px;
    }
  
    /* Compact Navbar for Mobile */
    .nav-bar {
      padding: 6px 8px;
      gap: 6px;
    }
  
    .nav-group-left,
    .nav-group-right {
      width: 100%;
      gap: 6px;
    }
  
    .nav-group-left {
      display: flex;
      flex-wrap: wrap;
    }
  
    .nav-item {
      flex: 1 1 auto;
    }
  
    .nav-btn {
      padding: 6px 10px;
      font-size: 12px;
      width: 100%;
      text-align: center;
    }
  
    .grammar-select,
    .lang-select {
      width: 100%;
      max-width: 100%;
      padding: 5px 8px;
      font-size: 12px;
    }
  
    .kanji-toggle-label {
      padding: 5px 8px;
      font-size: 11px;
      flex: 1;
      justify-content: center;
    }
  
    .lang-switch {
      flex: 1;
    }
  
    /* Main Quiz Body Mobile Adjustments */
    .main-content {
      padding: 16px 12px;
    }
  
    .prompt-text {
      font-size: 13px;
      line-height: 1.35;
      margin-bottom: 6px;
      min-height: 18px;
    }
  
    .target-word {
      font-size: 30px;
      margin: 8px 0 4px 0;
    }
  
    .target-meaning {
      font-size: 13px;
      margin-bottom: 14px;
    }
  
    .input-group {
      flex-direction: column;
      gap: 8px;
      margin: 14px 0;
    }
  
    .answer-input {
      width: 100%;
      max-width: 100%;
      font-size: 16px; /* Prevents WebKit auto-zoom */
      padding: 10px;
    }
  
    .btn-submit {
      width: 100%;
      padding: 10px;
      font-size: 15px;
    }
  
    .feedback-area {
      font-size: 14px;
      margin-top: 8px;
      min-height: 32px;
    }
  
    /* Stats Footer Mobile Layout */
    .stats-bar {
      display: flex;
      flex-wrap: wrap;
      justify-content: space-around;
      padding: 8px 10px;
      font-size: 11px;
      gap: 4px;
    }
  
    /* Windows and Cards Padding */
    .mistakes-window,
    .dictionary-window {
      padding: 12px;
    }
  
    .mistakes-header,
    .dictionary-header {
      flex-direction: column;
      align-items: flex-start;
      gap: 6px;
    }
  
    .dictionary-controls {
      width: 100%;
      justify-content: space-between;
    }
  
    .dict-search-input {
      flex: 1;
      width: auto;
      font-size: 12px;
    }
  
    .mistake-card {
      padding: 10px;
      font-size: 13px;
    }
  
    .mistake-details {
      flex-direction: column;
      gap: 4px;
    }
  
    .dict-word-grid {
      grid-template-columns: 1fr;
    }
  }
  /* Checkbox Dropdown Actions Fix for Mobile */
.dropdown-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid #eee;
}

.btn-action-small {
  flex: 1;
  background: #e2e8f0;
  border: none;
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  color: #334155;
  text-align: center;
}

.btn-action-small:hover {
  background: #cbd5e1;
}

@media (max-width: 640px) {
  .dropdown-menu.checkbox-dropdown {
    position: absolute;
    width: 100%;
    min-width: 240px;
    z-index: 200;
  }
}
/* ==========================================================================
   7. AUTHOR & BRANDING FOOTER STYLES
   ========================================================================== */
   .app-footer {
    text-align: center;
    background: #ffffff;
    border: 1px solid #e0e6ed;
    border-radius: 8px;
    padding: 20px;
    color: #475569;
    font-size: 13px;
    line-height: 1.6;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04);
  }
  
  .app-footer p {
    margin-bottom: 8px;
  }
  
  .app-footer p:last-child {
    margin-bottom: 0;
  }
  
  .app-footer strong {
    color: #1e293b;
  }
  
  .footer-ps {
    font-size: 13px;
    color: #64748b;
    margin-top: 6px;
  }
  
  .footer-ps a {
    color: #3b82f6;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
  }
  
  .footer-ps a:hover {
    color: #1d4ed8;
    text-decoration: underline;
  }
  
  @media (max-width: 640px) {
    .app-footer {
      padding: 14px 10px;
      font-size: 12px;
    }
  }