:root {
  --canvas: #000000;
  --surface: #0f1216;
  --surface-2: #171d24;
  --surface-3: #202832;
  --text: #ffffff;
  --muted: #c7d0dc;
  --quiet: #8f9aaa;
  --cyan: #00d4ff;
  --green: #7dffba;
  --amber: #ffd166;
  --orange: #ff8a3d;
  --magenta: #ff5bd6;
  --line: rgba(255, 255, 255, 0.13);
  --line-strong: rgba(255, 255, 255, 0.24);
  --cyan-glow: rgba(0, 212, 255, 0.42);
  --orange-glow: rgba(255, 138, 61, 0.36);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 600px;
  height: 600px;
  margin: 0;
  overflow: hidden;
  background: var(--canvas);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

#app {
  width: 600px;
  height: 600px;
  padding: 8px;
  --anchor-x: 0px;
  --anchor-y: 0px;
}

.hud {
  width: 584px;
  height: 584px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.topbar,
.commandbar,
.proxy-card,
.attribute-rail,
.status-button {
  background: rgba(15, 18, 22, 0.94);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.topbar {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 13px 15px;
}

h1,
h2,
p,
ol {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.05;
}

.brand p {
  margin-top: 6px;
  color: var(--quiet);
  font-size: 13px;
}

.brand .bridge-line {
  margin-top: 4px;
  color: var(--green);
  font-size: 11px;
  font-weight: 760;
}

.brand .bridge-line.stale {
  color: var(--amber);
}

.brand .bridge-line.offline {
  color: var(--quiet);
}

.status-button {
  width: 72px;
  height: 50px;
  color: var(--green);
  font-size: 14px;
  font-weight: 850;
}

.viewport {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  border-radius: 12px;
}

.world-grid {
  position: absolute;
  inset: 0;
  opacity: 0.58;
  background:
    linear-gradient(90deg, rgba(0, 212, 255, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(0, 212, 255, 0.08) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at 50% 46%, black, transparent 72%);
}

.layer {
  position: absolute;
  inset: 0;
}

.hidden {
  display: none !important;
}

.world-anchor {
  position: absolute;
  inset: 0;
  transform: translate(var(--anchor-x), var(--anchor-y));
  transition: transform 140ms linear;
}

#app[data-anchor="head"] .world-anchor {
  transform: translate(0, 0);
}

#app[data-anchor="locked"] .world-anchor::after {
  content: "book locked";
  position: absolute;
  left: 58px;
  top: 20px;
  padding: 5px 8px;
  color: var(--green);
  background: rgba(15, 18, 22, 0.86);
  border: 1px solid rgba(125, 255, 186, 0.22);
  border-radius: 7px;
  font-size: 10px;
  font-weight: 850;
}

.book-frame {
  position: absolute;
  left: 58px;
  top: 58px;
  width: 356px;
  height: 292px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(90deg, transparent 49%, rgba(255, 255, 255, 0.14) 50%, transparent 51%),
    rgba(255, 255, 255, 0.035);
  transform: perspective(580px) rotateX(8deg) rotateY(-10deg);
  box-shadow: 0 0 34px rgba(0, 212, 255, 0.08);
}

.page-edge {
  position: absolute;
  inset: 16px;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: 6px;
}

.page-line {
  position: absolute;
  left: 32px;
  width: 120px;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}

.page-line.long {
  top: 64px;
  width: 126px;
}

.page-line:not(.long):not(.short) {
  top: 88px;
}

.page-line.short {
  top: 112px;
  width: 92px;
}

.page-focus {
  position: absolute;
  left: 190px;
  top: 70px;
  width: 124px;
  height: 92px;
  border: 2px solid var(--cyan);
  border-radius: 8px;
  box-shadow: 0 0 22px var(--cyan-glow);
}

.anchor-pin {
  position: absolute;
  left: 242px;
  top: 120px;
  width: 30px;
  height: 30px;
  border: 2px solid var(--amber);
  border-radius: 50%;
  box-shadow: 0 0 18px rgba(255, 209, 102, 0.34);
}

.anchor-pin::before,
.anchor-pin::after {
  content: "";
  position: absolute;
  background: var(--amber);
}

.anchor-pin::before {
  left: 13px;
  top: -9px;
  width: 2px;
  height: 44px;
}

.anchor-pin::after {
  left: -9px;
  top: 13px;
  width: 44px;
  height: 2px;
}

.translation-overlay {
  position: absolute;
  left: 178px;
  top: 86px;
  width: 142px;
  display: none;
  gap: 6px;
  transform: translateZ(28px);
}

.translation-overlay span,
.translation-overlay strong {
  display: block;
  padding: 5px 7px;
  border-radius: 5px;
  background: rgba(0, 212, 255, 0.11);
  border: 1px solid rgba(0, 212, 255, 0.26);
  box-shadow: 0 0 16px rgba(0, 212, 255, 0.16);
}

.translation-overlay span {
  color: var(--quiet);
  font-size: 8px;
  font-weight: 760;
}

.translation-overlay strong {
  color: var(--text);
  font-size: 10px;
  line-height: 1.22;
}

.scan-view.show-translation .translation-overlay {
  display: grid;
}

.proxy-chip {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 164px;
  min-height: 66px;
  padding: 10px 12px;
  color: var(--text);
  text-align: left;
  background: rgba(23, 29, 36, 0.94);
  border: 2px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
}

.proxy-chip span {
  display: block;
  color: var(--green);
  font-size: 12px;
  font-weight: 850;
}

.proxy-chip strong {
  display: block;
  margin-top: 7px;
  font-size: 15px;
  line-height: 1.15;
}

.proxy-chip.selected {
  border-color: var(--orange);
  box-shadow: 0 0 24px var(--orange-glow);
}

.hand-zone {
  position: absolute;
  right: 28px;
  bottom: 22px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--amber);
  font-size: 13px;
  font-weight: 850;
}

.hand-dot {
  width: 18px;
  height: 18px;
  border: 3px solid var(--amber);
  border-radius: 50%;
  box-shadow: 0 0 18px rgba(255, 209, 102, 0.42);
}

.proxy-view {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 104px;
  gap: 10px;
  overflow: hidden;
}

.proxy-stack {
  position: relative;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.proxy-card {
  position: absolute;
  inset: 0;
  padding: 18px;
  background: linear-gradient(145deg, rgba(23, 29, 36, 0.96), rgba(12, 18, 23, 0.96));
}

.proxy-card:not(.active) {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.card-label {
  color: var(--green);
  font-size: 13px;
  font-weight: 850;
}

.proxy-card h2 {
  margin-top: 16px;
  font-size: 31px;
  line-height: 1.05;
}

#summary-list {
  display: flex;
  flex-direction: column;
  gap: 11px;
  margin-top: 20px;
  padding-left: 28px;
  font-size: 18px;
  line-height: 1.24;
  font-weight: 720;
}

#summary-list li::marker {
  color: var(--cyan);
  font-weight: 900;
}

.diagram {
  display: grid;
  grid-template-columns: 1fr 46px 1fr;
  grid-template-rows: 88px 42px 88px;
  gap: 10px;
  margin-top: 26px;
}

.graph-space {
  position: relative;
  height: 202px;
  margin-top: 18px;
  perspective: 520px;
  transform: translate(calc(var(--anchor-x) * 0.45), calc(var(--anchor-y) * 0.45));
  transition: transform 140ms linear;
}

#app[data-anchor="head"] .graph-space {
  transform: translate(0, 0);
}

#app[data-anchor="locked"] .graph-space::after {
  content: "book locked";
  position: absolute;
  left: 16px;
  top: 8px;
  padding: 5px 8px;
  color: var(--green);
  background: rgba(15, 18, 22, 0.86);
  border: 1px solid rgba(125, 255, 186, 0.22);
  border-radius: 7px;
  font-size: 10px;
  font-weight: 850;
}

.graph-plane {
  position: absolute;
  left: 42px;
  top: 28px;
  width: 288px;
  height: 146px;
  border: 1px solid rgba(0, 212, 255, 0.22);
  background:
    linear-gradient(90deg, rgba(0, 212, 255, 0.12) 1px, transparent 1px),
    linear-gradient(rgba(0, 212, 255, 0.12) 1px, transparent 1px),
    rgba(0, 212, 255, 0.035);
  background-size: 24px 24px;
  transform: rotateX(62deg) rotateZ(-8deg);
  transform-origin: 50% 72%;
  box-shadow: 0 26px 38px rgba(0, 0, 0, 0.28), 0 0 28px rgba(0, 212, 255, 0.16);
}

.graph-space svg {
  position: absolute;
  inset: 0;
  filter: drop-shadow(0 0 12px rgba(0, 212, 255, 0.28));
}

.axis {
  fill: none;
  stroke: rgba(255, 255, 255, 0.32);
  stroke-width: 2;
}

.graph-curve {
  fill: none;
  stroke: url("#graph-stroke");
  stroke-width: 6;
  stroke-linecap: round;
}

.graph-point {
  fill: var(--amber);
  stroke: rgba(255, 255, 255, 0.9);
  stroke-width: 2;
}

.graph-point.soft {
  fill: var(--magenta);
}

.equation {
  position: absolute;
  right: 12px;
  top: 4px;
  max-width: 178px;
  padding: 8px 10px;
  color: #001219;
  background: var(--green);
  border-radius: 8px;
  font-size: 15px;
  font-weight: 850;
  text-align: center;
}

.graph-insights {
  display: grid;
  gap: 7px;
  margin: 4px 0 0;
  padding-left: 22px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.22;
  font-weight: 740;
}

.translation-demo {
  display: grid;
  gap: 8px;
  margin-top: 20px;
  padding: 18px;
  border: 1px solid rgba(0, 212, 255, 0.24);
  border-radius: 10px;
  background:
    linear-gradient(90deg, transparent 49%, rgba(255, 255, 255, 0.11) 50%, transparent 51%),
    rgba(255, 255, 255, 0.035);
}

.translation-demo p {
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 15px;
  line-height: 1.25;
  font-weight: 760;
}

.translation-demo .original-line {
  color: var(--quiet);
  background: rgba(255, 255, 255, 0.055);
}

#translation-line-1,
#translation-line-2 {
  color: var(--text);
  background: rgba(0, 212, 255, 0.12);
  border: 1px solid rgba(0, 212, 255, 0.26);
}

.memory-panel {
  display: grid;
  gap: 10px;
  margin-top: 20px;
  padding: 18px;
  border: 1px solid rgba(125, 255, 186, 0.22);
  border-radius: 10px;
  background: rgba(125, 255, 186, 0.055);
}

.memory-label {
  color: var(--green);
  font-size: 12px;
  font-weight: 850;
}

#highlight-quote {
  margin: 0;
  padding: 12px 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  border-left: 4px solid var(--amber);
  border-radius: 8px;
  font-size: 17px;
  line-height: 1.28;
  font-weight: 760;
}

.memory-target,
.ask-question,
.ask-answer {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.26;
  font-weight: 760;
}

.memory-target {
  color: var(--quiet);
  background: rgba(255, 255, 255, 0.055);
}

.ask-question {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.055);
}

.ask-answer {
  color: var(--text);
  background: rgba(0, 212, 255, 0.12);
  border: 1px solid rgba(0, 212, 255, 0.26);
}

.hierarchy-list {
  display: flex;
  gap: 7px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
}

.hierarchy-list li {
  max-width: 96px;
  padding: 7px 9px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
}

.hierarchy-list li.current {
  color: #001219;
  background: var(--green);
}

.node {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  border-radius: 11px;
  text-align: center;
  font-size: 18px;
  font-weight: 850;
  background: var(--surface-3);
  border: 1px solid var(--line);
}

.node.proxy {
  color: #001219;
  background: var(--cyan);
}

.node.action {
  grid-column: 2 / 4;
}

.connector {
  align-self: center;
  height: 4px;
  border-radius: 999px;
  background: var(--amber);
}

.connector.down {
  grid-column: 2;
  grid-row: 2;
  width: 4px;
  height: 42px;
  justify-self: center;
}

.attribute-rail {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 12px;
  overflow: hidden;
}

.attribute-rail p {
  color: var(--quiet);
  font-size: 12px;
  font-weight: 850;
}

.attribute-rail span {
  display: block;
  padding: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  font-size: 11px;
  font-weight: 760;
}

.attribute-list {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 2px 0 0;
  padding: 0;
  list-style: none;
  overflow: hidden;
}

.attribute-list li {
  padding: 7px 8px;
  color: var(--green);
  background: rgba(125, 255, 186, 0.09);
  border: 1px solid rgba(125, 255, 186, 0.18);
  border-radius: 8px;
  font-size: 10px;
  font-weight: 760;
  line-height: 1.15;
}

.commandbar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  min-height: 88px;
  padding: 0;
  background: transparent;
  border: 0;
}

.command {
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--text);
  background: var(--surface-2);
  border: 2px solid transparent;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 850;
}

.command.primary {
  color: #001219;
  background: var(--cyan);
}

.key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.3);
}

.primary .key {
  color: #001219;
  background: rgba(255, 255, 255, 0.52);
}

.focusable {
  transition:
    transform 475ms cubic-bezier(0.6, 0, 0.4, 1),
    border-color 300ms cubic-bezier(0.4, 0.04, 0.5, 1),
    box-shadow 300ms cubic-bezier(0.4, 0.04, 0.5, 1);
}

.focusable:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 24px var(--cyan-glow);
  transform: scale(0.96);
}

.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  z-index: 20;
  width: min(536px, calc(100% - 48px));
  padding: 14px 18px;
  color: var(--text);
  background: rgba(32, 40, 50, 0.98);
  border: 1px solid var(--cyan);
  border-radius: 24px;
  font-size: 15px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(-16px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .focusable,
  .toast {
    transition: none;
  }
}
