:root {
  --bg: #05070d;
  --panel: rgba(11, 16, 30, 0.78);
  --text: #d8e6ff;
  --muted: #91a8d6;
  --line: rgba(120, 162, 255, 0.35);
  --accent: #7aa2ff;
  --accent-2: #ff5c8a;
  --glow: rgba(122, 162, 255, 0.35);
  --danger: #ff6a89;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: "JetBrains Mono", monospace;
  color: var(--text);
  background: radial-gradient(circle at 20% -20%, #1a223f 0%, var(--bg) 50%),
    linear-gradient(180deg, #050912 0%, var(--bg) 100%);
  position: relative;
  letter-spacing: 0.01em;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  opacity: 0.08;
  background: repeating-linear-gradient(
    to bottom,
    rgba(203, 255, 232, 0.25) 0,
    rgba(203, 255, 232, 0.25) 1px,
    transparent 2px,
    transparent 4px
  );
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.26;
  background-image:
    linear-gradient(rgba(122, 162, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(122, 162, 255, 0.08) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(circle at 50% 30%, black 45%, transparent 95%);
}

#matrix-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  opacity: 0.18;
  pointer-events: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 5vw;
  border-bottom: 1px solid rgba(122, 162, 255, 0.45);
  backdrop-filter: blur(8px);
  background: rgba(7, 11, 22, 0.84);
  box-shadow: 0 10px 30px rgba(1, 4, 15, 0.45);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}

.prompt {
  color: var(--muted);
}

.typed::after {
  content: "_";
  animation: blink 1s steps(1) infinite;
}

nav {
  display: flex;
  gap: 1rem;
}

nav a {
  color: var(--text);
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.24rem 0.62rem;
  transition: color 160ms ease, border-color 160ms ease, background-color 160ms ease;
}

nav a:hover {
  color: var(--accent);
  border-color: var(--line);
  background: rgba(122, 162, 255, 0.08);
}

.container {
  width: min(1040px, 92vw);
  margin: 2rem auto 4rem;
  position: relative;
  z-index: 1;
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(122, 162, 255, 0.32);
  border-radius: 12px;
  padding: 1.2rem 1.2rem 1.4rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 0 30px rgba(122, 162, 255, 0.1), inset 0 0 40px rgba(7, 16, 38, 0.42);
  position: relative;
  overflow: hidden;
  animation: panelIn 420ms ease both;
}

.panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: -30%;
  width: 40%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  box-shadow: 0 0 12px var(--glow);
}

.panel:hover::before {
  animation: sweep 1.8s linear infinite;
}

.focus-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin: 0.85rem 0 1rem;
}

.chip {
  display: inline-block;
  border: 1px solid var(--line);
  background: rgba(14, 22, 42, 0.85);
  color: var(--accent);
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
}

.terminal-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 0.8rem;
  align-items: center;
  border-style: solid;
  background: linear-gradient(90deg, rgba(122, 162, 255, 0.08), rgba(255, 92, 138, 0.05));
}

.search-panel {
  display: grid;
  gap: 0.55rem;
}

.search-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#intel-search {
  flex: 1;
  border: 1px solid rgba(122, 162, 255, 0.4);
  background: rgba(10, 16, 34, 0.85);
  color: var(--text);
  border-radius: 8px;
  padding: 0.56rem 0.7rem;
  font-family: inherit;
}

#intel-search:focus {
  outline: 2px solid rgba(122, 162, 255, 0.55);
  outline-offset: 1px;
}

.kbd-hint {
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 0.2rem 0.48rem;
  font-size: 0.82rem;
  color: var(--muted);
  background: rgba(7, 11, 23, 0.8);
}

.impact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.7rem;
}

.impact-card {
  border: 1px solid rgba(122, 162, 255, 0.25);
  border-radius: 10px;
  background: rgba(9, 15, 32, 0.82);
  padding: 0.8rem;
}

.impact-value {
  margin: 0;
  font-size: 1.28rem;
  font-weight: 800;
  color: var(--accent);
}

.impact-label {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.terminal-strip p {
  margin: 0;
  font-size: 0.86rem;
}

.meta-key {
  color: var(--muted);
  margin-right: 0.45rem;
}

.hero h1 {
  margin: 0.2rem 0 0.8rem;
  font-size: clamp(1.8rem, 4.2vw, 3.2rem);
  text-shadow: 0 0 18px rgba(122, 162, 255, 0.35);
}

.status {
  margin: 0;
  color: var(--accent);
  letter-spacing: 0.08em;
  font-size: 0.82rem;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid rgba(122, 162, 255, 0.35);
  background: rgba(122, 162, 255, 0.09);
}

.status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 10px rgba(255, 92, 138, 0.9);
  animation: pulse 1.2s ease-in-out infinite;
}

h2 {
  margin-top: 0;
  color: var(--accent-2);
  font-size: 1.05rem;
}

.card {
  padding: 1rem;
  border: 1px solid rgba(122, 162, 255, 0.28);
  background: rgba(16, 26, 50, 0.85);
  background: rgba(8, 12, 24, 0.78);
  margin-bottom: 0.8rem;
  transition: transform 220ms ease, box-shadow 220ms ease, border-color 220ms ease;
  transform-style: preserve-3d;
}

.card:hover {
  border-color: rgba(122, 162, 255, 0.75);
  box-shadow: 0 0 24px rgba(122, 162, 255, 0.25);
}

.card.filtered-out {
  display: none;
}

.card-layout {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 1rem;
  align-items: center;
}

.card-copy {
  min-width: 0;
}

.card-figure {
  width: 100%;
  height: 146px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(122, 162, 255, 0.35);
  background: rgba(8, 12, 24, 0.82);
  filter: saturate(1.08) contrast(1.05);
}

.card h3 {
  margin: 0.2rem 0 0.6rem;
  font-size: 1.1rem;
}

.meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

a {
  color: var(--accent);
}

.btn {
  display: inline-block;
  text-decoration: none;
  border: 1px solid var(--accent);
  color: #eaf1ff;
  background: linear-gradient(120deg, rgba(122, 162, 255, 0.2), rgba(122, 162, 255, 0.4));
  padding: 0.55rem 0.9rem;
  border-radius: 8px;
  font-weight: 700;
  margin-right: 0.6rem;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 14px rgba(122, 162, 255, 0.4);
}

.btn-alt {
  color: var(--accent);
  background: rgba(122, 162, 255, 0.06);
}

.small-note {
  color: var(--muted);
  font-size: 0.85rem;
}

.toast {
  position: fixed;
  right: 1.2rem;
  bottom: 1.2rem;
  z-index: 20;
  border: 1px solid var(--line);
  background: rgba(8, 13, 26, 0.95);
  color: var(--text);
  padding: 0.6rem 0.85rem;
  border-radius: 8px;
}

.back-to-top {
  position: fixed;
  right: 1.2rem;
  bottom: 4.8rem;
  z-index: 15;
}

.chatbot-toggle {
  position: fixed;
  right: 1.2rem;
  bottom: 1.2rem;
  z-index: 22;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: linear-gradient(120deg, rgba(122, 162, 255, 0.24), rgba(255, 92, 138, 0.16));
  color: var(--text);
  font-family: inherit;
  font-weight: 700;
  padding: 0.58rem 0.9rem;
  cursor: pointer;
}

.chatbot-panel {
  position: fixed;
  right: 1.2rem;
  bottom: 5.7rem;
  width: min(380px, calc(100vw - 2.4rem));
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(8, 13, 26, 0.97);
  box-shadow: 0 10px 30px rgba(2, 8, 20, 0.55);
  z-index: 25;
  padding: 0.8rem;
  display: grid;
  gap: 0.65rem;
}

.chatbot-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.chatbot-controls {
  display: flex;
  gap: 0.4rem;
}

.chatbot-controls .btn {
  margin-right: 0;
  padding: 0.34rem 0.52rem;
  font-size: 0.78rem;
}

.chatbot-head h3 {
  margin: 0;
  color: var(--accent);
  font-size: 0.95rem;
}

.chatbot-messages {
  border: 1px solid rgba(122, 162, 255, 0.25);
  border-radius: 10px;
  background: rgba(7, 11, 22, 0.8);
  padding: 0.65rem;
  max-height: 300px;
  overflow-y: auto;
  display: grid;
  gap: 0.5rem;
}

.chat-line {
  margin: 0;
  padding: 0.44rem 0.52rem;
  border-radius: 8px;
  font-size: 0.86rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.chat-line.user {
  background: rgba(122, 162, 255, 0.15);
  border: 1px solid rgba(122, 162, 255, 0.25);
}

.chat-line.bot {
  background: rgba(255, 92, 138, 0.09);
  border: 1px solid rgba(255, 92, 138, 0.18);
}

.chatbot-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
}

#chatbot-input {
  border: 1px solid rgba(122, 162, 255, 0.35);
  background: rgba(10, 16, 34, 0.85);
  color: var(--text);
  border-radius: 8px;
  padding: 0.56rem 0.68rem;
  font-family: inherit;
}

#chatbot-input:focus {
  outline: 2px solid rgba(122, 162, 255, 0.5);
  outline-offset: 1px;
}

.hidden {
  display: none;
}

.reader-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

#post-content h1,
#post-content h2,
#post-content h3 {
  color: var(--accent);
}

#post-content p,
#post-content li {
  line-height: 1.65;
}

#post-content code {
  background: rgba(0, 0, 0, 0.28);
  padding: 0.05rem 0.3rem;
  border-radius: 4px;
}

#post-content pre {
  overflow-x: auto;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(122, 162, 255, 0.26);
  border-radius: 10px;
  padding: 0.9rem;
}

#post-content blockquote {
  border-left: 3px solid var(--accent-2);
  margin: 1rem 0;
  padding: 0.2rem 0 0.2rem 0.8rem;
  color: var(--muted);
}

.footer {
  text-align: center;
  padding: 1.8rem;
  color: var(--muted);
  position: relative;
  z-index: 1;
}

.glitch {
  position: relative;
  color: var(--text);
}

.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  clip-path: inset(0 0 0 0);
}

.glitch::before {
  color: #7aa2ff;
  transform: translate(1px, 0);
  animation: jitter 2s infinite linear alternate-reverse;
  opacity: 0.55;
}

.glitch::after {
  color: #ff5c8a;
  transform: translate(-1px, 0);
  animation: jitter 1.6s infinite linear alternate;
  opacity: 0.45;
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.25);
    opacity: 0.75;
  }
}

@keyframes panelIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes sweep {
  0% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(420%);
  }
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

@keyframes jitter {
  0% {
    clip-path: inset(10% 0 80% 0);
  }
  25% {
    clip-path: inset(45% 0 35% 0);
  }
  50% {
    clip-path: inset(80% 0 8% 0);
  }
  75% {
    clip-path: inset(35% 0 40% 0);
  }
  100% {
    clip-path: inset(5% 0 85% 0);
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
  }

  nav {
    width: 100%;
    justify-content: space-between;
  }

  .btn {
    margin-bottom: 0.5rem;
  }

  .card-layout {
    grid-template-columns: 1fr;
  }

  .card-figure {
    height: 170px;
  }

  .terminal-strip {
    grid-template-columns: 1fr 1fr;
  }

  .search-wrap {
    align-items: stretch;
  }

  .chatbot-panel {
    bottom: 5.2rem;
  }
}
