.knowledge-mastery-entry { margin: 5px 0 8px; }
dialog.knowledge-mastery {
  box-sizing: border-box;
  width: min(1240px, calc(100% - 28px));
  max-width: none;
  max-height: calc(100dvh - 30px);
  padding: 18px;
  border: 1px solid #4694d9;
  border-radius: 16px;
  color: #eef7ff;
  background: radial-gradient(ellipse at 12% 0%, #16598e 0%, transparent 52%),
    linear-gradient(165deg, #0d3155, #091c35 66%, #0b2847);
  box-shadow: inset 0 1px 12px #469de04d, 0 5px 16px #102d4a25;
}
.knowledge-mastery [hidden] { display: none; }
.knowledge-mastery::backdrop { background: #05192c99; }
.knowledge-mastery :is(h1,h2,p,ol) { margin: 0; }
.knowledge-mastery .km-title {
  background: none;
  position: static;
  border: 0;
  padding: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}
.knowledge-mastery .km-title h1 { font-size: clamp(20px, 3vw, 28px); color: #eef7ff; }
.knowledge-mastery .km-title p { font-size: 13px; color: #bfd8f0; margin-top: 4px; }
.knowledge-mastery .km-control, .knowledge-mastery select {
  color: #eef7ff;
  border: 1px solid #426e99;
  border-radius: 6px;
  background: #102944;
}
.knowledge-mastery .km-status { color: #bfd8f0; }
.knowledge-mastery .km-status:empty { display: none; }
.knowledge-mastery .km-book { display: grid; grid-template-columns: repeat(6, minmax(0,1fr)); gap: 11px; }
.knowledge-mastery .km-section {
  grid-column: span 2;
  border: 1px solid #386386;
  background: #0b223d;
  border-radius: 11px;
  padding: 10px;
  min-width: 0;
}
.knowledge-mastery .km-section:nth-child(-n+2) { grid-column: span 3; }
.knowledge-mastery .km-section h2 {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  font-size: 15px;
  padding-bottom: 7px;
  border-bottom: 1px solid #285172;
  color: #eef7ff;
}
.knowledge-mastery .km-section h2 small { color: #aac7e4; font-weight: normal; white-space: nowrap; }
.knowledge-mastery .km-units { margin-top: 4px; }
.knowledge-mastery .km-point {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(36px, .67fr) 36px;
  width: 100%;
  min-height: 28px;
  align-items: center;
  gap: 6px;
  padding: 3px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: #eef7ff;
  text-align: left;
  font: inherit;
  font-size: 12.5px;
}
.knowledge-mastery .km-point[data-stage="hint"] { --km-fill: #e2a761; }
.knowledge-mastery .km-point[data-stage="consistent"] { --km-fill: #76dfc5; }
.knowledge-mastery .km-point[data-stage="independent"] { --km-fill: #67cde8; }
.knowledge-mastery .km-point:hover, .knowledge-mastery .km-point[aria-pressed="true"] {
  border-color: #62b9db;
  background: #153b5a;
}
.knowledge-mastery :is(button,select):focus-visible { outline: 2px solid #a4f0ff; outline-offset: 1px; }
.knowledge-mastery .km-bar {
  display: block;
  height: 12px;
  border: 1px solid #2f5577;
  border-radius: 3px;
  background: #172e47;
  overflow: hidden;
}
.knowledge-mastery .km-fill { display: block; height: 100%; background: var(--km-fill,#5896db); }
.knowledge-mastery .km-score {
  color: #a4f0ff;
  text-align: right;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.knowledge-mastery .km-point[data-empty="true"] .km-score, .knowledge-mastery .km-reason { color: #adc6df; }
.knowledge-mastery .km-reason { grid-column: 2 / 4; font-size: 11px; text-align: right; }
.knowledge-mastery .km-detail {
  margin-top: 11px;
  border: 1px solid #396b96;
  border-radius: 9px;
  background: #0b223d;
  overflow: hidden;
}
.knowledge-mastery .km-detail-heading { display: flex; justify-content: space-between; padding: 9px 12px; background: #153755; }
.knowledge-mastery .km-detail h2 { font-size: 15px; color: #eef7ff; }
.knowledge-mastery .km-detail-heading p { color: #bddef2; font-size: 12.5px; }
.knowledge-mastery .km-detail-heading strong { font-size: 19px; }
.knowledge-mastery .km-history { list-style: none; padding: 0 11px; }
.knowledge-mastery .km-history li {
  display: grid;
  grid-template-columns: 42px minmax(128px,.8fr) minmax(0,2fr) 108px;
  align-items: center;
  gap: 7px;
  padding: 6px 0;
  border-top: 1px solid #274866;
  color: #c9dff1;
  font-size: 12px;
}
.knowledge-mastery .km-source-cell { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; }
.knowledge-mastery .km-source {
  border: 0;
  background: none;
  padding: 0;
  color: #a4f0ff;
  text-align: left;
  font: inherit;
  overflow-wrap: anywhere;
  max-width: 100%;
}
.knowledge-mastery .km-change { text-align: right; color: #bad4ec; white-space: nowrap; }
.knowledge-mastery .km-change[data-direction="up"] { color: #8ee6c3; }
.knowledge-mastery .km-change[data-direction="down"] { color: #ffacaa; }
@media (max-width: 900px) { .knowledge-mastery .km-section { grid-column: span 3; } }
@media (max-width: 600px) {
  dialog.knowledge-mastery { width: calc(100% - 14px); padding: 10px; }
  .knowledge-mastery .km-section, .knowledge-mastery .km-section:nth-child(-n+2) { grid-column: span 6; }
  .knowledge-mastery .km-history li { grid-template-columns: 38px minmax(0,1fr) 94px; }
  .knowledge-mastery .km-basis { grid-column: 2 / 4; grid-row: 2; }
  .knowledge-mastery .km-change { grid-column: 3; grid-row: 1; }
}
