:root {
  --bg: #061019;
  --bg2: #0d1f33;
  --cyan: #25f5d8;
  --blue: #2b8fff;
  --hot: #ff5c8a;
  --text: #eaf7ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Rajdhani", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 20% 15%, #12385f 0%, var(--bg) 40%),
              radial-gradient(circle at 80% 70%, #20216a 0%, var(--bg2) 45%),
              linear-gradient(140deg, #050810, #071a25 50%, #080b17);
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image: linear-gradient(rgba(37, 245, 216, 0.09) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(37, 245, 216, 0.09) 1px, transparent 1px);
  background-size: 36px 36px;
  z-index: -5;
  animation: drift 12s linear infinite;
}

@keyframes drift {
  from { transform: translateY(0); }
  to { transform: translateY(36px); }
}

.pulse-orb {
  position: fixed;
  width: 380px;
  height: 380px;
  border-radius: 50%;
  filter: blur(60px);
  z-index: -4;
}

.orb-a {
  left: -120px;
  top: -80px;
  background: rgba(43, 143, 255, 0.33);
  animation: floatA 8s ease-in-out infinite;
}

.orb-b {
  right: -140px;
  bottom: -120px;
  background: rgba(255, 92, 138, 0.25);
  animation: floatB 9s ease-in-out infinite;
}

@keyframes floatA {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(30px, 15px); }
}

@keyframes floatB {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(-30px, -20px); }
}

.hero {
  text-align: center;
  padding: 24px 20px 16px;
  position: relative;
  display: grid;
  gap: 14px;
  justify-items: center;
}

.hero-toolbar {
  width: min(1200px, 92vw);
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.lang-toggle,
.back-link {
  color: #25f5d8;
  text-decoration: none;
  border: 1px solid rgba(37,245,216,.35);
  padding: 10px 14px;
  border-radius: 999px;
  display: inline-block;
  background: rgba(2, 12, 20, 0.5);
  font: inherit;
}

.lang-toggle {
  cursor: pointer;
}

.lang-toggle:hover,
.back-link:hover {
  border-color: rgba(37,245,216,.6);
  box-shadow: 0 0 16px rgba(37, 245, 216, 0.24);
}

.hero h1 {
  margin: 0;
  font-family: "Orbitron", sans-serif;
  font-size: clamp(1.7rem, 3.6vw, 3rem);
  letter-spacing: 0.14em;
  text-shadow: 0 0 16px rgba(37, 245, 216, 0.4);
  max-width: min(1200px, 92vw);
  padding: 0 12px;
}

.hero p {
  margin-top: 8px;
  font-size: 1.05rem;
  color: rgba(234, 247, 255, 0.8);
}

.author-meta {
  color: rgba(234, 247, 255, 0.92);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.page-maintainer {
  grid-column: span 12;
  text-align: center;
  color: rgba(234, 247, 255, 0.9);
  font-size: 13px;
  letter-spacing: 0.02em;
  margin-top: -2px;
}

.back-link {
  margin-top: 12px;
}

.layout {
  width: min(1200px, 92vw);
  margin: 0 auto 44px;
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(12, 1fr);
}

.panel {
  border: 1px solid rgba(37, 245, 216, 0.25);
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(10, 25, 40, 0.88), rgba(8, 20, 32, 0.72));
  box-shadow: inset 0 0 16px rgba(37, 245, 216, 0.1), 0 10px 36px rgba(4, 8, 18, 0.45);
  padding: 16px;
  backdrop-filter: blur(3px);
  transform: translateY(20px);
  opacity: 0;
  animation: reveal 800ms forwards;
}

.panel:nth-child(2) { animation-delay: 120ms; }
.panel:nth-child(3) { animation-delay: 200ms; }
.panel:nth-child(4) { animation-delay: 280ms; }

@keyframes reveal {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.panel h2 {
  margin: 0 0 12px;
  font-family: "Orbitron", sans-serif;
  font-size: 1.02rem;
  letter-spacing: 0.08em;
}

.compliance-panel { grid-column: span 12; }
.onboarding-panel { grid-column: span 4; }
.session-panel { grid-column: span 8; }
.gateway-panel { grid-column: span 12; }
.wave-panel { grid-column: span 12; }
.device-panel { grid-column: span 6; }
.dashboard-panel { grid-column: span 6; }
.emotion-panel,
.scene-panel {
  grid-column: span 6;
  min-height: 380px;
}

.emotion-panel {
  display: grid;
  grid-template-rows: auto 1fr;
}

.scene-panel {
  display: grid;
  grid-template-rows: auto auto 1fr;
}
.clone-panel { grid-column: span 12; }
.log-panel { grid-column: span 12; }

.steps {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 8px;
}

.steps li {
  color: rgba(234, 247, 255, 0.74);
  border-left: 2px solid rgba(255, 255, 255, 0.12);
  padding-left: 10px;
}

.steps li.active {
  color: #bafdf1;
  border-left-color: rgba(37, 245, 216, 0.8);
}

.steps li.done {
  color: rgba(186, 253, 241, 0.82);
  border-left-color: rgba(37, 245, 216, 0.35);
}

.session-state {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.chip {
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  padding: 5px 10px;
  font-size: 12px;
  font-family: "Orbitron", sans-serif;
  letter-spacing: 0.04em;
}

.chip.ok {
  border-color: rgba(37, 245, 216, 0.45);
  color: #b9fff3;
  box-shadow: 0 0 12px rgba(37, 245, 216, 0.22);
}

.session-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.action-btn {
  border-radius: 10px;
  border: 1px solid rgba(37, 245, 216, 0.3);
  background: rgba(8, 24, 36, 0.72);
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
  cursor: pointer;
}

.action-btn.primary {
  background: linear-gradient(130deg, rgba(37, 245, 216, 0.26), rgba(43, 143, 255, 0.22));
}

.action-btn:hover {
  border-color: rgba(37, 245, 216, 0.62);
  box-shadow: 0 0 16px rgba(37, 245, 216, 0.2);
}

.session-note {
  margin: 0;
  color: rgba(234, 247, 255, 0.82);
}

.compliance-copy {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.compliance-copy p {
  margin: 0;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(37, 245, 216, 0.18);
  background: rgba(6, 20, 30, 0.68);
  color: rgba(234, 247, 255, 0.82);
  line-height: 1.55;
}

.gateway-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.gateway-grid input {
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(3, 12, 20, 0.7);
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
}

.gateway-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.protocol-block {
  margin-top: 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(2, 10, 18, 0.66);
  padding: 10px;
}

.protocol-block h3 {
  margin: 0 0 8px;
  font-family: "Orbitron", sans-serif;
  font-size: 0.9rem;
  letter-spacing: 0.06em;
}

.protocol-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.protocol-list span {
  border-radius: 999px;
  border: 1px solid rgba(37, 245, 216, 0.32);
  background: rgba(37, 245, 216, 0.08);
  padding: 4px 9px;
  font-size: 12px;
}

.frame-view {
  margin: 12px 0 0;
  min-height: 110px;
  max-height: 220px;
  overflow: auto;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.34);
  padding: 10px;
  color: rgba(234, 247, 255, 0.88);
  font-size: 12px;
  line-height: 1.5;
}

.device-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.device-grid div {
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 10px;
  background: rgba(3, 13, 22, 0.65);
  padding: 10px;
}

.device-grid small {
  display: block;
  color: rgba(234, 247, 255, 0.68);
  margin-bottom: 4px;
}

.device-grid strong {
  font-family: "Orbitron", sans-serif;
  letter-spacing: 0.04em;
}

#brainWave {
  width: 100%;
  height: 220px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.22);
}

.gauge-wrap {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.gauge {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  display: grid;
  place-content: center;
  text-align: center;
  background: conic-gradient(var(--cyan) calc(var(--v) * 1%), rgba(255, 255, 255, 0.06) 0);
  box-shadow: 0 0 24px rgba(37, 245, 216, 0.2);
  position: relative;
}

.gauge::before {
  content: "";
  position: absolute;
  width: 122px;
  height: 122px;
  border-radius: 50%;
  background: #081320;
}

.gauge span, .gauge small {
  position: relative;
  z-index: 2;
}

.gauge span {
  font-family: "Orbitron", sans-serif;
  font-size: 1.45rem;
}

.gauge small {
  color: rgba(234, 247, 255, 0.75);
}

.emotion-map {
  height: 100%;
  min-height: 220px;
  border-radius: 10px;
  position: relative;
  overflow: hidden;
  background: radial-gradient(circle at 40% 40%, rgba(37, 245, 216, 0.4), transparent 40%),
              radial-gradient(circle at 65% 58%, rgba(255, 92, 138, 0.45), transparent 45%),
              radial-gradient(circle at 30% 70%, rgba(43, 143, 255, 0.4), transparent 35%),
              rgba(2, 9, 16, 0.8);
}

.emotion-map[data-scene="focused"] {
  background: radial-gradient(circle at 40% 40%, rgba(37, 245, 216, 0.42), transparent 40%),
              radial-gradient(circle at 65% 58%, rgba(43, 143, 255, 0.4), transparent 42%),
              rgba(2, 9, 16, 0.82);
}

.emotion-map[data-scene="calm"] {
  background: radial-gradient(circle at 30% 30%, rgba(137, 231, 255, 0.32), transparent 44%),
              radial-gradient(circle at 70% 60%, rgba(109, 255, 211, 0.35), transparent 44%),
              rgba(2, 9, 16, 0.82);
}

.emotion-map[data-scene="stress"] {
  background: radial-gradient(circle at 35% 34%, rgba(255, 92, 138, 0.44), transparent 43%),
              radial-gradient(circle at 70% 66%, rgba(255, 175, 88, 0.35), transparent 45%),
              rgba(18, 8, 16, 0.85);
}

.emotion-map[data-scene="happy"] {
  background: radial-gradient(circle at 32% 38%, rgba(115, 255, 203, 0.42), transparent 42%),
              radial-gradient(circle at 68% 62%, rgba(255, 230, 120, 0.36), transparent 40%),
              rgba(8, 18, 22, 0.82);
}

.emotion-scenario-list {
  display: grid;
  gap: 10px;
  max-height: 100%;
  overflow: auto;
  padding-right: 4px;
}

.emotion-scenario-item {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(3, 12, 20, 0.62);
  padding: 10px 12px;
  display: grid;
  gap: 8px;
}

.emotion-scenario-item.active {
  border-color: rgba(37, 245, 216, 0.48);
  box-shadow: 0 0 20px rgba(37, 245, 216, 0.16);
}

.emotion-scenario-item strong {
  font-family: "Orbitron", sans-serif;
  letter-spacing: 0.04em;
}

.emotion-scenario-item p {
  margin: 6px 0 0;
  color: rgba(234, 247, 255, 0.78);
  line-height: 1.5;
}

.emotion-node {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan);
  animation: blink 1.8s infinite alternate;
}

@keyframes blink {
  to { opacity: 0.25; transform: scale(0.7); }
}

.clone-track {
  height: 140px;
  position: relative;
  border-radius: 12px;
  background: linear-gradient(90deg, rgba(37, 245, 216, 0.06), rgba(255, 92, 138, 0.08));
  border: 1px solid rgba(43, 143, 255, 0.3);
  overflow: hidden;
}

.scan-line {
  position: absolute;
  top: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(180deg, transparent, var(--cyan), transparent);
  box-shadow: 0 0 12px var(--cyan);
  animation: scan 3.5s ease-in-out infinite;
}

@keyframes scan {
  0% { left: 0; }
  50% { left: calc(100% - 4px); }
  100% { left: 0; }
}

.clone-core {
  position: absolute;
  inset: 14px;
  border-radius: 10px;
  border: 1px dashed rgba(234, 247, 255, 0.2);
}

.clone-percentage {
  position: absolute;
  right: 18px;
  bottom: 14px;
  font-family: "Orbitron", sans-serif;
  font-size: 2.1rem;
  color: var(--cyan);
}

.operation-log {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
  padding-right: 4px;
}

.log-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(2, 12, 20, 0.58);
  padding: 8px 10px;
  font-size: 13px;
}

.log-row strong {
  color: rgba(234, 247, 255, 0.68);
  font-size: 12px;
}

.log-row.ok {
  border-color: rgba(37, 245, 216, 0.28);
}

.log-row.warn {
  border-color: rgba(255, 184, 88, 0.34);
}

.brain-voiceover {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(18px);
  border-radius: 999px;
  border: 1px solid rgba(37, 245, 216, 0.45);
  background: rgba(3, 12, 22, 0.88);
  color: #d8fff7;
  font-family: "Orbitron", sans-serif;
  letter-spacing: 0.04em;
  font-size: 12px;
  padding: 10px 16px;
  max-width: min(900px, 92vw);
  text-align: center;
  opacity: 0;
  transition: all .24s ease;
  z-index: 90;
  pointer-events: none;
}

.brain-voiceover.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.demo-focus {
  outline: 2px solid rgba(37, 245, 216, 0.9);
  box-shadow: 0 0 0 7px rgba(37, 245, 216, 0.18), 0 0 40px rgba(37, 245, 216, 0.46);
}

body.brain-demo-mode {
  background: radial-gradient(circle at 10% 15%, #174e7f 0%, #081322 42%),
              radial-gradient(circle at 86% 70%, #2a1d7c 0%, #0a1627 45%),
              linear-gradient(150deg, #050812, #071a26 48%, #090e1a);
}

body.brain-demo-mode .panel {
  transform: perspective(1200px) rotateX(0.7deg);
}

@media (max-width: 900px) {
  .compliance-copy {
    grid-template-columns: 1fr;
  }

  .hero-toolbar {
    width: 100%;
    justify-content: center;
  }

  .onboarding-panel,
  .session-panel,
  .compliance-panel,
  .wave-panel,
  .device-panel,
  .dashboard-panel,
  .emotion-panel,
  .scene-panel,
  .clone-panel,
  .log-panel {
    grid-column: span 12;
    min-height: auto;
  }

  .device-grid {
    grid-template-columns: 1fr;
  }

  .session-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .gateway-grid {
    grid-template-columns: 1fr;
  }

  .gauge {
    width: 140px;
    height: 140px;
  }

  .gauge::before {
    width: 104px;
    height: 104px;
  }
}

@media (max-width: 640px) {
  .layout,
  .hero-toolbar,
  .hero h1 {
    width: min(100%, 100vw - 16px);
  }

  .panel {
    padding: 12px;
    border-radius: 12px;
  }

  .action-btn,
  .lang-toggle,
  .back-link,
  input,
  button {
    min-height: 44px;
  }

  #brainWave {
    height: 180px;
  }

  .protocol-list span {
    font-size: 11px;
  }
}
