/* Secondary views share the same calm, readable controls as the exercise. */
.page-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  margin: 30px 0 22px;
}
.page-heading h1 { margin: 0; font-size: 26px; line-height: 1.5; font-weight: 700; color: #263348; }
.page-heading > span { color: #667085; font-size: 14px; }
.page-heading > span strong { margin-right: 5px; color: #263348; font-size: 20px; font-weight: 600; }

#library-view button, #progress-view button { min-height: 40px; }
.rank-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.rank-filter {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 13px; border: 1px solid #dfe5ed; border-radius: 9px;
  background: #fff; color: #526176; font-size: 13px; line-height: 1.5; font-weight: 500;
}
.rank-filter strong { margin-left: 2px; color: #667085; font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums; }
.rank-filter[aria-pressed=true] { color: #206bd5; background: #edf4ff; border-color: #9bbff4; }
.rank-filter[aria-pressed=true] strong { color: #206bd5; }
.rank-filter .rank-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.library-toolbar { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.search-field {
  display: flex; flex: 1; min-width: 0; align-items: center; gap: 10px;
  min-height: 48px; padding: 10px 15px; border: 1px solid #dfe5ed; border-radius: 10px;
  background: #fff; color: #667085;
}
.search-field:focus-within { border-color: #75a7f0; box-shadow: 0 0 0 3px #2879ec12; }
.search-field input { width: 100%; min-width: 0; border: 0; outline: 0; background: none; font-size: 14px; color: #263348; }
.search-field input::placeholder { color: #8792a2; }
.check-label { display: inline-flex; align-items: center; gap: 9px; min-height: 40px; color: #526176; font-size: 14px; line-height: 1.5; white-space: nowrap; cursor: pointer; }
.check-label input { width: 18px; height: 18px; flex-shrink: 0; }
.selection-bar {
  display: flex; align-items: center; gap: 18px; padding: 14px 18px;
  border: 1px solid #dfe5ed; border-bottom: 0; border-radius: 12px 12px 0 0;
  background: #f0f4fa; color: #667085; font-size: 14px;
}
.selection-bar > span { color: #667085; font-size: 13px; }
.selection-bar > .button { margin-left: auto; }
.table-wrap { overflow: auto; border: 1px solid #dfe5ed; border-radius: 0 0 12px 12px; background: #fff; box-shadow: 0 2px 6px #26334804; }
#library-view table { border-collapse: collapse; width: 100%; text-align: left; }
#library-view th { padding: 15px 18px; background: #f8fafc; color: #667085; font-size: 13px; font-weight: 600; white-space: nowrap; }
#library-view td { padding: 17px 18px; border-top: 1px solid #e9edf3; color: #344054; font-size: 15px; line-height: 1.8; vertical-align: middle; overflow-wrap: anywhere; }
#library-view td:first-child { width: 48px; padding-right: 0; }
#library-view td:last-child { width: 80px; }
#library-view tr:hover td { background: #f9fbfe; }
#library-view td.han-cell { min-width: 100px; color: #263348; font-family: 'Noto Sans KR', sans-serif; font-size: 27px; font-weight: 500; }
#library-view td.meaning-cell { min-width: 180px; max-width: 440px; }
#library-view td.meaning-cell > small { display: block; margin-top: 4px; color: #667085; font-size: 13px; line-height: 1.7; }
#library-view .empty-row { padding: 48px 20px; text-align: center; color: #667085; }
.rank-select {
  min-height: 40px; max-width: 155px; padding: 8px 10px;
  border: 1px solid #cbd5e1; border-radius: 8px; background: var(--rank-bg, #f0f4fa);
  color: var(--rank-ink, #344054); font-size: 13px; line-height: 1.5; cursor: pointer;
}
.table-queue, .table-practice { padding: 8px 13px; border: 1px solid #c7dafa; border-radius: 8px; background: #edf4ff; color: #236ed8; font-size: 13px; font-weight: 600; white-space: nowrap; }
.masked-answer { padding: 8px 13px; border: 1px dashed #cbd5e1; border-radius: 8px; background: #f8fafc; color: #667085; font-size: 13px; white-space: nowrap; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 22px; color: #667085; font-size: 14px; }
.pagination > div { display: flex; gap: 8px; }

.record-summary {
  display: flex; align-items: center; gap: 48px; padding: 26px 30px; margin-bottom: 24px;
  border: 1px solid #dfe5ed; border-radius: 12px; background: #fff; box-shadow: 0 2px 6px #26334804;
}
.record-summary > div:first-child > span { display: block; margin-bottom: 8px; color: #667085; font-size: 14px; }
.record-summary > div:first-child > strong { color: #263348; font-size: 40px; line-height: 1.3; letter-spacing: -1px; font-weight: 700; font-variant-numeric: tabular-nums; }
.record-summary > div:first-child > strong small { margin-left: 6px; color: #667085; font-size: 18px; letter-spacing: 0; font-weight: 500; }
.record-distribution { display: flex; flex: 1; min-width: 0; align-items: center; gap: 24px; }
.rank-distribution { display: flex; flex: 1; gap: 2px; height: 18px; overflow: hidden; border-radius: 6px; background: #e9edf3; }
.rank-distribution > span { height: 100%; min-width: 0; background: var(--rank-bg, #e9edf3); }
.record-distribution > strong { color: #2879ec; font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.rank-board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.rank-tile {
  position: relative; min-width: 0; overflow: hidden; padding: 24px;
  border: 1px solid #dfe5ed; border-radius: 12px; background: #fff;
  text-align: left; box-shadow: 0 2px 6px #26334804;
}
.rank-tile::before { position: absolute; content: ''; top: 0; left: 0; right: 0; height: 4px; background: var(--rank-bg, #dfe5ed); }
.rank-tile > strong { display: block; margin: 18px 0 0; color: #263348; font-size: 32px; line-height: 1.4; font-weight: 700; font-variant-numeric: tabular-nums; }
.rank-tile > strong small { margin-left: 6px; color: #667085; font-size: 13px; font-weight: 500; }
.rank-tile .rank-badge { font-size: 12px; }
.rank-tile p { margin: 10px 0 0; color: #667085; font-size: 13px; line-height: 1.7; }
.rank-tile .tile-arrow { position: absolute; right: 20px; bottom: 24px; color: #8792a2; }
.rank-tile:hover { border-color: #a9c5ee; }

dialog {
  width: calc(100% - 40px); max-width: 420px; padding: 28px;
  border: 1px solid #dfe5ed; border-radius: 16px; background: #fff; color: #263348;
  box-shadow: 0 20px 80px #26334824;
}
dialog::backdrop { background: #1c2b414d; backdrop-filter: blur(3px); }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.dialog-heading h2 { margin: 0; color: #263348; font-size: 22px; line-height: 1.5; font-weight: 700; }
.dialog-heading .icon-button { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; min-height: 40px; padding: 0; border-radius: 8px; color: #667085; font-size: 28px; }
.dialog-heading .icon-button:hover { background: #f4f6f9; }
.field-label { display: block; margin: 20px 0 9px; color: #526176; font-size: 14px; font-weight: 600; }
#settings-form select { display: block; width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid #dfe5ed; border-radius: 8px; background: #f9fafc; color: #263348; font-size: 15px; }
.shuffle-label { margin: 20px 0 24px; }
#settings-form > .button { width: 100%; min-height: 46px; font-size: 15px; }
.notice { padding: 14px 18px; margin-bottom: 20px; border: 1px solid #cbdffc; border-radius: 10px; background: #eff5ff; color: #365b8c; font-size: 14px; line-height: 1.8; }
.notice.error { border-color: #eed4d1; background: #fff5f4; color: #9a4c44; }
.toast { position: fixed; z-index: 50; left: 50%; bottom: 24px; transform: translateX(-50%); width: max-content; max-width: min(560px, calc(100vw - 32px)); padding: 14px 20px; border: 1px solid #344054; border-radius: 12px; background: #263348; color: #fff; font-size: 14px; line-height: 1.7; box-shadow: 0 8px 30px #26334820; }
.toast.error { border-color: #904e46; background: #904e46; }

@media (max-width: 900px) {
  .rank-board { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .library-toolbar { flex-wrap: wrap; gap: 12px; }
  .search-field { flex-basis: 100%; }
  .library-toolbar > .button { margin-left: auto; }
}
@media (max-width: 640px) {
  .page-heading { margin: 24px 0 18px; gap: 12px; }
  .page-heading h1 { font-size: 22px; }
  .page-heading > span { font-size: 13px; }
  .page-heading > span strong { font-size: 18px; }
  .rank-filters { gap: 7px; margin-bottom: 18px; }
  .rank-filter { padding: 8px 10px; font-size: 12px; }
  .rank-filter strong { font-size: 12px; }
  .search-field { min-height: 46px; padding: 10px 12px; }
  .search-field input { font-size: 14px; }
  .check-label { font-size: 13px; }
  .selection-bar { flex-wrap: wrap; gap: 10px; padding: 12px; }
  .selection-bar > span { margin-left: auto; font-size: 12px; }
  .selection-bar > .button { flex-basis: 100%; margin-left: 0; font-size: 13px; }
  #library-view th { padding: 13px 12px; font-size: 12px; }
  #library-view td { padding: 15px 12px; font-size: 14px; }
  #library-view td:first-child { width: 40px; }
  #library-view td.han-cell { min-width: 85px; font-size: 24px; }
  #library-view td.meaning-cell { min-width: 160px; }
  #library-view td.meaning-cell > small { font-size: 12px; }
  .rank-select { max-width: 145px; padding: 8px; font-size: 12px; }
  .table-queue, .table-practice, .masked-answer { padding: 8px 11px; font-size: 12px; }
  .pagination { gap: 10px; margin-top: 18px; font-size: 12px; }
  .pagination > div { gap: 6px; }
  .pagination .button { padding: 8px 10px; font-size: 12px; }
  .record-summary { align-items: stretch; flex-direction: column; gap: 22px; padding: 22px; margin-bottom: 18px; }
  .record-summary > div:first-child > span { font-size: 13px; }
  .record-summary > div:first-child > strong { font-size: 36px; }
  .record-summary > div:first-child > strong small { font-size: 16px; }
  .record-distribution { gap: 18px; }
  .rank-distribution { height: 16px; }
  .record-distribution > strong { font-size: 20px; }
  .rank-board { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .rank-tile { padding: 20px 16px; }
  .rank-tile > strong { margin-top: 16px; font-size: 29px; }
  .rank-tile > strong small { font-size: 12px; }
  .rank-tile .rank-badge { font-size: 12px; }
  .rank-tile p { font-size: 12px; }
  dialog { padding: 22px; }
  .dialog-heading h2 { font-size: 20px; }
  .field-label { font-size: 13px; }
  #settings-form select { font-size: 14px; }
  #settings-form > .button { font-size: 14px; }
  .notice { padding: 12px 14px; font-size: 13px; }
  .toast { bottom: 18px; padding: 12px 16px; font-size: 13px; }
}
