.research-page {
  width: 100%;
  min-width: 0;
  container-type: inline-size;
  display: grid;
  gap: 24px;
}

.research-section {
  min-width: 0;
  padding: clamp(12px, 2.5vw, 26px);
  background: #101925;
  border: 1px solid #324255;
  border-radius: 12px;
}

.research-heading {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px 20px;
  margin-block-end: 16px;
  padding-block-end: 12px;
  border-bottom: 1px solid #324255;
}

.research-heading h1,
.research-heading h2 { margin: 0; }
.research-totals { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 16px; font-size: .875rem; }
.research-totals b, .research-route-note b, .research-slot-label span { color: #e4c983; font-variant-numeric: tabular-nums; }
.research-totals details { position: relative; }
.research-totals summary { color: #e4c983; cursor: pointer; }
.research-attrs {
  position: absolute;
  z-index: 3;
  inset-inline-end: 0;
  width: max-content;
  max-width: min(320px, 78vw);
  max-height: 55vh;
  overflow: auto;
  padding: 12px 15px;
  background: #192636;
  border: 1px solid #50617a;
  border-radius: 8px;
  display: grid;
  gap: 5px;
}

.research-books {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(3px, 1vw, 12px);
  margin-bottom: 20px;
}

.research-book {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
  min-height: 112px;
  padding: 8px 4px;
  background: #172231;
  border: 1px solid #34465b;
  border-radius: 8px;
  color: #d3dfec;
  overflow-wrap: anywhere;
  line-height: 1.3;
}

.research-book:hover:not(:disabled) { border-color: #dfc37b; background: #27303a; }
.research-book:focus-visible, .research-page .node:focus-visible { outline: 2px solid #f4dba0; outline-offset: 2px; }
.research-book .book-icon { width: 38px; height: 38px; }
.research-slot-label { display: flex; flex-wrap: wrap; justify-content: center; column-gap: .5em; font-size: .75rem; }
.research-vacant { margin: auto; }
.research-book small { white-space: nowrap; font-size: .72rem; }
.research-boards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.research-book-panel { min-width: 0; padding: 12px; border: 1px solid #324255; border-radius: 10px; scroll-margin-top: 150px; }
.research-book-panel:focus { outline: 2px solid #dfc37b; outline-offset: 2px; }
.research-book-panel h2 { margin: 0 0 8px; font-size: 1rem; }
.research-book-panel h2 span { margin-inline-end: 4px; color: #e4c983; font-size: .8125rem; }
.research-book-panel .acupoint-row { min-height: 80px; }
.research-book-panel .row-name { font-size: 1rem; }
.research-book-panel .row-icon { width: 24px; height: 24px; }

@container (min-width: 1050px) {
  .research-boards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@container (min-width: 1280px) {
  .research-boards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@container (min-width: 1480px) {
  .research-boards { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .research-book-panel { padding: 9px; }
  .research-book-panel .training-title { align-content: flex-start; min-height: 62px; gap: 6px; }
  .research-book-panel .research-book-power { width: 100%; }
  .research-book-panel .acupoint-row { gap: 6px; padding-inline: 8px; }
  .research-book-panel .node-track { gap: 3px; }
  .research-book-panel .node { width: 30px; height: 30px; min-height: 30px; }
}

@media (max-width: 820px) {
  .research-boards { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 620px) {
  .research-book-panel { padding: 8px; scroll-margin-top: 180px; }
}
.research-board .training-title { gap: 8px; flex-wrap: wrap; }
.research-board .node-track { min-width: 0; }
.research-materials { margin-top: 12px; }
.research-empty { padding: 18px 0; }
.research-empty p { margin: 0 0 10px; }
.research-route-note { margin-bottom: 12px; }
.research-route td:nth-child(3) { white-space: normal; min-width: 12ch; }
.research-route td:nth-child(n+4) { white-space: nowrap; font-variant-numeric: tabular-nums; }

@media (max-width: 620px) {
  .research-book { font-size: .75rem; min-height: 96px; }
  .research-book .book-icon { width: 30px; height: 30px; }
  .research-board .acupoint-row { padding-inline: 6px; gap: 4px; }
  .research-board .row-label { min-width: 32px; }
  .research-board .node { width: clamp(28px, 7vw, 40px); height: clamp(28px, 7vw, 40px); min-height: 0; }
  .research-totals details { position: static; }
  .research-totals { position: relative; }
}

.topbar .top-actions .quiet { white-space: nowrap; }

@media (min-width: 1051px) and (max-width: 1450px) {
  .topbar { gap: 12px; }
  .topbar nav .nav { padding-inline: clamp(8px, 1vw, 14px); }
}

@media (min-width: 651px) and (max-width: 1050px) {
  .topbar { flex-wrap: wrap; row-gap: 6px; }
  .topbar nav { order: 2; flex: 1 0 100%; justify-content: center; }
  .topbar nav .nav { padding-inline: clamp(6px, 1.4vw, 14px); }
}

.research-book-power small {
  white-space: nowrap;
  color: #b7c6d6;
}

.research-next {
  padding: 14px 16px;
  margin-block-end: 14px;
  background: #202631;
  border: 1px solid #7d6945;
  border-radius: 8px;
}

.research-next h3 {
  margin: 0 0 4px;
  color: #f4d68c;
  font-family: var(--serif);
  font-size: clamp(1.25rem, 2.45vw, 2rem);
  font-weight: 800;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.research-next h3 span { display: inline-block; margin-inline-start: .65em; }
.research-next p { margin: 0; color: #d4dfeb; }
.research-next b { color: #f4d68c; }

#toast.power-change {
  bottom: clamp(96px, 20vh, 190px);
  display: flex;
  align-items: baseline;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0 .65em;
  box-sizing: border-box;
  width: max-content;
  min-width: min(360px, 90vw);
  min-height: 76px;
  align-content: center;
  padding: 16px clamp(20px, 4vw, 42px);
  border: 0;
  border-radius: 0;
  background: url('./assets/research-power-toast.png') center / 100% 100% no-repeat,
    linear-gradient(90deg, #101827, #0b1120 15%, #0b1120 85%, #101827);
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  font: 800 clamp(1.35rem, 3vw, 2.15rem)/1.2 var(--serif);
  font-variant-numeric: tabular-nums;
  color: #ffcf67;
  text-shadow: 0 1px 3px #080b15;
}
#toast.power-change b { color: #81ed9d; }

.research-calculator-inputs { display: grid; gap: 8px; max-width: 740px; margin-block: 14px; }
.research-calculator-row {
  display: grid;
  grid-template-columns: minmax(48px, .65fr) minmax(88px, 2.4fr) repeat(2, minmax(60px, 1fr));
  gap: clamp(4px, 1vw, 12px);
  align-items: center;
}
.research-calculator-row div { font-size: .875rem; }
.research-calculator-row span { color: #e4c983; white-space: nowrap; }
.research-calculator-row select { min-width: 0; width: 100%; }
.research-calculator-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding-block: 12px;
  border-block: 1px solid #324255;
}
.research-calculator-summary dt { color: #c7d3e2; font-size: .875rem; }
.research-calculator-summary dd { margin: 0; color: #f4d68c; font-weight: 700; font-variant-numeric: tabular-nums; }
.research-calculator-attributes summary { margin-block: 8px; color: #e4c983; cursor: pointer; }
.research-calculator-attributes table { width: 100%; }

@media (max-width: 580px) {
  .research-calculator-row select { padding-inline-start: 5px; font-size: .8125rem; }
  .research-calculator-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.research-calculator-book { display: flex; align-items: center; gap: 4px; min-width: 0; }
.research-calculator-book button {
  flex: 0 0 30px;
  min-width: 30px;
  min-height: 34px;
  padding: 0;
  font-size: 1.25rem;
  line-height: 1;
}
