:root {
  --bg: #050907;
  --panel: #0D1711;
  --panel-2: #132219;
  --line: #1A3123;
  --line-bright: rgba(0, 230, 118, 0.3);
  --ink: #FFFFFF;
  --ink-dim: #94A3B8;
  --accent: #00E676;
  --accent-volt: #00FF87;
  --gold: #FBBF24;
  --cyan: #38BDF8;
  --danger: #EF4444;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: var(--bg); font-family: 'Plus Jakarta Sans', sans-serif;
  color: var(--ink); user-select: none;
}

#scene { position: fixed; inset: 0; display: block; touch-action: none; z-index: 1; }
#labels { position: fixed; inset: 0; pointer-events: none; z-index: 5; }

/* 3D Component floating labels */
.complabel {
  position: absolute; transform: translate(-50%, -100%); white-space: nowrap;
  font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 4px;
  background: rgba(13, 23, 17, 0.9); border: 1px solid var(--line-bright);
  color: var(--ink); display: flex; align-items: center; gap: 6px;
  backdrop-filter: blur(6px); box-shadow: 0 4px 14px rgba(0,0,0,0.6);
  transition: opacity 0.2s, transform 0.2s;
}
.complabel .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: none; box-shadow: 0 0 6px var(--accent); }
.complabel .bus-tag { font-family: 'JetBrains Mono', monospace; font-size: 9px; color: var(--gold); }

/* Toolbar */
#toolbar {
  position: fixed; top: 12px; left: 12px; right: 12px; z-index: 20;
  display: flex; align-items: center; gap: 8px; flex-wrap: nowrap;
  max-width: calc(100vw - 24px);
  pointer-events: none;
}
#toolbar > * { pointer-events: auto; }

#brand {
  background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  padding: 6px 12px; border-radius: 4px; display: flex; flex-direction: column;
  box-shadow: 0 4px 20px rgba(0,0,0,0.6); flex-shrink: 0;
}
#brand b { font-family: 'Oswald', sans-serif; font-size: 15px; letter-spacing: 0.8px; text-transform: uppercase; color: var(--ink); white-space: nowrap; }
#brand b span { color: var(--accent); }
#brand span.sub { font-size: 9.5px; color: var(--ink-dim); font-weight: 600; white-space: nowrap; }

/* Modes / Architecture Selector */
#modesBar {
  display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line);
  padding: 4px; border-radius: 6px; overflow-x: auto; flex-shrink: 1; min-width: 0;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
#modesBar::-webkit-scrollbar { display: none; }

.modebtn {
  background: transparent; border: 1px solid transparent; color: var(--ink-dim);
  font-family: 'Oswald', sans-serif; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px; padding: 6px 11px;
  border-radius: 4px; cursor: pointer; white-space: nowrap; transition: all 0.15s ease;
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
}
.modebtn:hover { background: var(--panel-2); color: var(--ink); }
.modebtn.active {
  background: var(--accent); color: #03140A; border-color: var(--accent);
  box-shadow: 0 0 12px rgba(0, 230, 118, 0.4);
}

/* Actions */
#actions {
  display: flex; gap: 5px; margin-left: auto; flex-shrink: 0;
  overflow-x: auto; scrollbar-width: none;
}
#actions::-webkit-scrollbar { display: none; }

.actbtn {
  display: flex; align-items: center; gap: 5px; padding: 6px 10px; border-radius: 6px;
  background: var(--panel); border: 1px solid var(--line); color: var(--ink);
  font-family: 'Plus Jakarta Sans', sans-serif; font-size: 11px; font-weight: 700;
  cursor: pointer; transition: all 0.15s; text-decoration: none; white-space: nowrap; flex-shrink: 0;
}
.actbtn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.8; flex-shrink: 0; }
.actbtn:hover { border-color: var(--accent); color: var(--accent); }
.actbtn.pulse-on { background: rgba(0, 230, 118, 0.15); border-color: var(--accent); color: var(--accent); }
.actbtn.mini { font-size: 10.5px; padding: 4px 8px; }

/* Responsive Media Queries for Hardware 3D */
@media (max-width: 1250px) {
  #actions .actbtn span { display: none; }
  .actbtn { padding: 6px 8px; }
  .modebtn { padding: 5px 8px; font-size: 10.5px; }
}

@media (max-width: 800px) {
  #brand span.sub { display: none; }
  #brand b { font-size: 13px; }
  .modebtn { padding: 4px 6px; font-size: 10px; }
}

@media (max-width: 600px) {
  #toolbar { top: 6px; left: 6px; right: 6px; gap: 4px; }
  #brand b span { display: none; }
}

/* Attribute Inspector Panel */
#panel {
  position: fixed; top: 12px; right: 12px; bottom: 12px; width: 340px; z-index: 25;
  background: rgba(13, 23, 17, 0.95); border: 1px solid var(--line-bright);
  border-top: 3px solid var(--accent); border-radius: 6px; padding: 18px;
  display: none; flex-direction: column; gap: 12px; overflow-y: auto;
  backdrop-filter: blur(14px); box-shadow: 0 15px 40px rgba(0,0,0,0.85);
}
#panel.show { display: flex; animation: slide-panel 0.25s ease; }
@keyframes slide-panel { from { opacity: 0; transform: translateX(15px); } to { opacity: 1; transform: translateX(0); } }

.ptop { display: flex; justify-content: space-between; align-items: flex-start; }
#pName { font-family: 'Oswald', sans-serif; font-size: 19px; font-weight: 800; text-transform: uppercase; color: var(--ink); line-height: 1.1; }
#pType { font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--accent); text-transform: uppercase; letter-spacing: 0.8px; margin-top: 4px; }
.xbtn { background: none; border: none; color: var(--ink-dim); cursor: pointer; font-size: 18px; line-height: 1; }
.xbtn:hover { color: var(--accent); }

.pbadge {
  display: inline-flex; align-items: center; gap: 6px; font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px; padding: 4px 8px; border-radius: 3px; background: rgba(0, 230, 118, 0.1);
  color: var(--accent-volt); border: 1px solid rgba(0, 230, 118, 0.25);
}
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 6px var(--accent); }

.pdesc { font-size: 11.5px; color: var(--ink-dim); line-height: 1.5; }

.spec-table { display: flex; flex-direction: column; gap: 5px; font-size: 11px; }
.spec-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 8px; background: var(--panel-2); border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.04);
}
.spec-row .k { color: var(--ink-dim); font-size: 10.5px; }
.spec-row .v { font-family: 'JetBrains Mono', monospace; font-weight: 700; color: var(--ink); }

/* Circuit Schematic Mini View */
.schematic-box {
  background: #040806; border: 1px solid var(--line); border-radius: 4px;
  padding: 9px; font-family: 'JetBrains Mono', monospace; font-size: 10px;
  color: var(--accent); display: flex; flex-direction: column; gap: 4px;
}
.schematic-box .title { font-size: 9px; color: var(--gold); text-transform: uppercase; font-weight: 700; margin-bottom: 2px; }

/* Sub-Bars (Disassembly, Thermal, Logic) */
.sub-bar {
  position: fixed; left: 50%; bottom: 44px; transform: translateX(-50%); z-index: 22;
  background: rgba(13, 23, 17, 0.96); border: 1px solid var(--line-bright);
  border-radius: 8px; padding: 12px 16px; display: none; flex-direction: column; gap: 10px;
  backdrop-filter: blur(16px); box-shadow: 0 10px 35px rgba(0,0,0,0.85);
  max-width: 92vw; width: 640px;
}
.sub-bar.show { display: flex; animation: slide-up 0.25s ease; }
@keyframes slide-up { from { opacity: 0; transform: translate(-50%, 15px); } to { opacity: 1; transform: translate(-50%, 0); } }

.bar-header { display: flex; justify-content: space-between; align-items: center; font-size: 12px; font-weight: 700; color: var(--ink); }
.bar-controls { display: flex; flex-direction: column; gap: 8px; }
.btn-group { display: flex; flex-wrap: wrap; gap: 6px; }

.slider-group { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--ink-dim); }
.slider-group label { display: flex; justify-content: space-between; }
.slider-group label b { color: var(--accent-volt); font-family: 'JetBrains Mono', monospace; }
.slider-group input[type="range"] {
  width: 100%; accent-color: var(--accent); background: #18281E; height: 6px; border-radius: 3px; cursor: pointer;
}
.slider-group select {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--ink);
  font-family: inherit; font-size: 11px; padding: 5px 8px; border-radius: 4px; outline: none;
}

/* Thermal Dashboard */
.thermal-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.gauge-card {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px;
  padding: 8px 12px; text-align: center; display: flex; flex-direction: column; gap: 2px;
}
.gauge-card .g-title { font-size: 9.5px; color: var(--ink-dim); text-transform: uppercase; font-weight: 600; }
.gauge-card .g-val { font-family: 'JetBrains Mono', monospace; font-size: 17px; font-weight: 800; color: var(--ink); }
.gauge-card .g-sub { font-size: 9px; color: var(--ink-dim); }

/* Logic Workspace */
.logic-workspace { display: flex; flex-direction: column; gap: 10px; }
.logic-inputs { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.logic-in { font-family: 'JetBrains Mono', monospace; }
.logic-in b { color: var(--accent); font-size: 13px; margin-left: 2px; }
.logic-indicator {
  display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--ink-dim);
  font-family: 'JetBrains Mono', monospace; background: var(--panel-2); padding: 5px 10px; border-radius: 4px;
}
.out-box { font-weight: 800; color: var(--accent-volt); font-size: 14px; }

.truth-table-wrap { overflow-x: auto; }
.truth-table { width: 100%; border-collapse: collapse; font-family: 'JetBrains Mono', monospace; font-size: 10px; }
.truth-table th, .truth-table td { padding: 5px 8px; text-align: center; border: 1px solid var(--line); }
.truth-table th { background: var(--panel-2); color: var(--gold); }
.truth-table tr.active { background: rgba(0, 230, 118, 0.18); color: var(--accent-volt); font-weight: 700; border: 1px solid var(--accent); }

/* Knowledge Quiz Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.8); backdrop-filter: blur(10px);
  z-index: 50; display: none; align-items: center; justify-content: center; padding: 16px;
}
.modal-overlay.show { display: flex; animation: fade-in 0.2s ease; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  background: var(--panel); border: 1px solid var(--line-bright); border-top: 3px solid var(--gold);
  border-radius: 8px; width: 560px; max-width: 100%; padding: 22px; display: flex;
  flex-direction: column; gap: 14px; box-shadow: 0 20px 50px rgba(0,0,0,0.9);
}
.m-top { display: flex; justify-content: space-between; align-items: flex-start; }
.m-top h3 { font-family: 'Oswald', sans-serif; font-size: 18px; color: var(--ink); }
.m-sub { font-size: 10.5px; color: var(--gold); font-family: 'JetBrains Mono', monospace; }

.quiz-body { display: flex; flex-direction: column; gap: 12px; }
.quiz-question { font-size: 13.5px; font-weight: 600; line-height: 1.4; color: var(--ink); }
.quiz-options { display: flex; flex-direction: column; gap: 6px; }
.q-opt {
  padding: 9px 12px; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 5px; font-size: 12px; color: var(--ink); cursor: pointer; text-align: left;
  transition: all 0.15s;
}
.q-opt:hover { border-color: var(--accent); background: #16281E; }
.q-opt.correct { background: rgba(0, 230, 118, 0.25); border-color: var(--accent); color: var(--accent-volt); font-weight: 700; }
.q-opt.wrong { background: rgba(239, 68, 68, 0.25); border-color: var(--danger); color: #FCA5A5; }

.quiz-exp {
  font-size: 11px; line-height: 1.4; color: var(--ink-dim); padding: 8px 10px;
  background: #060B08; border-left: 2px solid var(--gold); border-radius: 3px; display: none;
}
.quiz-exp.show { display: block; }

.m-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.quiz-score { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--ink-dim); }

/* Bottom Legend */
#bottomBar {
  position: fixed; left: 12px; bottom: 12px; z-index: 20;
  display: flex; align-items: center; gap: 12px; pointer-events: none;
}
#bottomBar > * { pointer-events: auto; }

#legend {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 12px; display: flex; gap: 12px; align-items: center; font-size: 10px;
  color: var(--ink-dim); font-weight: 600;
}
.lgitem { display: flex; align-items: center; gap: 6px; }
.lgdot { width: 7px; height: 7px; border-radius: 2px; }

#hint {
  position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 20;
  background: var(--panel); border: 1px solid var(--line-bright); padding: 6px 14px;
  border-radius: 20px; font-size: 10.5px; color: var(--ink-dim); text-align: center;
  pointer-events: none; transition: opacity 0.4s ease;
}
#hint b { color: var(--accent); }

#toast {
  position: fixed; left: 50%; top: 12px; transform: translate(-50%, -150%); z-index: 30;
  background: #0A160F; border: 1px solid var(--accent); color: var(--ink); padding: 7px 16px;
  border-radius: 20px; font-size: 11.5px; font-weight: 700; transition: transform 0.3s ease;
  box-shadow: 0 0 20px rgba(0, 230, 118, 0.4); pointer-events: none;
}
#toast.show { transform: translate(-50%, 0); }

/* Responsive Media Queries */
@media (max-width: 900px) {
  #panel { width: auto; left: 12px; right: 12px; bottom: 12px; top: auto; max-height: 50vh; }
  .sub-bar { width: auto; left: 12px; right: 12px; transform: none; bottom: 40px; }
  #brand b { font-size: 13px; }
  .modebtn { font-size: 10px; padding: 5px 8px; }
  #legend { display: none; }
}

@media (max-width: 600px) {
  #brand span.sub { display: none; }
  .actbtn span { display: none; }
  .actbtn { padding: 6px 8px; }
  .thermal-grid { grid-template-columns: 1fr; }
}

/* ATT-25 Animated Crest */
@keyframes attLogoSpin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes attCorePulse { 0%, 100% { transform: scale(1); filter: drop-shadow(0 0 4px #00FF87); } 50% { transform: scale(1.18); filter: drop-shadow(0 0 10px #00F0FF); } }
@keyframes attPhotonFlow { 0% { stroke-dashoffset: 24; } 100% { stroke-dashoffset: 0; } }
.att-animated-logo .logo-radar-ring { transform-origin: 32px 36px; animation: attLogoSpin 12s linear infinite; }
.att-animated-logo .logo-core-pulse { transform-origin: 32px 35.5px; animation: attCorePulse 2.4s ease-in-out infinite; }
.att-animated-logo .logo-photon-track { stroke-dasharray: 4 6; animation: attPhotonFlow 1.8s linear infinite; }

