/* ===== Ghibli + Apple 风格主题 ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ghibli-green: #5B8C5A;
  --ghibli-green-light: #7DAB7A;
  --ghibli-sky: #87CEEB;
  --ghibli-sky-light: #B0E0F0;
  --ghibli-peach: #F5CBA7;
  --ghibli-cream: #FEF9F0;
  --ghibli-forest: #2D5A2C;
  --ghibli-earth: #8B7D6B;
  --ghibli-warm: #E8D5B7;
  --apple-bg: #F5F5F7;
  --apple-text: #1D1D1F;
  --apple-text-secondary: #86868B;
  --apple-white: #FFFFFF;
  --apple-shadow: 0 2px 20px rgba(0,0,0,0.08);
  --nav-height: 56px;
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.25s ease;
}

html { font-size: 15px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  color: var(--apple-text);
  background: linear-gradient(135deg, #A8E6CF 0%, #DCEDC1 15%, #FFD3B6 30%, #FFAAA5 45%, #FF8B94 60%, #DDA0DD 78%, #87CEEB 100%);
  background-attachment: fixed;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

input, select, button, textarea { font-family: inherit; font-size: inherit; }
a { color: var(--ghibli-green); text-decoration: none; }
a:hover { color: var(--ghibli-green-light); }

/* ---- Toast ---- */
.toast {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  z-index: 9999; padding: 12px 24px; border-radius: 50px;
  font-size: 0.9rem; font-weight: 500;
  opacity: 0; transition: opacity var(--transition);
  pointer-events: none; background: #323232; color: #fff;
  box-shadow: 0 4px 24px rgba(0,0,0,0.15);
}
.toast.show { opacity: 1; }
.toast.error { background: #E74C3C; }
.toast.success { background: var(--ghibli-green); }

/* ---- Buttons ---- */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 24px; border: none; border-radius: 50px;
  background: var(--ghibli-green); color: #fff;
  font-size: 0.9rem; font-weight: 600;
  cursor: pointer; transition: all var(--transition);
  white-space: nowrap;
}
.btn-primary:hover { background: var(--ghibli-forest); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(91,140,90,0.3); }
.btn-primary:active { transform: translateY(0); }
.btn-link {
  background: none; border: none; color: var(--ghibli-green);
  cursor: pointer; font-size: 0.9rem; padding: 6px 12px;
  border-radius: var(--radius-sm); transition: background var(--transition);
}
.btn-link:hover { background: rgba(91,140,90,0.08); }
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%;
  border: none; background: var(--apple-white);
  cursor: pointer; font-size: 1.2rem; color: var(--apple-text-secondary);
  transition: all var(--transition); box-shadow: 0 1px 6px rgba(0,0,0,0.06);
}
.btn-icon:hover { box-shadow: 0 2px 12px rgba(0,0,0,0.1); color: var(--ghibli-green); }
.btn-danger {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 6px 16px; border: none; border-radius: 50px;
  background: #E74C3C; color: #fff; font-size: 0.8rem; font-weight: 500;
  cursor: pointer; transition: background var(--transition);
}
.btn-danger:hover { background: #C0392B; }
.btn-full { width: 100%; }
.hidden { display: none !important; }

/* ---- Auth Pages ---- */
.auth-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px;
  background: linear-gradient(135deg, var(--ghibli-cream) 0%, var(--ghibli-sky-light) 50%, var(--ghibli-cream) 100%);
}
.auth-card {
  width: 100%; max-width: 400px; background: rgba(255,255,255,0.5);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-radius: 20px; padding: 40px 32px; border: 1px solid rgba(255,255,255,0.7);
  box-shadow: 0 8px 40px rgba(0,0,0,0.08);
}
.auth-logo { 
  text-align: center; margin-bottom: 8px;
}
.auth-logo img { height: 80px; width: auto; }
.auth-title { font-size: 1.5rem; font-weight: 700; text-align: center; margin-bottom: 4px; color: var(--ghibli-forest); }
.auth-subtitle { text-align: center; color: var(--apple-text-secondary); font-size: 0.9rem; margin-bottom: 32px; }
.auth-form { display: flex; flex-direction: column; gap: 20px; }
.auth-switch { text-align: center; margin-top: 24px; font-size: 0.9rem; color: var(--apple-text-secondary); }

/* ---- Form Fields ---- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 0.85rem; font-weight: 600; color: var(--apple-text); }
.field input, .field select {
  padding: 12px 16px; border: 1.5px solid #E5E5EA;
  border-radius: 12px; font-size: 0.95rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none; width: 100%; background: var(--apple-white);
}
.field input:focus, .field select:focus {
  border-color: var(--ghibli-green);
  box-shadow: 0 0 0 3px rgba(91,140,90,0.12);
}
.field-hint { font-size: 0.75rem; color: var(--apple-text-secondary); }

/* ---- Navbar ---- */
.navbar {
  background: rgba(255,255,255,0.5);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid rgba(0,0,0,0.06);
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-height);
}
.nav-inner {
  max-width: 1200px; margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between;
  height: 100%;
}
.nav-left { display: flex; align-items: center; gap: 16px; flex: 1; }
.nav-right { display: flex; align-items: center; gap: 12px; }
.nav-brand { 
  display: flex; align-items: center; gap: 8px;
  font-size: 1rem; font-weight: 700; color: var(--ghibli-forest);
  letter-spacing: -0.3px;
}
.nav-brand img { height: 32px; width: auto; }
.nav-brand:hover { color: var(--ghibli-forest); }
.nav-sep { width: 1px; height: 20px; background: #E5E5EA; }
.nav-user { font-size: 0.85rem; color: var(--apple-text-secondary); font-weight: 500; }

/* ---- Search ---- */
.search-box { position: relative; display: flex; align-items: center; }
.search-icon { position: absolute; left: 14px; pointer-events: none; color: var(--apple-text-secondary); }
.search-box input {
  padding: 8px 16px 8px 38px; border: 1.5px solid transparent;
  border-radius: 24px; background: rgba(120,120,128,0.08);
  font-size: 0.85rem; width: 240px; outline: none;
  transition: all var(--transition);
}
.search-box input:focus {
  border-color: var(--ghibli-green); background: var(--apple-white);
  width: 300px; box-shadow: 0 0 0 3px rgba(91,140,90,0.08);
}

/* ---- Main Layout ---- */
.main-layout { padding-top: var(--nav-height); min-height: 100vh; }

/* ---- Hero Section ---- */
.hero-section {
  position: relative;
  background:
    radial-gradient(ellipse 100% 40% at 50% 10%, rgba(179,229,252,0.18), transparent),
    radial-gradient(ellipse 60% 30% at 80% 60%, rgba(200,230,201,0.12), transparent),
    radial-gradient(ellipse 50% 25% at 20% 70%, rgba(255,224,178,0.10), transparent),
    linear-gradient(180deg, #fafcfb 0%, #f5f9f7 100%);
  border-radius: 20px;
  padding: 36px 24px 30px;
  text-align: center;
}
/* Remove the ::before SVG pattern for cleaner look */
.hero-section::before {
  display: none;
}
.hero-logo { margin-bottom: 16px; }
.hero-logo img { height: 100px; width: auto; border-radius: 16px; }
.hero-title { font-size: 2.2rem; font-weight: 800; color: var(--ghibli-forest); letter-spacing: -0.5px; }
.hero-subtitle { font-size: 1rem; color: var(--apple-text-secondary); margin-top: 8px; max-width: 500px; margin-left: auto; margin-right: auto; }

/* ---- Content Area ---- */
.content-area { max-width: 1200px; margin: 0 auto; padding: 32px 24px; }
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.section-title { font-size: 1.5rem; font-weight: 700; color: var(--apple-text); letter-spacing: -0.3px; }

/* ---- Category Grid (Home) ---- */
.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.home-card {
  background: rgba(255,255,255,0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.7);
  border-radius: 16px;
  padding: 32px 24px;
  cursor: pointer;
  transition: all 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.home-card:hover {
  background: rgba(255,255,255,0.7);
  box-shadow: 0 12px 40px rgba(0,0,0,0.08);
  transform: translateY(-6px);
  border-color: rgba(125,171,122,0.3);
}
.home-card-icon { font-size: 2.4rem; margin-bottom: 14px; display: block; }
.home-card-name { font-size: 1.05rem; font-weight: 600; color: var(--apple-text); }
.home-card-count { font-size: 0.8rem; color: var(--apple-text-secondary); margin-top: 8px; }

/* ---- Sub Category Grid ---- */
.sub-header {
  display: flex; align-items: center; gap: 16px; margin-bottom: 20px;
}
.sub-header h2 { font-size: 1.4rem; font-weight: 700; }
.sub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
}
.sub-card {
  background: var(--apple-white); border: 1px solid rgba(0,0,0,0.04);
  border-radius: var(--radius); padding: 20px 16px;
  cursor: pointer; transition: all var(--transition); text-align: center;
}
.sub-card:hover {
  box-shadow: var(--apple-shadow); transform: translateY(-2px);
}
.sub-card .sub-name { font-size: 0.95rem; font-weight: 500; }
.sub-card .sub-count { font-size: 0.8rem; color: var(--apple-text-secondary); margin-top: 6px; }

/* ---- File List ---- */
.files-list { display: flex; flex-direction: column; gap: 8px; }
.file-row {
  display: flex; align-items: center; gap: 12px;
  background: rgba(255,255,255,0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.7);
  border-radius: 12px;
  padding: 14px 18px;
  transition: all 0.3s ease;
  box-shadow: 0 1px 4px rgba(0,0,0,0.03);
}
.file-row:hover {
  background: rgba(255,255,255,0.65);
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}
.file-icon { color: var(--ghibli-green); flex-shrink: 0; }
.file-info { flex: 1; min-width: 0; }
.file-name { font-weight: 600; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta { font-size: 0.78rem; color: var(--apple-text-secondary); margin-top: 2px; }
.file-actions { display: flex; gap: 8px; flex-shrink: 0; }
.file-download, .file-delete {
  padding: 6px 14px; border: 1.5px solid #E5E5EA; border-radius: 50px;
  background: transparent; font-size: 0.8rem; cursor: pointer;
  transition: all var(--transition); color: var(--apple-text-secondary);
}
.file-download:hover { border-color: var(--ghibli-green); color: var(--ghibli-green); }
.file-delete:hover { border-color: #E74C3C; color: #E74C3C; }

/* ---- Upload Modal ---- */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.3); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 24px;
}
.modal {
  background: var(--apple-white); border-radius: 20px;
  width: 100%; max-width: 460px; padding: 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.12);
  max-height: 90vh; overflow-y: auto;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px;
}
.modal-header h3 { font-size: 1.2rem; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--apple-text-secondary); padding: 4px; line-height: 1; }
.modal-close:hover { color: var(--apple-text); }

.upload-progress { display: flex; flex-direction: column; gap: 8px; }
.progress-bar { height: 4px; background: #E5E5EA; border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--ghibli-green); width: 0%; transition: width 0.3s ease; }
#progress-text { font-size: 0.8rem; color: var(--apple-text-secondary); }

/* ---- Admin ---- */
.admin-layout { padding-top: var(--nav-height); max-width: 1000px; margin: 0 auto; padding-left: 24px; padding-right: 24px; }
.admin-header { display: flex; align-items: center; gap: 16px; padding: 24px 0 16px; border-bottom: 1px solid #E5E5EA; margin-bottom: 20px; }
.admin-title { font-size: 1.5rem; font-weight: 700; }
.admin-tabs { display: flex; gap: 4px; margin-bottom: 20px; background: rgba(120,120,128,0.06); border-radius: var(--radius-sm); padding: 3px; }
.admin-tab { flex: 1; padding: 8px 16px; border: none; border-radius: var(--radius-sm); background: transparent; cursor: pointer; font-size: 0.85rem; font-weight: 500; color: var(--apple-text-secondary); transition: all var(--transition); }
.admin-tab:hover { color: var(--apple-text); }
.admin-tab.active { background: var(--apple-white); color: var(--apple-text); box-shadow: 0 1px 6px rgba(0,0,0,0.06); }
.admin-section {
  display: none;
}
.admin-section.active {
  display: block;
  background: rgba(255,255,255,0.45);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 20px;
  padding: 24px;
  border: 1px solid rgba(255,255,255,0.7);
  box-shadow: 0 4px 24px rgba(0,0,0,0.06);
  margin-bottom: 24px;
}
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th { text-align: left; padding: 10px 12px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--apple-text-secondary); border-bottom: 1px solid #E5E5EA; }
.admin-table td { padding: 10px 12px; font-size: 0.85rem; border-bottom: 1px solid #E5E5EA; }
.admin-table tr:hover td { background: rgba(0,0,0,0.01); }
.admin-tree { margin-top: 16px; }
.admin-tree-item { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid #E5E5EA; font-size: 0.9rem; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .home-grid { grid-template-columns: repeat(2, 1fr); }
  .search-box input { width: 140px; }
  .search-box input:focus { width: 180px; }
  .sub-grid { grid-template-columns: repeat(2, 1fr); }
  .hero-title { font-size: 1.8rem; }
}



/* ---- Subject Cards ---- */
.subject-card {
  background: transparent;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: none;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 16px;
  padding: 32px 24px 28px;
  cursor: pointer;
  transition: all 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  opacity: 0;
  transform: translateY(12px);
  animation: cardFadeIn 0.4s ease forwards;
  animation-delay: calc(var(--card-index, 0) * 0.04s);
}
.subject-card:hover {
  background: transparent;
  box-shadow: 0 8px 30px rgba(0,0,0,0.12);
  transform: translateY(-4px);
}
.subject-card .subject-icon {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  font-size: 1.6rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}
.subject-card .subject-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--apple-text);
}

@keyframes cardFadeIn {
  to { opacity: 1; transform: translateY(0); }
}
/* ---- Back Button (glass) ---- */
.sub-header .btn-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  background: rgba(255,255,255,0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.7);
  border-radius: 50px;
  font-size: 0.85rem;
  color: var(--apple-text);
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}
.sub-header .btn-back:hover {
  background: rgba(255,255,255,0.65);
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

/* ---- Content View (glass effect) ---- */
.content-view {
  background: transparent;
  border-radius: 20px;
  padding: 8px 0;
  margin-top: 20px;
}
.sub-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  flex: 1;
}


