 :root {
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --sky: #38bdf8;
  --bg: #f8fbff;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #dbeafe;
  --shadow: 0 24px 60px rgba(15, 23, 42, .10);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: Arial, sans-serif;
}

a {
  color: inherit;
}

.navbar {
  height: 78px;
  padding: 0 8%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, .9);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  font-size: 24px;
  font-weight: 900;
}

.logo img {
  width: 44px;
  height: 44px;
  border-radius: 14px;
}

.nav-links{
    display:flex;
    gap:24px;
}


.nav-links a {
  text-decoration: none;
  font-weight: 700;
  color: #334155;
}

.nav-links a:hover {
  color: var(--blue);
}

.login-btn,
.user-mini button {
  border: none;
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--blue);
  color: white;
  cursor: pointer;
  font-weight: 800;
}

.user-mini {
  display: flex;
  gap: 10px;
  align-items: center;
}

.user-mini img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
}

.hero {
  padding: 78px 8%;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  gap: 50px;
  align-items: center;
}

.badge {
  display: inline-block;
  padding: 9px 15px;
  border-radius: 999px;
  background: #e0ecff;
  color: var(--blue);
  font-weight: 900;
}

.hero h1 {
  font-size: 60px;
  line-height: 1.08;
  letter-spacing: -1.5px;
  margin: 18px 0;
}

.hero p {
  color: var(--muted);
  font-size: 18px;
  line-height: 1.7;
}

.hero img {
  width: 100%;
  filter: drop-shadow(0 30px 70px rgba(37, 99, 235, .18));
}

.search-box {
  margin-top: 28px;
  background: white;
  padding: 8px;
  border-radius: 20px;
  box-shadow: var(--shadow);
  display: flex;
}

.search-box input {
  flex: 1;
  padding: 16px;
  border: none;
  outline: none;
  font-size: 16px;
}

.search-box button {
  border: none;
  background: var(--blue);
  color: white;
  border-radius: 15px;
  padding: 14px 24px;
  cursor: pointer;
  font-weight: 900;
}

.hero-actions {
    margin-top: 30px;
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
}

.primary-link,
.secondary-link{
    display:inline-flex;
    align-items:center;
    justify-content:center;

    min-width:180px;
    height:50px;

    text-decoration:none;
    border-radius:12px;
    font-weight:700;
}

.primary-link {
  background: var(--blue);
  color: white;
}

.secondary-link {
  background: white;
  color: var(--blue);
  border: 1px solid var(--border);
}
.hero-actions a {
    flex: 1 1 220px;
    text-align: center;
    transition: .25s;
}

.hero-actions a:hover {
    transform: translateY(-3px);
}

.subjects,
.documents,
.page-section {
  padding: 44px 8%;
}

.subject-grid,
.doc-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
}

.subject-card,
.doc-card,
.form-card,
.detail-card,
.comment-section {
  background: white;
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.subject-card {
  text-decoration: none;
  transition: .25s;
}

.subject-card:hover,
.doc-card:hover {
  transform: translateY(-6px);
}
.doc-header{
    display:flex;
    justify-content:space-between;
    align-items:center;
    margin-bottom:16px;
}

.doc-subject{
    background:#eef4ff;
    color:var(--blue);
    padding:6px 12px;
    border-radius:999px;
    font-weight:700;
}

.doc-rating{
    font-weight:700;
    color:#f59e0b;
}

.doc-title{
    font-size:22px;
    margin:12px 0;
    line-height:1.4;
}

.doc-description{
    color:#666;
    line-height:1.7;
    margin-bottom:18px;
}

.doc-meta,
.doc-stats{
    display:flex;
    gap:18px;
    flex-wrap:wrap;
    margin-bottom:16px;
    color:#666;
}

.doc-buttons{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:12px;
    margin-top:20px;
}

.download-btn{
    flex:1;
    text-align:center;
    background:#eef4ff;
    color:var(--blue);
    padding:12px;
    border-radius:12px;
    text-decoration:none;
    font-weight:700;
}

.download-btn:hover{
    background:var(--blue);
    color:white;
}
.subject-icon {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  background: #e0ecff;
  border-radius: 20px;
  font-size: 32px;
  margin-bottom: 18px;
}

.section-title {
  margin-bottom: 24px;
}

.section-title span {
  color: var(--blue);
  font-weight: 900;
}

.section-title h2 {
  font-size: 36px;
  margin-top: 8px;
}

.doc-header,
.doc-meta,
.detail-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}

.doc-header span {
  background: #e0ecff;
  color: var(--blue);
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 900;
  font-size: 13px;
}

.doc-card h3 {
  font-size: 21px;
  margin-bottom: 10px;
  line-height: 1.35;
}

.doc-card p,
.detail-card p {
  color: var(--muted);
  line-height: 1.65;
  margin-bottom: 16px;
}

.detail-btn,
.doc-actions a,
.detail-actions a,
.detail-actions button,
.form-card button,
.comment-form button {
  display: inline-block;
  border: none;
  text-decoration: none;
  background: var(--blue);
  color: white;
  padding: 12px 16px;
  border-radius: 14px;
  font-weight: 900;
  cursor: pointer;
  text-align: center;
}

.detail-btn {
    display: flex;
    justify-content: center;
    align-items: center;

    width: 100%;
    height: 48px;

    margin-bottom: 0;

    background: var(--blue);
    color: white;

    border-radius: 12px;
    text-decoration: none;
    font-weight: 700;

    transition: .25s;
}
.download-btn {
    display: flex;
    justify-content: center;
    align-items: center;

    width: 100%;
    height: 48px;

    background: #eef4ff;
    color: var(--blue);

    border-radius: 12px;
    text-decoration: none;
    font-weight: 700;

    transition: .25s;
}

.download-btn:hover {
    background: var(--blue);
    color: white;
}
.detail-btn:hover {
    transform: translateY(-2px);
}

.doc-actions,
.detail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.page-hero {
  padding: 70px 8%;
  background: linear-gradient(135deg, #2563eb, #38bdf8);
  color: white;
}

.page-hero h1 {
  font-size: 48px;
  margin: 14px 0 10px;
}

.filter-panel {
  padding: 34px 8% 0;
  display: grid;
  grid-template-columns: 1fr 180px 180px;
  gap: 14px;
}

.filter-panel input,
.filter-panel select,
.form-card input,
.form-card select,
.form-card textarea,
.comment-form input,
.comment-form textarea {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  outline: none;
  font-size: 15px;
}

.form-card,
.detail-card,
.comment-section {
  max-width: 900px;
  margin: 40px auto;
}

.form-card {
  display: grid;
  gap: 13px;
.profile-card{
    display:flex;
    align-items:flex-start;
    gap:30px;
    padding:32px;
    background:#fff;
    border-radius:24px;
    box-shadow:0 12px 30px rgba(0,0,0,.08);
}

.profile-info{
    flex:1;
}

.profile-avatar{
    width:120px;
    height:120px;
    border-radius:50%;
    object-fit:cover;
    border:5px solid #3b82f6;
    flex-shrink:0;
}
}

.form-card label {
  font-weight: 900;
}

.form-card textarea,
.comment-form textarea {
  min-height: 110px;
  resize: vertical;
}

.detail-card h1 {
  font-size: 42px;
  margin: 18px 0;
}

.comment-form {
  display: grid;
  gap: 12px;
}

.comment {
  background: #f8fbff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  margin-top: 12px;
}

.empty-state {
  grid-column: 1 / -1;
  background: white;
  border: 1px dashed var(--border);
  border-radius: 20px;
  padding: 24px;
  color: var(--muted);
}
.menu-toggle{
    display:none;
    background:none;
    border:none;
    font-size:28px;
    cursor:pointer;
}
@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
  }
.navbar{
    flex-wrap: wrap;
}

.user-box{
    margin-left:auto;
}
  .subject-grid,
  .doc-grid {
    grid-template-columns: 1fr;
  }

  .filter-panel {
    grid-template-columns: 1fr;
  }

  .nav-links {
    display: none;
  }

  .hero h1 {
    font-size: 42px;
  }

  .search-box {
    flex-direction: column;
  }
}
.profile-form{
    display:flex;
    flex-direction:column;
    gap:16px;
    margin-top:20px;
}

.profile-form label{
    font-weight:600;
    color:#374151;
}

.profile-form input,
.profile-form textarea{
    width:100%;
    padding:12px 16px;
    border:1px solid #dbe3ef;
    border-radius:12px;
    font-size:15px;
    outline:none;
    transition:.2s;
}

.profile-form input:focus,
.profile-form textarea:focus{
    border-color:#3b82f6;
    box-shadow:0 0 0 3px rgba(59,130,246,.15);
}

.profile-form textarea{
    min-height:110px;
    resize:vertical;
}

.profile-form button{
    width:180px;
    padding:12px;
    border:none;
    border-radius:12px;
    background:#3b82f6;
    color:#fff;
    font-weight:600;
    cursor:pointer;
    transition:.2s;
}

.profile-form button:hover{
    background:#2563eb;
}
.user-mini{
    display:flex;
    align-items:center;
    gap:18px;
}

.user-mini img{
    width:44px;
    height:44px;
    border-radius:50%;
    object-fit:cover;
    border:4px solid #3b82f6;
}

.profile-link{
    display:flex;
    align-items:center;
    gap:12px;
    text-decoration:none;
    color:inherit;
}

.profile-link:hover{
    opacity:.9;
}
.profile-avatar{
    width:120px !important;
    height:120px !important;
    max-width:120px !important;
    max-height:120px !important;
    border-radius:50% !important;
    object-fit:cover !important;
    border:5px solid #3b82f6 !important;
    flex-shrink:0;
}
.profile-stats{
    width:260px;
    margin-left:auto;
    padding:22px;
    border-radius:20px;
    background:#f8fbff;
    border:1px solid #e5eefb;

}

.profile-stats h3{
    margin-bottom:14px;
    font-size:20px;
}

.profile-stats p{
    margin:10px 0;
    font-weight:600;
    color:#475569;
}
.profile-card{
    display:flex;
    align-items:flex-start;
    gap:30px;
}

.profile-info{
    flex:1;
}

.profile-stats{
    width:260px;
    margin-left:auto;
}
.xp-box{
    margin-top:14px;
}

.xp-bar{
    width:100%;
    height:10px;
    background:#e7eefc;
    border-radius:999px;
    overflow:hidden;
}

.xp-fill{
    height:100%;
    width:0%;
    background:linear-gradient(90deg,#3b82f6,#60a5fa);
    border-radius:999px;
    transition:width .4s ease;
}

.xp-box small{
    display:block;
    margin-top:8px;
    color:#64748b;
    font-size:13px;
}
.profile-actions{
    display:flex;
    gap:12px;
    margin-top:20px;
}

.btn-primary,
.btn-secondary{
    padding:10px 18px;
    border-radius:12px;
    border:none;
    font-weight:700;
    cursor:pointer;
    text-decoration:none;
    transition:.2s;
}

.btn-primary{
    background:#2563eb;
    color:#fff;
}

.btn-primary:hover{
    background:#1d4ed8;
}

.btn-secondary{
    background:#eef4ff;
    color:#2563eb;
}

.btn-secondary:hover{
    background:#dbeafe;
}
.documents-section{
    max-width:900px;
    margin:40px auto;
}

.documents-grid{
    display:grid;
    grid-template-columns:repeat(auto-fill,minmax(260px,1fr));
    gap:20px;
    margin-top:20px;
}

.document-card{
    background:#fff;
    border-radius:18px;
    padding:24px;
    margin-bottom:24px;
    box-shadow:0 10px 25px rgba(15,23,42,.08);
}

.document-card h3{
    margin-bottom:10px;
    font-size:18px;
}

.document-card p{
    font-size:14px;
    color:#64748b;
    margin:12px 0;
    line-height:1.6;
}
.document-card{
    background:#fff;
    border-radius:18px;
    padding:24px;
    margin-bottom:24px;
    box-shadow:0 10px 25px rgba(15,23,42,.08);
    border:1px solid #e5eefb;
    transition:.2s;
}

.document-card:hover{
    transform:translateY(-4px);
    box-shadow:0 16px 35px rgba(15,23,42,.12);
}

.document-card h3{
    font-size:18px;
    margin-bottom:8px;
    color:#1e293b;
}

.document-card p{
    font-size:14px;
    color:#64748b;
}
.doc-badge{
    display:inline-block;
    padding:6px 12px;
    border-radius:999px;
    background:#e0f2fe;
    color:#0369a1;
    font-size:13px;
    font-weight:700;
    margin-bottom:10px;
}
.doc-author{
    color:#64748b;
    font-size:14px;
    margin:6px 0 10px;
}
.doc-date{
    color:#94a3b8;
    font-size:13px;
    margin-bottom:10px;
}
.doc-actions{
    display:flex;
    gap:10px;
    margin-top:12px;
}

.btn-danger{
    padding:10px 18px;
    border-radius:12px;
    border:none;
    background:#fee2e2;
    color:#dc2626;
    font-weight:700;
    cursor:pointer;
}

.btn-danger:hover{
    background:#fecaca;
}
.edit-profile-section{
    display:none;
}

.edit-profile-section.active{
    display:block;
}
.document-card .btn-primary {
    margin-top: 12px;
}
.doc-detail-btn {
    display: inline-block;
    margin-top: 12px;
}
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.confirm-box {
    background: #fff;
    padding: 26px;
    border-radius: 22px;
    width: 340px;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.25);
    text-align: center;
}

.confirm-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 20px;
}
@media (max-width: 768px) {

    .container {
        width: 95%;
        padding: 0 12px;
    }
.menu-toggle{
    display:block;
    background:none;
    border:none;
    font-size:28px;
    cursor:pointer;
    z-index:10001;
}

.mobile-menu{
    position:fixed;
    top:0;
    left:0;
    width:260px;
    height:100vh;
    background:#fff;
    display:flex;
    flex-direction:column;
    gap:18px;
    padding:80px 20px 20px;
    box-shadow:0 0 30px rgba(0,0,0,.15);
    transform:translateX(-100%);
    transition:.3s;
    z-index:10000;
    overflow-y:auto;
}

.mobile-menu.active{
    transform:translateX(0);
}

.mobile-menu a{
    display:block;
    text-decoration:none;
    color:#334155;
    font-weight:700;
    padding:10px 0;
    border-bottom:1px solid #f1f5f9;
}
}
/* ===== Badge System ===== */

.badge-box{
    margin-top:20px;
}

.badge-box h3{
    margin-bottom:12px;
}

.badge-item{
    display:flex;
    align-items:center;
    gap:10px;

    padding:10px 14px;
    margin-bottom:10px;

    border-radius:10px;

    font-weight:600;

    transition:.25s;
}

.badge-item.unlocked{
    background:#fff7d6;
    border:1px solid #ffd54f;
    color:#7a5b00;
}

.badge-item.locked{
    background:#f3f4f6;
    border:1px solid #ddd;
    color:#999;
    opacity:.65;
}

.badge-item:hover{
    transform:translateX(6px);
}
/* ===== Comment V2 ===== */

.comment {
  padding: 14px;
  margin-bottom: 12px;
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
}

.comment-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.comment-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid #e5e7eb;
}

.comment-time {
  font-size: 12px;
  color: #6b7280;
  margin-top: 2px;
}

.comment p {
  margin: 6px 0 0 48px;
  line-height: 1.5;
}
/* ===== Comment Form V3 ===== */

.comment-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.comment-user img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid #e5e7eb;
}

#commentUsername {
  font-weight: 600;
  color: #1f2937;
}
.comment-form textarea {
    width: 100%;
    min-height: 140px;      /* Chiều cao */
    padding: 14px 16px;
    font-size: 16px;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    resize: vertical;
    outline: none;
    transition: 0.2s;
    box-sizing: border-box;
}

.comment-form textarea:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
/* ===== Public Profile ===== */


/* ===========================
   LEADERBOARD
=========================== */

.leaderboard-item{
    display:flex;
    align-items:center;
    gap:18px;

    background:#fff;

    border-radius:18px;

    padding:18px;

    margin-bottom:15px;

    text-decoration:none;

    color:#222;

    box-shadow:0 4px 14px rgba(0,0,0,.08);

    transition:.25s;
}

.leaderboard-item:hover{

    transform:translateY(-3px);

    box-shadow:0 10px 24px rgba(0,0,0,.12);

}

.leaderboard-rank{

    font-size:30px;

    width:55px;

    text-align:center;

    font-weight:bold;

}

.leaderboard-item img{

    width:70px;

    height:70px;

    border-radius:50%;

    object-fit:cover;

}

.leaderboard-item h3{

    margin-bottom:6px;

}

.leaderboard-item p{

    color:#666;

}
.leaderboard-stats{

    display:flex;

    gap:25px;

    margin-top:10px;

    font-size:14px;

    color:#666;

}
.rank-1{
    background: linear-gradient(90deg,#fff8dc,#fff2b8);
    border:2px solid #ffd700;
}

.rank-2{
    background: linear-gradient(90deg,#f8f8f8,#ececec);
    border:2px solid #c0c0c0;
}

.rank-3{
    background: linear-gradient(90deg,#fff5ef,#ffe2cf);
    border:2px solid #cd7f32;
}
/* =======================================
   LEADERBOARD TABS
======================================= */

.leaderboard-tabs{

    display:flex;

    gap:12px;

    flex-wrap:wrap;

    margin:25px 0;

}

.leaderboard-tab{

    padding:12px 20px;

    border:none;

    border-radius:12px;

    background:#f1f5f9;

    color:#334155;

    cursor:pointer;

    font-size:15px;

    font-weight:600;

    transition:.25s;

}

.leaderboard-tab:hover{

    background:#2563eb;

    color:white;

}

.leaderboard-tab.active{

    background:#2563eb;

    color:white;

}
/* ===== Leaderboard Search ===== */

.leaderboard-search{

    width:100%;

    max-width:420px;

    padding:14px 18px;

    margin:20px 0 30px;

    border:2px solid #e5e7eb;

    border-radius:14px;

    font-size:16px;

    outline:none;

    transition:.25s;

    background:#fff;

}

.leaderboard-search:focus{

    border-color:#2563eb;

    box-shadow:0 0 0 4px rgba(37,99,235,.12);

}
/* ===== Home Stats ===== */

.home-stats{
    margin-top:30px;
    display:grid;
    grid-template-columns:repeat(4,1fr);
    gap:18px;
}

.home-stats div{
    background:white;
    border:1px solid var(--border);
    border-radius:18px;
    padding:18px;
    text-align:center;
    box-shadow:0 8px 24px rgba(0,0,0,.05);
    transition:.25s;
}

.home-stats div:hover{
    transform:translateY(-5px);
}

.home-stats strong{
    display:block;
    font-size:28px;
    color:var(--blue);
    margin-bottom:8px;
}

.home-stats span{
    color:#666;
    font-size:15px;
}

/* Mobile */

@media(max-width:768px){

.home-stats{

grid-template-columns:repeat(2,1fr);

}
/* ===== Top Members Home ===== */

.top-members {
  padding: 40px 6%;
}

.top-members-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.top-member-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0,0,0,.05);
  transition: .25s;
}

.top-member-card:hover {
  transform: translateY(-5px);
}

.top-member-card img {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--blue);
}

.top-member-card h3 {
  margin: 12px 0 6px;
}

.top-member-card p {
  color: #666;
  margin-bottom: 14px;
}

@media(max-width: 768px) {
  .top-members-grid {
    grid-template-columns: 1fr;
  }
}
}
.top-members {
  padding: 40px 8%;
}

.top-members-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.top-member-card {
  display: block;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px;
  text-align: center;
  text-decoration: none;
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0,0,0,.06);
}

.top-member-card img {
  width: 82px !important;
  height: 82px !important;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 12px;
}

.top-member-card h3 {
  margin: 8px 0 4px;
}

.top-member-card p {
  color: #64748b;
  margin-bottom: 12px;
}
.top-members-grid {
  justify-content: center;
}

.top-member-card {
  max-width: 280px;
  width: 100%;
}
/* ===========================
   PROFILE COVER
=========================== */

.profile-cover{
    width:100%;
    max-width:980px;
    height:220px;
    overflow:hidden;
    border-radius:24px;
    margin:0 auto 20px;
}

.profile-cover img{
    width:100%;
    height:100%;
    object-fit:cover;
    object-position:center;
    display:block;
}
/* ===== Public Profile Cover ===== */


/* ===== Public Profile V2 ===== */


.profile-actions{
    display:flex;
    gap:12px;
    margin:18px 0;
}

#followBtn{
    padding:12px 22px;
    border-radius:999px;
    font-weight:800;
    border:none;
    cursor:pointer;
}


.documents-grid{
    display:flex;
    flex-direction:column;
    gap:22px;
}
/* ===== Public user documents spacing fix ===== */

#publicUserDocuments{
    display:flex;
    flex-direction:column;
    gap:26px;
    max-width:980px;
    margin:0 auto;
}

#publicUserDocuments .document-card{
    min-height:180px;
    padding:28px;
    margin-bottom:0;
    border-radius:22px;
}

#publicUserDocuments .document-card h3{
    margin:14px 0 10px;
}

#publicUserDocuments .document-card p{
    margin:10px 0;
    line-height:1.6;
}

#publicUserDocuments .document-meta{
    margin:16px 0;
}

#publicUserDocuments .btn-primary{
    margin-top:14px;
    display:inline-flex;
}
/* ===== My Profile Documents Grid ===== */

#savedDocuments,
#userDocuments{
    display:grid;
    grid-template-columns:repeat(2, minmax(0, 1fr));
    gap:24px;
    max-width:980px;
    margin:0 auto;
}

#savedDocuments .document-card,
#userDocuments .document-card{
    min-height:220px;
    padding:24px;
    border-radius:22px;
}

@media(min-width:1100px){
    #savedDocuments,
    #userDocuments{
        grid-template-columns:repeat(3, minmax(0, 1fr));
    }
}

@media(max-width:768px){
    #savedDocuments,
    #userDocuments{
        grid-template-columns:1fr;
    }
}
.notification-card{
    background:#fff;
    border:1px solid #e5e7eb;
    border-radius:18px;
    padding:20px;
    margin-bottom:18px;
    transition:.2s;
}

.notification-card:hover{
    transform:translateY(-3px);
    box-shadow:0 10px 25px rgba(0,0,0,.08);
}

.notification-card h3{
    margin-bottom:8px;
}

.notification-card p{
    color:#64748b;
}


/* ===== Public Profile Layout V3 ===== */


/* ===== Người đăng tài liệu ===== */

.detail-author{
    margin:24px 0;
}

.author-card{
    display:flex;
    align-items:center;
    gap:16px;
    padding:16px 20px;
    background:#f8fafe;
    border:1px solid #e6eefc;
    border-radius:18px;
    text-decoration:none;
    color:inherit;
    transition:.2s ease;
}

.author-card:hover{
    transform:translateY(-2px);
    box-shadow:0 8px 20px rgba(37,99,235,.12);
}

.author-avatar{
    width:64px;
    height:64px;
    border-radius:50%;
    object-fit:cover;
    border:3px solid #2563eb;
    flex-shrink:0;
}

.author-info{
    display:flex;
    flex-direction:column;
}

.author-info h3{
    margin:0;
    font-size:20px;
    color:#1e293b;
}

.author-info p{
    margin:6px 0 0;
    color:#64748b;
    font-size:14px;
}
.author-documents .document-meta,
#authorDocuments .document-meta{
    margin:10px 0 14px;
}

#authorDocuments .btn-primary{
    margin-top:8px;
    display:inline-block;
}
.user-search-card{
    display:flex;
    align-items:center;
    gap:18px;
    background:#fff;
    border:1px solid #e5eefb;
    border-radius:20px;
    padding:18px;
    text-decoration:none;
    color:inherit;
    box-shadow:0 10px 25px rgba(15,23,42,.06);
    margin-bottom:16px;
    transition:.2s;
}

.user-search-card:hover{
    transform:translateY(-3px);
    box-shadow:0 16px 35px rgba(37,99,235,.12);
}

.user-search-avatar{
    width:64px;
    height:64px;
    border-radius:50%;
    object-fit:cover;
    border:3px solid #2563eb;
}

.user-search-info{
    flex:1;
}

.user-search-info h3{
    margin:0 0 6px;
}

.user-search-info p{
    margin:0 0 8px;
    color:#64748b;
}

.user-search-meta{
    display:flex;
    gap:10px;
    color:#2563eb;
    font-size:13px;
}

.user-search-action{
    font-weight:700;
    color:#2563eb;
}
#searchInput{
    width:100%;
    max-width:500px;
    padding:14px 18px;
    border:1px solid #dbeafe;
    border-radius:14px;
    margin:18px 0 24px;
    font-size:16px;
    outline:none;
}

#searchInput:focus{
    border-color:#2563eb;
    box-shadow:0 0 0 4px rgba(37,99,235,.12);
}

#searchResult{
    max-width:900px;
}
.document-card .btn-primary{
    display:inline-block;
    margin-top:16px;
}
.leaderboard-search{
    width:100%;
    max-width:500px;
    padding:14px 18px;
    border:1px solid #dbeafe;
    border-radius:14px;
    margin:20px 0 24px;
    font-size:16px;
    outline:none;
}

.leaderboard-search:focus{
    border-color:#2563eb;
    box-shadow:0 0 0 4px rgba(37,99,235,.12);
}

.leaderboard-item{
    display:flex;
    align-items:center;
    gap:18px;
    padding:18px;
    background:#fff;
    border:1px solid #e5eefb;
    border-radius:20px;
    text-decoration:none;
    color:inherit;
    margin-bottom:16px;
    box-shadow:0 10px 25px rgba(15,23,42,.06);
}

.leaderboard-rank{
    width:46px;
    font-size:24px;
    font-weight:800;
    text-align:center;
}

.leaderboard-stats{
    display:flex;
    gap:14px;
    margin-top:8px;
    color:#2563eb;
    font-size:14px;
}


/* ===== FINAL MOBILE CLEAN FIX ===== */
@media (max-width: 1000px){

  html, body{
    max-width:100%;
    overflow-x:hidden;
  }

  .navbar,
  .main-header{
    height:auto;
    min-height:auto;
    padding:14px 16px;
    display:flex;
    flex-wrap:wrap;
    align-items:center;
    justify-content:flex-start;
    gap:12px;
  }

  .logo{
    font-size:24px;
    flex:0 0 auto;
  }

  .logo img{
    width:42px;
    height:42px;
  }

  .menu-toggle{
    display:block;
    margin-left:auto;
  }

  .nav-links,
  .main-header nav{
    width:100%;
    display:flex;
    flex-wrap:nowrap;
    gap:12px;
    overflow-x:auto;
    padding:4px 0 8px;
    white-space:nowrap;
  }

  .nav-links a,
  .main-header nav a{
    flex:0 0 auto;
    font-size:15px;
  }

  [data-user-area],
  .user-mini{
    width:100%;
    display:flex;
    align-items:center;
    gap:12px;
    flex-wrap:wrap;
  }
  .header-action-link{
    width:40px;
    height:40px;
    font-size:19px;
}

.profile-link{
    min-width:0;
    flex:1;
}

.profile-link span{
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
}

  .login-btn,
  .user-mini button{
    padding:10px 16px;
  }

  .hero,
  .subjects,
  .documents,
  .page-section,
  .top-members{
    padding-left:16px;
    padding-right:16px;
  }

  .hero{
    grid-template-columns:1fr;
    gap:28px;
    padding-top:36px;
  }

  .hero h1{
    font-size:42px;
    line-height:1.15;
  }

  .search-box{
    flex-direction:column;
    gap:10px;
  }

  .home-stats{
    grid-template-columns:repeat(2, minmax(0,1fr));
    gap:14px;
  }

  .top-members-grid,
  .featured-users,
  .community-grid{
    grid-template-columns:1fr !important;
    display:grid !important;
    gap:18px !important;
  }

  .top-member-card,
  .featured-user-card,
  .member-card{
    width:100%;
    max-width:100%;
  }

  .top-member-card .btn-primary,
  .featured-user-card .btn-primary,
  .member-card .btn-primary{
    display:inline-flex;
    width:100%;
    justify-content:center;
    white-space:normal;
    line-height:1.3;
    font-size:14px;
    padding:10px 12px;
  }

  

  .detail-card h1{
    font-size:34px;
  }

  .detail-actions{
    display:grid;
    grid-template-columns:1fr;
    gap:10px;
  }

  .detail-actions a,
  .detail-actions button{
    width:100%;
  }

  .author-card{
    flex-direction:column;
    align-items:center;
    text-align:center;
  }

  .profile-card{
    flex-direction:column !important;
    align-items:center !important;
    text-align:center;
  }

  .profile-info{
    width:100%;
  }

  .profile-stats{
    width:100% !important;
    margin-left:0 !important;
    display:grid;
    grid-template-columns:repeat(2, minmax(0,1fr));
    gap:12px;
  }

  .profile-actions{
    justify-content:center;
    flex-wrap:wrap;
  }

  

  

  

  

  

  

  

  

  

  .documents-grid,
  #savedDocuments,
  #userDocuments,
  #publicUserDocuments{
    display:grid !important;
    grid-template-columns:1fr !important;
    gap:18px;
  }

  .leaderboard-tabs{
    display:flex;
    flex-wrap:nowrap;
    overflow-x:auto;
    gap:10px;
    padding-bottom:10px;
  }

  .leaderboard-tab{
    flex:0 0 auto;
    white-space:nowrap;
  }

  .leaderboard-search{
    max-width:100%;
  }

  .leaderboard-item{
    display:grid;
    grid-template-columns:44px 60px 1fr;
    align-items:center;
    gap:12px;
    overflow:hidden;
  }

  .leaderboard-rank{
    width:auto;
    font-size:22px;
  }

  .leaderboard-item img{
    width:56px;
    height:56px;
  }

  .leaderboard-stats{
    display:flex;
    flex-wrap:wrap;
    gap:10px;
  }
}

@media (max-width: 520px){

  .logo{
    font-size:22px;
  }

  .hero h1{
    font-size:34px;
  }

  .section-title h2,
  .top-members h2,
  .page-section h1{
    font-size:32px;
    line-height:1.15;
  }

  

  .leaderboard-item{
    grid-template-columns:36px 52px 1fr;
    padding:14px;
  }

  .leaderboard-item img{
    width:52px;
    height:52px;
  }
}

/* ===== Leaderboard Mobile Polish ===== */
@media (max-width: 768px){

  .leaderboard-tabs{
    display:flex;
    overflow-x:auto;
    flex-wrap:nowrap;
    gap:10px;
    padding-bottom:10px;
  }

  .leaderboard-tab{
    flex:0 0 auto;
    font-size:14px;
    padding:10px 16px;
  }

  .leaderboard-search{
    max-width:100%;
  }

  .leaderboard-item{
    display:grid;
    grid-template-columns:44px 56px 1fr;
    gap:12px;
    align-items:center;
  }

  .leaderboard-rank{
    width:auto;
    font-size:22px;
  }

  .leaderboard-item img{
    width:56px;
    height:56px;
  }

  .leaderboard-item h3{
    font-size:18px;
  }

  .leaderboard-item p{
    font-size:13px;
    line-height:1.5;
  }

  .leaderboard-stats{
    grid-column:1 / -1;
    display:flex;
    flex-wrap:wrap;
    gap:12px;
    font-size:13px;
  }
}
/* ===== Header nav polish for simple pages ===== */

.main-header nav{
    display:flex;
    gap:14px;
    flex-wrap:wrap;
    align-items:center;
}

.main-header nav a{
    text-decoration:none;
    padding:8px 14px;
    border-radius:999px;
    font-weight:700;
    color:#334155;
    background:#f1f5f9;
    transition:.2s;
}

.main-header nav a:hover,
.main-header nav a.active{
    background:#2563eb;
    color:white;
}
.grade-filter{
    display:flex;
    gap:20px;
    justify-content:center;
    margin:30px 0;
    flex-wrap:wrap;
}

.grade-card{
    text-decoration:none;
    background:#ffffff;
    border-radius:16px;
    padding:20px 35px;
    box-shadow:0 6px 18px rgba(0,0,0,.08);
    color:#333;
    font-weight:700;
    transition:.25s;
    display:flex;
    flex-direction:column;
    align-items:center;
    font-size:18px;
}

.grade-card:hover{
    transform:translateY(-5px);
    box-shadow:0 12px 28px rgba(0,0,0,.15);
}
/* =========================
   HOCLIEUHUB CHAT
========================= */

.chat-body{
  margin:0;
  background:#f4f7fb;
  overflow:hidden;
}

.messenger-layout{
  display:grid;
  grid-template-columns:320px minmax(0, 1fr) 300px;
  height:100vh;
  background:#ffffff;
}

/* CỘT TRÁI */

.messenger-sidebar{
  display:flex;
  flex-direction:column;
  min-width:0;
  background:#ffffff;
  border-right:1px solid #e5e7eb;
}

.messenger-sidebar-header{
  min-height:72px;
  padding:14px 18px;
  display:flex;
  align-items:center;
  gap:14px;
  border-bottom:1px solid #e5e7eb;
}

.messenger-sidebar-header h1{
  margin:0;
  font-size:21px;
  color:#172033;
}

.messenger-sidebar-header p{
  margin:3px 0 0;
  color:#7b8494;
  font-size:13px;
}

.chat-back-btn{
  width:38px;
  height:38px;
  display:flex;
  align-items:center;
  justify-content:center;
  flex-shrink:0;
  border-radius:50%;
  color:#2563eb;
  text-decoration:none;
  font-size:23px;
  transition:0.2s;
}

.chat-back-btn:hover{
  background:#eff6ff;
}

.conversation-search{
  margin:14px;
  padding:0 13px;
  display:flex;
  align-items:center;
  gap:9px;
  background:#f1f4f8;
  border:1px solid transparent;
  border-radius:10px;
}

.conversation-search:focus-within{
  background:#ffffff;
  border-color:#93c5fd;
  box-shadow:0 0 0 3px rgba(37,99,235,0.1);
}

.conversation-search input{
  width:100%;
  padding:11px 0;
  border:none;
  outline:none;
  background:transparent;
  font:inherit;
  color:#172033;
}

.conversation-list{
  flex:1;
  min-height:0;
  padding:0 8px 14px;
  overflow-y:auto;
}

.chat-empty-state{
  padding:40px 18px;
  color:#8a94a5;
  text-align:center;
  line-height:1.6;
}
/* CỘT GIỮA */

.messenger-chat{
  min-width:0;
  display:flex;
  flex-direction:column;
  background:#f5f7fb;
}

.messenger-chat-header{
  height:72px;
  padding:0 20px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  background:#ffffff;
  border-bottom:1px solid #e5e7eb;
}

.chat-user-info{
  min-width:0;
  display:flex;
  align-items:center;
  gap:12px;
}

.chat-user-info img{
  width:44px;
  height:44px;
  border-radius:50%;
  object-fit:cover;
  background:#eef2ff;
}

.chat-user-info h2{
  margin:0;
  font-size:17px;
  color:#172033;
}

.chat-user-info p{
  margin:4px 0 0;
  font-size:13px;
  color:#7b8494;
}

.chat-header-actions{
  display:flex;
  gap:8px;
}

.chat-header-actions button{
  width:38px;
  height:38px;
  border:none;
  border-radius:50%;
  background:transparent;
  cursor:pointer;
  font-size:18px;
}

.chat-header-actions button:hover{
  background:#eff6ff;
}

.messenger-messages{
  flex:1;
  min-height:0;
  padding:24px;
  overflow-y:auto;
  background:
    linear-gradient(rgba(248,250,252,.92), rgba(248,250,252,.92)),
    url("../assets/images/logo.svg") center/140px no-repeat;
}

.chat-welcome{
  max-width:420px;
  margin:90px auto 0;
  padding:28px;
  text-align:center;
  background:rgba(255,255,255,.92);
  border:1px solid #e5e7eb;
  border-radius:18px;
  box-shadow:0 12px 35px rgba(15,23,42,.08);
}

.chat-welcome-icon{
  font-size:44px;
}

.chat-welcome h2{
  margin:12px 0 8px;
  color:#172033;
}

.chat-welcome p{
  margin:0;
  color:#6b7280;
  line-height:1.6;
}

.messenger-composer{
  padding:12px 16px;
  display:flex;
  align-items:flex-end;
  gap:10px;
  background:#ffffff;
  border-top:1px solid #e5e7eb;
}

.composer-tools{
  display:flex;
  gap:4px;
}

.composer-tools button,
.composer-input-box button{
  width:36px;
  height:36px;
  border:none;
  border-radius:50%;
  background:transparent;
  cursor:pointer;
  font-size:18px;
}

.composer-tools button:hover,
.composer-input-box button:hover{
  background:#eff6ff;
}

.composer-input-box{
  flex:1;
  min-width:0;
  padding:7px 10px 7px 14px;
  display:flex;
  align-items:flex-end;
  gap:8px;
  background:#f1f4f8;
  border:1px solid transparent;
  border-radius:18px;
}

.composer-input-box:focus-within{
  background:#ffffff;
  border-color:#93c5fd;
}

.composer-input-box textarea{
  flex:1;
  min-height:24px;
  max-height:120px;
  padding:5px 0;
  border:none;
  outline:none;
  resize:none;
  background:transparent;
  font:inherit;
  line-height:1.45;
}

.chat-send-btn{
  width:42px;
  height:42px;
  flex-shrink:0;
  border:none;
  border-radius:50%;
  background:#2563eb;
  color:#ffffff;
  cursor:pointer;
  font-size:18px;
}

.chat-send-btn:hover{
  background:#1d4ed8;
}
/* =========================
   CỘT PHẢI
========================= */

.messenger-info{
    width:300px;
    background:#fff;
    border-left:1px solid #e5e7eb;
    display:flex;
    flex-direction:column;
    overflow-y:auto;
}

.chat-info-profile{
    padding:30px 20px;
    text-align:center;
    border-bottom:1px solid #e5e7eb;
}

.chat-info-profile img{
    width:90px;
    height:90px;
    border-radius:50%;
    object-fit:cover;
    margin-bottom:14px;
    background:#eef2ff;
}

.chat-info-profile h2{
    margin:0;
    font-size:22px;
    color:#172033;
}

.chat-info-profile p{
    margin-top:8px;
    color:#6b7280;
    line-height:1.6;
}

.chat-info-actions{
    padding:20px;
    display:flex;
    flex-direction:column;
    gap:12px;
}

.chat-info-actions button{
    width:100%;
    padding:13px;
    border:none;
    border-radius:12px;
    background:#f3f4f6;
    cursor:pointer;
    transition:.2s;
    text-align:left;
    font-size:15px;
}

.chat-info-actions button:hover{
    background:#2563eb;
    color:white;
}

.chat-shared-section{
    padding:20px;
    border-top:1px solid #e5e7eb;
}

.chat-shared-section h3{
    margin-bottom:14px;
    color:#172033;
}

.chat-shared-section button{
    width:100%;
    margin-bottom:10px;
    padding:12px;
    border:none;
    border-radius:10px;
    background:#eef2ff;
    cursor:pointer;
    transition:.2s;
}

.chat-shared-section button:hover{
    background:#dbeafe;
}

/* =========================
   RESPONSIVE
========================= */

@media(max-width:1200px){

.messenger-layout{
grid-template-columns:280px 1fr;
}

.messenger-info{
display:none;
}

}

@media(max-width:768px){

.messenger-layout{
grid-template-columns:1fr;
}

.messenger-sidebar{
display:none;
}

}
.message-row{
  display:flex;
  margin-bottom:10px;
}

.message-row.mine{
  justify-content:flex-end;
}

.message-row.theirs{
  justify-content:flex-start;
}

.message-bubble{
  max-width:70%;
  padding:10px 14px;
  border-radius:16px;
  line-height:1.5;
  word-break:break-word;
}

.message-row.mine .message-bubble{
  background:#2563eb;
  color:#fff;
  border-bottom-right-radius:5px;
}

.message-row.theirs .message-bubble{
  background:#fff;
  color:#172033;
  border:1px solid #e5e7eb;
  border-bottom-left-radius:5px;
}
.conversation-item{
  display:flex;
  align-items:center;
  gap:12px;
  padding:12px;
  margin-bottom:4px;
  border-radius:12px;
  color:#172033;
  text-decoration:none;
  transition:.2s;
}

.conversation-item:hover{
  background:#eff6ff;
}

.conversation-item img{
  width:48px;
  height:48px;
  flex-shrink:0;
  border-radius:50%;
  object-fit:cover;
  background:#eef2ff;
}

.conversation-content{
  min-width:0;
  flex:1;
}

.conversation-top{
  display:flex;
  justify-content:space-between;
  gap:8px;
}

.conversation-content strong{
  display:block;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.conversation-content p{
  margin:5px 0 0;
  color:#7b8494;
  font-size:13px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.mobile-chat-back{
  display:none;
  width:38px;
  height:38px;
  flex-shrink:0;
  border:none;
  border-radius:50%;
  background:transparent;
  color:#2563eb;
  cursor:pointer;
  font-size:24px;
}

.mobile-chat-back:hover{
  background:#eff6ff;
}

@media(max-width:768px){
  .chat-body{
    overflow:hidden;
  }

  .messenger-layout{
    display:block;
    height:100dvh;
  }

  .messenger-sidebar,
  .messenger-chat{
    width:100%;
    height:100dvh;
  }

  .messenger-info{
    display:none;
  }

  .messenger-sidebar{
    display:flex;
  }

  .messenger-chat{
    display:none;
  }

  .chat-body.mobile-chat-open .messenger-sidebar{
    display:none;
  }

  .chat-body.mobile-chat-open .messenger-chat{
    display:flex;
  }

  .mobile-chat-back{
    display:flex;
    align-items:center;
    justify-content:center;
  }

  .messenger-chat-header{
    padding:0 10px;
  }

  .messenger-composer{
    padding:10px;
  }

  .composer-tools{
    display:none;
  }

  .message-bubble{
    max-width:82%;
  }
}


/* ===== FIX PUBLIC PROFILE MOBILE ===== */


/* ===== FINAL PUBLIC PROFILE MOBILE FIX ===== */
.message-seen{
    margin-top:4px;
    font-size:12px;
    color:#64748b;
    text-align:right;
    padding-right:10px;
}
/* ===== CHAT FIX: CHỈ CUỘN KHU VỰC TIN NHẮN ===== */
body.chat-body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

.chat-body .messenger-layout {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

/* Cột danh sách bên trái */
.chat-body .messenger-sidebar{
    display:flex;
    flex-direction:column;
    height:100%;
    min-height:0;
    overflow:hidden;
}

.chat-body .messenger-sidebar-header{
    flex:0 0 auto;
}

.chat-body .conversation-search{
    flex:0 0 auto;
}

.chat-body .conversation-list{
    flex:1 1 auto;
    min-height:0;
    overflow-y:auto;
    overflow-x:hidden;
}

/* Cột chat chính */
.chat-body .messenger-chat {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Phần đầu luôn cố định */
.chat-body .messenger-chat-header {
  flex: 0 0 auto;
  position: relative;
  z-index: 5;
}

/* Chỉ vùng tin nhắn được cuộn */
.chat-body .messenger-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

/* Thanh nhập luôn nằm dưới */
.chat-body .messenger-composer {
  flex: 0 0 auto;
  position: relative;
  z-index: 10;
  background: #ffffff;
}

/* Điện thoại */
@media (max-width: 768px) {
  body.chat-body {
    width: 100%;
    height: 100%;
    overflow: hidden;
  }

  .chat-body .messenger-layout {
    width: 100%;
    height: var(--chat-viewport-height, 100dvh);
    min-height: 0;
    max-height: var(--chat-viewport-height, 100dvh);
    overflow: hidden;
  }

  .chat-body .messenger-chat {
    height: 100%;
    min-height: 0;
  }

  .chat-body .messenger-messages {
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .chat-body .messenger-composer {
    flex: 0 0 auto;
    flex-shrink: 0;
  }
}
/* Cho phép các trang thường cuộn dọc trên điện thoại */
@media (max-width: 1000px) {
  body:not(.chat-body) {
    height: auto !important;
    min-height: 100vh !important;
    overflow-y: auto !important;
    position: static !important;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
  }
}
/* ===== KHÔI PHỤC CUỘN TRANG THƯỜNG TRÊN ĐIỆN THOẠI ===== */
@media (max-width: 1000px) {
  html {
    height: auto !important;
    min-height: 100% !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    touch-action: pan-y !important;
  }

  body:not(.chat-body) {
    height: auto !important;
    min-height: 100vh !important;
    max-height: none !important;
    overflow: visible !important;
    position: static !important;
    touch-action: pan-y !important;
  }
}
/* ===== CHAT IMAGE PREVIEW ===== */

.chat-image-preview {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;

  padding: 10px 14px;
  background: #ffffff;
  border-top: 1px solid #e5e7eb;
}

.chat-image-preview[hidden] {
  display: none !important;
}

.chat-image-preview img {
  display: block;
  width: 88px;
  height: 88px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid #e5e7eb;
}

.chat-image-preview button {
  position: absolute;
  top: 5px;
  left: 92px;

  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;

  background: #111827;
  color: #ffffff;
  font-size: 15px;
  cursor: pointer;
}

@media (max-width: 768px) {
  .chat-image-preview {
    padding: 8px 12px;
  }

  .chat-image-preview img {
    width: 72px;
    height: 72px;
    border-radius: 12px;
  }

  .chat-image-preview button {
    left: 72px;
  }
}
.chat-message-image {
  display: block;
  width: min(280px, 65vw);
  max-height: 360px;
  object-fit: cover;
  border-radius: 14px;
  cursor: pointer;
}

.message-row.mine .message-bubble:has(.chat-message-image),
.message-row.theirs .message-bubble:has(.chat-message-image) {
  padding: 0;
  background: transparent;
}
.chat-image-lightbox{
    position:fixed;
    inset:0;
    background:rgba(0,0,0,.85);
    display:flex;
    justify-content:center;
    align-items:center;
    z-index:99999;
}

.chat-image-lightbox[hidden]{
    display:none;
}

.chat-image-lightbox img{
    width:auto;
    height:auto;
    max-width:90vw;
    max-height:90vh;
    object-fit:contain;
    border-radius:12px;
    box-shadow:0 15px 40px rgba(0,0,0,.5);
}


.chat-lightbox-close{
    position:absolute;
    top:20px;
    right:20px;
    width:42px;
    height:42px;
    border:none;
    border-radius:50%;
    background:#fff;
    cursor:pointer;
    font-size:22px;
    font-weight:bold;
}

body.lightbox-open{
    overflow:hidden;
}
/* Lightbox trên điện thoại */
@media (max-width: 768px) {
  .chat-image-lightbox {
    padding: 16px;
  }

  .chat-image-lightbox img {
    width: auto;
    height: auto;
    max-width: calc(100vw - 24px);
    max-height: calc(100dvh - 80px);
    border-radius: 10px;
    object-fit: contain;
  }

  .chat-lightbox-close {
    position: fixed;
    top: 14px;
    right: 14px;

    width: 40px;
    height: 40px;

    font-size: 20px;
    z-index: 100000;
  }
}

/* ===== CHAT FINAL FIX: PREVIEW + BỐ CỤC ===== */

.chat-body .chat-file-preview {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  padding: 9px 16px;
  background: #eef5ff;
  border-top: 1px solid #cfe0ff;
}

.chat-body .chat-file-preview[hidden] {
  display: none !important;
}

.chat-body #filePreviewName {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #1e3a8a;
  font-size: 14px;
  font-weight: 600;
}

.chat-body #removeFileBtn {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #475569;
  cursor: pointer;
  font-size: 18px;
}

.chat-body #removeFileBtn:hover {
  background: #dbeafe;
}

.chat-body .messenger-composer {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  min-height: 66px;
  padding: 12px 16px;
}

.chat-body .composer-tools {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

/* Giữ cột thông tin ở màn hình laptop; chỉ ẩn khi thật sự hẹp. */
@media (min-width: 981px) {
  .chat-body .messenger-layout {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr) 280px;
  }

  .chat-body .messenger-info {
    display: flex;
    width: auto;
    min-width: 0;
  }
}

@media (min-width: 769px) and (max-width: 980px) {
  .chat-body .messenger-layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .chat-body .messenger-info {
    display: none;
  }
}

@media (max-width: 768px) {
  .chat-body .messenger-composer {
    min-height: 60px;
    padding: 9px 10px;
    gap: 6px;
  }

  .chat-body .composer-tools {
    display: flex;
    gap: 2px;
  }

  .chat-body .composer-tools button,
  .chat-body .composer-input-box button {
    width: 34px;
    height: 34px;
  }

  .chat-body .chat-file-preview {
    padding: 8px 12px;
  }
}
/* ===========================
   Shared Files Modal
=========================== */

.shared-files-modal {
  position: fixed;
  inset: 0;

  display: flex;
  justify-content: center;
  align-items: center;

  background: rgba(0, 0, 0, 0.45);

  z-index: 12000;
}

.shared-files-modal[hidden] {
  display: none;
}

.shared-files-panel {
  width: min(700px, 92vw);
  max-height: 75vh;

  display: flex;
  flex-direction: column;

  background: #fff;
  border-radius: 18px;

  overflow: hidden;

  box-shadow: 0 18px 40px rgba(0,0,0,.25);
}

.shared-files-header {
  display: flex;
  justify-content: space-between;
  align-items: center;

  padding: 18px 22px;

  border-bottom: 1px solid #ececec;
}

.shared-files-header h2 {
  margin: 0;
  font-size: 20px;
}

.shared-files-header button {
  border: none;
  background: none;
  cursor: pointer;

  font-size: 24px;
}

.shared-files-list {
  overflow-y: auto;
  padding: 18px;
}

.shared-files-empty {
  text-align: center;
  color: #777;
  padding: 40px 0;
}
.shared-file-item {
  display: flex;
  align-items: center;
  gap: 14px;

  padding: 14px 16px;
  margin-bottom: 10px;

  color: #222;
  text-decoration: none;

  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 12px;

  transition:
    background 0.2s ease,
    transform 0.2s ease,
    border-color 0.2s ease;
}

.shared-file-item:hover {
  background: #eef5ff;
  border-color: #b7d2ff;
  transform: translateY(-1px);
}

.shared-file-icon {
  flex: 0 0 auto;

  width: 42px;
  height: 42px;

  display: grid;
  place-items: center;

  font-size: 24px;

  background: #e8f1ff;
  border-radius: 10px;
}

.shared-file-info {
  min-width: 0;

  display: flex;
  flex-direction: column;
  gap: 4px;
}

.shared-file-info strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;

  font-size: 15px;
}

.shared-file-info small {
  color: #6b7280;
  font-size: 13px;
}
/* ===========================
   Mobile Chat Info Screen
=========================== */

.mobile-info-back {
  display: none;
}

@media (max-width: 768px) {
  .messenger-info {
    position: fixed;
    inset: 0;
    z-index: 10000;

    width: 100%;
    height: var(--chat-viewport-height, 100dvh);

    display: flex;
    flex-direction: column;

    background: #ffffff;

    transform: translateX(100%);
    transition: transform 0.25s ease;
  }

  body.mobile-info-open .messenger-info {
    transform: translateX(0);
  }

  .mobile-info-back {
    display: flex;
    align-items: center;
    justify-content: center;

    position: absolute;
    top: 14px;
    left: 14px;

    width: 40px;
    height: 40px;

    border: none;
    border-radius: 50%;
    background: #f1f5f9;

    font-size: 24px;
    cursor: pointer;

    z-index: 2;
  }

  body.mobile-info-open {
    overflow: hidden;
  }
}
#sharedImagesList {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.shared-image-item {
  aspect-ratio: 1;
  padding: 0;

  border: none;
  border-radius: 12px;
  overflow: hidden;

  background: #eef2f7;
  cursor: pointer;
}

.shared-image-item img {
  width: 100%;
  height: 100%;

  display: block;
  object-fit: cover;
}

@media (max-width: 480px) {
  #sharedImagesList {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
.chat-image-lightbox {
  z-index: 13000;
}
/* =========================
   HEADER ACTIONS
   Chat và Notification
========================= */

.header-action-link{
    position:relative;
    display:flex;
    align-items:center;
    justify-content:center;

    width:42px;
    height:42px;

    border-radius:50%;
    background:#eff6ff;
    border:1px solid #dbeafe;

    color:#2563eb;
    font-size:20px;
    text-decoration:none;

    flex-shrink:0;
    transition:
        background-color .2s ease,
        transform .2s ease,
        box-shadow .2s ease;
}

.header-action-link:hover{
    background:#dbeafe;
    transform:translateY(-2px);
    box-shadow:0 6px 16px rgba(37, 99, 235, .16);
}

.header-action-link:active{
    transform:scale(.94);
}

.header-action-link:focus-visible{
    outline:3px solid rgba(59, 130, 246, .28);
    outline-offset:2px;
}
.header-action-link{
    position:relative;
    display:flex;
    align-items:center;
    justify-content:center;

    width:42px;
    height:42px;

    border-radius:50%;
    background:#eff6ff;
    border:1px solid #dbeafe;

    color:#2563eb;
    font-size:20px;
    text-decoration:none;

    flex-shrink:0;
    transition:
        background-color .2s ease,
        transform .2s ease,
        box-shadow .2s ease;
}

.notification-count{
    position:absolute;
    top:-5px;
    right:-7px;

    display:flex;
    align-items:center;
    justify-content:center;

    min-width:20px;
    height:20px;
    padding:0 5px;

    border:2px solid #ffffff;
    border-radius:999px;

    background:#ef4444;
    color:#ffffff;

    font-size:11px;
    font-weight:700;
    line-height:1;

    pointer-events:none;
}

.notification-count[hidden]{
    display:none;
}

/* ===== COMPACT DESKTOP NAVBAR - PROFILE ===== */
.compact-navbar{
  min-height:78px;
  height:78px;
  padding:0 clamp(24px, 6vw, 96px);
  display:grid;
  grid-template-columns:auto minmax(300px, 680px) auto;
  gap:clamp(20px, 3vw, 48px);
  position:sticky;
  overflow:visible;
}

.compact-logo{white-space:nowrap;}

.compact-search{
  width:100%;
  height:50px;
  display:flex;
  align-items:center;
  gap:12px;
  padding:0 14px 0 18px;
  border:1px solid #cfe0f7;
  border-radius:999px;
  background:#f8fbff;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.8);
}

.compact-search:focus-within{
  border-color:#60a5fa;
  box-shadow:0 0 0 4px rgba(37,99,235,.10);
  background:#fff;
}

.compact-search-icon{font-size:27px;line-height:1;color:#0f172a;transform:rotate(-20deg);}
.compact-search input{
  min-width:0;
  flex:1;
  border:0;
  outline:0;
  background:transparent;
  color:#17233b;
  font-size:16px;
  font-weight:600;
}
.compact-search input::placeholder{color:#64748b;font-weight:600;}
.compact-search-shortcut{
  flex:0 0 auto;
  padding:5px 9px;
  border:1px solid #cbd5e1;
  border-radius:8px;
  background:#fff;
  color:#64748b;
  font-size:12px;
  font-weight:800;
}

.compact-actions{display:flex;align-items:center;justify-content:flex-end;gap:14px;min-width:max-content;}
.compact-navbar [data-user-area]{width:auto;}
.compact-navbar .user-mini{width:auto;flex-wrap:nowrap;gap:10px;}
.compact-navbar .header-action-link{
  width:44px;height:44px;display:grid;place-items:center;
  border:1px solid #dbeafe;border-radius:50%;background:#f3f8ff;
  text-decoration:none;font-size:19px;transition:.2s;
}
.compact-navbar .header-action-link:hover{transform:translateY(-1px);background:#e8f1ff;border-color:#93c5fd;}
.compact-navbar .profile-link{display:flex;align-items:center;gap:9px;text-decoration:none;font-weight:800;white-space:nowrap;}
.compact-navbar .profile-link img{width:44px;height:44px;border:3px solid #2563eb;object-fit:cover;}
.compact-navbar .user-mini > button[data-logout]{display:none;}

.compact-menu-toggle{
  width:48px;height:48px;display:flex!important;flex-direction:column;
  align-items:center;justify-content:center;gap:5px;
  border:2px solid #2563eb;border-radius:16px;background:#fff;
  color:#1d4ed8;transition:.2s;
}
.compact-menu-toggle:hover{background:#eff6ff;transform:translateY(-1px);}
.compact-menu-toggle span{display:block;width:20px;height:2px;border-radius:999px;background:currentColor;}

.compact-nav-menu{
  position:absolute;
  top:calc(100% - 2px);
  right:clamp(24px, 6vw, 96px);
  width:270px;
  max-height:min(74vh, 690px);
  padding:14px;
  display:flex;
  flex-direction:column;
  gap:3px;
  overflow-y:auto;
  visibility:hidden;
  opacity:0;
  transform:translateY(-8px) scale(.98);
  transform-origin:top right;
  pointer-events:none;
  border:1px solid #dbeafe;
  border-radius:22px;
  background:rgba(255,255,255,.98);
  box-shadow:0 24px 60px rgba(15,23,42,.18);
  backdrop-filter:blur(18px);
  transition:opacity .18s ease,transform .18s ease,visibility .18s ease;
  z-index:1000;
}
.compact-nav-menu.active{visibility:visible;opacity:1;transform:none;pointer-events:auto;}
.compact-nav-menu a,.compact-nav-menu button{
  width:100%;min-height:42px;padding:10px 12px;
  display:flex;align-items:center;gap:12px;
  border:0;border-radius:11px;background:transparent;
  color:#24324a;text-decoration:none;text-align:left;
  font:700 15px/1.25 Arial,sans-serif;cursor:pointer;
}
.compact-nav-menu a span,.compact-nav-menu button span{width:22px;text-align:center;font-size:17px;}
.compact-nav-menu a:hover,.compact-nav-menu button:hover,.compact-nav-menu .compact-nav-highlight{background:#eaf2ff;color:#1d4ed8;}
.compact-nav-divider{height:1px;margin:8px 2px;background:#e2e8f0;}
.compact-nav-label{padding:2px 12px 4px;color:#94a3b8;font-size:11px;font-weight:900;letter-spacing:.09em;text-transform:uppercase;}
.compact-logout{color:#dc2626!important;}
.compact-logout:hover{background:#fff1f2!important;color:#b91c1c!important;}

@media (max-width:1100px){
  .compact-navbar{grid-template-columns:auto 1fr auto;padding:0 24px;gap:18px;}
  .compact-nav-menu{right:24px;}
  .compact-navbar .profile-link span{display:none;}
}

@media (max-width:760px){
  .compact-navbar{
    min-height:70px;height:auto;padding:11px 16px;
    display:grid;grid-template-columns:auto 1fr auto;gap:10px;
  }
  .compact-logo span{font-size:21px;}
  .compact-logo img{width:40px;height:40px;}
  .compact-search{grid-column:1/-1;grid-row:2;height:44px;}
  .compact-search-shortcut{display:none;}
  .compact-actions{grid-column:3;grid-row:1;gap:8px;}
  .compact-navbar [data-user-area] .header-action-link{display:none;}
  .compact-navbar .profile-link{display:none;}
  .compact-navbar .login-btn{padding:9px 12px;font-size:12px;}
  .compact-menu-toggle{width:43px;height:43px;border-radius:14px;}
  .compact-nav-menu{
    position:fixed;top:0;right:0;width:min(86vw,340px);height:100dvh;max-height:none;
    padding:82px 18px 24px;border-radius:0;border-top:0;border-right:0;
    transform:translateX(100%);transform-origin:right center;
  }
  .compact-nav-menu.active{transform:none;}
  body:has(.compact-nav-menu.active)::before{
    content:"";position:fixed;inset:0;background:rgba(15,23,42,.42);z-index:900;
  }
  .compact-menu-toggle{position:relative;z-index:1100;}
}


/* ===== Upload thumbnail system (V0.91 - 1.1) ===== */
.optional-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.thumbnail-uploader {
  display: grid;
  grid-template-columns: minmax(160px, 220px) 1fr;
  gap: 20px;
  align-items: center;
  padding: 18px;
  border: 1px dashed var(--border);
  border-radius: 18px;
  background: #f8fbff;
}

.thumbnail-preview-wrap {
  overflow: hidden;
  width: 100%;
  aspect-ratio: 16 / 10;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
}

.thumbnail-preview {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumbnail-controls {
  display: grid;
  gap: 10px;
}

.thumbnail-controls input[type="file"] {
  width: 100%;
  background: #fff;
}

.field-help {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.form-card .thumbnail-remove {
  justify-self: start;
  width: auto;
  padding: 10px 14px;
}

#uploadStatus {
  min-height: 22px;
  margin: 0;
  font-weight: 700;
}

#uploadStatus.is-error {
  color: #dc2626;
}

.form-card button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

@media (max-width: 640px) {
  .thumbnail-uploader {
    grid-template-columns: 1fr;
  }

  .thumbnail-preview-wrap {
    max-width: 320px;
  }
}

/* ===== Document cards V0.91 - 1.2 ===== */
.doc-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  align-items: stretch;
}

.doc-card {
  display: flex;
  min-width: 0;
  overflow: hidden;
  padding: 0;
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 12px 35px rgba(15, 23, 42, 0.08);
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}

.doc-card:hover {
  transform: translateY(-6px);
  border-color: #bfdbfe;
  box-shadow: 0 20px 44px rgba(37, 99, 235, 0.14);
}

.doc-thumbnail-link {
  position: relative;
  display: block;
  flex: 0 0 42%;
  min-height: 250px;
  overflow: hidden;
  background: #eef4ff;
}

.doc-thumbnail {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.35s ease;
}

.doc-card:hover .doc-thumbnail {
  transform: scale(1.045);
}

.doc-thumbnail-overlay {
  position: absolute;
  inset: auto 12px 12px;
  padding: 9px 12px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.76);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  opacity: 0;
  transform: translateY(6px);
  backdrop-filter: blur(7px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.doc-card:hover .doc-thumbnail-overlay,
.doc-thumbnail-link:focus-visible .doc-thumbnail-overlay {
  opacity: 1;
  transform: translateY(0);
}

.doc-card-body {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-direction: column;
  padding: 22px;
}

.doc-card .doc-header {
  margin-bottom: 12px;
}

.doc-card .doc-subject {
  max-width: 65%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.doc-card .doc-title {
  margin: 0 0 10px;
  font-size: 20px;
  line-height: 1.38;
}

.doc-card .doc-title a {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text);
  text-decoration: none;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.doc-card .doc-title a:hover {
  color: var(--blue);
}

.doc-card .doc-description {
  display: -webkit-box;
  overflow: hidden;
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.6;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.doc-card .doc-meta {
  gap: 8px;
  margin-bottom: 16px;
}

.doc-card .doc-meta span {
  padding: 7px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
  color: #475569;
  font-size: 13px;
  font-weight: 700;
}

.doc-card-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid #edf2f7;
}

.doc-card .doc-stats {
  justify-content: flex-start;
  margin-bottom: 12px;
  color: #64748b;
  font-size: 14px;
  font-weight: 700;
}

.doc-card .doc-buttons {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 0;
}

.doc-card .detail-btn,
.doc-card .download-btn {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
}

.doc-card .download-btn.is-disabled {
  pointer-events: none;
  opacity: 0.55;
}

@media (max-width: 1080px) {
  .doc-card {
    flex-direction: column;
  }

  .doc-thumbnail-link {
    flex-basis: auto;
    min-height: 0;
    aspect-ratio: 16 / 10;
  }
}

@media (max-width: 640px) {
  .subjects,
  .documents,
  .page-section {
    padding-right: 16px;
    padding-left: 16px;
  }

  .doc-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .doc-card {
    border-radius: 20px;
  }

  .doc-card-body {
    padding: 18px;
  }

  .doc-thumbnail-overlay {
    opacity: 1;
    transform: none;
  }
}


/* ===== Shared UI feedback V0.91 - 1.3 ===== */
.app-toast-region {
  position: fixed;
  z-index: 10050;
  top: 18px;
  right: 18px;
  display: grid;
  width: min(390px, calc(100vw - 32px));
  gap: 12px;
  pointer-events: none;
}

.app-toast {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 30px;
  align-items: start;
  gap: 11px;
  padding: 14px;
  border: 1px solid #dbe5f2;
  border-left-width: 5px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.18);
  opacity: 0;
  pointer-events: auto;
  transform: translateX(24px) scale(0.98);
  backdrop-filter: blur(12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.app-toast.is-visible { opacity: 1; transform: translateX(0) scale(1); }
.app-toast.is-leaving { opacity: 0; transform: translateX(24px) scale(0.98); }
.app-toast--success { border-left-color: #16a34a; }
.app-toast--error { border-left-color: #dc2626; }
.app-toast--warning { border-left-color: #d97706; }
.app-toast--info { border-left-color: #2563eb; }

.app-toast-icon {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 50%;
  background: #eff6ff;
  color: #2563eb;
  font-weight: 900;
}
.app-toast--success .app-toast-icon { background: #ecfdf3; color: #15803d; }
.app-toast--error .app-toast-icon { background: #fef2f2; color: #b91c1c; }
.app-toast--warning .app-toast-icon { background: #fffbeb; color: #b45309; }
.app-toast-content { min-width: 0; }
.app-toast-content strong { display: block; margin: 1px 0 3px; color: #0f172a; font-size: 14px; }
.app-toast-content p { margin: 0; color: #475569; font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.app-toast-close {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #64748b;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.app-toast-close:hover { background: #f1f5f9; color: #0f172a; }

.app-loading-overlay {
  position: fixed;
  z-index: 10040;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.36);
  opacity: 0;
  backdrop-filter: blur(4px);
  transition: opacity 0.2s ease;
}
.app-loading-overlay[hidden] { display: none; }
.app-loading-overlay.is-visible { opacity: 1; }
.app-loading-card {
  display: grid;
  min-width: min(280px, 90vw);
  justify-items: center;
  gap: 14px;
  padding: 26px 28px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24);
}
.app-loading-card p { margin: 0; color: #334155; font-weight: 800; text-align: center; }
.app-spinner {
  width: 42px;
  height: 42px;
  border: 4px solid #dbeafe;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: app-spin 0.75s linear infinite;
}
.has-app-loading { overflow: hidden; }
@keyframes app-spin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  .app-toast-region { top: 12px; right: 12px; width: calc(100vw - 24px); }
  .app-toast { grid-template-columns: 34px minmax(0, 1fr) 28px; padding: 12px; border-radius: 14px; }
  .app-toast-icon { width: 32px; height: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  .app-toast, .app-loading-overlay, .app-spinner { transition: none; animation-duration: 1.5s; }
}

/* ===== Motion & micro-interactions V0.91 - 1.4 ===== */
:root {
  --motion-fast: 160ms;
  --motion-base: 260ms;
  --motion-slow: 520ms;
  --motion-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --motion-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

.motion-enabled .motion-reveal {
  opacity: 0;
  transform: translate3d(0, 20px, 0) scale(0.985);
  transition:
    opacity var(--motion-slow) var(--motion-ease) var(--motion-delay, 0ms),
    transform var(--motion-slow) var(--motion-ease) var(--motion-delay, 0ms);
  will-change: opacity, transform;
}

.motion-enabled .motion-reveal.is-revealed {
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
  will-change: auto;
}

/* Cards: lift, depth and image response */
.doc-card,
.subject-card,
.top-member-card,
.stat-card,
.achievement-card,
.mission-card,
.leaderboard-card,
.profile-card,
.dashboard-card {
  transition:
    transform var(--motion-base) var(--motion-ease),
    box-shadow var(--motion-base) ease,
    border-color var(--motion-base) ease,
    background-color var(--motion-base) ease;
}

@media (hover: hover) and (pointer: fine) {
  .doc-card:hover,
  .subject-card:hover,
  .top-member-card:hover,
  .stat-card:hover,
  .achievement-card:hover,
  .mission-card:hover,
  .leaderboard-card:hover,
  .profile-card:hover,
  .dashboard-card:hover {
    transform: translateY(-6px);
    border-color: rgba(37, 99, 235, 0.24);
    box-shadow: 0 20px 44px rgba(15, 23, 42, 0.13);
  }

  .doc-card:hover .doc-thumbnail {
    transform: scale(1.045);
  }

  .subject-card:hover .subject-icon,
  .top-member-card:hover img {
    transform: translateY(-2px) scale(1.055);
  }
}

.doc-thumbnail,
.subject-icon,
.top-member-card img {
  transition: transform var(--motion-slow) var(--motion-ease), filter var(--motion-base) ease;
}

/* Buttons and links */
button,
.btn-primary,
.btn-secondary,
.detail-btn,
.download-btn,
.search-btn,
.nav-login-btn {
  transition:
    transform var(--motion-fast) var(--motion-ease),
    box-shadow var(--motion-base) ease,
    filter var(--motion-fast) ease,
    background-color var(--motion-fast) ease,
    border-color var(--motion-fast) ease,
    color var(--motion-fast) ease;
}

@media (hover: hover) and (pointer: fine) {
  button:not(:disabled):hover,
  .btn-primary:hover,
  .btn-secondary:hover,
  .detail-btn:hover,
  .download-btn:not(.is-disabled):hover,
  .search-btn:hover,
  .nav-login-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.025);
  }
}

button:not(:disabled):active,
.btn-primary:active,
.btn-secondary:active,
.detail-btn:active,
.download-btn:not(.is-disabled):active,
.search-btn:active,
.nav-login-btn:active,
.motion-pressed {
  transform: translateY(0) scale(0.975) !important;
}

/* Ripple */
.motion-ripple-host {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.motion-ripple-wave {
  position: absolute;
  z-index: -1;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.18;
  pointer-events: none;
  transform: scale(0);
  animation: motion-ripple 620ms var(--motion-ease) forwards;
}

@keyframes motion-ripple {
  55% { opacity: 0.13; }
  100% { opacity: 0; transform: scale(1); }
}

/* Navbar underline */
.nav-links a,
.compact-nav a,
.nav-menu a {
  position: relative;
}

.nav-links a::after,
.compact-nav a::after,
.nav-menu a::after {
  position: absolute;
  right: 50%;
  bottom: -5px;
  left: 50%;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  content: "";
  opacity: 0;
  transition: right var(--motion-base) var(--motion-ease), left var(--motion-base) var(--motion-ease), opacity var(--motion-fast) ease;
}

.nav-links a:hover::after,
.nav-links a.active::after,
.compact-nav a:hover::after,
.compact-nav a.active::after,
.nav-menu a:hover::after,
.nav-menu a.active::after {
  right: 12%;
  left: 12%;
  opacity: 0.65;
}

/* Focus feedback remains accessible */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.28);
  outline-offset: 3px;
  transition: outline-offset var(--motion-fast) ease;
}

/* Modal and dropdown entrance */
.modal:not([hidden]),
.dropdown-menu:not([hidden]),
.user-menu:not([hidden]) {
  animation: motion-pop-in 220ms var(--motion-spring) both;
}

@keyframes motion-pop-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 640px) {
  .motion-enabled .motion-reveal {
    transform: translate3d(0, 12px, 0);
  }

  .doc-card:hover,
  .subject-card:hover,
  .top-member-card:hover {
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
  }

  .motion-enabled .motion-reveal,
  .motion-enabled .motion-reveal.is-revealed {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .motion-ripple-wave {
    display: none;
  }

  .doc-card,
  .subject-card,
  .top-member-card,
  .stat-card,
  .achievement-card,
  .mission-card,
  .leaderboard-card,
  .profile-card,
  .dashboard-card,
  button,
  .btn-primary,
  .btn-secondary,
  .detail-btn,
  .download-btn,
  .search-btn,
  .nav-login-btn,
  .doc-thumbnail,
  .subject-icon,
  .top-member-card img {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}


/* =========================================================
   V0.91 / 1.5 — Global UI polish & responsive consistency
   ========================================================= */
:root {
  --blue-soft: #eff6ff;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --border-soft: #e2e8f0;
  --text-soft: #475569;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 28px;
  --shadow-sm: 0 8px 24px rgba(15, 23, 42, .06);
  --shadow-md: 0 16px 40px rgba(15, 23, 42, .10);
  --shadow-lg: 0 26px 70px rgba(15, 23, 42, .14);
  --content-max: 1240px;
  --page-gutter: clamp(16px, 4vw, 64px);
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  line-height: 1.6;
  overflow-x: hidden;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

img,
svg,
video,
canvas {
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
[role="button"],
input[type="submit"],
input[type="button"] {
  -webkit-tap-highlight-color: transparent;
}

::selection {
  background: rgba(37, 99, 235, .18);
  color: var(--text);
}

/* Shared page widths */
main,
.container,
.page-container,
.content-container,
.dashboard-container,
.profile-container,
.explore-container,
.search-container,
.curriculum-container,
.leaderboard-container {
  max-width: var(--content-max);
  margin-inline: auto;
}

section {
  scroll-margin-top: 96px;
}

/* Navbar consistency */
.navbar {
  min-height: 72px;
  height: auto;
  padding: 12px var(--page-gutter);
  gap: 20px;
  box-shadow: 0 1px 0 rgba(148, 163, 184, .12);
}

.logo {
  flex: 0 0 auto;
}

.logo img {
  object-fit: cover;
}

.nav-links {
  align-items: center;
  flex-wrap: wrap;
  row-gap: 8px;
}

.nav-links a {
  position: relative;
  padding: 8px 0;
  transition: color .2s ease;
}

.nav-links a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 2px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: center;
  transition: transform .2s ease;
}

.nav-links a:hover::after,
.nav-links a.active::after {
  transform: scaleX(1);
}

/* Typography rhythm */
h1,
h2,
h3,
h4 {
  line-height: 1.18;
  text-wrap: balance;
}

p,
li,
label,
small {
  color: inherit;
}

.hero,
.section,
.documents,
.subjects,
.features,
.latest-documents {
  padding-left: var(--page-gutter);
  padding-right: var(--page-gutter);
}

.hero h1 {
  font-size: clamp(2.35rem, 5.5vw, 3.75rem);
  letter-spacing: clamp(-1.8px, -0.04em, -1px);
}

.hero p {
  max-width: 62ch;
  color: var(--text-soft);
}

/* Inputs and controls */
input,
select,
textarea {
  min-height: 46px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  background: var(--surface);
  color: var(--text);
  transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #bfdbfe;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .12);
  outline: none;
}

input::placeholder,
textarea::placeholder {
  color: #94a3b8;
}

/* Unified buttons */
button,
.btn,
.btn-primary,
.btn-secondary,
.login-btn,
.search-btn,
.detail-btn,
.download-btn,
.upload-btn,
.nav-login-btn {
  min-height: 44px;
  border-radius: 999px;
  font-weight: 800;
  letter-spacing: -.01em;
}

button:disabled,
.btn:disabled,
[aria-disabled="true"] {
  opacity: .58;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* Shared card polish */
.doc-card,
.subject-card,
.stat-card,
.profile-card,
.dashboard-card,
.achievement-card,
.mission-card,
.leaderboard-card,
.top-member-card,
.card,
.panel {
  border: 1px solid rgba(226, 232, 240, .9);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, .96);
  box-shadow: var(--shadow-sm);
}

.doc-card:hover,
.subject-card:hover,
.stat-card:hover,
.achievement-card:hover,
.mission-card:hover,
.leaderboard-card:hover,
.top-member-card:hover {
  box-shadow: var(--shadow-md);
  border-color: rgba(147, 197, 253, .85);
}

.doc-card,
.subject-card,
.stat-card,
.achievement-card,
.mission-card,
.leaderboard-card,
.top-member-card {
  min-width: 0;
}

.doc-title,
.card-title,
.subject-card h3,
.doc-card h3 {
  overflow-wrap: anywhere;
}

/* Grid consistency */
.document-grid,
.documents-grid,
.doc-grid,
.subject-grid,
.subjects-grid,
.cards-grid,
.stats-grid,
.achievement-grid,
.mission-grid {
  gap: clamp(16px, 2vw, 24px);
}

/* Tables stay usable on mobile */
.table-wrapper,
.table-responsive,
.leaderboard-table-wrapper {
  width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  border-radius: var(--radius-md);
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  vertical-align: middle;
}

/* Modals */
.modal-content,
.dialog,
.auth-modal-content {
  width: min(92vw, 560px);
  max-height: min(88vh, 760px);
  overflow-y: auto;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
}

/* Footer */
footer,
.footer {
  margin-top: clamp(48px, 8vw, 96px);
}

/* Tablet */
@media (max-width: 960px) {
  .navbar {
    padding-inline: 20px;
  }

  .nav-links {
    gap: 14px;
    font-size: 14px;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 30px;
    padding-top: 52px;
    padding-bottom: 52px;
    text-align: center;
  }

  .hero > * {
    min-width: 0;
  }

  .hero p,
  .hero-actions,
  .search-box {
    margin-inline: auto;
  }

  .document-grid,
  .documents-grid,
  .doc-grid,
  .subject-grid,
  .subjects-grid,
  .cards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Mobile */
@media (max-width: 680px) {
  :root {
    --page-gutter: 16px;
    --radius-lg: 18px;
    --radius-xl: 22px;
  }

  body {
    font-size: 15px;
  }

  .navbar {
    min-height: 64px;
    padding: 10px 14px;
  }

  .logo {
    gap: 8px;
    font-size: 19px;
  }

  .logo img {
    width: 38px;
    height: 38px;
    border-radius: 12px;
  }

  .nav-links {
    max-width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
    padding-bottom: 2px;
  }

  .nav-links::-webkit-scrollbar {
    display: none;
  }

  .nav-links a {
    white-space: nowrap;
  }

  .hero {
    padding-top: 38px;
    padding-bottom: 42px;
  }

  .hero h1 {
    margin-block: 14px;
  }

  .hero-actions,
  .action-group,
  .form-actions {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .hero-actions > *,
  .action-group > *,
  .form-actions > * {
    width: 100%;
  }

  .search-box,
  .search-bar,
  .search-form {
    width: 100%;
  }

  .document-grid,
  .documents-grid,
  .doc-grid,
  .subject-grid,
  .subjects-grid,
  .cards-grid,
  .stats-grid,
  .achievement-grid,
  .mission-grid {
    grid-template-columns: 1fr;
  }

  .doc-card,
  .subject-card,
  .stat-card,
  .profile-card,
  .dashboard-card,
  .achievement-card,
  .mission-card,
  .leaderboard-card,
  .top-member-card,
  .card,
  .panel {
    border-radius: var(--radius-lg);
  }

  .modal-content,
  .dialog,
  .auth-modal-content {
    width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
    border-radius: 20px;
  }

  button,
  .btn,
  .btn-primary,
  .btn-secondary,
  .login-btn,
  .search-btn,
  .detail-btn,
  .download-btn,
  .upload-btn,
  .nav-login-btn {
    min-height: 46px;
  }
}

@media (max-width: 380px) {
  .logo span {
    display: none;
  }

  .navbar {
    gap: 10px;
  }
}

/* ===== V0.92 / 2.3: Level System ===== */
.dashboard-progress[aria-valuenow] {
  position: relative;
}

.profile-level-title {
  margin: -4px 0 12px;
  color: var(--primary, #2563eb);
  font-weight: 700;
  letter-spacing: .01em;
}

.level-up-popup {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: grid;
  place-items: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease;
}

.level-up-popup.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.level-up-popup.is-closing {
  opacity: 0;
}

.level-up-popup__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .68);
  backdrop-filter: blur(7px);
}

.level-up-popup__card {
  position: relative;
  width: min(420px, 100%);
  padding: 34px 28px 28px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, .75);
  border-radius: 28px;
  background: linear-gradient(155deg, #ffffff 0%, #eff6ff 52%, #eef2ff 100%);
  box-shadow: 0 28px 80px rgba(15, 23, 42, .32);
  transform: translateY(22px) scale(.92);
  transition: transform .34s cubic-bezier(.2, .9, .25, 1.2);
  overflow: hidden;
}

.level-up-popup.is-visible .level-up-popup__card {
  transform: translateY(0) scale(1);
}

.level-up-popup__card::before {
  content: "";
  position: absolute;
  width: 220px;
  height: 220px;
  left: 50%;
  top: -150px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: rgba(59, 130, 246, .22);
  filter: blur(5px);
}

.level-up-popup__close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 38px;
  height: 38px;
  min-height: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(148, 163, 184, .14);
  color: #475569;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.level-up-popup__sparkles {
  position: relative;
  margin-bottom: 6px;
  font-size: 24px;
  animation: levelSparkle 1.2s ease-in-out infinite alternate;
}

.level-up-popup__eyebrow {
  position: relative;
  display: block;
  color: #2563eb;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .2em;
}

.level-up-popup__level {
  position: relative;
  display: grid;
  place-items: center;
  width: 110px;
  height: 110px;
  margin: 14px auto;
  border: 8px solid rgba(255, 255, 255, .9);
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  box-shadow: 0 14px 32px rgba(79, 70, 229, .32);
  color: #fff;
  font-size: 46px;
  line-height: 1;
}

.level-up-popup__card h2 {
  margin: 4px 0 8px;
  color: #0f172a;
  font-size: clamp(24px, 6vw, 32px);
}

.level-up-popup__card p {
  margin: 0 auto 22px;
  max-width: 310px;
  color: #64748b;
  line-height: 1.6;
}

.level-up-popup__action {
  min-height: 46px;
  padding: 0 22px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(37, 99, 235, .24);
}

@keyframes levelSparkle {
  from { transform: translateY(0) scale(.96); opacity: .72; }
  to { transform: translateY(-4px) scale(1.06); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .level-up-popup,
  .level-up-popup__card,
  .level-up-popup__sparkles {
    transition: none;
    animation: none;
  }
}


/* ===== V0.92 / 2.4: XP & Level UI ===== */
.profile-link--level {
  min-width: 0;
}

.user-mini-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.user-mini-name {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.navbar-level-row {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #2563eb;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
}

.navbar-xp-track {
  width: 54px;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: #dbeafe;
}

.navbar-xp-track i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #38bdf8, #4f46e5);
  transition: width .45s ease;
}

.profile-level-panel {
  margin: 18px 0 20px;
  padding: 18px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  border: 1px solid #dbeafe;
  border-radius: 20px;
  background:
    radial-gradient(circle at 100% 0, rgba(99, 102, 241, .14), transparent 36%),
    linear-gradient(135deg, #eff6ff, #ffffff 52%, #eef2ff);
  box-shadow: 0 14px 36px rgba(37, 99, 235, .08);
}

.profile-level-emblem {
  width: 66px;
  height: 66px;
  display: grid;
  place-items: center;
  border: 5px solid rgba(255, 255, 255, .9);
  border-radius: 20px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  box-shadow: 0 12px 28px rgba(79, 70, 229, .25);
  font-size: 30px;
}

.profile-level-content { min-width: 0; }

.profile-level-heading,
.profile-level-meta {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 14px;
}

.profile-level-kicker {
  display: block;
  margin-bottom: 3px;
  color: #2563eb;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.profile-level-heading h2 {
  margin: 0;
  color: #0f172a;
  font-size: 22px;
}

.profile-level-heading h2 small {
  color: #64748b;
  font-size: 13px;
  font-weight: 700;
}

.profile-xp-total {
  color: #4f46e5;
  white-space: nowrap;
}

.profile-xp-bar {
  height: 11px;
  margin: 13px 0 8px;
  background: rgba(148, 163, 184, .24);
}

.profile-xp-bar .xp-fill {
  position: relative;
  background: linear-gradient(90deg, #38bdf8, #2563eb 56%, #7c3aed);
  box-shadow: 0 0 18px rgba(59, 130, 246, .32);
  transition: width .65s cubic-bezier(.2, .8, .2, 1);
}

.profile-xp-bar .xp-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 20%, rgba(255,255,255,.5) 45%, transparent 70%);
  transform: translateX(-100%);
  animation: xpShine 2.4s ease-in-out infinite;
}

.profile-level-meta {
  align-items: center;
  color: #64748b;
  font-size: 12px;
}

.profile-level-meta strong { color: #334155; }

@keyframes xpShine {
  55%, 100% { transform: translateX(130%); }
}

@media (max-width: 760px) {
  .compact-navbar .profile-link--level .user-mini-copy { display: none; }

  .profile-level-panel {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .profile-level-emblem { margin: 0 auto; }

  .profile-level-heading,
  .profile-level-meta {
    align-items: center;
  }
}

@media (max-width: 520px) {
  .profile-level-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
    text-align: left;
  }

  .profile-level-meta {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  .navbar-xp-track i,
  .profile-xp-bar .xp-fill { transition: none; }
  .profile-xp-bar .xp-fill::after { animation: none; }
}


/* ===== Shared loading overlay mobile centering fix V0.95 =====
   Keep every global loading dialog centered on the visual viewport,
   including Chrome Android/custom tabs. */
.app-loading-overlay {
  position: fixed !important;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  left: 0 !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  margin: 0 !important;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)) !important;
  display: block !important;
  box-sizing: border-box !important;
  transform: none !important;
  overflow: hidden !important;
  isolation: isolate;
}

.app-loading-overlay[hidden] {
  display: none !important;
}

.app-loading-card {
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  right: auto !important;
  bottom: auto !important;
  width: min(320px, calc(100vw - 32px)) !important;
  min-width: 0 !important;
  max-width: calc(100vw - 32px) !important;
  margin: 0 !important;
  box-sizing: border-box !important;
  transform: translate(-50%, -50%) !important;
}


/* ===== Shared confirm/message modal centering fix V0.96 =====
   Keeps all .modal-overlay/.confirm-box dialogs centered in Chrome Android. */
.modal-overlay {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  margin: 0 !important;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)) !important;
  box-sizing: border-box !important;
  background: rgba(15, 23, 42, 0.45) !important;
  z-index: 100000 !important;
  overflow: hidden !important;
  transform: none !important;
  isolation: isolate;
}

.confirm-box {
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  right: auto !important;
  bottom: auto !important;
  width: min(340px, calc(100vw - 32px)) !important;
  min-width: 0 !important;
  max-width: calc(100vw - 32px) !important;
  max-height: min(80vh, 560px) !important;
  max-height: min(80dvh, 560px) !important;
  margin: 0 !important;
  padding: 26px !important;
  box-sizing: border-box !important;
  transform: translate(-50%, -50%) !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  text-align: center !important;
}

@media (max-width: 480px) {
  .confirm-box {
    width: calc(100vw - 28px) !important;
    max-width: calc(100vw - 28px) !important;
    padding: 22px 18px !important;
    border-radius: 20px !important;
  }

  .confirm-box h3,
  .confirm-box p {
    overflow-wrap: anywhere;
  }

  .confirm-actions {
    width: 100%;
    flex-wrap: wrap;
  }
}


/* ===== Modal centering root fix V0.97 =====
   Modal overlays must remain layout containers. JS opens them with display:grid. */
.modal-overlay {
  position: fixed !important;
  inset: 0 !important;
  width: auto !important;
  height: auto !important;
  margin: 0 !important;
  padding: max(16px, env(safe-area-inset-top))
           max(16px, env(safe-area-inset-right))
           max(16px, env(safe-area-inset-bottom))
           max(16px, env(safe-area-inset-left)) !important;
  box-sizing: border-box !important;
  display: grid;
  place-items: center !important;
  background: rgba(15, 23, 42, 0.45) !important;
  z-index: 100000 !important;
  overflow: auto !important;
  transform: none !important;
}

.confirm-box {
  position: relative !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  bottom: auto !important;
  width: min(340px, 100%) !important;
  min-width: 0 !important;
  max-width: 100% !important;
  max-height: min(80vh, 560px) !important;
  max-height: min(80dvh, 560px) !important;
  margin: auto !important;
  padding: 26px !important;
  box-sizing: border-box !important;
  transform: none !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  text-align: center !important;
}

@media (max-width: 480px) {
  .confirm-box {
    width: 100% !important;
    padding: 22px 18px !important;
    border-radius: 20px !important;
  }
}



/* ===== Native confirm dialogs (Chrome Android-safe) =====
   Top-layer dialogs are centered by the browser's visual viewport and are
   unaffected by horizontal page overflow, transformed ancestors or scroll. */
.app-confirm-dialog {
  width: min(340px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  max-height: min(80dvh, 560px);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 22px;
  background: transparent;
  color: inherit;
  overflow: visible;
}

.app-confirm-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(1px);
}

.app-confirm-dialog .confirm-box {
  position: static !important;
  width: 100% !important;
  max-width: 100% !important;
  max-height: min(80dvh, 560px) !important;
  margin: 0 !important;
  padding: 26px !important;
  box-sizing: border-box !important;
  transform: none !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
}

@media (max-width: 480px) {
  .app-confirm-dialog {
    width: calc(100vw - 28px);
    max-width: calc(100vw - 28px);
  }

  .app-confirm-dialog .confirm-box {
    padding: 22px 18px !important;
    border-radius: 20px !important;
  }
}
