:root {
  --bg-canvas: #101114;
  --bg-topbar: #181a1f;
  --bg-panel: #15171c;
  --bg-card: #1c1f26;
  --border: #282c35;
  --text-primary: #f1f3f5;
  --text-secondary: #9aa1ae;
  --text-muted: #6c7380;
  --green: #43d159;
  --amber: #df9c38;
  --red: #d95555;
  --accent-link: #68b5ff;
}

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

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.app {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
}

/* ================= TOP BAR (Crypto Bubbles Style) ================= */
.topbar {
  height: 52px;
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  gap: 16px;
  flex-shrink: 0;
  user-select: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-name {
  font-size: 0.94rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: #ffffff;
}

.mc-filters {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #111317;
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.filter-label {
  font-size: 0.76rem;
  color: var(--text-secondary);
  padding: 0 8px 0 6px;
}

.mc-btn {
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  padding: 5px 12px;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.mc-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.05);
}

.mc-btn.active {
  background: #2b303c;
  color: #ffffff;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar-note {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.77rem;
  color: var(--text-secondary);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dot.safe {
  background: var(--green);
}

.hud-social-links {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

/* Compact Top-Bar X / Twitter Button (matching Sheen & Glow Effect, staggered phase) */
.hud-twitter-btn {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 23px;
  padding: 0 9px;
  border-radius: 3px;
  text-decoration: none;
  cursor: pointer;
  flex-shrink: 0;
  background: linear-gradient(180deg, #35abf9 0%, #1d8cd8 60%, #146eb0 100%);
  border: 1px solid #8dd2ff;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
  box-shadow: 0 0 8px rgba(29, 155, 240, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.24);
  transition: filter 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
  animation: twitterHudBreath 11s ease-in-out 5.5s infinite;
}

.hud-twitter-btn svg,
.hud-twitter-btn span {
  pointer-events: none;
  flex-shrink: 0;
}

.hud-twitter-btn::after {
  content: '';
  position: absolute;
  width: 28px;
  height: 180%;
  top: -40%;
  left: -36px;
  transform: rotate(22deg);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent);
  pointer-events: none;
  animation: discordHudSheen 11s ease-in-out 5.5s infinite;
}

.hud-twitter-btn:hover {
  background: linear-gradient(180deg, #4cb8ff 0%, #1d9bf0 100%);
  border-color: var(--gold, #ffd454);
  color: #fff;
  box-shadow: 0 0 12px rgba(29, 155, 240, 0.7), 0 0 6px rgba(255, 212, 84, 0.35);
  transform: translateY(-0.5px);
}

.hud-twitter-btn:active {
  transform: translateY(0.5px);
}

@keyframes twitterHudBreath {
  0%, 82%, 100% {
    box-shadow: 0 0 8px rgba(29, 155, 240, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.24);
    border-color: #8dd2ff;
  }
  90% {
    box-shadow: 0 0 14px rgba(56, 178, 255, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.36);
    border-color: #c4e8ff;
  }
}

/* Compact Top-Bar Discord Button (with Periodic Sheen & Glow Effect) */
.hud-discord-btn {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 23px;
  padding: 0 9px;
  border-radius: 3px;
  text-decoration: none;
  cursor: pointer;
  flex-shrink: 0;
  background: linear-gradient(180deg, #6b78f8 0%, #4e5ad6 60%, #404ab8 100%);
  border: 1px solid #9ba6ff;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
  box-shadow: 0 0 8px rgba(88, 101, 242, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.22);
  transition: filter 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
  animation: discordHudBreath 11s ease-in-out infinite;
}

.hud-discord-btn svg,
.hud-discord-btn span {
  pointer-events: none;
  flex-shrink: 0;
}

.hud-discord-btn::after {
  content: '';
  position: absolute;
  width: 28px;
  height: 180%;
  top: -40%;
  left: -36px;
  transform: rotate(22deg);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent);
  pointer-events: none;
  animation: discordHudSheen 11s ease-in-out infinite;
}

.hud-discord-btn:hover {
  background: linear-gradient(180deg, #7985ff 0%, #5865f2 100%);
  border-color: var(--gold, #ffd454);
  color: #fff;
  box-shadow: 0 0 12px rgba(88, 101, 242, 0.7), 0 0 6px rgba(255, 212, 84, 0.35);
  transform: translateY(-0.5px);
}

.hud-discord-btn:active {
  transform: translateY(0.5px);
}

@keyframes discordHudSheen {
  0%, 83% { left: -36px; opacity: 0; }
  84% { opacity: 1; }
  96% { left: calc(100% + 28px); opacity: 1; }
  100% { left: calc(100% + 28px); opacity: 0; }
}

@keyframes discordHudBreath {
  0%, 82%, 100% {
    box-shadow: 0 0 8px rgba(88, 101, 242, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.22);
    border-color: #9ba6ff;
  }
  90% {
    box-shadow: 0 0 14px rgba(105, 118, 255, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.35);
    border-color: #c7ceff;
  }
}

@media (max-width: 960px) {
  .hud-discord-lbl,
  .hud-twitter-lbl { display: none; }
  .hud-discord-btn,
  .hud-twitter-btn { padding: 0 7px; }
}

@media (prefers-reduced-motion: reduce) {
  .hud-discord-btn,
  .hud-discord-btn::after,
  .hud-twitter-btn,
  .hud-twitter-btn::after {
    animation: none;
  }
}

/* ================= MAIN WORKSPACE ================= */
.main-area {
  display: flex;
  flex: 1;
  min-height: 0;
}

.canvas-wrap {
  flex: 1;
  min-width: 0;
  height: 100%;
  position: relative;
  background: var(--bg-canvas);
}

#bubbleCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  user-select: none;
}

#bubbleCanvas:active {
  cursor: grabbing;
}

/* ================= RIGHT SELECTED TOKEN PANEL ================= */
.detail-panel {
  width: 356px;
  flex-shrink: 0;
  height: 100%;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}

.panel-kicker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.panel-hint {
  font-weight: 500;
  letter-spacing: 0;
  color: var(--text-secondary);
}

.token-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.token-logo {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
}

.token-logo svg {
  width: 46px;
  height: 46px;
  display: block;
}

.token-meta {
  flex: 1;
  min-width: 0;
}

.token-title-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.token-title-line h2 {
  font-size: 1.02rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.25;
}

.token-sym {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 6px;
  border-radius: 4px;
}

.token-sub-line {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 5px;
  font-size: 0.76rem;
  color: var(--text-secondary);
}

.token-sub-line strong {
  color: var(--text-primary);
}

.sep {
  color: var(--text-muted);
}

.overall-badge {
  font-size: 0.73rem;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 4px;
}

/* RSA & ECC Source Cards */
.crypto-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 13px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sec-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sec-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: #ffffff;
}

.sec-pct {
  font-size: 0.8rem;
  font-weight: 700;
}

.bar-bg {
  width: 100%;
  height: 7px;
  background: #101216;
  border-radius: 999px;
  overflow: hidden;
}

.bar-bg.sm {
  height: 5px;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.28s ease, background-color 0.25s ease;
}

.source-snippet {
  font-size: 0.78rem;
  line-height: 1.48;
  color: #cfd4dc;
  border-left: 2px solid #353b47;
  padding-left: 9px;
  margin-top: 2px;
}

.source-link {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-link);
  text-decoration: none;
  margin-top: 1px;
}

.source-link:hover {
  text-decoration: underline;
  color: #93c8ff;
}

.panel-footer-note {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 0.74rem;
  line-height: 1.45;
  color: var(--text-muted);
}

/* ================= FLOATING HOVER TOOLTIP ================= */
.tooltip {
  position: fixed;
  top: 0;
  left: 0;
  width: 326px;
  background: #181b21;
  border: 1px solid #343946;
  border-radius: 10px;
  padding: 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.65);
  pointer-events: none;
  z-index: 100;
}

.tooltip[hidden] {
  display: none !important;
}

.tt-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--border);
}

.tt-logo {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.tt-logo svg {
  width: 32px;
  height: 32px;
  display: block;
}

.tt-head-text {
  flex: 1;
  min-width: 0;
}

.tt-title {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tt-title strong {
  font-size: 0.88rem;
  color: #ffffff;
}

.tt-sym {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.tt-sub {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 1px;
}

.tt-badge {
  font-size: 0.73rem;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 5px;
}

.tt-block {
  margin-top: 9px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tt-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-primary);
}

.tt-snippet {
  font-size: 0.72rem;
  line-height: 1.38;
  color: var(--text-secondary);
  margin-top: 1px;
}

.tt-cite {
  font-size: 0.69rem;
  color: var(--accent-link);
  font-weight: 500;
}

.tt-foot {
  margin-top: 9px;
  padding-top: 7px;
  border-top: 1px solid var(--border);
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: center;
}

/* Responsive */
@media (max-width: 980px) {
  html, body {
    overflow: auto;
  }
  .app {
    height: auto;
    min-height: 100vh;
  }
  .topbar {
    height: auto;
    padding: 10px 14px;
    flex-wrap: wrap;
  }
  .topbar-note {
    display: none;
  }
  .main-area {
    flex-direction: column;
  }
  .canvas-wrap {
    height: 600px;
    flex: none;
  }
  .detail-panel {
    width: 100%;
    height: auto;
    border-left: none;
    border-top: 1px solid var(--border);
  }
}
