/* ========= JLPT Browser – polished (updated) ========= */
:root{
  --jlpt-bg:#f7f7f8;
  --jlpt-card:#eee;
  --jlpt-text:#131313;
  --jlpt-muted:#111;
  --jlpt-primary:#f05a25;      /* brand */
  --jlpt-primary-weak:#1f2937;
  --jlpt-ring:#0ea5e9;         /* sky-500 */
  --jlpt-border:#e5e7eb;
  --jlpt-radius:12px;
  --jlpt-shadow:0 8px 20px rgba(0,0,0,.06);
}
#jlpt-modal .tudien-result-block{
  border-radius: 0;
  border:0;
  margin-top: 0;
}
.jlpt-browser{
  color:var(--jlpt-text);
  background:transparent;
}

/* Toolbar */
.jlpt-toolbar{
  position:relative; top:0; z-index:5;
  display:grid;
  grid-template-columns: auto 1fr auto;
  gap:.8rem 1rem;
  align-items:center;
  padding:.75rem 0 1.5rem;
  background:linear-gradient(to bottom, rgba(255,255,255,.95), rgba(255,255,255,.85));
  backdrop-filter:saturate(140%) blur(2px);
  border-bottom:1px solid var(--jlpt-border);
}

@media (max-width: 860px){
  .jlpt-toolbar{ grid-template-columns: 1fr; }
}

/* Group + Label */
.jlpt-group{ display:flex; flex-direction:column; gap:.35rem; }
.jlpt-label{ font-weight:600; font-size:14px; color:#333; }

/* Type segment (Vocab/Kanji/Grammar) */
.jlpt-type{
  display:flex; gap:.4rem; align-items:center; flex-wrap:wrap;
}
.jlpt-type .btn{
  font-weight:600;
  background:var(--jlpt-card);
  border:1px solid var(--jlpt-border);
  color:#666;
  padding:.5rem .9rem;
  border-radius:999px;
  transition:.15s ease;
}
.jlpt-type .btn.active{
  background:var(--jlpt-primary);
  color:#fff;
  border-color:transparent;
  box-shadow:0 6px 16px rgba(17,24,39,.18);
}
.jlpt-type .btn:not(.active):hover{
  border-color:#cbd5e1;
  transform:translateY(-1px);
}

/* Level chips (N5…N1) */
.jlpt-levels{
  display:flex; flex-wrap:wrap; gap:.5rem;
}
.jlpt-levels .btn{
  position:relative;
  background:var(--jlpt-card);
  border:1px solid var(--jlpt-border);
  padding:.46rem .75rem;
  border-radius:10px;
  font-weight:700;
  min-width:64px;
  text-align:center;
  transition:.15s ease;
  color:#666;
}
.jlpt-levels .btn.active:hover,
.jlpt-type .btn.active:hover,
.jlpt-search .btn:hover{
  border-color:#4d7b3a;
}

/* Ẩn badge đếm trong cấp độ */
.jlpt-levels .btn .jlpt-count{ display:none !important; }

.jlpt-levels .btn.active{
  background:#f05a25; color:#fff; border-color:#f05a25;
}
.jlpt-levels .btn:not(.active):hover{
  transform:translateY(-1px); border-color:#cbd5e1;
}

/* Search */
.jlpt-search{
  display:flex; gap:.5rem; align-items:center; justify-self:end;
}
#jlpt-q{
  width:min(54vw, 270px);
  padding:.76rem .9rem;
  border:1px solid var(--jlpt-border);
  border-radius:10px;
  outline:none;
  background:#fff;
  transition:border-color .15s, box-shadow .15s;
}
#jlpt-q:focus{
  border-color:var(--jlpt-ring);
  box-shadow:0 0 0 4px rgba(14,165,233,.15);
}
.jlpt-search .btn{
  background:#f05a25; color:#fff; border:1px solid #f05a25;
  padding:.56rem .9rem; border-radius:10px; font-weight:600;
}
#jlpt-clear-btn{
  background:#fff; color:#f05a25; border:1px solid var(--jlpt-border);
}
#jlpt-clear-btn:hover{ border-color:#cbd5e1; color:#fff; }

/* List grid */
.jlpt-list{
  margin:1.5rem 0 .7rem;
  display:grid; gap:.9rem;
  grid-template-columns: repeat(4, 1fr);
}
@media (max-width: 1240px){ .jlpt-list{ grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 980px){  .jlpt-list{ grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px){  .jlpt-list{ grid-template-columns: 1fr; } }

/* Card */
.jlpt-card{
  background:#fff;
  border:1px solid var(--jlpt-border);
  border-radius:var(--jlpt-radius);
  padding:.9rem 1rem;
  box-shadow:var(--jlpt-shadow);
  transition:transform .12s ease, box-shadow .12s ease, border-color .12s ease;
  cursor:pointer;
}
.jlpt-card:hover{
  transform:translateY(-2px);
  box-shadow:0 12px 26px rgba(0,0,0,.08);
  border-color:#dfe3ea;
}
.jlpt-card h4{
  margin:0 0 .35rem;
  font-size:1.02rem;
  line-height:1.25;
}
.jlpt-card h4 .link{
  color:#262a34; text-decoration:none; font-size:16px;
  text-align:left; font-weight:600;
}
.jlpt-card h4 .link small{
  color:#7a809b; font-size:14px; clear:both; display:block; font-weight:500;
}
.jlpt-card .meta{
  font-size:14px; color:#464853;
  overflow:hidden; text-overflow:ellipsis;
  display:-webkit-box; -webkit-line-clamp:3; -webkit-box-orient:vertical;
}

/* Paging */
.jlpt-paging{
  display:flex; gap:.5rem; justify-content:center; align-items:center;
  margin:1rem 0 1.4rem;
}
.jlpt-paging .btn{
  background:#fff; border:1px solid var(--jlpt-border); color:#111;
  padding:.46rem .8rem; border-radius:10px; min-width:40px;
}
.jlpt-paging .btn:hover{ border-color:#cbd5e1; }
.jlpt-paging .btn.disabled{ opacity:.45; pointer-events:none; }
/* Không cần hiển thị tổng số mục – JS đã bỏ; style vẫn giữ nếu cần hiển thị lại trong tương lai */
.jlpt-paging span{ color:var(--jlpt-muted); font-weight:500; }

/* Modal (shared) */
.hl-modal[hidden]{ display:none }
.hl-modal{ position:fixed; inset:0; z-index:9999; }
.hl-modal__backdrop{ position:absolute; inset:0; background:rgba(0,0,0,.45); }
.hl-modal__dialog{
  position:relative; margin:5vh auto; max-width:860px;
  background:#fff; border-radius:14px; overflow:hidden;
  box-shadow:0 20px 60px rgba(0,0,0,.25);
}
.hl-modal__header{
  display:flex; align-items:center; justify-content:space-between;
  padding:1rem 1.1rem; border-bottom:1px solid var(--jlpt-border);
}
.hl-modal__close{
  border:0; background:transparent; font-size:1.6rem; cursor:pointer; line-height:1;
}
.hl-modal__body{ padding:1rem 1.1rem; max-height:72vh; overflow:auto; }
.hl-modal__body h4{ margin:.8rem 0 .4rem; }

/* Small enhancements */
button.btn{ cursor:pointer; }
button.btn:focus, .jlpt-card:focus-within{
  outline:none; box-shadow:0 0 0 4px rgba(14,165,233,.18);
}
.kanji-results{gap:20px}
.vocab-title strong {
    color: #f05a25;
    font-size: 24px;
    font-weight: bold;
}
.vocab-title span{
  margin-left: 10px;
    font-weight: 600;
}
.hl-loading .hl-skel{background:#eee;border-radius:6px;animation:hlShine 1.2s linear infinite;background-image:linear-gradient(90deg,#eee, #f5f5f5, #eee);background-size:200% 100%}
.hl-loading .title{height:20px;width:60%;margin:8px 0}
.hl-loading .line{height:14px;width:100%;margin:8px 0}
.hl-loading .kvg{height:160px;width:160px;margin:12px auto}
@keyframes hlShine{0%{background-position:200% 0}100%{background-position:-200% 0}}
#jlpt-modal[aria-busy="true"] { cursor: progress; }
