/* Research skill tree (#/research, js/screens/research.js): painted backdrop, top bar, pannable tree, engram card. Portrait first. */
.shell[data-screen="research"] main { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.rs-screen.screen { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; max-width: none; margin: 0; padding: 0; }
.rs-screen.gu-backdrop { margin: 0; padding: 0; min-height: 0;
  background: linear-gradient(180deg, rgba(13,16,21,.35) 0, rgba(13,16,21,.62) 40%, rgba(13,16,21,.82) 100%), var(--gu-bg, none) center / cover no-repeat, var(--bg-void); }

/* ---------- top bar ---------- */
.rs-top { flex: none; padding: 8px 10px 0; display: grid; gap: 6px; position: relative; z-index: 2; }
.rs-top .gu-plate { margin-bottom: 0; min-height: 48px; }
.rs-rp { display: inline-flex; align-items: center; gap: 4px; min-height: 36px; padding: 0 8px; background: rgba(8,10,14,.72); border: 1px solid #3A4658; font-size: 14px; white-space: nowrap; }
.rs-rp .rs-rate { color: #6FDDA0; font-size: 12px; }
.rs-rp .rs-rate.warn { color: var(--signal-warn); }
.rs-icon-btn { background: rgba(8,10,14,.6); }
.rs-now { display: flex; align-items: center; gap: 8px; min-height: 56px; padding: 6px 8px; background: rgba(22,26,33,.88); border: 1px solid var(--lc, #3A4658); }
.rs-now.idle { border-color: #3A4658; }
.rs-now-ic { flex: none; display: flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; padding: 0; background: none; border: 0; cursor: pointer; }
.rs-now-b { flex: 1; min-width: 0; display: grid; gap: 3px; line-height: 1.3; }
.rs-now-t { display: flex; gap: 6px; align-items: baseline; min-width: 0; }
.rs-now-t b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rs-now-k { flex: none; font-size: 11px; color: var(--lc, var(--text-2)); }
.rs-now .gu-gauge { height: 10px; }
.rs-bar-empty { height: 10px; background: #0B0E12; border: 1px dashed #3A4658; }
.rs-cancel.btn.small { flex: none; min-height: 44px; }
.rs-chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.rs-chips::-webkit-scrollbar { display: none; }
.rs-chip { flex: none; position: relative; display: inline-flex; align-items: center; gap: 5px; min-height: 40px; padding: 0 10px; background: rgba(20,24,31,.9); border: 1px solid #3A4658;
  color: var(--text-1); font: 600 13px var(--font-head); cursor: pointer; clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px); }
.rs-chip.on { border-color: var(--lc, var(--text-1)); background: linear-gradient(180deg, rgba(255,255,255,.12), rgba(255,255,255,.02)), rgba(20,24,31,.95); box-shadow: inset 0 -3px 0 var(--lc, var(--text-1)); }
.rs-chip-em { display: flex; }
.rs-chip-n { font-size: 11px; color: var(--text-2); }
.rs-chip-n.soon { color: #3FD1C2; }
.rs-chip-dot { position: absolute; top: 4px; right: 4px; width: 7px; height: 7px; border-radius: 50%; background: var(--lc); }
.rs-chip.quick { border-color: #6A5520; color: #F2C860; }
.rs-chip.quick b { min-width: 20px; text-align: center; padding: 0 4px; background: #F2C860; color: #0D1015; }
.rs-chip.quick.hot { animation: rs-hot 1.6s ease-in-out infinite; }
@keyframes rs-hot { 50% { box-shadow: 0 0 0 2px rgba(242,200,96,.5), 0 0 14px rgba(242,200,96,.35); } }
.rs-chip:focus-visible, .rs-node:focus-visible, .rs-zb:focus-visible, .rs-lhead:focus-visible { outline: 2px solid var(--signal-warn); outline-offset: 2px; }

/* ---------- tree viewport ---------- */
.rs-vp { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab;
  border-top: 1px solid rgba(58,70,88,.6); }
.rs-vp.dragging { cursor: grabbing; }
.rs-canvas { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform;
  background-image: linear-gradient(rgba(79,168,232,.06) 1px, transparent 1px), linear-gradient(90deg, rgba(79,168,232,.06) 1px, transparent 1px); background-size: 28px 28px; }
.rs-canvas.rs-anim, .rs-gutter.rs-anim .rs-tier { transition: transform .32s cubic-bezier(.2,.8,.2,1); }
.rs-band { position: absolute; left: 0; right: 0; pointer-events: none; }
.rs-band.odd { background: linear-gradient(90deg, rgba(255,255,255,.035), rgba(255,255,255,.015)); }
.rs-block { position: absolute; top: 0; transition: opacity .2s; }
.rs-canvas[data-filter] .rs-block:not(.on) { opacity: .28; }
.rs-block.soon .rs-node, .rs-block.soon .rs-link { filter: saturate(.55); }

/* line header */
.rs-lhead { position: absolute; left: 4px; right: 4px; top: 8px; height: 70px; display: flex; align-items: center; gap: 8px; padding: 4px 8px; cursor: pointer;
  background: linear-gradient(180deg, rgba(30,36,46,.92), rgba(16,19,25,.92)); border: 1px solid #3A4658; border-bottom: 3px solid var(--lc); color: var(--text-1); text-align: left;
  clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 0 100%, 0 8px); }
.rs-lhead-em { flex: none; display: flex; filter: drop-shadow(0 2px 0 rgba(0,0,0,.6)); }
.rs-lhead-t { min-width: 0; display: grid; line-height: 1.25; }
.rs-lhead-t b { font: 600 15px var(--font-head); color: var(--lc); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rs-lhead-n { font-size: 12px; color: var(--text-2); }
.rs-soon { position: absolute; top: 4px; right: -2px; padding: 1px 8px; background: #3FD1C2; color: #0D1015; font: 700 10px var(--font-head); letter-spacing: .04em; transform: rotate(6deg); }

/* connectors (art: ui:rs_link / _v / _on, repeat along the run) */
.rs-link { position: absolute; display: block; pointer-events: none; image-rendering: pixelated; }
.rs-link.h { height: 12px; background: var(--rs-h) left center / 16px 12px repeat-x; }
.rs-link.v { width: 12px; background: var(--rs-v) center top / 12px 16px repeat-y; }
.rs-link.h.on { background-image: var(--rs-h-on); filter: drop-shadow(0 0 4px var(--lc)); }
.rs-link.v.on { background-image: var(--rs-v-on); filter: drop-shadow(0 0 4px var(--lc)); }
.rs-canvas.noart .rs-link.h { background: linear-gradient(#2D333D, #2D333D) center / 100% 4px no-repeat; }
.rs-canvas.noart .rs-link.v { background: linear-gradient(#2D333D, #2D333D) center / 4px 100% no-repeat; }
.rs-canvas.noart .rs-link.on { background-image: linear-gradient(var(--lc), var(--lc)); }

/* nodes */
.rs-node { position: absolute; width: 56px; height: 56px; padding: 0; border: 0; background: none; cursor: pointer; z-index: 2; }
.rs-frame { position: absolute; inset: 0; display: block; }
.rs-frame .rs-frame-img { image-rendering: pixelated; }
.rs-frame.flat { background: #161A21; border: 2px solid #3A4658; clip-path: polygon(14px 0, calc(100% - 14px) 0, 100% 14px, 100% calc(100% - 14px), calc(100% - 14px) 100%, 14px 100%, 0 calc(100% - 14px), 0 14px); }
.rs-node.s-open .rs-frame.flat { border-color: var(--lc); }
.rs-node.s-done .rs-frame.flat { border-color: #E3B341; }
.rs-ico { position: absolute; left: 8px; top: 8px; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; }
.rs-ico > * { filter: drop-shadow(0 1px 0 rgba(0,0,0,.7)); }
.rs-node.s-locked .rs-ico { filter: grayscale(1) brightness(.6); opacity: .75; }
.rs-node.busy .rs-ico { opacity: .85; }
.rs-node:active { transform: scale(.94); }
.rs-glow { position: absolute; inset: -10px; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--lc) 70%, transparent) 0, transparent 68%); animation: rs-pulse 1.6s ease-in-out infinite; pointer-events: none; z-index: -1; }
@supports not (background: color-mix(in srgb, red 50%, transparent)) { .rs-glow { background: radial-gradient(circle, rgba(242,200,96,.55) 0, transparent 68%); } }
@keyframes rs-pulse { 0%, 100% { opacity: .45; transform: scale(.9); } 50% { opacity: 1; transform: scale(1.1); } }
.rs-check { position: absolute; right: -4px; bottom: -4px; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #FFE59A, #E3A72F 60%, #9A6A12); color: #2A1C02; border: 1.5px solid #0B0D14; box-shadow: 0 1px 0 rgba(0,0,0,.6); }
.rs-check.sm { width: 14px; height: 14px; right: -2px; bottom: -2px; }
.rs-lock { position: absolute; right: 2px; top: 2px; }
.rs-ring { position: absolute; left: -8px; top: -8px; width: 72px; height: 72px; transform: rotate(-90deg); pointer-events: none; }
.rs-ring-bg { fill: none; stroke: rgba(0,0,0,.55); stroke-width: 5; }
.rs-ring-fg { fill: none; stroke: var(--lc); stroke-width: 5; stroke-linecap: butt; transition: stroke-dashoffset 1s linear; filter: drop-shadow(0 0 3px var(--lc)); }
.rs-node.s-active { animation: rs-bob 2.4s ease-in-out infinite; }
@keyframes rs-bob { 50% { transform: translateY(-2px); } }

.rs-label { position: absolute; z-index: 3; display: grid; justify-items: center; gap: 1px; padding: 2px 3px 3px; text-align: center; pointer-events: none;
  background: rgba(10,12,16,.82); border: 1px solid rgba(58,70,88,.7); line-height: 1.2; }
.rs-name { font-size: 11px; color: var(--text-1); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.rs-st { font-size: 10px; color: var(--text-2); white-space: nowrap; }
.rs-label.s-open .rs-st { color: var(--lc); font-weight: 600; }
.rs-label.s-done .rs-st { color: #F2C860; }
.rs-label.s-active { border-color: var(--lc); }
.rs-label.s-active .rs-st { color: var(--lc); }
.rs-label.s-locked .rs-name { color: var(--text-2); }
.rs-st.why-lab, .rs-st.why-relic { color: #D9925A; }

/* sticky tier labels on the left */
.rs-gutter { position: absolute; left: 0; top: 0; bottom: 0; width: 52px; pointer-events: none; z-index: 3; background: linear-gradient(90deg, rgba(10,12,16,.75), rgba(10,12,16,0)); }
.rs-tier { position: absolute; left: 0; top: 0; width: 48px; margin-top: -20px; display: grid; justify-items: center; padding: 3px 0; background: rgba(16,19,25,.9); border: 1px solid #3A4658; border-left: 0; line-height: 1.15; }
.rs-tier b { font: 600 12px var(--font-head); }
.rs-tier span { font-size: 10px; color: var(--text-2); }
.rs-tier.lock span { color: #D9925A; }

/* zoom buttons */
.rs-zoom { position: absolute; right: 8px; bottom: calc(10px + var(--safe-b)); display: grid; gap: 6px; z-index: 4; }
.rs-zb { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; padding: 0; color: var(--text-1); cursor: pointer;
  background: linear-gradient(180deg, #2A3342, #1A1F28); border: 1px solid #4A5870; box-shadow: 0 2px 0 #0A0C10; }
.rs-zb:active { transform: translateY(1px); box-shadow: none; }

/* no Research Lab yet */
.rs-nolab { position: absolute; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(8,10,14,.55); }
.rs-nolab-card { width: min(340px, 100%); display: grid; gap: 8px; justify-items: center; text-align: center; padding: 16px; background: rgba(22,26,33,.96); border: 1px solid #4A5870; cursor: default; touch-action: auto; }
.rs-nolab-card h2 { font-size: 18px; }
.rs-nolab-card p { margin: 0; font-size: 14px; line-height: 1.5; color: var(--text-1); }
.rs-nolab-art { padding: 8px 12px; background: radial-gradient(circle, rgba(79,168,232,.25), transparent 70%); }
.rs-nolab-eta { color: var(--signal-warn); }
.rs-big.btn { min-height: 52px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-size: 16px; }

/* ---------- engram card (sheet) ---------- */
.rs-card { display: grid; gap: 12px; }
.rs-card-head { display: flex; gap: 12px; align-items: center; }
.rs-big-node { position: relative; flex: none; display: flex; }
.rs-big-node .rs-glow.big { inset: -14px; }
.rs-card-ht { min-width: 0; display: grid; gap: 2px; }
.rs-card-ht h2 { font-size: 19px; line-height: 1.25; }
.rs-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.rs-tag { display: inline-flex; align-items: center; gap: 4px; min-height: 22px; padding: 0 6px; font-size: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.rs-tag.line { border-color: var(--lc); color: var(--lc); }
.rs-tag.done { background: #E3A72F; color: #1A1203; border-color: #FFE59A; }
.rs-tag.open { border-color: var(--lc); color: #0D1015; background: var(--lc); }
.rs-tag.active { border-color: var(--lc); color: var(--lc); }
.rs-tag.locked { color: #D9925A; border-color: #5A3E28; }
.rs-mini { position: relative; flex: none; display: inline-block; }
.rs-mini.flat { background: #161A21; border: 2px solid #3A4658; }
.rs-mini .rs-frame-img { position: absolute; inset: 0; }
.rs-mini-ic { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.rs-mini.s-locked .rs-mini-ic { filter: grayscale(1) brightness(.65); }
.rs-sec { display: grid; gap: 6px; }
.rs-sec-t { font: 600 13px var(--font-head); color: var(--lc, var(--text-2)); letter-spacing: .02em; border-bottom: 1px solid var(--line); padding-bottom: 3px; }
.rs-what, .rs-needs { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.rs-what li { display: flex; gap: 8px; align-items: flex-start; font-size: 15px; line-height: 1.45; }
.rs-what-ic { flex: none; display: flex; width: 20px; justify-content: center; padding-top: 2px; color: var(--lc); }
.rs-what li.craft { padding: 6px 8px; background: rgba(63,209,194,.08); border: 1px solid rgba(63,209,194,.35); }
.rs-cost { display: flex; flex-wrap: wrap; gap: 6px; }
.rs-pill { display: inline-flex; align-items: center; gap: 5px; min-height: 34px; padding: 0 10px; background: var(--surface-2); border: 1px solid var(--line); font-size: 14px; }
.rs-pill.short { border-color: #8A5A2A; }
.rs-pill.short b { color: var(--signal-warn); }
.rs-have { color: var(--text-2); }
.rs-needs li { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; line-height: 1.45; }
.rs-needs li.col { flex-direction: column; gap: 6px; }
.rs-req-row { display: flex; gap: 8px; align-items: flex-start; }
.rs-ok { flex: none; width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; }
.rs-ok.y { color: #6FDDA0; }
.rs-req-nodes { display: flex; flex-wrap: wrap; gap: 6px; }
.rs-req-node { display: inline-flex; align-items: center; gap: 6px; min-height: 48px; padding: 4px 10px 4px 4px; background: var(--surface-2); border: 1px solid var(--line); color: var(--text-1); font-size: 13px; cursor: pointer; text-align: left; }
.rs-req-node:active { background: #262C36; }
.rs-act { position: sticky; bottom: calc(-16px - var(--safe-b)); display: grid; gap: 8px; margin: 0 -14px calc(-16px - var(--safe-b)); padding: 10px 14px calc(14px + var(--safe-b)); background: linear-gradient(180deg, rgba(22,26,33,.9), var(--surface-1) 30%); border-top: 1px solid var(--line); }
.rs-act-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rs-why { display: flex; gap: 6px; align-items: center; color: #D9925A; font-size: 14px; }
.rs-done-banner { display: flex; gap: 8px; align-items: center; justify-content: center; min-height: 48px; padding: 0 10px; background: linear-gradient(180deg, #F2C860, #D69A22); color: #1A1203; font: 600 14px var(--font-head); text-align: center; }

/* quick list */
.rs-q { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.rs-q-row { width: 100%; display: flex; align-items: center; gap: 10px; min-height: 60px; padding: 6px 8px; background: var(--surface-2); border: 1px solid var(--line); color: var(--text-1); text-align: left; cursor: pointer; }
.rs-q-b { flex: 1; min-width: 0; display: grid; line-height: 1.35; }
.rs-q-b .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rs-q-c { flex: none; display: inline-flex; align-items: center; gap: 3px; font-size: 13px; }

@media (prefers-reduced-motion: reduce) {
  .rs-glow, .rs-chip.quick.hot, .rs-node.s-active { animation: none !important; }
  .rs-canvas.rs-anim, .rs-gutter.rs-anim .rs-tier, .rs-ring-fg, .rs-block { transition: none !important; }
}
html.reduced .rs-glow, html.reduced .rs-chip.quick.hot, html.reduced .rs-node.s-active { animation: none !important; }
html.reduced .rs-canvas.rs-anim, html.reduced .rs-gutter.rs-anim .rs-tier, html.reduced .rs-ring-fg { transition: none !important; }
.rs-vp.far .rs-gutter { opacity: 0; }
.rs-gutter { transition: opacity .2s; }
