.research-workspace { display: grid; gap: 16px; }

.research-scene {
  --research-scene-image: url('assets/research-laboratory.jpg');
  --room-atlas-row: 0%;
  --room-atlas-x: 50%;
  --room-atlas-y: 50%;
  --room-atlas-shade: linear-gradient(112deg, #081323ae 0%, #0813235c 26%, transparent 57%);
  display: grid;
  align-content: end;
  justify-items: start;
  gap: 8px;
  min-block-size: clamp(235px, 28vw, 415px);
  padding: clamp(12px, 2vw, 24px);
  border: 1px solid #547084;
  border-radius: 11px;
  background:
    var(--room-atlas-shade),
    #172637 var(--research-scene-image) 60% 53% / cover no-repeat;
  box-shadow: inset 0 1px #b4e9fa46, 0 9px 24px #0206109c;
}

.research-scene[data-species='reptilian'] { --room-atlas-image: url('assets/research-rooms-reptilian.jpg'); }
.research-scene[data-species='insectoid'] { --room-atlas-image: url('assets/research-rooms-insectoid.jpg'); }
.research-scene[data-species='grey'] { --room-atlas-image: url('assets/research-rooms-grey.jpg'); }
.research-scene[data-species='biomechanical'] { --room-atlas-image: url('assets/research-rooms-biomechanical.jpg'); }

.research-workspace:has([data-research-area='civilian'][aria-selected='true']) .research-scene {
  --research-scene-image: url('assets/research-laboratory-civil.jpg');
  --room-atlas-row: 50%;
  border-color: #607d79;
}
.research-workspace:has([data-research-area='military'][aria-selected='true']) .research-scene {
  --research-scene-image: url('assets/research-laboratory-military.jpg');
  --room-atlas-row: 100%;
  border-color: #78665e;
}
.research-workspace:has([data-research-area='espionage'][aria-selected='true']) .research-scene {
  --room-atlas-shade: linear-gradient(112deg, #17142cb8 0%, #251a4566 32%, transparent 72%);
  border-color: #74688d;
}

.research-console {
  display: grid;
  gap: 1px;
  width: min(285px, 56%);
  overflow: hidden;
  border: 1px solid #557489;
  border-radius: 8px;
  background: #081320ed;
  box-shadow: 0 6px 19px #020610b8;
}

.research-institute {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 3px 8px;
  min-block-size: 44px;
  padding: 9px 12px;
  border: 0;
  border-bottom: 1px solid #37576c;
  background: linear-gradient(125deg, #193548f5, #0d1828f5);
  color: #e4f0fb;
  text-align: start;
  font-size: .88rem;
  font-weight: 650;
}
.research-institute:hover { background: #1c3e51; }
.research-institute:focus-visible { outline-offset: -3px; }
.research-institute strong { color: #83dcf5; white-space: nowrap; }

.research-activity { padding: 8px 12px 9px; }
.research-activity h2 { margin: 0 0 3px; color: #b7cbe0; font: 650 .81rem / 1.2 var(--heading); }
.research-activity p { margin: 0; color: #dce7f4; font-size: .87rem; }
.research-activity button {
  display: block;
  min-block-size: 44px;
  padding: 3px 0;
  border: 0;
  background: transparent;
  color: var(--amber);
  text-align: start;
  font-size: .87rem;
  font-weight: 650;
}
.research-activity button:hover { text-decoration: underline; }
.research-remaining { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 3px 8px; color: #b7cbe0; font-size: .8rem; }
.research-remaining time { color: var(--cyan); font-weight: 700; font-variant-numeric: tabular-nums; }

.research-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.research-focus { display: grid; min-width: 0; gap: 12px; }
.research-return { display: none; justify-self: start; min-block-size: 44px; scroll-margin-block-start: 130px; }
#research-catalog:empty { display: none; }
#research-tree-panel, .research-metadata { min-width: 0; scroll-margin-top: 130px; }
#research-tree-panel { overflow: clip; }

.research-tools {
  display: grid;
  gap: 9px;
  padding: 12px;
  border-bottom: 1px solid #2b4056;
  background: linear-gradient(150deg, #142437, #0d1828 72%);
}

.research-areas {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) repeat(3, minmax(0, 1fr));
  gap: 5px;
  inline-size: min(100%, 620px);
  padding: 4px;
  border: 1px solid #536e84;
  border-radius: 8px;
  background: #081320ed;
  box-shadow: 0 5px 16px #020610b8;
}
.research-areas button {
  --area-accent: #83dcf5;
  min-width: 0;
  min-block-size: 48px;
  padding: 5px 9px;
  border: 1px solid #30445b;
  border-radius: 5px;
  background: #102033;
  color: #dae6f1;
  text-align: center;
  overflow-wrap: anywhere;
  font: 700 clamp(.88rem, 1.45vw, 1.05rem) / 1.22 var(--heading);
}
.research-areas [data-research-area='civilian'] { --area-accent: #b7ebcb; }
.research-areas [data-research-area='military'] { --area-accent: #f7c581; }
.research-areas [data-research-area='espionage'] { --area-accent: #d9c9ff; }
.research-areas button:hover { background: #21344a; color: #f0f6fd; }
.research-areas button[aria-selected='true'] {
  border-color: color-mix(in srgb, var(--area-accent) 64%, #28364a);
  background: color-mix(in srgb, var(--area-accent) 15%, #0d1828);
  color: var(--area-accent);
  box-shadow: inset 0 -2px var(--area-accent);
}

.research-filters { display: flex; flex-wrap: wrap; gap: 5px; }
.research-filters button {
  min-height: 40px;
  padding: 5px 8px;
  border: 1px solid #344d63;
  border-radius: 6px;
  background: #111f31;
  color: #d7e0ee;
  font-size: .81rem;
  font-weight: 650;
}
.research-filters button:hover { background: #1b3148; }
.research-filters button[aria-pressed='true'] { border-color: #4a839a; background: #142f42; color: #b2ecfc; }
.research-search input {
  width: 100%;
  min-height: 40px;
  padding: 7px 9px;
  border: 1px solid #38536a;
  border-radius: 6px;
  background: #050b16;
  color: inherit;
  font: inherit;
  font-size: .87rem;
}
.research-search input::placeholder { color: #aebbd0; }
.research-search input:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.research-key {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 13px;
  padding: 8px 12px;
  border-bottom: 1px solid #354257;
  color: #b8c8dc;
  font-size: .75rem;
}
.research-key span { display: inline-flex; align-items: center; gap: 5px; }
.research-key span::before { width: 14px; height: 2px; content: ''; background: var(--amber); }
.research-key [data-tone='unlocks']::before { background: var(--cyan); }

.research-board { position: relative; --research-columns: repeat(4, minmax(0, 1fr)); background: radial-gradient(ellipse at 10% 0%, #14253a, transparent 62%), #080f1c; }
.research-edges { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.research-phases, .research-stages { display: grid; grid-template-columns: var(--research-columns); }
.research-phases { position: relative; background: #132234; }
.research-phases span { padding: 8px; border-left: 1px solid #29364b; color: #becde2; font-size: .76rem; font-weight: 650; }
.research-phases span:first-child { border-left: 0; }
.research-lane + .research-lane { border-top: 1px solid #344358; }
.research-lane header { position: relative; padding: 8px 9px; border-block: 1px solid #2b4056; background: linear-gradient(90deg, #142a3e, #0d1828 78%); }
.research-lane h3 { margin: 0; color: #e0eafa; font: 650 .9rem var(--heading); }
.research-stage { display: grid; min-width: 0; gap: 6px; align-content: start; padding: 8px; border-left: 1px solid #29364b; }
.research-stage:first-child { border-left: 0; }
.research-mobile-phase { display: none; }
.research-node {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 4px;
  align-content: center;
  min-width: 0;
  min-height: 54px;
  padding: 6px 7px;
  border: 1px solid #354c63;
  border-radius: 6px;
  background: linear-gradient(153deg, #142437, #0d1828 78%);
  text-align: start;
}
.research-node strong { line-height: 1.2; overflow-wrap: anywhere; font-size: .82rem; }
.research-node small { color: #b4c4d9; font-size: .71rem; }
.research-node[data-research-status='planned'] { background: #101a2a; }
.research-node[data-research-status='running'] small, .research-node[data-research-status='finished'] small { color: var(--cyan); }
.research-node[data-relation='required'] { border-color: #ac8556; box-shadow: inset 2px 0 #f7c581; }
.research-node[data-relation='unlocks'] { border-color: #4b8696; box-shadow: inset 2px 0 #63a8bc; }
.research-node:hover { background: #1a3046; border-color: #658ba5; }
.research-node[aria-pressed='true'] { border-color: #5da1b7; background: linear-gradient(153deg, #193c4e, #102436); box-shadow: inset 2px 0 #83dcf5; color: #b2ecfc; }
.research-empty { margin: 0; padding: 14px 12px; color: #b8c8dc; font-size: .86rem; }

.research-metadata { padding: clamp(11px, 2vw, 16px); }
.research-metadata-heading {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.research-metadata-group + .research-metadata-group {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.research-metadata-heading h2 { margin: 0 0 6px; font: 650 clamp(1.25rem, 2.6vw, 1.85rem)/1.15 var(--heading); overflow-wrap: anywhere; }
.research-metadata-heading h2:focus { outline: none; }
.research-metadata-heading p:last-of-type { margin-bottom: 0; }
.research-metadata-heading .button-secondary { margin-top: 9px; }
.research-metadata-group h3 { margin: 0 0 7px; font: 650 1rem var(--heading); }
.research-metadata-group h4 { margin: 9px 0 5px; color: #c9d7e9; font-size: .81rem; }
.research-metadata-group p, .research-metadata-heading p:not(.eyebrow) { color: #bbcade; font-size: .87rem; }
.research-metadata-group p { margin: 7px 0 0; }
.research-effects, .research-references { display: grid; gap: 5px; margin: 0; padding: 0; list-style: none; }
.research-effects li {
  display: grid;
  gap: 3px;
  padding: 7px 8px;
  border: 1px solid #30475c;
  border-radius: 5px;
  background: #0d1929;
  overflow-wrap: anywhere;
  font-size: .84rem;
}
.research-effects li > span { color: #becce0; }
.research-effects small, .research-reference-name small { color: #b7c5da; font-weight: 500; font-size: .72rem; }
.research-effects small { margin-left: 5px; }
.research-references button {
  display: flex;
  width: 100%;
  min-height: 38px;
  justify-content: space-between;
  align-items: center;
  gap: 7px;
  padding: 5px 7px;
  border: 1px solid #3c5269;
  border-radius: 5px;
  background: #112034;
  text-align: start;
  color: #e5effa;
  font-size: .82rem;
}
.research-references button:hover { border-color: #6a9bb4; background: #193247; }
.research-reference-name { display: grid; gap: 2px; overflow-wrap: anywhere; }
.research-references button > span:last-child { flex: none; color: #ebcda6; font-size: .76rem; }

@media (max-width: 1150px) {
  .research-layout { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .research-return { display: inline-flex; }
  #catalog-jump[aria-controls='research-tree-panel'] { display: inline-flex; }
}

@media (max-width: 640px) {
  .research-workspace { gap: 12px; }
  .research-scene { padding: 9px; background-position: center, 63% 53%; }
  .research-console { width: min(252px, 62%); }
  .research-institute, .research-activity { padding-inline: 9px; }
  .research-phases { display: none; }
  .research-stages { display: block; }
  .research-stage { grid-template-columns: repeat(2, minmax(0, 1fr)); border-left: 0; }
  .research-stage[data-empty] { display: none; }
  .research-mobile-phase {
    position: relative;
    z-index: 1;
    display: block;
    grid-column: 1 / -1;
    color: #b9cbe2;
    font-size: .74rem;
    font-weight: 650;
  }
}

@media (orientation: landscape) and (max-height: 600px) {
  .research-workspace { gap: 10px; }
  .research-scene { min-block-size: clamp(170px, 46dvh, 250px); padding: 10px; background-position: center, 60% 46%; }
  .research-areas { inline-size: min(100%, 510px); }
  .research-areas button { min-block-size: 44px; padding-inline: 6px; font-size: .9rem; }
  .research-tools { gap: 6px; padding: 8px; }
  .research-key { padding: 6px 8px; }
  .research-metadata { padding: 9px 10px; }
  .research-return { scroll-margin-block-start: 4px; }
}

@media (orientation: landscape) and (max-height: 600px) and (min-width: 745px) {
  .research-layout { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 10px; }
  .research-return { display: none; }
}
