/*!
 * ClassPets v2.0 — Gamified Classroom Pet System
 * © 2026 ClassPets (classpets.app) — All rights reserved.
 * Unauthorized copying, modification, or distribution is strictly prohibited.
 */

/* ─── ClassPets v2 Design System ─── */

:root {
  --brand:        #7C3AED;
  --brand-hover:  #6D28D9;
  --brand-light:  #EDE9FE;
  --brand-dark:   #4C1D95;
  --amber:        #F59E0B;
  --amber-light:  #FEF3C7;
  --green:        #059669;
  --green-light:  #D1FAE5;
  --red:          #DC2626;
  --red-light:    #FEE2E2;
  --sky:          #0EA5E9;
  --bg:           #F5F3FF;
  --surface:      #FFFFFF;
  --border:       #E5E7EB;
  --border-light: #F3F4F6;
  --text:         #1E1B4B;
  --text-2:       #4B5563;
  --text-3:       #9CA3AF;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow:       0 4px 12px rgba(124,58,237,.12);
  --shadow-lg:    0 10px 30px rgba(124,58,237,.18);
  --r-sm:         6px;
  --r:            12px;
  --r-lg:         18px;
  --r-xl:         24px;

  /* level palette */
  --lv1: #9CA3AF; --lv2: #34D399; --lv3: #38BDF8;
  --lv4: #818CF8; --lv5: #C084FC; --lv6: #F472B6;
  --lv7: #FB923C; --lv8: #FBBF24;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ─── Layout ─── */

.app { display: flex; flex-direction: column; min-height: 100vh; }

/* Header */
.header {
  background: linear-gradient(135deg, #7C3AED 0%, #4F46E5 50%, #0EA5E9 100%);
  color: #fff;
  padding: 0 20px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(79,70,229,.35);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -.02em;
  white-space: nowrap;
  text-decoration: none;
  color: #fff;
}
.header-logo span { font-size: 1.4rem; }

.header-class-selector {
  flex: 0 0 auto;
  max-width: 220px;
}
.class-select-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,.18);
  border: 1.5px solid rgba(255,255,255,.3);
  color: #fff;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-size: .85rem;
  font-weight: 600;
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background .15s;
}
.class-select-btn:hover { background: rgba(255,255,255,.28); }
.class-select-btn .chevron { opacity: .7; font-size: .7rem; }

.header-spacer { flex: 1; }

.header-actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  background: rgba(255,255,255,.18);
  border: 1.5px solid rgba(255,255,255,.28);
  color: #fff;
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  transition: background .15s;
}
.icon-btn:hover { background: rgba(255,255,255,.32); }

.lang-btn {
  background: rgba(255,255,255,.18);
  border: 1.5px solid rgba(255,255,255,.28);
  color: #fff;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
  font-size: .8rem;
  font-weight: 600;
  display: flex; align-items: center; gap: 4px;
  transition: background .15s;
}
.lang-btn:hover { background: rgba(255,255,255,.32); }

/* Tab bar */
.tabbar {
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  display: flex;
  padding: 0 20px;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabbar::-webkit-scrollbar { display: none; }

.tab-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 12px 16px;
  border: none; background: none;
  color: var(--text-2);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2.5px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.tab-btn:hover { color: var(--brand); }
.tab-btn.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab-btn .tab-icon { font-size: 1rem; }

/* Main content */
.main { flex: 1; padding: 24px 20px; max-width: 1400px; margin: 0 auto; width: 100%; }

/* ─── Empty States ─── */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 80px 20px; text-align: center; color: var(--text-3);
}
.empty-state .empty-icon { font-size: 3.5rem; }
.empty-state h3 { font-size: 1.1rem; font-weight: 700; color: var(--text-2); }
.empty-state p { font-size: .9rem; max-width: 300px; line-height: 1.5; }

/* ─── Student Grid ─── */
.view-toolbar {
  display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap;
}
.search-box {
  flex: 1; min-width: 180px; max-width: 300px;
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 999px; padding: 7px 14px;
}
.search-box input {
  border: none; background: none; outline: none;
  font-size: .875rem; color: var(--text); width: 100%;
}
.search-box input::placeholder { color: var(--text-3); }
.search-icon { color: var(--text-3); font-size: .9rem; }

.sort-select {
  border: 1.5px solid var(--border); border-radius: 999px;
  padding: 7px 12px; font-size: .8rem; font-weight: 600;
  color: var(--text-2); background: var(--surface); cursor: pointer; outline: none;
}

.student-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(172px, 1fr));
  gap: 16px;
}

/* Student Card */
.student-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 16px 12px 12px;
  box-shadow: var(--shadow-sm);
  border: 2px solid transparent;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  position: relative;
  cursor: pointer;
  transition: transform .18s, box-shadow .18s, border-color .18s;
}
.student-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.student-card.selected { border-color: var(--brand); background: var(--brand-light); }

.card-level-badge {
  position: absolute; top: 10px; left: 10px;
  font-size: .7rem; font-weight: 800;
  padding: 2px 7px; border-radius: 999px; color: #fff;
  letter-spacing: .02em;
}

.card-menu-btn {
  position: absolute; top: 8px; right: 8px;
  background: none; border: none; cursor: pointer;
  color: var(--text-3); font-size: 1.1rem; padding: 2px 4px;
  border-radius: 4px; opacity: 0; transition: opacity .15s;
}
.student-card:hover .card-menu-btn { opacity: 1; }
.card-menu-btn:hover { color: var(--text); background: var(--border-light); }

.pet-img-wrap {
  width: 90px; height: 90px;
  border-radius: 50%;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  border: 3px solid var(--border);
  position: relative;
}
.pet-img-wrap img { width: 100%; height: 100%; object-fit: contain; }
.max-level-glow { border-color: var(--amber); box-shadow: 0 0 12px rgba(245,158,11,.4); }

.card-name {
  font-size: .95rem; font-weight: 700; color: var(--text);
  text-align: center; max-width: 100%; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; width: 100%;
}
.card-number { font-size: .75rem; color: var(--text-3); }

.xp-bar-wrap { width: 100%; }
.xp-bar-track {
  height: 5px; background: var(--border); border-radius: 999px; overflow: hidden;
}
.xp-bar-fill {
  height: 100%; border-radius: 999px;
  transition: width .4s ease;
}

.card-points {
  font-size: 1rem; font-weight: 800; color: var(--amber);
  display: flex; align-items: center; gap: 4px;
}
.card-points .pt-label { font-size: .7rem; font-weight: 600; color: var(--text-3); }

.card-actions {
  display: flex; gap: 6px; width: 100%;
}
.card-action-btn {
  flex: 1; padding: 7px 4px;
  border-radius: var(--r-sm); border: none; cursor: pointer;
  font-size: .78rem; font-weight: 700;
  transition: transform .12s, filter .12s;
}
.card-action-btn:active { transform: scale(.96); }
.btn-add  { background: var(--green-light); color: var(--green); }
.btn-add:hover  { filter: brightness(.94); }
.btn-deduct { background: var(--red-light); color: var(--red); }
.btn-deduct:hover { filter: brightness(.94); }

/* Add student card */
.add-student-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  border: 2px dashed var(--border);
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 8px;
  padding: 40px 12px;
  cursor: pointer; color: var(--text-3);
  transition: border-color .15s, color .15s, background .15s;
  min-height: 260px;
}
.add-student-card:hover {
  border-color: var(--brand); color: var(--brand); background: var(--brand-light);
}
.add-student-card .add-icon { font-size: 2rem; }
.add-student-card span { font-size: .85rem; font-weight: 600; }

/* Batch bar */
.batch-bar {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--brand); color: #fff;
  padding: 12px 20px; border-radius: 999px;
  display: flex; align-items: center; gap: 14px;
  box-shadow: var(--shadow-lg); z-index: 200;
  font-size: .875rem; font-weight: 600;
  animation: slideUp .2s ease;
}
.batch-action-btn {
  background: rgba(255,255,255,.22); border: none;
  color: #fff; padding: 6px 14px; border-radius: 999px;
  cursor: pointer; font-weight: 700; font-size: .8rem;
  transition: background .15s;
}
.batch-action-btn:hover { background: rgba(255,255,255,.36); }

/* ─── Honor Roll ─── */
.honor-table {
  background: var(--surface); border-radius: var(--r-lg);
  overflow: hidden; box-shadow: var(--shadow-sm);
}
.honor-table table { width: 100%; border-collapse: collapse; }
.honor-table th {
  background: var(--brand-light); color: var(--brand);
  font-size: .8rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; padding: 12px 16px; text-align: left;
}
.honor-table td { padding: 12px 16px; border-top: 1px solid var(--border); }
.honor-table tr:hover td { background: var(--bg); }
.rank-badge {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 800;
}
.rank-1 { background: #FEF3C7; color: #D97706; }
.rank-2 { background: #F1F5F9; color: #64748B; }
.rank-3 { background: #FEF0E7; color: #C2410C; }

.honor-pet-thumb {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--bg); object-fit: contain;
  border: 2px solid var(--border);
}

.badge-list { display: flex; gap: 4px; flex-wrap: wrap; }
.badge-chip {
  display: flex; align-items: center; gap: 3px;
  background: var(--amber-light); color: #92400E;
  padding: 2px 7px; border-radius: 999px; font-size: .72rem; font-weight: 700;
}

/* ─── Shop ─── */
.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.shop-card {
  background: var(--surface); border-radius: var(--r-lg);
  padding: 20px; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 10px;
  border: 2px solid transparent;
  transition: border-color .15s, box-shadow .15s;
}
.shop-card:hover { border-color: var(--amber); box-shadow: var(--shadow); }
.shop-icon { font-size: 2.2rem; }
.shop-name { font-size: 1rem; font-weight: 700; }
.shop-desc { font-size: .83rem; color: var(--text-2); line-height: 1.45; flex: 1; }
.shop-footer { display: flex; align-items: center; justify-content: space-between; }
.shop-price {
  display: flex; align-items: center; gap: 4px;
  font-size: .9rem; font-weight: 800; color: var(--amber);
}
.shop-stock { font-size: .75rem; color: var(--text-3); }

/* ─── History ─── */
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-item {
  background: var(--surface); border-radius: var(--r);
  padding: 12px 16px; display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow-sm);
}
.history-delta {
  font-size: .9rem; font-weight: 800; min-width: 52px;
  text-align: center; padding: 4px 8px; border-radius: var(--r-sm);
}
.delta-pos { background: var(--green-light); color: var(--green); }
.delta-neg { background: var(--red-light); color: var(--red); }
.history-info { flex: 1; }
.history-name { font-size: .9rem; font-weight: 700; }
.history-reason { font-size: .8rem; color: var(--text-2); }
.history-time { font-size: .75rem; color: var(--text-3); white-space: nowrap; }

/* ─── Settings ─── */
.settings-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
}
@media (max-width: 760px) { .settings-grid { grid-template-columns: 1fr; } }

.settings-card {
  background: var(--surface); border-radius: var(--r-lg);
  padding: 20px; box-shadow: var(--shadow-sm);
}
.settings-card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.settings-card-title { font-size: .95rem; font-weight: 700; }

.rule-list { display: flex; flex-direction: column; gap: 8px; }
.rule-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--r-sm);
  background: var(--bg); font-size: .85rem;
}
.rule-delta {
  font-weight: 800; min-width: 40px; text-align: center;
  padding: 2px 6px; border-radius: 4px;
}

.level-config-list { display: flex; flex-direction: column; gap: 8px; }
.level-config-item {
  display: flex; align-items: center; gap: 10px;
  font-size: .85rem;
}
.level-config-item label { min-width: 60px; font-weight: 600; }
.level-config-item input {
  border: 1.5px solid var(--border); border-radius: var(--r-sm);
  padding: 5px 10px; width: 100px; font-size: .85rem;
  outline: none;
}
.level-config-item input:focus { border-color: var(--brand); }

.data-actions { display: flex; flex-direction: column; gap: 10px; }

/* ─── Buttons ─── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: 999px;
  font-size: .875rem; font-weight: 700; cursor: pointer; border: none;
  transition: filter .15s, transform .12s;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary { background: var(--border-light); color: var(--text-2); border: 1.5px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger  { background: var(--red-light); color: var(--red); }
.btn-danger:hover  { filter: brightness(.94); }
.btn-amber   { background: var(--amber-light); color: #92400E; }
.btn-amber:hover   { filter: brightness(.94); }
.btn-sm { padding: 5px 12px; font-size: .78rem; }
.btn-full { width: 100%; }
.btn-icon { width: 34px; height: 34px; padding: 0; border-radius: 50%; }

/* ─── Modals ─── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(15,10,40,.5);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadeIn .15s ease;
}
.modal {
  background: var(--surface);
  border-radius: var(--r-xl);
  padding: 28px;
  width: 100%; max-width: 480px;
  max-height: 88vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.22);
  animation: scaleIn .18s ease;
}
.modal-lg { max-width: 680px; }
.modal-xl { max-width: 860px; }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.modal-title { font-size: 1.15rem; font-weight: 800; }
.modal-close {
  background: var(--border-light); border: none; cursor: pointer;
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; color: var(--text-2);
  transition: background .15s;
}
.modal-close:hover { background: var(--border); }

.modal-footer {
  display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ─── Forms ─── */
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.form-label { font-size: .8rem; font-weight: 700; color: var(--text-2); }
.form-input, .form-select, .form-textarea {
  border: 1.5px solid var(--border); border-radius: var(--r-sm);
  padding: 9px 12px; font-size: .9rem; color: var(--text);
  background: var(--surface); outline: none; width: 100%;
  transition: border-color .15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--brand); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: .75rem; color: var(--text-3); }

/* ─── Points modal ─── */
.points-mode-toggle {
  display: flex; gap: 8px; margin-bottom: 16px;
}
.mode-btn {
  flex: 1; padding: 10px; border-radius: var(--r);
  border: 2px solid var(--border); background: var(--bg);
  cursor: pointer; font-weight: 700; font-size: .9rem;
  transition: all .15s;
}
.mode-btn.mode-add.active  { border-color: var(--green); background: var(--green-light); color: var(--green); }
.mode-btn.mode-ded.active  { border-color: var(--red);   background: var(--red-light);   color: var(--red);   }

.rules-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  max-height: 280px; overflow-y: auto; margin-bottom: 14px;
}
.rule-tile {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: var(--r);
  border: 1.5px solid var(--border); background: var(--bg);
  cursor: pointer; font-size: .85rem; font-weight: 600;
  transition: border-color .15s, background .15s;
}
.rule-tile:hover { border-color: var(--brand); background: var(--brand-light); }
.rule-tile.selected-add  { border-color: var(--green); background: var(--green-light); }
.rule-tile.selected-ded  { border-color: var(--red);   background: var(--red-light);   }
.rule-tile-pts { margin-left: auto; font-weight: 800; }

.custom-pts-row {
  display: flex; gap: 8px; align-items: flex-end;
}
.custom-pts-row .form-group { flex: 1; margin: 0; }

/* ─── Pet select modal ─── */
.pet-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 10px; max-height: 400px; overflow-y: auto;
}
.pet-option {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 8px 4px; border-radius: var(--r);
  border: 2px solid var(--border); background: var(--bg);
  cursor: pointer; text-align: center;
  transition: border-color .15s, background .15s;
}
.pet-option:hover { border-color: var(--brand); background: var(--brand-light); }
.pet-option.selected { border-color: var(--brand); background: var(--brand-light); }
.pet-option img { width: 56px; height: 56px; object-fit: contain; }
.pet-option-name { font-size: .65rem; font-weight: 600; color: var(--text-2); line-height: 1.2; }

/* ─── Class dropdown ─── */
.dropdown {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 300;
  background: var(--surface); border-radius: var(--r);
  box-shadow: var(--shadow-lg); border: 1px solid var(--border);
  min-width: 220px; overflow: hidden;
  animation: scaleIn .15s ease;
}
.dropdown-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; cursor: pointer; font-size: .875rem; font-weight: 600;
  transition: background .12s;
}
.dropdown-item:hover { background: var(--bg); }
.dropdown-item.active { color: var(--brand); background: var(--brand-light); }
.dropdown-divider { border-top: 1px solid var(--border); margin: 4px 0; }
.dropdown-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}

/* ─── Toast ─── */
.toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%);
  z-index: 1000; padding: 12px 22px; border-radius: 999px;
  font-size: .875rem; font-weight: 700;
  box-shadow: var(--shadow-lg);
  animation: slideUp .2s ease;
  pointer-events: none;
}
.toast-success { background: #059669; color: #fff; }
.toast-error   { background: #DC2626; color: #fff; }
.toast-info    { background: var(--brand); color: #fff; }

/* ─── Level-up overlay ─── */
.levelup-overlay {
  position: fixed; inset: 0; z-index: 900;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.levelup-card {
  background: var(--surface); border-radius: var(--r-xl);
  padding: 40px; text-align: center;
  box-shadow: 0 20px 60px rgba(124,58,237,.3);
  animation: popIn .35s cubic-bezier(.34,1.56,.64,1);
}
.levelup-card img { width: 120px; height: 120px; object-fit: contain; margin-bottom: 12px; }
.levelup-card h2 { font-size: 1.6rem; font-weight: 900; color: var(--brand); }
.levelup-card p  { color: var(--text-2); margin-top: 4px; }

/* ─── Misc ─── */
.color-dot {
  width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0;
}
.relative { position: relative; }

.tag {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 999px;
  font-size: .72rem; font-weight: 700;
}

.privacy-bar {
  background: var(--green-light); color: var(--green);
  text-align: center; font-size: .78rem; font-weight: 600; padding: 6px;
}

/* ─── Animations ─── */
@keyframes fadeIn  { from { opacity: 0 } to { opacity: 1 } }
@keyframes scaleIn { from { opacity:0; transform:scale(.93) } to { opacity:1; transform:scale(1) } }
@keyframes slideUp { from { opacity:0; transform:translateX(-50%) translateY(12px) } to { opacity:1; transform:translateX(-50%) translateY(0) } }
@keyframes popIn   { from { opacity:0; transform:scale(.7) } to { opacity:1; transform:scale(1) } }

.fade-enter-active, .fade-leave-active { transition: opacity .15s; }
.fade-enter-from, .fade-leave-to { opacity: 0; }

/* ─── Responsive ─── */
/* ════════════════════════════════════════════════════
   ClassPets v2 — App Component Classes (app.js layer)
   ════════════════════════════════════════════════════ */

/* ── Layout shell ── */
.app-wrap { display: flex; flex-direction: column; min-height: 100vh; }
.rtl { direction: rtl; }

/* ── App Header ── */
.app-header {
  background: linear-gradient(135deg, #7C3AED 0%, #4F46E5 50%, #0EA5E9 100%);
  color: #fff;
  padding: 0 20px;
  height: 60px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 12px rgba(79,70,229,.35);
  gap: 12px;
}
.header-brand { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.header-paw   { font-size: 1.4rem; }
.header-name  { font-size: 1.15rem; font-weight: 900; letter-spacing: -.02em; }
.header-controls { display: flex; align-items: center; gap: 8px; }

.class-btn {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.18); border: 1.5px solid rgba(255,255,255,.3);
  color: #fff; padding: 6px 12px; border-radius: 999px;
  cursor: pointer; font-size: .85rem; font-weight: 700;
  white-space: nowrap; max-width: 200px; overflow: hidden; text-overflow: ellipsis;
  transition: background .15s;
}
.class-btn:hover { background: rgba(255,255,255,.28); }
.class-btn .chevron { opacity: .7; font-size: .7rem; }

.class-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; display: inline-block;
}

.dropdown-menu {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 400;
  background: var(--surface); border-radius: var(--r);
  box-shadow: 0 8px 32px rgba(0,0,0,.16); border: 1px solid var(--border);
  min-width: 200px; overflow: hidden;
  animation: scaleIn .15s ease;
  /* Prevent inheriting white text from the gradient header */
  color: var(--text);
}
/* Lang picker aligns to right edge so it never overflows the viewport */
.lang-selector .dropdown-menu {
  left: auto; right: 0;
}
.add-item { color: var(--brand); font-weight: 700; }
.dropdown-item { color: var(--text); }

/* ── Tab bar ── */
.tab-bar {
  background: var(--surface); border-bottom: 2px solid var(--border);
  display: flex; padding: 0 16px; gap: 2px; overflow-x: auto; scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar { display: none; }

/* ── Content ── */
.tab-content { flex: 1; overflow-y: auto; }
.tab-pane { padding: 20px; max-width: 1200px; margin: 0 auto; }

/* ── Tab toolbar ── */
.tab-toolbar {
  display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap;
}
.search-input {
  flex: 1; min-width: 120px; max-width: 240px;
  border: 1.5px solid var(--border); border-radius: 999px;
  padding: 7px 14px; font-size: .875rem; color: var(--text);
  background: var(--surface); outline: none;
  transition: border-color .15s;
}
.search-input:focus { border-color: var(--brand); }

/* ── Student card internals ── */
.card-header-row {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
}
.stu-number { font-size: .7rem; font-weight: 700; color: var(--text-3); }
.batch-check {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--border); display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 900; color: #fff;
  transition: background .15s, border-color .15s;
}
.batch-check.checked { background: var(--brand); border-color: var(--brand); }
.student-card.batch-mode { cursor: pointer; }
.card-actions { display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.student-card:hover .card-actions { opacity: 1; }

.avatar-wrap { position: relative; cursor: pointer; }
.pet-avatar {
  width: 88px; height: 88px; border-radius: 50%;
  border: 3px solid var(--border); object-fit: contain;
  background: var(--bg); display: block;
  transition: border-color .2s;
}
.avatar-wrap:hover .pet-avatar { border-color: var(--brand); }

.lv-badge {
  position: absolute; bottom: -4px; left: 50%; transform: translateX(-50%);
  font-size: .65rem; font-weight: 900; padding: 1px 8px; border-radius: 999px;
  color: #fff; white-space: nowrap; letter-spacing: .03em;
}
.lv1 { background: var(--lv1); } .lv2 { background: var(--lv2); }
.lv3 { background: var(--lv3); } .lv4 { background: var(--lv4); }
.lv5 { background: var(--lv5); } .lv6 { background: var(--lv6); }
.lv7 { background: var(--lv7); } .lv8 { background: var(--lv8); }

.stu-name {
  font-size: .9rem; font-weight: 700; color: var(--text);
  text-align: center; width: 100%; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.exp-bar-wrap { width: 100%; height: 5px; background: var(--border); border-radius: 999px; overflow: hidden; }
.exp-bar-fill { height: 100%; background: var(--brand); border-radius: 999px; transition: width .4s ease; }

.stu-footer { display: flex; align-items: center; justify-content: space-between; width: 100%; }
.pts-display { font-size: .9rem; font-weight: 800; }
.pts-display.pos { color: var(--green); }
.pts-display.neg { color: var(--red); }
.btn-star {
  background: var(--amber-light); border: none; cursor: pointer;
  width: 28px; height: 28px; border-radius: 50%; font-size: .9rem;
  display: flex; align-items: center; justify-content: center;
  transition: transform .12s;
}
.btn-star:hover { transform: scale(1.15); }

.add-stu-card {
  background: var(--surface); border-radius: var(--r-lg);
  border: 2px dashed var(--border);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 40px 12px; cursor: pointer; color: var(--text-3);
  min-height: 240px; transition: all .15s;
}
.add-stu-card:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-light); }
.add-plus { font-size: 2rem; font-weight: 300; }

/* ── Section headings ── */
.section-heading {
  font-size: .85rem; font-weight: 800; color: var(--text-2);
  text-transform: uppercase; letter-spacing: .06em; margin: 20px 0 10px;
}

/* ── Points tab — mini student grid ── */
.student-mini-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px; margin-bottom: 16px;
}
.mini-card {
  background: var(--surface); border-radius: var(--r);
  border: 2px solid transparent; padding: 10px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  cursor: pointer; transition: border-color .15s, background .15s;
}
.mini-card:hover { border-color: var(--brand); }
.mini-card.selected { border-color: var(--brand); background: var(--brand-light); }
.mini-avatar { width: 52px; height: 52px; border-radius: 50%; object-fit: contain; background: var(--bg); border: 2px solid var(--border); }
.mini-name { font-size: .8rem; font-weight: 700; text-align: center; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-pts { font-size: .75rem; font-weight: 800; }
.mini-pts.pos { color: var(--green); } .mini-pts.neg { color: var(--red); }

.pts-tab-bar {
  display: flex; align-items: center; gap: 12px;
  background: var(--brand-light); border: 1.5px solid var(--brand);
  border-radius: var(--r); padding: 10px 16px; margin-top: 8px;
  flex-wrap: wrap;
}
.sel-count { font-size: .875rem; font-weight: 700; color: var(--brand); flex: 1; }

/* ── Rule tile categories ── */
.rule-tile.positive { border-color: var(--green); }
.rule-tile.positive:hover { background: var(--green-light); border-color: var(--green); }
.rule-tile.negative { border-color: var(--red); }
.rule-tile.negative:hover { background: var(--red-light); border-color: var(--red); }
.rule-tile.custom { border-color: var(--brand); }
.rule-tile.custom:hover { background: var(--brand-light); }
.rule-tile.selected { border-color: var(--amber); background: var(--amber-light); }
.rule-icon { font-size: 1.1rem; flex-shrink: 0; }
.rule-label { flex: 1; text-align: left; }
.rule-delta { font-weight: 900; margin-left: auto; white-space: nowrap; }
.rules-grid.compact { max-height: 220px; }
.rule-tile.sm { padding: 7px 10px; font-size: .8rem; }

/* ── Shop ── */
.shop-btn {
  width: 100%; margin-top: auto;
  padding: 8px; font-size: .85rem;
  border-radius: var(--r-sm);
}
.shop-price { font-size: .9rem; font-weight: 800; color: var(--amber); }

/* ── History list ── */
.hist-item {
  background: var(--surface); border-radius: var(--r);
  padding: 12px 14px; display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow-sm); font-size: .875rem;
}
.hist-icon { font-size: 1.2rem; flex-shrink: 0; }
.hist-info { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hist-who { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist-what { font-size: .8rem; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0; }
.hist-delta { font-weight: 800; font-size: .85rem; }
.hist-delta.pos { color: var(--green); }
.hist-delta.neg { color: var(--red); }
.hist-time { font-size: .72rem; color: var(--text-3); white-space: nowrap; }
.undo-btn {
  background: none; border: 1px solid var(--border); color: var(--text-3);
  width: 28px; height: 28px; border-radius: 50%; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: .9rem;
  transition: background .12s, color .12s;
}
.undo-btn:hover { background: var(--brand-light); color: var(--brand); border-color: var(--brand); }

.pagination { display: flex; align-items: center; gap: 12px; justify-content: center; padding: 16px 0; }
.page-btn { padding: 6px 14px; font-size: 1rem; }
.page-info { font-size: .85rem; font-weight: 600; color: var(--text-2); }

/* ── Honor roll ── */
.honor-wrap { overflow-x: auto; }
.honor-table {
  width: 100%; border-collapse: collapse;
  background: var(--surface); border-radius: var(--r-lg);
  overflow: hidden; box-shadow: var(--shadow-sm);
}
.honor-table th {
  background: var(--brand-light); color: var(--brand);
  font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em;
  padding: 12px 14px; text-align: left;
}
.honor-table td { padding: 11px 14px; border-top: 1px solid var(--border); }
.honor-table .rank-row:hover td { background: var(--bg); }
.honor-table .rank-row.rank-1 td { background: #FFFBEB; }
.honor-table .rank-row.rank-2 td { background: #F8FAFC; }
.honor-table .rank-row.rank-3 td { background: #FFF7F0; }
.rank-cell { text-align: center; width: 50px; }
.medal { font-size: 1.3rem; }
.rank-num { font-size: .85rem; font-weight: 700; color: var(--text-3); }
.tbl-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: contain; background: var(--bg); border: 2px solid var(--border); }
.stu-name-cell { font-weight: 700; }
.lv-chip {
  display: inline-block; font-size: .7rem; font-weight: 800; color: #fff;
  padding: 2px 8px; border-radius: 999px; letter-spacing: .03em;
}
.pts-cell { font-size: 1rem; font-weight: 800; text-align: right; }
.pts-cell.pos { color: var(--green); } .pts-cell.neg { color: var(--red); }

/* ── Settings ── */
.settings-pane { max-width: 900px; }
.settings-section {
  background: var(--surface); border-radius: var(--r-lg);
  padding: 20px; box-shadow: var(--shadow-sm); margin-bottom: 16px;
}
.settings-title { font-size: .9rem; font-weight: 800; margin-bottom: 14px; color: var(--text); }
.settings-hint { font-size: .8rem; color: var(--text-3); margin-bottom: 10px; }
.settings-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.settings-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; background: var(--bg); border-radius: var(--r-sm);
  font-size: .85rem;
}
.row-icon { font-size: 1rem; flex-shrink: 0; }
.row-label { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-badge {
  font-size: .72rem; font-weight: 800; padding: 2px 8px;
  border-radius: 999px; white-space: nowrap;
}
.row-badge.pos { background: var(--green-light); color: var(--green); }
.row-badge.neg { background: var(--red-light); color: var(--red); }
.row-badge.neutral { background: var(--border-light); color: var(--text-2); }

.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.flex-grow { flex: 1; min-width: 120px; width: auto; }
.icon-inp { width: 52px; text-align: center; }
.num-inp { width: 72px; }

.empty-sm { font-size: .85rem; color: var(--text-3); padding: 8px 0; }

.lv-config-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.lv-config-row { display: flex; align-items: center; gap: 8px; }

.lang-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.lang-chip {
  padding: 6px 14px; border-radius: 999px; font-size: .85rem; font-weight: 600;
  cursor: pointer; border: 1.5px solid var(--border); background: var(--bg);
  color: var(--text-2); transition: all .15s;
}
.lang-chip.active, .lang-chip:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-light); }

.data-actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* ── Batch bar extras ── */
.batch-left  { display: flex; align-items: center; gap: 10px; }
.batch-right { display: flex; align-items: center; gap: 8px; }
.batch-count { font-size: .875rem; font-weight: 700; }
.btn.sm { padding: 5px 12px; font-size: .78rem; }

/* ── Modal extras ── */
.modal-wide { max-width: 760px; }
.modal-sm   { max-width: 360px; }
.modal-subtitle { font-size: .875rem; color: var(--text-2); margin: -8px 0 16px; }
.modal-actions {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border);
}

/* ── Color picker ── */
.color-row { display: flex; gap: 10px; flex-wrap: wrap; }
.color-dot {
  width: 28px; height: 28px; border-radius: 50%; cursor: pointer; border: 3px solid transparent;
  transition: transform .12s, border-color .12s;
}
.color-dot:hover { transform: scale(1.15); }
.color-dot.active { border-color: var(--text); transform: scale(1.1); }

/* ── Pet preview (student form) ── */
.pet-preview {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border: 1.5px solid var(--border); border-radius: var(--r-sm);
  cursor: pointer; transition: border-color .15s;
  background: var(--bg);
}
.pet-preview:hover { border-color: var(--brand); }
.pet-preview-img { width: 44px; height: 44px; border-radius: 50%; object-fit: contain; background: var(--surface); }
.pet-preview-name { flex: 1; font-size: .85rem; font-weight: 600; color: var(--text-2); }
.pet-preview .chevron { color: var(--text-3); }

/* ── Pet picker grid ── */
.pet-picker-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px; max-height: 420px; overflow-y: auto; padding: 4px;
}
.pet-pick-item {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 8px 4px; border-radius: var(--r); border: 2px solid var(--border);
  background: var(--bg); cursor: pointer; text-align: center;
  transition: border-color .15s, background .15s;
}
.pet-pick-item img { width: 52px; height: 52px; object-fit: contain; }
.pet-pick-item span { font-size: .6rem; font-weight: 600; color: var(--text-2); line-height: 1.2; word-break: break-all; }
.pet-pick-item:hover { border-color: var(--brand); background: var(--brand-light); }
.pet-pick-item.active { border-color: var(--brand); background: var(--brand-light); }

/* ── Points modal ── */
.target-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.target-chip {
  background: var(--brand-light); color: var(--brand);
  padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700;
}
.sub-heading { font-size: .8rem; font-weight: 700; color: var(--text-2); margin-bottom: 8px; }

/* ── Shop redeem — student list ── */
.stu-select-list { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; margin-bottom: 8px; }
.stu-select-row {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: var(--r-sm);
  border: 1.5px solid transparent; background: var(--bg);
  cursor: pointer; transition: border-color .15s, background .15s;
}
.stu-select-row:hover { border-color: var(--amber); background: var(--amber-light); }
.stu-select-row.active { border-color: var(--amber); background: var(--amber-light); }
.stu-select-row.weak { opacity: .5; cursor: not-allowed; }
.stu-select-row .stu-name { flex: 1; font-size: .875rem; font-weight: 700; }
.pts-chip { font-size: .75rem; font-weight: 800; padding: 2px 8px; border-radius: 999px; }
.pts-chip.ok  { background: var(--green-light); color: var(--green); }
.pts-chip.low { background: var(--red-light); color: var(--red); }

/* ── Toast — visibility toggle ── */
.toast {
  background: var(--brand); color: #fff;
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  transform: translateX(-50%) translateY(8px);
}
.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Level-up overlay ── */
.lvup-overlay {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(15,10,40,.6); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; animation: fadeIn .2s ease;
}
.lvup-card {
  background: var(--surface); border-radius: var(--r-xl);
  padding: 40px; text-align: center; max-width: 320px; width: 90%;
  box-shadow: 0 20px 60px rgba(124,58,237,.35);
  animation: popIn .35s cubic-bezier(.34,1.56,.64,1);
}
.lvup-sparks { font-size: 2rem; margin-bottom: 4px; }
.lvup-title { font-size: 1.7rem; font-weight: 900; color: var(--brand); margin-bottom: 16px; }
.lvup-avatar { width: 120px; height: 120px; object-fit: contain; margin-bottom: 16px; }
.lvup-info { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.lvup-name { font-size: 1.1rem; font-weight: 700; }
.lvup-lv { font-size: .9rem; padding: 4px 14px; }

/* ── icon-btn override (non-header context) ── */
.student-card .icon-btn,
.settings-row .icon-btn,
.hist-item .icon-btn {
  background: none; border: 1px solid var(--border); color: var(--text-3);
  width: 26px; height: 26px; border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: .75rem;
  transition: background .12s, color .12s, border-color .12s;
}
.student-card .icon-btn:hover,
.settings-row .icon-btn:hover { background: var(--brand-light); color: var(--brand); border-color: var(--brand); }
.settings-row .icon-btn:last-child:hover { background: var(--red-light); color: var(--red); border-color: var(--red); }

/* ── btn:disabled ── */
.btn:disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }

/* ════ Original responsive breakpoint ════ */
@media (max-width: 600px) {
  .student-grid { grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); gap: 10px; }
  .rules-grid { grid-template-columns: 1fr; }
  .main { padding: 16px 12px; }
  .header { padding: 0 12px; }
  .modal { padding: 20px 16px; border-radius: var(--r-lg); }
  .tab-btn { padding: 10px 10px; font-size: .78rem; }
}

/* ── Rule category filter tabs ── */
.rule-cat-tabs {
  display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap;
}
.rule-cat-btn {
  padding: 5px 14px; border-radius: 20px; border: 1.5px solid var(--border);
  background: transparent; color: var(--text-2); font-size: .82rem; font-weight: 600;
  cursor: pointer; transition: all .15s ease;
}
.rule-cat-btn:hover { border-color: var(--brand); color: var(--brand); }
.rule-cat-btn.active {
  background: var(--brand); border-color: var(--brand); color: #fff;
}

/* ── Footer ── */
.app-footer {
  text-align: center;
  padding: 16px;
  font-size: .75rem;
  color: var(--text-3);
  border-top: 1px solid var(--border);
  margin-top: auto;
}
.app-footer a {
  color: var(--text-3);
  text-decoration: none;
}
.app-footer a:hover {
  color: var(--brand);
  text-decoration: underline;
}

/* ── Desktop Download Section ── */
.download-section { border: 2px solid var(--brand-light); border-radius: var(--r-lg); }
.download-desc {
  font-size: .875rem; color: var(--text-2); margin-bottom: 16px; line-height: 1.5;
}
.download-btns {
  display: flex; flex-wrap: wrap; gap: 10px;
}
.btn-download {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--r);
  text-decoration: none; font-weight: 700; font-size: .875rem;
  border: 2px solid transparent; transition: transform .15s, box-shadow .15s;
}
.btn-download:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.btn-download.mac  { background: #1d1d1f; color: #fff; border-color: #1d1d1f; }
.btn-download.win  { background: #0078d4; color: #fff; border-color: #0078d4; }
.btn-download.linux{ background: #f7931e; color: #fff; border-color: #f7931e; }
.btn-download .dl-icon { font-size: 1.1rem; }
.btn-download .dl-ext {
  font-size: .72rem; opacity: .75; font-weight: 500;
  background: rgba(255,255,255,.2); padding: 1px 6px;
  border-radius: 4px; margin-left: 2px;
}
