:root {
  --yomi-main: #872732;
  --yomi-main-ink: #8a303a;
  --yomi-gray: #ccc;
  --yomi-ink: #222;
}

/* ===============================
   コントロールエリア
   =============================== */
.hier-data-bar-controls {
  margin-bottom: 1.8em;
  display: grid;
  gap: 10px;
}

.hier-data-bar-controls .control-group {
  display: grid;
  grid-template-columns: 5.5em 1fr;
  align-items: center;
  column-gap: 8px;
}

.control-total {
  font-weight: bold;
  margin-bottom: 4px;
}
.control-pagesize-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.current-range {
  font-size: 0.9em;
  color: #555;
  white-space: nowrap;
}
.total-count {
  font-variant-numeric: tabular-nums;
  font-weight: normal;
}


.level-title {
  font-weight: bold;
  font-size: 17px;
}

.page-size-select {
  padding: 4px 8px;
  font-size: 15px;
}

/* 検索ボックス */
.search-box {
  position: relative;
  display: inline-block;
  width: 100%;
  max-width: 260px;
}

.yomi-search-input {
  width: 100%;
  padding: 3px 28px 3px 8px;
  font-size: 16px;
  border: 1px solid #ccc;
  border-radius: 6px;
}

.yomi-clear-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: none;
  font-size: 17px;
  color: #51383f;
  cursor: pointer;
}
.yomi-clear-btn:hover {
  color: #340e12;
}

/* ===============================
   ロッカー（三段階スイッチ）
   =============================== */
.student-visibility {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}

.student-visibility .sv-hit {
  border: none;
  background: none;
  padding: 0;
  font-size: 16px;
  font-weight: 600;
  color: inherit;
  cursor: pointer;
}

.student-visibility .sv-rocker {
  position: relative;
  width: 66px;
  height: 28px;
  border-radius: 999px;
  background: var(--yomi-gray);
  overflow: hidden;
}

.student-visibility .sv-rocker::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  height: 100%;
  background: var(--yomi-main);
  transition: width .2s ease;
  clip-path: inset(0 0 0 0 round 999px);
  width: 0;
}

.student-visibility .sv-rocker .sv-thumb {
  position: absolute;
  top: 50%;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: left .2s ease;
  transform: translateY(-50%);
  z-index: 1;
}

/* state制御 */
.student-visibility[data-state="off"] .sv-thumb { left: 3px; }
.student-visibility[data-state="off"] .sv-rocker::before { width: 0; }
.student-visibility[data-state="partial"] .sv-thumb { left: calc(50% - 11px); }
.student-visibility[data-state="partial"] .sv-rocker::before { width: calc(50% + 13px); }
.student-visibility[data-state="on"] .sv-thumb { left: calc(100% - 25px); }
.student-visibility[data-state="on"] .sv-rocker::before { width: 100%; }

/* ===============================
   データバー本体
   =============================== */
.hier-data-bar-wrapper { width: 100%; overflow-x: auto; }
.hier-data-bar { width: 100%; max-width: 900px; }

.bar-wrap {
  display: grid;
  grid-template-columns: 3em 2.5em 7em 1fr; /* 順位・同率・ラベル・バーを揃える */
  align-items: center;
  gap: 6px;
  margin: 6px 0;
  max-width: 100%;
}

.bar-rank, .bar-tie, .bar-label {
  font-weight: 600;
  font-size: 16px;
  color: var(--yomi-ink);
  white-space: nowrap;
}

.bar-tie {
  color: #777;
  font-size: 0.8em;
  text-align: justify;
}

.bar-label {
  cursor: pointer;
}

.bar-icon {
  margin-left: 4px;
  font-size: 14px;
}

.bar-track {
  position: relative;
  flex: 1 1 auto;
  height: 22px;
}

.bar {
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
  background: var(--yomi-main);
  color: #fff;
  border-radius: 4px;
  overflow: visible;
}

.bar-value {
  font-weight: normal;
  line-height: 1;
}

.bar .bar-value-in {
  display: inline-block;
  padding-left: 6px;
  white-space: nowrap;
}
.bar .bar-value-out {
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  margin-left: 6px;
  white-space: nowrap;
  display: none;
  color: var(--yomi-main-ink);
}

.bar-wrap.bar-text-outside-right .bar .bar-value-in { visibility: hidden; }
.bar-wrap.bar-text-outside-right .bar .bar-value-out { display: inline-block; }

/* ==============================
   ラベルの折り返し設定
   ============================== */
/* ラベルを左右に分けて配置（左：文字列、右：アイコン） */
.bar-label {
  display: flex;
  align-items: center;
  justify-content: space-between; /* ← 左右端に配置 */
  gap: 6px;
  text-align: left;               /* ← テキストは左揃え */
  flex: 0 0 8em;                  /* ラベル幅を固定したい場合はここを調整 */
  margin-right: 8px;
}

.bar-label .label-inner {
  display: inline-block;
  white-space: nowrap;           /* 通常は折り返さない */
  word-break: keep-all;
  line-height: 1.2;
  font-weight: 600;
  color: var(--hdb-ink, #222);
}

/* pc→5文字超え時に付与されるクラス */
.bar-label .label-inner.wrap {
  white-space: normal !important;  /* 折り返し許可 */
  word-break: break-all;
  width: 5em;                      /* 3文字相当の幅で折返し */
}

/* 見栄え調整 */
.yomi-bar .bar-label {
  flex: 0 0 auto;
  margin-right: 8px;

}

/* 右端の SWELL アイコン部分 */
.bar-label .bar-icon {
  flex-shrink: 0;          /* アイコンが潰れないように固定 */
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  width: 1.2em;            /* アイコン領域を一定に確保 */
  margin-left: 4px;
}


/* ===============================
   生徒チップ（組カラー準拠）
   =============================== */
.student-list {
  margin-left: calc(3em + 2.5em + 7em + 6px + 6px + 6px + 1em);
  white-space: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.student-list .student-chip {
  display: block;
  padding: 2px 6px;
  margin: 2px 2px;
  border-radius: 3px;
  border: none;
  cursor: pointer;
  white-space: nowrap;
}

.student-chip.sh-g1 { background:#dd8094; color:#fff; } /* 花 */
.student-chip.sh-g2 { background:#f1b500; color:#fff; } /* 月 */
.student-chip.sh-g3 { background:#8db3a0; color:#fff; } /* 雪 */
.student-chip.sh-g4 { background:#66b8d5; color:#fff; } /* 星 */
.student-chip.sh-g5 { background:#ae7ac6; color:#fff; } /* 宙 */
.student-chip.sh-g6 { background:#0f2b46; color:#fff; } /* 専 */
.student-chip.sh-g7 { background:#ffffff; color:#333; border:1px solid #ddd; } /* 定 */
.student-chip.sh-g0 { background:#fafafa; color:#333; border:1px solid #ddd; } /* その他 */

/* ===============================
   モーダル
   =============================== */
.student-modal-overlay[hidden]{ display:none; }
.student-modal-overlay{
  position:fixed; inset:0; background:rgba(0,0,0,.45);
  display:flex; align-items:center; justify-content:center;
  z-index:9999; padding:20px;
}
.student-modal-dialog{
  background:#f2efe7; border-radius:12px; max-width:520px; width:100%;
  box-shadow:0 10px 30px rgba(0,0,0,.25);
  padding:20px 24px; position:relative;
  font-size:1.125rem; line-height:1.7;
}
.student-modal-dialog h3{ margin:0 0 1em 0; }
.student-modal-link a{ color:#1176d4; }
.student-modal-link a:hover{ text-decoration:none; }
.student-modal-lock{ overflow:hidden; }

/* ===============================
   ページネーション
   =============================== */
/* ===== ページネーション親ラッパ ===== */
.pagination {
  display: flex;
  justify-content: center;       /* PC時中央寄せ */
  align-items: center;
  flex-wrap: nowrap;             /* 折り返さない */
  overflow-x: auto;              /* スマホ時は横スクロール許可 */
  scroll-behavior: smooth;
  gap: 6px;
  padding: 6px 0;
  margin-bottom: 0.5em;
  max-width: 100%;               /* 親要素幅を超えない */
  box-sizing: border-box;
}

/* ===== スクロールバー非表示（見た目を綺麗に） ===== */
.pagination::-webkit-scrollbar {
  display: none;
}
.pagination {
  -ms-overflow-style: none; /* IE/Edge */
  scrollbar-width: none;    /* Firefox */
}

/* ===== ページボタン ===== */
.page-btn {
  flex: 0 0 auto;            /* ボタン幅固定（伸縮しない） */
  padding: 6px 10px;
  min-width: 34px;
  text-align: center;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #f7f7f7;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;       /* 折り返さない */
}

.page-btn.active {
  background: #51383f;
  color: #fff;
  font-weight: bold;
}

.page-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

/* ===== スマホ最適化 ===== */
@media (max-width: 600px) {
  .pagination {
    justify-content: flex-start;   /* 左寄せに変更（自然な並び） */
    gap: 4px;
    padding: 6px 2px;
  }
  .page-btn {
    font-size: 13px;
    padding: 5px 8px;
  }
}


.page-btn.ellipsis {
  pointer-events: none;
  background: transparent;
  border: none;
  color: #777;
}

/* ===============================
   レスポンシブ
   =============================== */
@media (max-width:768px){
  .hier-data-bar-controls .control-group {
    grid-template-columns: 5em 1fr;
  }
  .level-title { font-size: 15px; }


}

/* 3文字超え時に付与されるクラス */
@media (max-width: 600px) {
.bar-label .label-inner.wrap {
  white-space: normal !important;  /* 折り返し許可 */
  word-break: break-all;
  width: 3em;                      /* 3文字相当の幅で折返し */
}
.bar-wrap {
  grid-template-columns: 3em 2.5em 5.5em 1fr; /* 順位・同率・ラベル・バーを揃える */
}
.student-list {
  margin-left: calc(3em + 2.5em + 5em + 6px + 6px + 6px + 1em);
}
}