:root {
  color-scheme: light;
  --bg: #c7ccd2;
  --surface: rgba(241, 243, 245, 0.88);
  --surface-strong: rgba(250, 251, 252, 0.94);
  --line: rgba(94, 103, 113, 0.24);
  --line-strong: rgba(75, 83, 92, 0.38);
  --text: #252b33;
  --muted: #66707d;
  --steel: #737d89;
  --gold: #c99a35;
  --copper: #b86843;
  --learn: #147a8a;
  --learn-strong: #0f6577;
  --red: #bd4f44;
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  min-height: 100dvh;
  background:
    linear-gradient(rgba(55, 64, 74, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(55, 64, 74, 0.045) 1px, transparent 1px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.18) 0 1px, rgba(69, 79, 90, 0.035) 1px 5px),
    linear-gradient(135deg, #e9ecef 0%, #bcc3ca 48%, #eef0f2 100%);
  background-size: 36px 36px, 36px 36px, auto, auto;
  color: var(--text);
}

button,
a,
select {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
a,
select {
  cursor: pointer;
}

.errors-app {
  width: min(1520px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 18px 24px 28px;
}

.errors-topbar {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(197, 203, 210, 0.66)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.18) 0 1px, rgba(63, 72, 83, 0.035) 1px 5px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.86),
    inset 0 -1px 0 rgba(82, 90, 99, 0.16),
    0 12px 34px rgba(61, 69, 78, 0.20);
  padding: 0 18px;
}

.lesson-id {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, #fff6c2, #d8a43a 38%, #94682b 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.78),
    0 0 0 5px rgba(201, 154, 53, 0.14),
    0 8px 18px rgba(105, 79, 34, 0.22);
}

.lesson-id strong,
.lesson-id small {
  display: block;
}

.lesson-id strong {
  color: #1f2730;
  font-size: 17px;
  line-height: 1.15;
  font-weight: 900;
}

.lesson-id small,
.panel-head p,
.metric-strip span,
.detail-card p,
.detail-card span,
.rank-item span,
.empty-state span,
.user-switcher span {
  color: var(--muted);
}

.lesson-id small,
.panel-head p,
.user-switcher span {
  font-size: 12px;
  font-weight: 760;
}

.errors-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.errors-actions a,
.errors-actions button,
.user-switcher {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(82, 90, 99, 0.25);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.76), rgba(203, 209, 216, 0.58)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.16) 0 1px, rgba(67, 76, 86, 0.04) 1px 4px);
  color: #27313d;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.82),
    0 4px 10px rgba(70, 78, 88, 0.10);
  padding: 0 14px;
  font-weight: 820;
}

.errors-actions a:hover,
.errors-actions button:hover,
.user-switcher:hover {
  border-color: rgba(201, 154, 53, 0.48);
  color: #1d2730;
  filter: brightness(1.02);
}

.user-switcher {
  gap: 9px;
}

.user-switcher select {
  border: 0;
  background: transparent;
  color: #1f2b38;
  font-weight: 900;
  outline: 0;
}

.errors-shell {
  min-height: calc(100dvh - 116px);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  padding-top: 18px;
}

.chart-panel,
.detail-card,
.rank-list {
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, var(--surface-strong), rgba(213, 219, 225, 0.72)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.18) 0 1px, rgba(63, 72, 83, 0.035) 1px 5px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.88),
    inset 0 -1px 0 rgba(74, 84, 95, 0.16),
    0 18px 42px rgba(59, 68, 78, 0.18);
}

.chart-panel {
  min-width: 0;
  padding: 18px;
}

.panel-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.panel-head p,
.panel-head h1 {
  margin: 0;
}

.panel-head h1 {
  margin-top: 5px;
  color: #252a31;
  font-size: clamp(34px, 4.2vw, 58px);
  line-height: 0.98;
  letter-spacing: 0;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.74);
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(112px, 1fr));
  gap: 10px;
}

.metric-strip div,
.detail-grid div {
  border: 1px solid rgba(85, 94, 104, 0.20);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(186, 194, 203, 0.36)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.13) 0 1px, rgba(63, 72, 83, 0.035) 1px 5px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.82),
    0 5px 13px rgba(65, 72, 82, 0.10);
  padding: 12px;
}

.metric-strip strong,
.metric-strip span,
.detail-grid strong,
.detail-grid span {
  display: block;
}

.metric-strip strong,
.detail-grid strong {
  color: #202831;
  font-size: 27px;
  line-height: 1.05;
  font-weight: 1000;
  font-variant-numeric: tabular-nums;
}

.metric-strip span,
.detail-grid span {
  margin-top: 4px;
  font-size: 12px;
  font-weight: 760;
}

.treemap-wrap {
  position: relative;
  min-height: 660px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background:
    linear-gradient(rgba(66, 75, 85, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(66, 75, 85, 0.055) 1px, transparent 1px),
    linear-gradient(180deg, rgba(239, 242, 245, 0.70), rgba(168, 176, 185, 0.44)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.18) 0 1px, rgba(62, 70, 80, 0.04) 1px 5px);
  background-size: 44px 44px, 44px 44px, auto, auto;
  overflow: hidden;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.82),
    inset 0 -2px 6px rgba(65, 74, 84, 0.18);
}

.treemap {
  position: absolute;
  inset: 6px;
}

.tile {
  position: absolute;
  min-width: 24px;
  min-height: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border: 2px solid rgba(245, 247, 249, 0.78);
  border-radius: var(--radius);
  overflow: hidden;
  padding: 12px;
  background:
    linear-gradient(150deg, hsl(var(--tile-hue) 78% 48% / 0.95), hsl(calc(var(--tile-hue) + 24) 66% 42% / 0.84)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.13) 0 1px, transparent 1px 7px);
  color: #ffffff;
  text-align: left;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.36),
    inset 0 -12px 28px rgba(55, 34, 24, 0.14),
    0 1px 2px rgba(56, 64, 74, 0.16);
  transition: transform 160ms ease, filter 160ms ease, box-shadow 160ms ease;
}

.tile::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), transparent 36%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.10) 0 1px, rgba(0, 0, 0, 0.025) 1px 5px);
  pointer-events: none;
}

.tile:hover,
.tile.is-active {
  transform: scale(0.988);
  filter: brightness(1.06);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.42),
    0 0 0 1px rgba(118, 88, 36, 0.26),
    0 10px 18px rgba(56, 64, 74, 0.20);
}

.tile.is-learnable {
  border-color: rgba(232, 250, 255, 0.92);
  background:
    linear-gradient(135deg, rgba(29, 150, 166, 0.96), rgba(195, 151, 48, 0.88)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.15) 0 1px, transparent 1px 6px);
}

.tile.is-learnable::before {
  content: "可认识";
  position: absolute;
  top: 9px;
  right: 9px;
  z-index: 2;
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--learn-strong);
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 1000;
}

.tile strong,
.tile span,
.tile small {
  min-width: 0;
  display: block;
  position: relative;
  z-index: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile strong {
  color: #ffffff;
  font-size: clamp(18px, 2.3vw, 36px);
  line-height: 1.05;
  font-weight: 1000;
  overflow-wrap: anywhere;
  white-space: normal;
  text-shadow: 0 2px 0 rgba(52, 35, 27, 0.20);
}

.tile span {
  margin-top: 8px;
  color: rgba(255, 255, 255, 0.90);
  font-size: 16px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tile small {
  margin-top: 7px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
  line-height: 1.25;
  white-space: nowrap;
}

.tile.is-medium {
  padding: 9px;
}

.tile.is-medium strong {
  font-size: clamp(15px, 1.45vw, 22px);
}

.tile.is-medium small {
  display: none;
}

.tile.is-small {
  justify-content: center;
  padding: 6px;
}

.tile.is-small strong {
  font-size: 13px;
  line-height: 1;
}

.tile.is-small span,
.tile.is-small small,
.tile.is-small::before,
.tile.is-tiny strong,
.tile.is-tiny span,
.tile.is-tiny small,
.tile.is-tiny::before {
  display: none;
}

.tile.is-tiny {
  padding: 0;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 9px;
  text-align: center;
}

.empty-state strong {
  color: #252b33;
  font-size: 30px;
}

.detail-panel {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(0, 1.2fr);
  gap: 16px;
}

.detail-card,
.rank-list {
  padding: 16px;
}

.detail-card p,
.detail-card h2 {
  margin: 0;
}

.detail-card h2 {
  margin-top: 4px;
  color: #202831;
  font-size: clamp(30px, 3.2vw, 46px);
  line-height: 1.02;
  letter-spacing: 0;
  font-weight: 1000;
  overflow-wrap: anywhere;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 15px;
}

.detail-meaning,
.detail-sentence,
.detail-attempt {
  margin-top: 12px !important;
  line-height: 1.55;
  font-weight: 760;
}

.detail-meaning {
  color: #33414f !important;
}

.detail-sentence {
  color: #46515d !important;
}

.detail-attempt {
  color: #9b3f38 !important;
}

.detail-practice-link {
  min-height: 42px;
  width: fit-content;
  display: inline-flex;
  align-items: center;
  margin-top: 14px;
  border: 1px solid rgba(20, 122, 138, 0.32);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(20, 122, 138, 0.96), rgba(201, 154, 53, 0.86));
  color: #ffffff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.42),
    0 10px 20px rgba(20, 122, 138, 0.16);
  padding: 0 15px;
  font-weight: 1000;
}

.rank-list {
  display: flex;
  align-content: flex-start;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 10px;
}

.rank-item {
  min-height: 54px;
  display: inline-grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px 12px;
  border: 1px solid rgba(83, 93, 104, 0.22);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.70), rgba(189, 197, 207, 0.42)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.15) 0 1px, rgba(63, 72, 83, 0.035) 1px 5px);
  color: var(--text);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.76),
    0 5px 12px rgba(64, 72, 82, 0.10);
  padding: 8px 11px;
  text-align: left;
}

.rank-item.is-learnable {
  border-color: rgba(20, 122, 138, 0.34);
  background:
    linear-gradient(180deg, rgba(226, 250, 255, 0.82), rgba(185, 209, 214, 0.48)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.16) 0 1px, rgba(20, 122, 138, 0.05) 1px 5px);
}

.rank-item strong,
.rank-item span {
  display: block;
}

.rank-item strong {
  color: #2c3540;
  font-size: 16px;
  font-weight: 1000;
}

.rank-item span span {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-item b {
  color: #8b5d1e;
  font-weight: 1000;
  font-variant-numeric: tabular-nums;
}

.rank-item em {
  grid-column: 1 / -1;
  width: fit-content;
  border-radius: 999px;
  background: rgba(20, 122, 138, 0.12);
  color: var(--learn-strong);
  padding: 2px 8px;
  font-size: 12px;
  font-style: normal;
  font-weight: 1000;
}

@media (max-width: 980px) {
  .errors-topbar,
  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .metric-strip,
  .detail-panel {
    width: 100%;
    grid-template-columns: minmax(0, 1fr);
  }

  .treemap-wrap {
    min-height: 560px;
  }
}

@media (max-width: 720px) {
  .errors-app {
    padding: 12px;
  }

  .errors-topbar {
    padding: 12px;
  }

  .metric-strip {
    grid-template-columns: minmax(0, 1fr);
  }

  .treemap-wrap {
    min-height: 560px;
  }

  .tile {
    padding: 8px;
  }
}
